diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..403e068506e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,51 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + +Please run down the following list and make sure you've tried the usual "quick fixes": + + - Search the issues already opened: https://github.com/googleapis/java-spanner/issues + - Check for answers on StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform + +If you are still having issues, please include as much information as possible: + +#### Environment details + +1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). + General, Core, and Other are also allowed as types +2. OS type and version: +3. Java version: +4. spanner version(s): + +#### Steps to reproduce + + 1. ? + 2. ? + +#### Code example + +```java +// example +``` + +#### Stack trace +``` +Any relevant stacktrace here. +``` + +#### External references such as API reference guides + +- ? + +#### Any additional information below + + +Following these steps guarantees the quickest resolution possible. + +Thanks! diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..754e30c68a0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this library + +--- + +Thanks for stopping by to let us know something could be better! + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. + +**Is your feature request related to a problem? Please describe.** +What the problem is. Example: I'm always frustrated when [...] + +**Describe the solution you'd like** +What you want to happen. + +**Describe alternatives you've considered** +Any alternative solutions or features you've considered. + +**Additional context** +Any other context or screenshots about the feature request. diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md new file mode 100644 index 00000000000..99586903212 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -0,0 +1,7 @@ +--- +name: Support request +about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. + +--- + +**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000000..0bd0ee0620f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1 @@ +Fixes # (it's a good idea to open an issue first for context and/or discussion) \ No newline at end of file diff --git a/.github/release-please.yml b/.github/release-please.yml new file mode 100644 index 00000000000..dce2c845092 --- /dev/null +++ b/.github/release-please.yml @@ -0,0 +1,2 @@ +releaseType: java-yoshi +bumpMinorPreMajor: true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..48ec8bf6665 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Packages +dist +bin +var +sdist +target + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject +*.iml +.idea +.settings +.DS_Store +.classpath + +# Built documentation +docs/ + +# Python utilities +*.pyc diff --git a/.kokoro/build.bat b/.kokoro/build.bat new file mode 100644 index 00000000000..30e63a7c7cc --- /dev/null +++ b/.kokoro/build.bat @@ -0,0 +1,3 @@ +:: See documentation in type-shell-output.bat + +"C:\Program Files\Git\bin\bash.exe" github/java-spanner/.kokoro/build.sh diff --git a/.kokoro/build.sh b/.kokoro/build.sh new file mode 100755 index 00000000000..dc2936ef76a --- /dev/null +++ b/.kokoro/build.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Copyright 2019 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 +# +# http://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. + +set -eo pipefail + +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +# Print out Java version +java -version +echo ${JOB_TYPE} + +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true \ + -T 1C + +# if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it +if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then + export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_ROOT}/src/${GOOGLE_APPLICATION_CREDENTIALS}) +fi + +case ${JOB_TYPE} in +test) + mvn test -B -Dclirr.skip=true -Denforcer.skip=true + bash ${KOKORO_GFILE_DIR}/codecov.sh + bash .kokoro/coerce_logs.sh + ;; +lint) + mvn com.coveo:fmt-maven-plugin:check + ;; +javadoc) + mvn javadoc:javadoc javadoc:test-javadoc + ;; +integration) + mvn -B ${INTEGRATION_TEST_ARGS} \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify + bash .kokoro/coerce_logs.sh + ;; +clirr) + mvn -B -Denforcer.skip=true clirr:check + ;; +*) + ;; +esac diff --git a/.kokoro/coerce_logs.sh b/.kokoro/coerce_logs.sh new file mode 100755 index 00000000000..5cf7ba49e6b --- /dev/null +++ b/.kokoro/coerce_logs.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2019 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 +# +# http://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. + +# This script finds and moves sponge logs so that they can be found by placer +# and are not flagged as flaky by sponge. + +set -eo pipefail + +## Get the directory of the build script +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) +## cd to the parent directory, i.e. the root of the git repo +cd ${scriptDir}/.. + +job=$(basename ${KOKORO_JOB_NAME}) + +echo "coercing sponge logs..." +for xml in `find . -name *-sponge_log.xml` +do + echo "processing ${xml}" + class=$(basename ${xml} | cut -d- -f2) + dir=$(dirname ${xml})/${job}/${class} + text=$(dirname ${xml})/${class}-sponge_log.txt + mkdir -p ${dir} + mv ${xml} ${dir}/sponge_log.xml + mv ${text} ${dir}/sponge_log.txt +done diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg new file mode 100644 index 00000000000..950c271d1f9 --- /dev/null +++ b/.kokoro/common.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# All builds use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +# Tell the trampoline which build file to use. +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/build.sh" +} \ No newline at end of file diff --git a/.kokoro/continuous/common.cfg b/.kokoro/continuous/common.cfg new file mode 100644 index 00000000000..7fee8357389 --- /dev/null +++ b/.kokoro/continuous/common.cfg @@ -0,0 +1,30 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} diff --git a/.kokoro/continuous/dependencies.cfg b/.kokoro/continuous/dependencies.cfg new file mode 100644 index 00000000000..808bf138e1c --- /dev/null +++ b/.kokoro/continuous/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/dependencies.sh" +} diff --git a/.kokoro/continuous/integration.cfg b/.kokoro/continuous/integration.cfg new file mode 100644 index 00000000000..3b017fc80f0 --- /dev/null +++ b/.kokoro/continuous/integration.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/continuous/java11.cfg b/.kokoro/continuous/java11.cfg new file mode 100644 index 00000000000..709f2b4c73d --- /dev/null +++ b/.kokoro/continuous/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/continuous/java7.cfg b/.kokoro/continuous/java7.cfg new file mode 100644 index 00000000000..cb24f44eea3 --- /dev/null +++ b/.kokoro/continuous/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/continuous/java8-osx.cfg b/.kokoro/continuous/java8-osx.cfg new file mode 100644 index 00000000000..63f547222f5 --- /dev/null +++ b/.kokoro/continuous/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.sh" diff --git a/.kokoro/continuous/java8-win.cfg b/.kokoro/continuous/java8-win.cfg new file mode 100644 index 00000000000..b219b38ad4a --- /dev/null +++ b/.kokoro/continuous/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.bat" diff --git a/.kokoro/continuous/java8.cfg b/.kokoro/continuous/java8.cfg new file mode 100644 index 00000000000..3b017fc80f0 --- /dev/null +++ b/.kokoro/continuous/java8.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/continuous/lint.cfg b/.kokoro/continuous/lint.cfg new file mode 100644 index 00000000000..6d323c8ae76 --- /dev/null +++ b/.kokoro/continuous/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/continuous/propose_release.cfg b/.kokoro/continuous/propose_release.cfg new file mode 100644 index 00000000000..7fa8a9708e3 --- /dev/null +++ b/.kokoro/continuous/propose_release.cfg @@ -0,0 +1,53 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/continuous/propose_release.sh" +} + +# tokens used by release-please to keep an up-to-date release PR. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-key-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-token-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-url-release-please" + } + } +} diff --git a/.kokoro/continuous/propose_release.sh b/.kokoro/continuous/propose_release.sh new file mode 100755 index 00000000000..3a4d950e968 --- /dev/null +++ b/.kokoro/continuous/propose_release.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Copyright 2019 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. + +set -eo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then + # Groom the release PR as new commits are merged. + npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ + --repo-url=googleapis/java-spanner \ + --package-name="spanner" \ + --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ + --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ + --release-type=java-yoshi +fi diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh new file mode 100755 index 00000000000..a9af4ef85aa --- /dev/null +++ b/.kokoro/dependencies.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Copyright 2019 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 +# +# http://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. + +set -eo pipefail + +cd github/java-spanner/ + +# Print out Java +java -version +echo $JOB_TYPE + +export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" + +# this should run maven enforcer +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true + +mvn -B dependency:analyze -DfailOnWarning=true diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh new file mode 100755 index 00000000000..e0896944bff --- /dev/null +++ b/.kokoro/linkage-monitor.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2019 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 +# +# http://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. + +set -eo pipefail +# Display commands being run. +set -x + +cd github/java-spanner/ + +# Print out Java version +java -version +echo ${JOB_TYPE} + +mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V + +# Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR +JAR=linkage-monitor-latest-all-deps.jar +curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}" + +# Fails if there's new linkage errors compared with baseline +java -jar ${JAR} com.google.cloud:libraries-bom diff --git a/.kokoro/nightly/common.cfg b/.kokoro/nightly/common.cfg new file mode 100644 index 00000000000..a802e96228a --- /dev/null +++ b/.kokoro/nightly/common.cfg @@ -0,0 +1,31 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + diff --git a/.kokoro/nightly/dependencies.cfg b/.kokoro/nightly/dependencies.cfg new file mode 100644 index 00000000000..808bf138e1c --- /dev/null +++ b/.kokoro/nightly/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/dependencies.sh" +} diff --git a/.kokoro/nightly/integration.cfg b/.kokoro/nightly/integration.cfg new file mode 100644 index 00000000000..3b017fc80f0 --- /dev/null +++ b/.kokoro/nightly/integration.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/nightly/java11.cfg b/.kokoro/nightly/java11.cfg new file mode 100644 index 00000000000..709f2b4c73d --- /dev/null +++ b/.kokoro/nightly/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/nightly/java7.cfg b/.kokoro/nightly/java7.cfg new file mode 100644 index 00000000000..cb24f44eea3 --- /dev/null +++ b/.kokoro/nightly/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/nightly/java8-osx.cfg b/.kokoro/nightly/java8-osx.cfg new file mode 100644 index 00000000000..63f547222f5 --- /dev/null +++ b/.kokoro/nightly/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.sh" diff --git a/.kokoro/nightly/java8-win.cfg b/.kokoro/nightly/java8-win.cfg new file mode 100644 index 00000000000..b219b38ad4a --- /dev/null +++ b/.kokoro/nightly/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.bat" diff --git a/.kokoro/nightly/java8.cfg b/.kokoro/nightly/java8.cfg new file mode 100644 index 00000000000..3b017fc80f0 --- /dev/null +++ b/.kokoro/nightly/java8.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/nightly/lint.cfg b/.kokoro/nightly/lint.cfg new file mode 100644 index 00000000000..6d323c8ae76 --- /dev/null +++ b/.kokoro/nightly/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/presubmit/clirr.cfg b/.kokoro/presubmit/clirr.cfg new file mode 100644 index 00000000000..ec572442e2e --- /dev/null +++ b/.kokoro/presubmit/clirr.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "clirr" +} \ No newline at end of file diff --git a/.kokoro/presubmit/common.cfg b/.kokoro/presubmit/common.cfg new file mode 100644 index 00000000000..1f79e7d98a7 --- /dev/null +++ b/.kokoro/presubmit/common.cfg @@ -0,0 +1,39 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + regex: "**/*sponge_log.txt" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/build.sh" +} + +env_vars: { + key: "JOB_TYPE" + value: "test" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "dpebot_codecov_token" + } + } +} diff --git a/.kokoro/presubmit/dependencies.cfg b/.kokoro/presubmit/dependencies.cfg new file mode 100644 index 00000000000..808bf138e1c --- /dev/null +++ b/.kokoro/presubmit/dependencies.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/dependencies.sh" +} diff --git a/.kokoro/presubmit/integration.cfg b/.kokoro/presubmit/integration.cfg new file mode 100644 index 00000000000..141f90c13c5 --- /dev/null +++ b/.kokoro/presubmit/integration.cfg @@ -0,0 +1,31 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "integration" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "keystore/73713_java_it_service_account" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "java_it_service_account" + } + } +} diff --git a/.kokoro/presubmit/java11.cfg b/.kokoro/presubmit/java11.cfg new file mode 100644 index 00000000000..709f2b4c73d --- /dev/null +++ b/.kokoro/presubmit/java11.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java11" +} diff --git a/.kokoro/presubmit/java7.cfg b/.kokoro/presubmit/java7.cfg new file mode 100644 index 00000000000..cb24f44eea3 --- /dev/null +++ b/.kokoro/presubmit/java7.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java7" +} diff --git a/.kokoro/presubmit/java8-osx.cfg b/.kokoro/presubmit/java8-osx.cfg new file mode 100644 index 00000000000..63f547222f5 --- /dev/null +++ b/.kokoro/presubmit/java8-osx.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.sh" diff --git a/.kokoro/presubmit/java8-win.cfg b/.kokoro/presubmit/java8-win.cfg new file mode 100644 index 00000000000..b219b38ad4a --- /dev/null +++ b/.kokoro/presubmit/java8-win.cfg @@ -0,0 +1,3 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +build_file: "java-spanner/.kokoro/build.bat" diff --git a/.kokoro/presubmit/java8.cfg b/.kokoro/presubmit/java8.cfg new file mode 100644 index 00000000000..3b017fc80f0 --- /dev/null +++ b/.kokoro/presubmit/java8.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} diff --git a/.kokoro/presubmit/linkage-monitor.cfg b/.kokoro/presubmit/linkage-monitor.cfg new file mode 100644 index 00000000000..083448f9f80 --- /dev/null +++ b/.kokoro/presubmit/linkage-monitor.cfg @@ -0,0 +1,12 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/linkage-monitor.sh" +} \ No newline at end of file diff --git a/.kokoro/presubmit/lint.cfg b/.kokoro/presubmit/lint.cfg new file mode 100644 index 00000000000..6d323c8ae76 --- /dev/null +++ b/.kokoro/presubmit/lint.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. + +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "lint" +} \ No newline at end of file diff --git a/.kokoro/release/bump_snapshot.cfg b/.kokoro/release/bump_snapshot.cfg new file mode 100644 index 00000000000..6b870903f64 --- /dev/null +++ b/.kokoro/release/bump_snapshot.cfg @@ -0,0 +1,53 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/bump_snapshot.sh" +} + +# tokens used by release-please to keep an up-to-date release PR. +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-key-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-token-release-please" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "github-magic-proxy-url-release-please" + } + } +} diff --git a/.kokoro/release/bump_snapshot.sh b/.kokoro/release/bump_snapshot.sh new file mode 100755 index 00000000000..65dc2b5a412 --- /dev/null +++ b/.kokoro/release/bump_snapshot.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Copyright 2019 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. + +set -eo pipefail + +export NPM_CONFIG_PREFIX=/home/node/.npm-global + +if [ -f ${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please ]; then + # Groom the snapshot release PR immediately after publishing a release + npx release-please release-pr --token=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-token-release-please \ + --repo-url=googleapis/java-spanner \ + --package-name="spanner" \ + --api-url=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-url-release-please \ + --proxy-key=${KOKORO_KEYSTORE_DIR}/73713_github-magic-proxy-key-release-please \ + --snapshot \ + --release-type=java-auth-yoshi +fi diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg new file mode 100644 index 00000000000..adffcbe4873 --- /dev/null +++ b/.kokoro/release/common.cfg @@ -0,0 +1,49 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "java-spanner/.kokoro/trampoline.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-keyring" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-passphrase" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "maven-gpg-pubkeyring" + } + } +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 70247 + keyname: "sonatype-credentials" + } + } +} diff --git a/.kokoro/release/common.sh b/.kokoro/release/common.sh new file mode 100755 index 00000000000..6e3f65999b3 --- /dev/null +++ b/.kokoro/release/common.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright 2018 Google Inc. +# +# 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 +# +# http://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. + +set -eo pipefail + +# Get secrets from keystore and set and environment variables +setup_environment_secrets() { + export GPG_PASSPHRASE=$(cat ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-passphrase) + export GPG_TTY=$(tty) + export GPG_HOMEDIR=/gpg + mkdir $GPG_HOMEDIR + mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-pubkeyring $GPG_HOMEDIR/pubring.gpg + mv ${KOKORO_KEYSTORE_DIR}/70247_maven-gpg-keyring $GPG_HOMEDIR/secring.gpg + export SONATYPE_USERNAME=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f1 -d'|') + export SONATYPE_PASSWORD=$(cat ${KOKORO_KEYSTORE_DIR}/70247_sonatype-credentials | cut -f2 -d'|') +} + +create_settings_xml_file() { + echo " + + + ossrh + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + + sonatype-nexus-staging + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + + sonatype-nexus-snapshots + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + +" > $1 +} \ No newline at end of file diff --git a/.kokoro/release/drop.cfg b/.kokoro/release/drop.cfg new file mode 100644 index 00000000000..d541e5ac427 --- /dev/null +++ b/.kokoro/release/drop.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/drop.sh" +} diff --git a/.kokoro/release/drop.sh b/.kokoro/release/drop.sh new file mode 100755 index 00000000000..5c4551efa2c --- /dev/null +++ b/.kokoro/release/drop.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright 2018 Google Inc. +# +# 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 +# +# http://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. + +set -eo pipefail + +# STAGING_REPOSITORY_ID must be set +if [ -z "${STAGING_REPOSITORY_ID}" ]; then + echo "Missing STAGING_REPOSITORY_ID environment variable" + exit 1 +fi + +source $(dirname "$0")/common.sh +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn nexus-staging:drop -B \ + --settings=settings.xml \ + -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/promote.cfg b/.kokoro/release/promote.cfg new file mode 100644 index 00000000000..5551fdd0dd7 --- /dev/null +++ b/.kokoro/release/promote.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/promote.sh" +} diff --git a/.kokoro/release/promote.sh b/.kokoro/release/promote.sh new file mode 100755 index 00000000000..1fa95fa537a --- /dev/null +++ b/.kokoro/release/promote.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2018 Google Inc. +# +# 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 +# +# http://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. + +set -eo pipefail + +# STAGING_REPOSITORY_ID must be set +if [ -z "${STAGING_REPOSITORY_ID}" ]; then + echo "Missing STAGING_REPOSITORY_ID environment variable" + exit 1 +fi + +source $(dirname "$0")/common.sh + +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn nexus-staging:release -B \ + -DperformRelease=true \ + --settings=settings.xml \ + -DstagingRepositoryId=${STAGING_REPOSITORY_ID} diff --git a/.kokoro/release/publish_javadoc.cfg b/.kokoro/release/publish_javadoc.cfg new file mode 100644 index 00000000000..2b07d18e99e --- /dev/null +++ b/.kokoro/release/publish_javadoc.cfg @@ -0,0 +1,19 @@ +# Format: //devtools/kokoro/config/proto/build.proto +env_vars: { + key: "STAGING_BUCKET" + value: "docs-staging" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/publish_javadoc.sh" +} + +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "docuploader_service_account" + } + } +} diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh new file mode 100755 index 00000000000..2809dfdfb8d --- /dev/null +++ b/.kokoro/release/publish_javadoc.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright 2019 Google Inc. +# +# 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 +# +# http://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. + +set -eo pipefail + +if [[ -z "${CREDENTIALS}" ]]; then + CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account +fi + +if [[ -z "${STAGING_BUCKET}" ]]; then + echo "Need to set STAGING_BUCKET environment variable" + exit 1 +fi + +# work from the git root directory +pushd $(dirname "$0")/../../ + +# install docuploader package +python3 -m pip install gcp-docuploader + +# compile all packages +mvn clean install -B -DskipTests=true + +NAME=google-cloud-spanner +VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) + +# build the docs +mvn site -B + +pushd target/site/apidocs + +# create metadata +python3 -m docuploader create-metadata \ + --name ${NAME} \ + --version ${VERSION} \ + --language java + +# upload docs +python3 -m docuploader upload . \ + --credentials ${CREDENTIALS} \ + --staging-bucket ${STAGING_BUCKET} + +popd diff --git a/.kokoro/release/snapshot.cfg b/.kokoro/release/snapshot.cfg new file mode 100644 index 00000000000..1f10492392c --- /dev/null +++ b/.kokoro/release/snapshot.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/snapshot.sh" +} \ No newline at end of file diff --git a/.kokoro/release/snapshot.sh b/.kokoro/release/snapshot.sh new file mode 100755 index 00000000000..098168a7373 --- /dev/null +++ b/.kokoro/release/snapshot.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2019 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 +# +# http://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. + +set -eo pipefail + +source $(dirname "$0")/common.sh +MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml +pushd $(dirname "$0")/../../ + +# ensure we're trying to push a snapshot (no-result returns non-zero exit code) +grep SNAPSHOT versions.txt + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn clean install deploy -B \ + --settings ${MAVEN_SETTINGS_FILE} \ + -DperformRelease=true \ + -Dgpg.executable=gpg \ + -Dgpg.passphrase=${GPG_PASSPHRASE} \ + -Dgpg.homedir=${GPG_HOMEDIR} diff --git a/.kokoro/release/stage.cfg b/.kokoro/release/stage.cfg new file mode 100644 index 00000000000..50752321afa --- /dev/null +++ b/.kokoro/release/stage.cfg @@ -0,0 +1,44 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/java-spanner/.kokoro/release/stage.sh" +} + +# Need to save the properties file +action { + define_artifacts { + regex: "github/java-spanner/target/nexus-staging/staging/*.properties" + strip_prefix: "github/java-spanner" + } +} + +# Fetch the token needed for reporting release status to GitHub +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "yoshi-automation-github-key" + } + } +} + +# Fetch magictoken to use with Magic Github Proxy +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "releasetool-magictoken" + } + } +} + +# Fetch api key to use with Magic Github Proxy +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "magic-github-proxy-api-key" + } + } +} diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh new file mode 100755 index 00000000000..3c482cbc55f --- /dev/null +++ b/.kokoro/release/stage.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Copyright 2018 Google Inc. +# +# 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 +# +# http://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. + +set -eo pipefail + +# Start the releasetool reporter +python3 -m pip install gcp-releasetool +python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script + +source $(dirname "$0")/common.sh +MAVEN_SETTINGS_FILE=$(realpath $(dirname "$0")/../../)/settings.xml +pushd $(dirname "$0")/../../ + +setup_environment_secrets +create_settings_xml_file "settings.xml" + +mvn clean install deploy -B \ + --settings ${MAVEN_SETTINGS_FILE} \ + -DskipTests=true \ + -DperformRelease=true \ + -Dgpg.executable=gpg \ + -Dgpg.passphrase=${GPG_PASSPHRASE} \ + -Dgpg.homedir=${GPG_HOMEDIR} + +if [[ -n "${AUTORELEASE_PR}" ]] +then + mvn nexus-staging:release -B \ + -DperformRelease=true \ + --settings=settings.xml +fi \ No newline at end of file diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh new file mode 100644 index 00000000000..ba17ce01466 --- /dev/null +++ b/.kokoro/trampoline.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright 2018 Google Inc. +# +# 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 +# +# http://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. +set -eo pipefail +# Always run the cleanup script, regardless of the success of bouncing into +# the container. +function cleanup() { + chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh + echo "cleanup"; +} +trap cleanup EXIT +python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" diff --git a/google-cloud-spanner/.repo-metadata.json b/.repo-metadata.json similarity index 73% rename from google-cloud-spanner/.repo-metadata.json rename to .repo-metadata.json index 2ff7fad1dbe..8c4767cb0c0 100644 --- a/google-cloud-spanner/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,12 +2,12 @@ "name": "spanner", "name_pretty": "Cloud Spanner", "product_documentation": "https://cloud.google.com/spanner/docs/", - "client_documentation": "https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/spanner/package-summary.html", + "client_documentation": "https://googleapis.dev/java/google-cloud-spanner/latest/", "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:190851%2B%20status:open", "release_level": "ga", "language": "java", - "repo": "googleapis/google-cloud-java", - "repo_short": "google-cloud-java", + "repo": "googleapis/java-spanner", + "repo_short": "java-spanner", "distribution_name": "com.google.cloud:google-cloud-spanner", "api_id": "spanner.googleapis.com" } \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..6b2238bb75e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,93 @@ +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *[PROJECT STEWARD NAME(s) AND EMAIL(s)]*, the +Project Steward(s) for *[PROJECT NAME]*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..ebbb59e5310 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. + +## Community Guidelines + +This project follows +[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/). \ No newline at end of file diff --git a/LICENSE b/LICENSE index 4eedc0116ad..d6456956733 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Apache License + + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ Apache License APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a diff --git a/google-cloud-spanner/README.md b/README.md similarity index 100% rename from google-cloud-spanner/README.md rename to README.md diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 00000000000..5724ea9478d --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,4 @@ +--- +codecov: + ci: + - source.cloud.google.com diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/README.md b/google-cloud-contrib/google-cloud-spanner-jdbc/README.md deleted file mode 100644 index 666bc7384d7..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# JDBC Driver for Google Cloud Spanner - -JDBC Driver for -[Google Cloud Spanner](https://cloud.google.com/spanner/). - -## Quickstart - -[//]: # ({x-version-update-start:google-cloud-spanner-jdbc:released}) -If you are using Maven, add this to your pom.xml file -```xml - - com.google.cloud - google-cloud-spanner-jdbc - 1.12.0 - -``` -If you are using Gradle, add this to your dependencies -```Groovy -compile 'com.google.cloud:google-cloud-spanner-jdbc:1.12.0' -``` -If you are using SBT, add this to your dependencies -```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner-jdbc" % "1.12.0" -``` -[//]: # ({x-version-update-end}) - -## Getting Started -You can access Google Cloud Spanner through JDBC like this: - -```java -String url = "jdbc:cloudspanner:/projects/my_project_id/" - + "instances/my_instance_id/" - + "databases/my_database_name" - + "?credentials=/home/cloudspanner-keys/my-key.json" - + ";autocommit=false"; -try (Connection connection = DriverManager.getConnection(url)) { - try(ResultSet rs = connection.createStatement() - .executeQuery("SELECT SingerId, AlbumId, MarketingBudget FROM Albums")) { - while(rs.next()) { - Long singerId = rs.getLong(1); - } - } -} -``` - -### Connection URL -The JDBC connection URL must be specified in the following format: - -``` -jdbc:cloudspanner:[//host[:port]]/projects/project-id[/instances/instance-id[/databases/database-name]][\?property-name=property-value[;property-name=property-value]*]? -``` - -The property-value strings should be url-encoded. - -The project-id part of the URI may be filled with the placeholder DEFAULT_PROJECT_ID. This -placeholder will be replaced by the default project id of the environment that is requesting a -connection. -The supported connection properties are: - -* credentials (String): URL for the credentials file to use for the connection. If you do not specify any credentials, the default credentials of the environment as returned by {@link GoogleCredentials#getApplicationDefault()} will be used. -* autocommit (boolean): Sets the initial autocommit mode for the connection. Default is true. -* readonly (boolean): Sets the initial readonly mode for the connection. Default is false. -* retryAbortsInternally (boolean): Sets the initial retryAbortsInternally mode for the connection. Default is true. See -CloudSpannerJdbcConnection#setRetryAbortsInternally(boolean) for more information. - -### Authentication -The JDBC Driver will either use the credentials that are specified in the connection URL, or if none specified, the default credentials of the environment. - -See the -[Authentication](https://github.com/googleapis/google-cloud-java#authentication) -section in the base directory's README for more information. - -## Shaded JAR - -You can build a shaded JAR of the JDBC Driver to use with third-party tools using the following command: - -``` -mvn package -Pbuild-jdbc-driver -``` - -## Java Versions - -Java 7 or above is required for using this JDBC Driver. - -## Versioning - -This library follows [Semantic Versioning](http://semver.org/). - -## Contributing - -Contributions to this library are always welcome and highly encouraged. - -See `google-cloud`'s [CONTRIBUTING] documentation and the -[shared documentation](https://github.com/googleapis/google-cloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) -for more information on how to get started. - -Please note that this project is released with a Contributor Code of Conduct. -By participating in this project you agree to abide by its terms. See -[Code of Conduct][code-of-conduct] for more information. - -## License - -Apache 2.0 - See [LICENSE] for more information. - - -[CONTRIBUTING]:https://github.com/googleapis/google-cloud-java/blob/master/CONTRIBUTING.md -[code-of-conduct]:https://github.com/googleapis/google-cloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct -[LICENSE]: https://github.com/googleapis/google-cloud-java/blob/master/LICENSE -[cloud-platform]: https://cloud.google.com/ - -[cloud-spanner]: https://cloud.google.com/spanner/ -[cloud-spanner-docs]: https://cloud.google.com/spanner/docs/overview diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/pom.xml b/google-cloud-contrib/google-cloud-spanner-jdbc/pom.xml deleted file mode 100644 index bde10c67c3b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/pom.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - 4.0.0 - google-cloud-spanner-jdbc - 1.12.1-SNAPSHOT - jar - Google Cloud Spanner JDBC - https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-contrib/google-cloud-spanner-jdbc - - JDBC driver for Google Cloud Spanner. - - - com.google.cloud - google-cloud-contrib - 0.120.1-alpha-SNAPSHOT - - - google-cloud-spanner-jdbc - - - - com.google.cloud - google-cloud-spanner - 1.47.1-SNAPSHOT - - - com.google.cloud - google-cloud-spanner - 1.47.1-SNAPSHOT - test-jar - test - - - com.google.api - gax-grpc - testlib - test - - - com.google.truth - truth - test - - - org.mockito - mockito-core - 1.9.5 - test - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M4 - - com.google.cloud.spanner.IntegrationTest - sponge_log - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.0.0-M4 - - - com.google.cloud.spanner.GceTestEnvConfig - projects/gcloud-devel/instances/spanner-testing - - com.google.cloud.spanner.IntegrationTest - com.google.cloud.spanner.FlakyTest - 2400 - - - - - integration-test - - - - - - - - - - generate-test-sql-scripts - - - - org.codehaus.mojo - exec-maven-plugin - - - generateTestScripts - compile - - java - - - com.google.cloud.spanner.jdbc.SqlTestScriptsGenerator - - - do_log_statements - true - - - test - false - - - - - - - - - - build-jdbc-driver - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - - shade - - - true - true - false - false - - - *:* - - - java:* - junit:* - - - - - - META-INF/services - java.sql.Driver - - - com.google.cloud.spanner.jdbc - ClientSideStatements.json - - - com.google.cloud.spanner.jdbc - *.sql - - - - META-INF/SIGNINGC.RSA - META-INF/SIGNINGC.SF - META-INF/DEPENDENCIES - META-INF/LICENSE - META-INF/LICENSE.txt - META-INF/NOTICE - META-INF/NOTICE.txt - - - - - - - - - - - - diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractBaseUnitOfWork.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractBaseUnitOfWork.java deleted file mode 100644 index 099fd36e357..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractBaseUnitOfWork.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.StatementExecutor.StatementTimeout; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import javax.annotation.concurrent.GuardedBy; - -/** Base for all {@link Connection}-based transactions and batches. */ -abstract class AbstractBaseUnitOfWork implements UnitOfWork { - private final StatementExecutor statementExecutor; - private final StatementTimeout statementTimeout; - - /** - * The {@link Future} that monitors the result of the statement currently being executed for this - * unit of work. - */ - @GuardedBy("this") - private Future currentlyRunningStatementFuture = null; - - enum InterceptorsUsage { - INVOKE_INTERCEPTORS, - IGNORE_INTERCEPTORS; - } - - abstract static class Builder, T extends AbstractBaseUnitOfWork> { - private StatementExecutor statementExecutor; - private StatementTimeout statementTimeout = new StatementTimeout(); - - Builder() {} - - @SuppressWarnings("unchecked") - B self() { - return (B) this; - } - - B withStatementExecutor(StatementExecutor executor) { - Preconditions.checkNotNull(executor); - this.statementExecutor = executor; - return self(); - } - - B setStatementTimeout(StatementTimeout timeout) { - Preconditions.checkNotNull(timeout); - this.statementTimeout = timeout; - return self(); - } - - abstract T build(); - } - - AbstractBaseUnitOfWork(Builder builder) { - Preconditions.checkState(builder.statementExecutor != null, "No statement executor specified"); - this.statementExecutor = builder.statementExecutor; - this.statementTimeout = builder.statementTimeout; - } - - StatementExecutor getStatementExecutor() { - return statementExecutor; - } - - StatementTimeout getStatementTimeout() { - return statementTimeout; - } - - @Override - public void cancel() { - synchronized (this) { - if (currentlyRunningStatementFuture != null - && !currentlyRunningStatementFuture.isDone() - && !currentlyRunningStatementFuture.isCancelled()) { - currentlyRunningStatementFuture.cancel(true); - } - } - } - - T asyncExecuteStatement(ParsedStatement statement, Callable callable) { - return asyncExecuteStatement(statement, callable, InterceptorsUsage.INVOKE_INTERCEPTORS); - } - - T asyncExecuteStatement( - ParsedStatement statement, Callable callable, InterceptorsUsage interceptorUsage) { - Preconditions.checkNotNull(statement); - Preconditions.checkNotNull(callable); - - if (interceptorUsage == InterceptorsUsage.INVOKE_INTERCEPTORS) { - statementExecutor.invokeInterceptors( - statement, StatementExecutionStep.EXECUTE_STATEMENT, this); - } - Future future = statementExecutor.submit(callable); - synchronized (this) { - this.currentlyRunningStatementFuture = future; - } - T res; - try { - if (statementTimeout.hasTimeout()) { - TimeUnit unit = statementTimeout.getAppropriateTimeUnit(); - res = future.get(statementTimeout.getTimeoutValue(unit), unit); - } else { - res = future.get(); - } - } catch (TimeoutException e) { - // statement timed out, cancel the execution - future.cancel(true); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.DEADLINE_EXCEEDED, - "Statement execution timeout occurred for " + statement.getSqlWithoutComments(), - e); - } catch (ExecutionException e) { - Throwable cause = e.getCause(); - Set causes = new HashSet<>(); - while (cause != null && !causes.contains(cause)) { - if (cause instanceof SpannerException) { - throw (SpannerException) cause; - } - causes.add(cause); - cause = cause.getCause(); - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNKNOWN, - "Statement execution failed for " + statement.getSqlWithoutComments(), - e); - } catch (InterruptedException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.CANCELLED, "Statement execution was interrupted", e); - } catch (CancellationException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.CANCELLED, "Statement execution was cancelled", e); - } finally { - synchronized (this) { - this.currentlyRunningStatementFuture = null; - } - } - return res; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcConnection.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcConnection.java deleted file mode 100644 index 71a1c20a62e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcConnection.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.common.annotations.VisibleForTesting; -import com.google.rpc.Code; -import java.sql.CallableStatement; -import java.sql.ResultSet; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Struct; -import java.util.Properties; -import java.util.concurrent.Executor; - -/** Base class for Cloud Spanner JDBC connections. */ -abstract class AbstractJdbcConnection extends AbstractJdbcWrapper - implements CloudSpannerJdbcConnection { - private static final String CALLABLE_STATEMENTS_UNSUPPORTED = - "Callable statements are not supported"; - private static final String ONLY_SERIALIZABLE = - "Only isolation level TRANSACTION_SERIALIZABLE is supported"; - private static final String ONLY_CLOSE_ALLOWED = - "Only holdability CLOSE_CURSORS_AT_COMMIT is supported"; - private static final String SAVEPOINTS_UNSUPPORTED = "Savepoints are not supported"; - private static final String SQLXML_UNSUPPORTED = "SQLXML is not supported"; - private static final String STRUCTS_UNSUPPORTED = "Structs are not supported"; - private static final String ABORT_UNSUPPORTED = "Abort is not supported"; - private static final String NETWORK_TIMEOUT_UNSUPPORTED = "Network timeout is not supported"; - static final String CLIENT_INFO_NOT_SUPPORTED = - "Cloud Spanner does not support any ClientInfo properties"; - - private final String connectionUrl; - private final ConnectionOptions options; - private final com.google.cloud.spanner.jdbc.Connection spanner; - - private SQLWarning firstWarning = null; - private SQLWarning lastWarning = null; - - AbstractJdbcConnection(String connectionUrl, ConnectionOptions options) { - this.connectionUrl = connectionUrl; - this.options = options; - this.spanner = options.getConnection(); - } - - /** Return the corresponding {@link com.google.cloud.spanner.jdbc.Connection} */ - com.google.cloud.spanner.jdbc.Connection getSpannerConnection() { - return spanner; - } - - @Override - public String getConnectionUrl() { - return connectionUrl; - } - - ConnectionOptions getConnectionOptions() { - return options; - } - - @Override - public CallableStatement prepareCall(String sql) throws SQLException { - return checkClosedAndThrowUnsupported(CALLABLE_STATEMENTS_UNSUPPORTED); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return checkClosedAndThrowUnsupported(CALLABLE_STATEMENTS_UNSUPPORTED); - } - - @Override - public CallableStatement prepareCall( - String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) - throws SQLException { - return checkClosedAndThrowUnsupported(CALLABLE_STATEMENTS_UNSUPPORTED); - } - - @Override - public void setTransactionIsolation(int level) throws SQLException { - checkClosed(); - JdbcPreconditions.checkArgument( - level == TRANSACTION_SERIALIZABLE - || level == TRANSACTION_REPEATABLE_READ - || level == TRANSACTION_READ_UNCOMMITTED - || level == TRANSACTION_READ_COMMITTED, - "Not a transaction isolation level"); - JdbcPreconditions.checkSqlFeatureSupported( - level == TRANSACTION_SERIALIZABLE, ONLY_SERIALIZABLE); - } - - @Override - public int getTransactionIsolation() throws SQLException { - checkClosed(); - return TRANSACTION_SERIALIZABLE; - } - - @Override - public void setHoldability(int holdability) throws SQLException { - checkClosed(); - JdbcPreconditions.checkArgument( - holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT - || holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT, - "Not a holdability value"); - JdbcPreconditions.checkSqlFeatureSupported( - holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT, ONLY_CLOSE_ALLOWED); - } - - @Override - public int getHoldability() throws SQLException { - checkClosed(); - return ResultSet.CLOSE_CURSORS_AT_COMMIT; - } - - @Override - public SQLWarning getWarnings() throws SQLException { - checkClosed(); - return firstWarning; - } - - @Override - public void clearWarnings() throws SQLException { - checkClosed(); - firstWarning = null; - lastWarning = null; - } - - @Override - public Savepoint setSavepoint() throws SQLException { - return checkClosedAndThrowUnsupported(SAVEPOINTS_UNSUPPORTED); - } - - @Override - public Savepoint setSavepoint(String name) throws SQLException { - return checkClosedAndThrowUnsupported(SAVEPOINTS_UNSUPPORTED); - } - - @Override - public void rollback(Savepoint savepoint) throws SQLException { - checkClosedAndThrowUnsupported(SAVEPOINTS_UNSUPPORTED); - } - - @Override - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - checkClosedAndThrowUnsupported(SAVEPOINTS_UNSUPPORTED); - } - - @Override - public SQLXML createSQLXML() throws SQLException { - return checkClosedAndThrowUnsupported(SQLXML_UNSUPPORTED); - } - - @Override - public void setClientInfo(String name, String value) throws SQLClientInfoException { - try { - checkClosed(); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - throw JdbcSqlExceptionFactory.clientInfoException( - e.getMessage(), ((JdbcSqlException) e).getCode()); - } else { - throw JdbcSqlExceptionFactory.clientInfoException(e.getMessage(), Code.UNKNOWN); - } - } - pushWarning(new SQLWarning(CLIENT_INFO_NOT_SUPPORTED)); - } - - @Override - public void setClientInfo(Properties properties) throws SQLClientInfoException { - try { - checkClosed(); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - throw JdbcSqlExceptionFactory.clientInfoException( - e.getMessage(), ((JdbcSqlException) e).getCode()); - } else { - throw JdbcSqlExceptionFactory.clientInfoException(e.getMessage(), Code.UNKNOWN); - } - } - pushWarning(new SQLWarning(CLIENT_INFO_NOT_SUPPORTED)); - } - - @Override - public String getClientInfo(String name) throws SQLException { - checkClosed(); - return null; - } - - @Override - public Properties getClientInfo() throws SQLException { - checkClosed(); - return null; - } - - @Override - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - return checkClosedAndThrowUnsupported(STRUCTS_UNSUPPORTED); - } - - @Override - public void abort(Executor executor) throws SQLException { - checkClosedAndThrowUnsupported(ABORT_UNSUPPORTED); - } - - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { - checkClosedAndThrowUnsupported(NETWORK_TIMEOUT_UNSUPPORTED); - } - - @Override - public int getNetworkTimeout() throws SQLException { - return checkClosedAndThrowUnsupported(NETWORK_TIMEOUT_UNSUPPORTED); - } - - @VisibleForTesting - void pushWarning(SQLWarning warning) { - if (lastWarning == null) { - firstWarning = warning; - lastWarning = warning; - } else { - lastWarning.setNextWarning(warning); - lastWarning = warning; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcPreparedStatement.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcPreparedStatement.java deleted file mode 100644 index ef0c5af4b90..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcPreparedStatement.java +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.rpc.Code; -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.Calendar; - -/** Base class for Cloud Spanner {@link PreparedStatement}s. */ -abstract class AbstractJdbcPreparedStatement extends JdbcStatement implements PreparedStatement { - private static final String METHOD_NOT_ON_PREPARED_STATEMENT = - "This method may not be called on a PreparedStatement"; - private final JdbcParameterStore parameters = new JdbcParameterStore(); - - AbstractJdbcPreparedStatement(JdbcConnection connection) { - super(connection); - } - - JdbcParameterStore getParameters() { - return parameters; - } - - private T checkClosedAndThrowNotOnPreparedStatement() throws SQLException { - checkClosed(); - throw JdbcSqlExceptionFactory.of(METHOD_NOT_ON_PREPARED_STATEMENT, Code.INVALID_ARGUMENT); - } - - @Override - public ResultSet executeQuery(String sql) throws SQLException { - return checkClosedAndThrowNotOnPreparedStatement(); - } - - @Override - public int executeUpdate(String sql) throws SQLException { - return checkClosedAndThrowNotOnPreparedStatement(); - } - - @Override - public boolean execute(String sql) throws SQLException { - return checkClosedAndThrowNotOnPreparedStatement(); - } - - @Override - public void addBatch(String sql) throws SQLException { - checkClosedAndThrowNotOnPreparedStatement(); - } - - @Override - public void setNull(int parameterIndex, int sqlType) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, null, sqlType, null); - } - - @Override - public void setBoolean(int parameterIndex, boolean value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BOOLEAN); - } - - @Override - public void setByte(int parameterIndex, byte value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.TINYINT); - } - - @Override - public void setShort(int parameterIndex, short value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.SMALLINT); - } - - @Override - public void setInt(int parameterIndex, int value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.INTEGER); - } - - @Override - public void setLong(int parameterIndex, long value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BIGINT); - } - - @Override - public void setFloat(int parameterIndex, float value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.FLOAT); - } - - @Override - public void setDouble(int parameterIndex, double value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.DOUBLE); - } - - @Override - public void setBigDecimal(int parameterIndex, BigDecimal value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.DECIMAL); - } - - @Override - public void setString(int parameterIndex, String value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR); - } - - @Override - public void setBytes(int parameterIndex, byte[] value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BINARY); - } - - @Override - public void setDate(int parameterIndex, Date value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.DATE); - } - - @Override - public void setTime(int parameterIndex, Time value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.TIME); - } - - @Override - public void setTimestamp(int parameterIndex, Timestamp value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.TIMESTAMP); - } - - @Override - public void setAsciiStream(int parameterIndex, InputStream value, int length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.VARCHAR, length); - } - - @Override - public void setUnicodeStream(int parameterIndex, InputStream value, int length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR, length); - } - - @Override - public void setBinaryStream(int parameterIndex, InputStream value, int length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BINARY, length); - } - - @Override - public void clearParameters() throws SQLException { - checkClosed(); - parameters.clearParameters(); - } - - @Override - public void setObject(int parameterIndex, Object value, int targetSqlType) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, targetSqlType, null); - } - - @Override - public void setObject(int parameterIndex, Object value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, null); - } - - @Override - public void setCharacterStream(int parameterIndex, Reader reader, int length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.NVARCHAR, length); - } - - @Override - public void setRef(int parameterIndex, Ref value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.REF); - } - - @Override - public void setBlob(int parameterIndex, Blob value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BLOB); - } - - @Override - public void setClob(int parameterIndex, Clob value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.CLOB); - } - - @Override - public void setArray(int parameterIndex, Array value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.ARRAY); - } - - @Override - public ResultSetMetaData getMetaData() throws SQLException { - checkClosed(); - try (ResultSet rs = executeQuery()) { - return rs.getMetaData(); - } - } - - @Override - public void setDate(int parameterIndex, Date value, Calendar cal) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.DATE); - } - - @Override - public void setTime(int parameterIndex, Time value, Calendar cal) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.TIME); - } - - @Override - public void setTimestamp(int parameterIndex, Timestamp value, Calendar cal) throws SQLException { - checkClosed(); - parameters.setParameter( - parameterIndex, - cal == null ? value : JdbcTypeConverter.setTimestampInCalendar(value, cal), - Types.TIMESTAMP); - } - - @Override - public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, null, sqlType, null); - } - - @Override - public void setURL(int parameterIndex, URL value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR); - } - - @Override - public void setRowId(int parameterIndex, RowId value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.ROWID); - } - - @Override - public void setNString(int parameterIndex, String value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR); - } - - @Override - public void setNCharacterStream(int parameterIndex, Reader value, long length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR); - } - - @Override - public void setNClob(int parameterIndex, NClob value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NCLOB); - } - - @Override - public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.CLOB); - } - - @Override - public void setBlob(int parameterIndex, InputStream inputStream, long length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, inputStream, Types.BLOB); - } - - @Override - public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.NCLOB); - } - - @Override - public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, xmlObject, Types.SQLXML); - } - - @Override - public void setObject(int parameterIndex, Object value, int targetSqlType, int scaleOrLength) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, targetSqlType, scaleOrLength); - } - - @Override - public void setAsciiStream(int parameterIndex, InputStream value, long length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.VARCHAR); - } - - @Override - public void setBinaryStream(int parameterIndex, InputStream value, long length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BINARY); - } - - @Override - public void setCharacterStream(int parameterIndex, Reader reader, long length) - throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.NVARCHAR); - } - - @Override - public void setAsciiStream(int parameterIndex, InputStream value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.VARCHAR); - } - - @Override - public void setBinaryStream(int parameterIndex, InputStream value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.BINARY); - } - - @Override - public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.NVARCHAR); - } - - @Override - public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, value, Types.NVARCHAR); - } - - @Override - public void setClob(int parameterIndex, Reader reader) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.CLOB); - } - - @Override - public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, inputStream, Types.BLOB); - } - - @Override - public void setNClob(int parameterIndex, Reader reader) throws SQLException { - checkClosed(); - parameters.setParameter(parameterIndex, reader, Types.NVARCHAR); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSet.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSet.java deleted file mode 100644 index 6016bd2c303..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSet.java +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; - -/** Base class for Cloud Spanner {@link ResultSet}s. */ -abstract class AbstractJdbcResultSet extends AbstractJdbcWrapper implements ResultSet { - /** The underlying Cloud Spanner {@link com.google.cloud.spanner.ResultSet}. */ - final com.google.cloud.spanner.ResultSet spanner; - /** Current fetch size hint for this result set. */ - private int fetchSize; - - AbstractJdbcResultSet(com.google.cloud.spanner.ResultSet spanner) { - this.spanner = spanner; - } - - @Override - public SQLWarning getWarnings() throws SQLException { - return null; - } - - @Override - public void clearWarnings() throws SQLException {} - - @Override - public String getCursorName() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean isLast() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void beforeFirst() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void afterLast() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean first() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean last() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean absolute(int row) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean relative(int rows) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public boolean previous() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void setFetchDirection(int direction) throws SQLException { - JdbcPreconditions.checkArgument(direction == FETCH_FORWARD, direction); - } - - @Override - public int getFetchDirection() throws SQLException { - return FETCH_FORWARD; - } - - @Override - public void setFetchSize(int rows) throws SQLException { - this.fetchSize = rows; - } - - @Override - public int getFetchSize() throws SQLException { - return fetchSize; - } - - @Override - public int getType() throws SQLException { - return TYPE_FORWARD_ONLY; - } - - @Override - public int getConcurrency() throws SQLException { - return CONCUR_READ_ONLY; - } - - @Override - public boolean rowUpdated() throws SQLException { - return false; - } - - @Override - public boolean rowInserted() throws SQLException { - return false; - } - - @Override - public boolean rowDeleted() throws SQLException { - return false; - } - - @Override - public void updateNull(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBoolean(int columnIndex, boolean x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateByte(int columnIndex, byte x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateShort(int columnIndex, short x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateInt(int columnIndex, int x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateLong(int columnIndex, long x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateFloat(int columnIndex, float x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateDouble(int columnIndex, double x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateString(int columnIndex, String x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBytes(int columnIndex, byte[] x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateDate(int columnIndex, Date x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateTime(int columnIndex, Time x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateObject(int columnIndex, Object x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNull(String columnLabel) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBoolean(String columnLabel, boolean x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateByte(String columnLabel, byte x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateShort(String columnLabel, short x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateInt(String columnLabel, int x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateLong(String columnLabel, long x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateFloat(String columnLabel, float x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateDouble(String columnLabel, double x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateString(String columnLabel, String x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBytes(String columnLabel, byte[] x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateDate(String columnLabel, Date x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateTime(String columnLabel, Time x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x, int length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader, int length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateObject(String columnLabel, Object x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void insertRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void deleteRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void refreshRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void cancelRowUpdates() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void moveToInsertRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void moveToCurrentRow() throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public Ref getRef(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public Ref getRef(String columnLabel) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateRef(int columnIndex, Ref x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateRef(String columnLabel, Ref x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(int columnIndex, Blob x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(String columnLabel, Blob x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(int columnIndex, Clob x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(String columnLabel, Clob x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateArray(int columnIndex, Array x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateArray(String columnLabel, Array x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public RowId getRowId(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public RowId getRowId(String columnLabel) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateRowId(String columnLabel, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNString(int columnIndex, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNString(String columnLabel, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(int columnIndex, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(String columnLabel, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public SQLXML getSQLXML(String columnLabel) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNCharacterStream(String columnLabel, Reader reader, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(int columnIndex, InputStream inputStream, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(String columnLabel, InputStream inputStream, long length) - throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } - - @Override - public void updateNClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcStatement.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcStatement.java deleted file mode 100644 index 94ddaf17d69..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcStatement.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType; -import com.google.rpc.Code; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.Statement; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; - -/** Base class for Cloud Spanner JDBC {@link Statement}s */ -abstract class AbstractJdbcStatement extends AbstractJdbcWrapper implements Statement { - private static final String CURSORS_NOT_SUPPORTED = "Cursors are not supported"; - private static final String ONLY_FETCH_FORWARD_SUPPORTED = "Only fetch_forward is supported"; - private boolean closed; - private boolean closeOnCompletion; - private boolean poolable; - private final JdbcConnection connection; - private int queryTimeout; - - AbstractJdbcStatement(JdbcConnection connection) { - this.connection = connection; - } - - @Override - public JdbcConnection getConnection() { - return connection; - } - - private Options.QueryOption[] getQueryOptions(QueryOption... options) throws SQLException { - QueryOption[] res = options == null ? new QueryOption[0] : options; - if (getFetchSize() > 0) { - res = Arrays.copyOf(res, res.length + 1); - res[res.length - 1] = Options.prefetchChunks(getFetchSize()); - } - return res; - } - - /** The {@link TimeUnit}s that are supported for timeout and staleness durations */ - private static final TimeUnit[] SUPPORTED_UNITS = - new TimeUnit[] { - TimeUnit.SECONDS, TimeUnit.MILLISECONDS, TimeUnit.MICROSECONDS, TimeUnit.NANOSECONDS - }; - - /** - * Get the {@link TimeUnit} with the least precision that is able to represent the timeout of this - * statement. - */ - private TimeUnit getAppropriateTimeUnit() { - int index = 0; - if (connection.getSpannerConnection().hasStatementTimeout()) { - for (TimeUnit unit : SUPPORTED_UNITS) { - long duration = connection.getSpannerConnection().getStatementTimeout(unit); - if (index + 1 < SUPPORTED_UNITS.length) { - if (duration > 0L - && duration * 1000 - == connection - .getSpannerConnection() - .getStatementTimeout(SUPPORTED_UNITS[index + 1])) { - return unit; - } - } else { - // last unit, we have to use this one - return unit; - } - index++; - } - throw new IllegalStateException("Unsupported duration"); - } - return null; - } - - /** - * Local class to temporarily hold the statement timeout of the Spanner {@link Connection}. The - * Spanner connection API sets the timeout on the connection and applies it to all statements that - * are executed on the {@link Connection}. JDBC specifies a timeout per statement, so we need to - * temporarily hold on to the timeout specified for the connection while using the timeout - * specified for a JDBC statement, and then after executing the JDBC statement setting the timeout - * on the Spanner {@link Connection} again. - */ - private static class StatementTimeout { - private final long timeout; - private final TimeUnit unit; - - private static StatementTimeout of(long timeout, TimeUnit unit) { - return new StatementTimeout(timeout, unit); - } - - private StatementTimeout(long timeout, TimeUnit unit) { - this.timeout = timeout; - this.unit = unit; - } - } - - /** - * Sets the statement timeout of the Spanner {@link Connection} to the query timeout of this JDBC - * {@link Statement} and returns the original timeout of the Spanner {@link Connection} so it can - * be reset after the execution of a statement - */ - private StatementTimeout setTemporaryStatementTimeout() throws SQLException { - StatementTimeout originalTimeout = null; - if (getQueryTimeout() > 0) { - if (connection.getSpannerConnection().hasStatementTimeout()) { - TimeUnit unit = getAppropriateTimeUnit(); - originalTimeout = - StatementTimeout.of(connection.getSpannerConnection().getStatementTimeout(unit), unit); - } - connection.getSpannerConnection().setStatementTimeout(getQueryTimeout(), TimeUnit.SECONDS); - } - return originalTimeout; - } - - /** - * Resets the statement timeout of the Spanner {@link Connection} after a JDBC {@link Statement} - * has been executed. - */ - private void resetStatementTimeout(StatementTimeout originalTimeout) throws SQLException { - if (getQueryTimeout() > 0) { - if (originalTimeout == null) { - connection.getSpannerConnection().clearStatementTimeout(); - } else { - connection - .getSpannerConnection() - .setStatementTimeout(originalTimeout.timeout, originalTimeout.unit); - } - } - } - - /** - * Executes a SQL statement on the connection of this {@link Statement} as a query. - * - * @param statement The SQL statement to executed. - * @param options {@link QueryOption}s that should be applied to the query. - * @return the result of the SQL statement as a {@link ResultSet}. - * @throws SQLException if a database error occurs. - */ - ResultSet executeQuery(com.google.cloud.spanner.Statement statement, QueryOption... options) - throws SQLException { - StatementTimeout originalTimeout = setTemporaryStatementTimeout(); - try { - return JdbcResultSet.of( - this, - connection.getSpannerConnection().executeQuery(statement, getQueryOptions(options))); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } finally { - resetStatementTimeout(originalTimeout); - } - } - - /** - * Executes a SQL statement on the connection of this {@link Statement} as an update (DML) - * statement. - * - * @param statement The SQL statement to execute. - * @return the number of rows that was inserted/updated/deleted. - * @throws SQLException if a database error occurs, or if the number of rows affected is larger - * than {@link Integer#MAX_VALUE}. - */ - int executeUpdate(com.google.cloud.spanner.Statement statement) throws SQLException { - StatementTimeout originalTimeout = setTemporaryStatementTimeout(); - try { - long count = connection.getSpannerConnection().executeUpdate(statement); - if (count > Integer.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - "update count too large for executeUpdate: " + count, Code.OUT_OF_RANGE); - } - return (int) count; - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } finally { - resetStatementTimeout(originalTimeout); - } - } - - /** - * Executes a SQL statement on the connection of this {@link Statement}. The SQL statement can be - * any supported SQL statement, including client side statements such as SET AUTOCOMMIT ON|OFF. - * - * @param statement The SQL statement to execute. - * @return a {@link StatementResult} containing either a {@link ResultSet}, an update count or - * nothing depending on the type of SQL statement. - * @throws SQLException if a database error occurs. - */ - StatementResult execute(com.google.cloud.spanner.Statement statement) throws SQLException { - StatementTimeout originalTimeout = setTemporaryStatementTimeout(); - boolean mustResetTimeout = false; - try { - StatementResult result = connection.getSpannerConnection().execute(statement); - mustResetTimeout = !resultIsSetStatementTimeout(result); - if (mustResetTimeout && resultIsShowStatementTimeout(result)) { - // it was a 'SHOW STATEMENT_TIMEOUT statement, we need to re-run to get the correct value - mustResetTimeout = false; - result = rerunShowStatementTimeout(statement, result, originalTimeout); - } - return result; - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } finally { - if (mustResetTimeout) { - resetStatementTimeout(originalTimeout); - } - } - } - - /** - * The Spanner Connection API sets the statement timeout on a {@link Connection}. JDBC on the - * other hand sets this on the {@link Statement} object. This means that when a JDBC statement has - * a query timeout set, we need to temporarily set the statement timeout on the underlying Spanner - * {@link Connection}, then execute the actual statement, and then reset the timeout on the - * Spanner connection. But if the executed statement was a SHOW STATEMENT_TIMEOUT or SET - * STATEMENT_TIMEOUT, then we need to handle it differently: - * - *
    - *
  • SHOW STATEMENT_TIMEOUT: Reset the statement timeout on the {@link Connection} to the - * original value and re-run the statement - *
  • SET STATEMENT_TIMEOUT: Do not reset the statement timeout on the {@link Connection} after - * the execution - *
- * - * @param result The result of a statement that was executed. - * @return true if the {@link StatementResult} indicates that the statement that was - * executed was a SET STATEMENT_TIMEOUT statement. - */ - private boolean resultIsSetStatementTimeout(StatementResult result) { - return result.getClientSideStatementType() == ClientSideStatementType.SET_STATEMENT_TIMEOUT; - } - - private boolean resultIsShowStatementTimeout(StatementResult result) { - return result.getClientSideStatementType() == ClientSideStatementType.SHOW_STATEMENT_TIMEOUT; - } - - private StatementResult rerunShowStatementTimeout( - com.google.cloud.spanner.Statement statement, - StatementResult result, - StatementTimeout originalTimeout) - throws SQLException { - resetStatementTimeout(originalTimeout); - return connection.getSpannerConnection().execute(statement); - } - - @Override - public int getQueryTimeout() throws SQLException { - checkClosed(); - return queryTimeout; - } - - @Override - public void setQueryTimeout(int seconds) throws SQLException { - checkClosed(); - this.queryTimeout = seconds; - } - - @Override - public void cancel() throws SQLException { - checkClosed(); - connection.getSpannerConnection().cancel(); - } - - @Override - public void close() throws SQLException { - this.closed = true; - } - - @Override - public boolean isClosed() throws SQLException { - return closed; - } - - @Override - public void setPoolable(boolean poolable) throws SQLException { - checkClosed(); - this.poolable = poolable; - } - - @Override - public boolean isPoolable() throws SQLException { - checkClosed(); - return poolable; - } - - @Override - public void closeOnCompletion() throws SQLException { - checkClosed(); - this.closeOnCompletion = true; - } - - @Override - public boolean isCloseOnCompletion() throws SQLException { - checkClosed(); - return closeOnCompletion; - } - - @Override - public int getMaxFieldSize() throws SQLException { - checkClosed(); - return 0; - } - - @Override - public void setMaxFieldSize(int max) throws SQLException { - checkClosed(); - } - - @Override - public int getMaxRows() throws SQLException { - checkClosed(); - return 0; - } - - @Override - public void setMaxRows(int max) throws SQLException { - checkClosed(); - } - - @Override - public void setEscapeProcessing(boolean enable) throws SQLException { - checkClosed(); - } - - @Override - public SQLWarning getWarnings() throws SQLException { - checkClosed(); - return null; - } - - @Override - public void clearWarnings() throws SQLException { - checkClosed(); - } - - @Override - public void setCursorName(String name) throws SQLException { - throw JdbcSqlExceptionFactory.unsupported(CURSORS_NOT_SUPPORTED); - } - - @Override - public void setFetchDirection(int direction) throws SQLException { - if (direction != ResultSet.FETCH_FORWARD) { - throw JdbcSqlExceptionFactory.unsupported(ONLY_FETCH_FORWARD_SUPPORTED); - } - } - - @Override - public int getFetchDirection() throws SQLException { - return ResultSet.FETCH_FORWARD; - } - - @Override - public int getResultSetConcurrency() throws SQLException { - return ResultSet.CONCUR_READ_ONLY; - } - - @Override - public int getResultSetType() throws SQLException { - return ResultSet.TYPE_FORWARD_ONLY; - } - - @Override - public int getResultSetHoldability() throws SQLException { - return ResultSet.CLOSE_CURSORS_AT_COMMIT; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapper.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapper.java deleted file mode 100644 index abfa0f58d8a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapper.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.Code; -import com.google.common.base.Preconditions; -import java.sql.Date; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.Timestamp; -import java.sql.Types; -import java.sql.Wrapper; - -/** Base class for all Cloud Spanner JDBC classes that implement the {@link Wrapper} interface. */ -abstract class AbstractJdbcWrapper implements Wrapper { - static final String OTHER_NAME = "OTHER"; - - /** - * Extract {@link java.sql.Types} code from Spanner {@link Type}. - * - * @param type The Cloud Spanner type to convert. May not be null. - */ - static int extractColumnType(Type type) { - Preconditions.checkNotNull(type); - if (type.equals(Type.bool())) return Types.BOOLEAN; - if (type.equals(Type.bytes())) return Types.BINARY; - if (type.equals(Type.date())) return Types.DATE; - if (type.equals(Type.float64())) return Types.DOUBLE; - if (type.equals(Type.int64())) return Types.BIGINT; - if (type.equals(Type.string())) return Types.NVARCHAR; - if (type.equals(Type.timestamp())) return Types.TIMESTAMP; - if (type.getCode() == Code.ARRAY) return Types.ARRAY; - return Types.OTHER; - } - - /** Extract Spanner type name from {@link java.sql.Types} code. */ - static String getSpannerTypeName(int sqlType) { - if (sqlType == Types.BOOLEAN) return Type.bool().getCode().name(); - if (sqlType == Types.BINARY) return Type.bytes().getCode().name(); - if (sqlType == Types.DATE) return Type.date().getCode().name(); - if (sqlType == Types.DOUBLE || sqlType == Types.FLOAT) return Type.float64().getCode().name(); - if (sqlType == Types.BIGINT - || sqlType == Types.INTEGER - || sqlType == Types.SMALLINT - || sqlType == Types.TINYINT) return Type.int64().getCode().name(); - if (sqlType == Types.NVARCHAR) return Type.string().getCode().name(); - if (sqlType == Types.TIMESTAMP) return Type.timestamp().getCode().name(); - if (sqlType == Types.ARRAY) return Code.ARRAY.name(); - - return OTHER_NAME; - } - - /** Get corresponding Java class name from {@link java.sql.Types} code. */ - static String getClassName(int sqlType) { - if (sqlType == Types.BOOLEAN) return Boolean.class.getName(); - if (sqlType == Types.BINARY) return Byte[].class.getName(); - if (sqlType == Types.DATE) return Date.class.getName(); - if (sqlType == Types.DOUBLE || sqlType == Types.FLOAT) return Double.class.getName(); - if (sqlType == Types.BIGINT - || sqlType == Types.INTEGER - || sqlType == Types.SMALLINT - || sqlType == Types.TINYINT) return Long.class.getName(); - if (sqlType == Types.NVARCHAR) return String.class.getName(); - if (sqlType == Types.TIMESTAMP) return Timestamp.class.getName(); - if (sqlType == Types.ARRAY) return Object.class.getName(); - - return null; - } - - /** - * Get corresponding Java class name from Spanner {@link Type}. - * - * @param type The Cloud Spanner type to convert. May not be null. - */ - static String getClassName(Type type) { - Preconditions.checkNotNull(type); - if (type == Type.bool()) return Boolean.class.getName(); - if (type == Type.bytes()) return byte[].class.getName(); - if (type == Type.date()) return Date.class.getName(); - if (type == Type.float64()) return Double.class.getName(); - if (type == Type.int64()) return Long.class.getName(); - if (type == Type.string()) return String.class.getName(); - if (type == Type.timestamp()) return Timestamp.class.getName(); - if (type.getCode() == Code.ARRAY) { - if (type.getArrayElementType() == Type.bool()) return Boolean[].class.getName(); - if (type.getArrayElementType() == Type.bytes()) return byte[][].class.getName(); - if (type.getArrayElementType() == Type.date()) return Date[].class.getName(); - if (type.getArrayElementType() == Type.float64()) return Double[].class.getName(); - if (type.getArrayElementType() == Type.int64()) return Long[].class.getName(); - if (type.getArrayElementType() == Type.string()) return String[].class.getName(); - if (type.getArrayElementType() == Type.timestamp()) return Timestamp[].class.getName(); - } - return null; - } - - /** Standard error message for out-of-range values. */ - private static final String OUT_OF_RANGE_MSG = "Value out of range for %s: %s"; - - /** Cast value and throw {@link SQLException} if out-of-range. */ - static byte checkedCastToByte(long val) throws SQLException { - if (val > Byte.MAX_VALUE || val < Byte.MIN_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format(OUT_OF_RANGE_MSG, "byte", val), com.google.rpc.Code.OUT_OF_RANGE); - } - return (byte) val; - } - - /** Cast value and throw {@link SQLException} if out-of-range. */ - static short checkedCastToShort(long val) throws SQLException { - if (val > Short.MAX_VALUE || val < Short.MIN_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format(OUT_OF_RANGE_MSG, "short", val), com.google.rpc.Code.OUT_OF_RANGE); - } - return (short) val; - } - - /** Cast value and throw {@link SQLException} if out-of-range. */ - static int checkedCastToInt(long val) throws SQLException { - if (val > Integer.MAX_VALUE || val < Integer.MIN_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format(OUT_OF_RANGE_MSG, "int", val), com.google.rpc.Code.OUT_OF_RANGE); - } - return (int) val; - } - - /** Cast value and throw {@link SQLException} if out-of-range. */ - static float checkedCastToFloat(double val) throws SQLException { - if (val > Float.MAX_VALUE || val < -Float.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format(OUT_OF_RANGE_MSG, "float", val), com.google.rpc.Code.OUT_OF_RANGE); - } - return (float) val; - } - - /** Should return true if this object has been closed */ - public abstract boolean isClosed() throws SQLException; - - /** Throws a {@link SQLException} if this object is closed */ - void checkClosed() throws SQLException { - if (isClosed()) { - throw JdbcSqlExceptionFactory.of( - "This " + getClass().getName() + " has been closed", - com.google.rpc.Code.FAILED_PRECONDITION); - } - } - - /** - * Throws a {@link SQLException} if this object is closed and otherwise a {@link - * SQLFeatureNotSupportedException} with the given message - */ - T checkClosedAndThrowUnsupported(String message) throws SQLException { - checkClosed(); - throw JdbcSqlExceptionFactory.unsupported(message); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return iface != null && iface.isAssignableFrom(getClass()); - } - - @Override - public T unwrap(Class iface) throws SQLException { - if (isWrapperFor(iface)) { - return iface.cast(this); - } - throw JdbcSqlExceptionFactory.of( - "Cannot unwrap to " + iface.getName(), com.google.rpc.Code.INVALID_ARGUMENT); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractMultiUseTransaction.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractMultiUseTransaction.java deleted file mode 100644 index 6468c0042da..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AbstractMultiUseTransaction.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ReadContext; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; -import java.util.concurrent.Callable; - -/** - * Base class for {@link Connection}-based transactions that can be used for multiple read and - * read/write statements. - */ -abstract class AbstractMultiUseTransaction extends AbstractBaseUnitOfWork { - - AbstractMultiUseTransaction(Builder builder) { - super(builder); - } - - @Override - public Type getType() { - return Type.TRANSACTION; - } - - @Override - public boolean isActive() { - return getState().isActive(); - } - - /** - * Check that the current transaction actually has a valid underlying transaction. If not, the - * method will throw a {@link SpannerException}. - */ - abstract void checkValidTransaction(); - - /** Returns the {@link ReadContext} that can be used for queries on this transaction. */ - abstract ReadContext getReadContext(); - - @Override - public ResultSet executeQuery( - final ParsedStatement statement, - final AnalyzeMode analyzeMode, - final QueryOption... options) { - Preconditions.checkArgument(statement.isQuery(), "Statement is not a query"); - checkValidTransaction(); - return asyncExecuteStatement( - statement, - new Callable() { - @Override - public ResultSet call() throws Exception { - return DirectExecuteResultSet.ofResultSet( - internalExecuteQuery(statement, analyzeMode, options)); - } - }); - } - - ResultSet internalExecuteQuery( - final ParsedStatement statement, AnalyzeMode analyzeMode, QueryOption... options) { - if (analyzeMode == AnalyzeMode.NONE) { - return getReadContext().executeQuery(statement.getStatement(), options); - } - return getReadContext() - .analyzeQuery(statement.getStatement(), analyzeMode.getQueryAnalyzeMode()); - } - - @Override - public long[] runBatch() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Run batch is not supported for transactions"); - } - - @Override - public void abortBatch() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Run batch is not supported for transactions"); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AnalyzeMode.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AnalyzeMode.java deleted file mode 100644 index 457ceec2a12..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AnalyzeMode.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; - -/** - * {@link AnalyzeMode} indicates whether a query should be executed as a normal query (NONE), - * whether only a query plan should be returned, or whether the query should be profiled while - * executed. - */ -enum AnalyzeMode { - NONE(null), - PLAN(QueryAnalyzeMode.PLAN), - PROFILE(QueryAnalyzeMode.PROFILE); - - private final QueryAnalyzeMode mode; - - private AnalyzeMode(QueryAnalyzeMode mode) { - this.mode = mode; - } - - QueryAnalyzeMode getQueryAnalyzeMode() { - return mode; - } - - /** Translates from the Spanner client library QueryAnalyzeMode to {@link AnalyzeMode}. */ - static AnalyzeMode of(QueryAnalyzeMode mode) { - switch (mode) { - case PLAN: - return AnalyzeMode.PLAN; - case PROFILE: - return AnalyzeMode.PROFILE; - default: - throw new IllegalArgumentException(mode + " is unknown"); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AutocommitDmlMode.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AutocommitDmlMode.java deleted file mode 100644 index c390edd1b45..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/AutocommitDmlMode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -/** Enum used to define the behavior of DML statements in autocommit mode */ -enum AutocommitDmlMode { - TRANSACTIONAL, - PARTITIONED_NON_ATOMIC; - - private final String statementString; - - private AutocommitDmlMode() { - this.statementString = name(); - } - - /** - * Use this method to get the correct format for use in a SQL statement. Autocommit dml mode must - * be wrapped between single quotes in SQL statements: - * SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL' This method returns the value - * without the single quotes. - * - * @return a string representation of this {@link AutocommitDmlMode} that can be used in a SQL - * statement. - */ - public String getStatementString() { - return statementString; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ChecksumResultSet.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ChecksumResultSet.java deleted file mode 100644 index 0e0d7b433c3..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ChecksumResultSet.java +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.ByteArray; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type.Code; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.common.hash.Funnel; -import com.google.common.hash.HashCode; -import com.google.common.hash.HashFunction; -import com.google.common.hash.Hasher; -import com.google.common.hash.Hashing; -import com.google.common.hash.PrimitiveSink; -import java.util.Objects; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; - -/** - * {@link ResultSet} implementation that keeps a running checksum that can be used to determine - * whether a transaction retry is possible or not. The checksum is based on all the rows that have - * actually been consumed by the user. If the user has not yet consumed any part of the result set - * (i.e. never called next()), the checksum will be null and retry will always be - * allowed. - * - *

If all the rows in the result set have been consumed, the checksum will be based on the values - * of all those rows, and a retry will only be possible if the query returns the exact same results - * during the retry as during the original transaction. - * - *

If some of the rows in the result set have been consumed, the checksum will be based on the - * values of the rows that have been consumed. A retry will succeed if the query returns the same - * results for the already consumed rows. - * - *

The checksum of a {@link ResultSet} is the SHA256 checksum of the current row together with - * the previous checksum value of the result set. The calculation of the checksum is executed in a - * separate {@link Thread} to allow the checksum calculation to lag behind the actual consumption of - * rows, and catch up again if the client slows down the consumption of rows, for example while - * waiting for more data from Cloud Spanner. If the checksum calculation queue contains more than - * {@link ChecksumExecutor#MAX_IN_CHECKSUM_QUEUE} items that have not yet been calculated, calls to - * {@link ResultSet#next()} will slow down in order to allow the calculation to catch up. - */ -@VisibleForTesting -class ChecksumResultSet extends ReplaceableForwardingResultSet implements RetriableStatement { - private final ReadWriteTransaction transaction; - private long numberOfNextCalls; - private final ParsedStatement statement; - private final AnalyzeMode analyzeMode; - private final QueryOption[] options; - private final ChecksumResultSet.ChecksumCalculator checksumCalculator = new ChecksumCalculator(); - - ChecksumResultSet( - ReadWriteTransaction transaction, - ResultSet delegate, - ParsedStatement statement, - AnalyzeMode analyzeMode, - QueryOption... options) { - super(delegate); - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(delegate); - Preconditions.checkNotNull(statement); - Preconditions.checkNotNull(statement.getStatement()); - Preconditions.checkNotNull(statement.getStatement().getSql()); - this.transaction = transaction; - this.statement = statement; - this.analyzeMode = analyzeMode; - this.options = options; - } - - /** Simple {@link Callable} for calling {@link ResultSet#next()} */ - private final class NextCallable implements Callable { - @Override - public Boolean call() throws Exception { - transaction - .getStatementExecutor() - .invokeInterceptors( - statement, StatementExecutionStep.CALL_NEXT_ON_RESULT_SET, transaction); - return ChecksumResultSet.super.next(); - } - } - - private final NextCallable nextCallable = new NextCallable(); - - @Override - public boolean next() { - // Call next() with retry. - boolean res = transaction.runWithRetry(nextCallable); - // Only update the checksum if there was another row to be consumed. - if (res) { - checksumCalculator.calculateNextChecksum(getCurrentRowAsStruct()); - } - numberOfNextCalls++; - return res; - } - - @VisibleForTesting - HashCode getChecksum() throws InterruptedException, ExecutionException { - // HashCode is immutable and can be safely returned. - return checksumCalculator.getChecksum(); - } - - /** - * Execute the same query as in the original transaction and consume the {@link ResultSet} to the - * same point as the original {@link ResultSet}. The {@link HashCode} of the new {@link ResultSet} - * is compared with the {@link HashCode} of the original {@link ResultSet} at the point where the - * consumption of the {@link ResultSet} stopped. - */ - @Override - public void retry(AbortedException aborted) throws AbortedException { - // Execute the same query and consume the result set to the same point as the original. - ChecksumResultSet.ChecksumCalculator newChecksumCalculator = new ChecksumCalculator(); - ResultSet resultSet = null; - long counter = 0L; - try { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - resultSet = - DirectExecuteResultSet.ofResultSet( - transaction.internalExecuteQuery(statement, analyzeMode, options)); - boolean next = true; - while (counter < numberOfNextCalls && next) { - transaction - .getStatementExecutor() - .invokeInterceptors( - statement, StatementExecutionStep.RETRY_NEXT_ON_RESULT_SET, transaction); - next = resultSet.next(); - if (next) { - newChecksumCalculator.calculateNextChecksum(resultSet.getCurrentRowAsStruct()); - } - counter++; - } - } catch (Throwable e) { - if (resultSet != null) { - resultSet.close(); - } - // If it was a SpannerException other than an AbortedException, the retry should fail - // because of different results from the database. - if (e instanceof SpannerException && !(e instanceof AbortedException)) { - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException( - aborted, (SpannerException) e); - } - // For other types of exceptions we should just re-throw the exception. - throw e; - } - // Check that we have the same number of rows and the same checksum. - HashCode newChecksum = newChecksumCalculator.getChecksum(); - HashCode currentChecksum = checksumCalculator.getChecksum(); - if (counter == numberOfNextCalls && Objects.equals(newChecksum, currentChecksum)) { - // Checksum is ok, we only need to replace the delegate result set if it's still open. - if (isClosed()) { - resultSet.close(); - } else { - replaceDelegate(resultSet); - } - } else { - // The results are not equal, there is an actual concurrent modification, so we cannot - // continue the transaction. - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } - } - - /** Calculates and keeps the current checksum of a {@link ChecksumResultSet} */ - private static final class ChecksumCalculator { - private static final HashFunction SHA256_FUNCTION = Hashing.sha256(); - private HashCode currentChecksum; - - private void calculateNextChecksum(Struct row) { - Hasher hasher = SHA256_FUNCTION.newHasher(); - if (currentChecksum != null) { - hasher.putBytes(currentChecksum.asBytes()); - } - hasher.putObject(row, StructFunnel.INSTANCE); - currentChecksum = hasher.hash(); - } - - private HashCode getChecksum() { - return currentChecksum; - } - } - - /** - * A {@link Funnel} implementation for calculating a {@link HashCode} for each row in a {@link - * ResultSet}. - */ - private enum StructFunnel implements Funnel { - INSTANCE; - private static final String NULL = "null"; - - @Override - public void funnel(Struct row, PrimitiveSink into) { - for (int i = 0; i < row.getColumnCount(); i++) { - if (row.isNull(i)) { - funnelValue(Code.STRING, null, into); - } else { - Code type = row.getColumnType(i).getCode(); - switch (type) { - case ARRAY: - funnelArray(row.getColumnType(i).getArrayElementType().getCode(), row, i, into); - break; - case BOOL: - funnelValue(type, row.getBoolean(i), into); - break; - case BYTES: - funnelValue(type, row.getBytes(i), into); - break; - case DATE: - funnelValue(type, row.getDate(i), into); - break; - case FLOAT64: - funnelValue(type, row.getDouble(i), into); - break; - case INT64: - funnelValue(type, row.getLong(i), into); - break; - case STRING: - funnelValue(type, row.getString(i), into); - break; - case TIMESTAMP: - funnelValue(type, row.getTimestamp(i), into); - break; - - case STRUCT: - default: - throw new IllegalArgumentException("unsupported row type"); - } - } - } - } - - private void funnelArray( - Code arrayElementType, Struct row, int columnIndex, PrimitiveSink into) { - funnelValue(Code.STRING, "BeginArray", into); - switch (arrayElementType) { - case BOOL: - into.putInt(row.getBooleanList(columnIndex).size()); - for (Boolean value : row.getBooleanList(columnIndex)) { - funnelValue(Code.BOOL, value, into); - } - break; - case BYTES: - into.putInt(row.getBytesList(columnIndex).size()); - for (ByteArray value : row.getBytesList(columnIndex)) { - funnelValue(Code.BYTES, value, into); - } - break; - case DATE: - into.putInt(row.getDateList(columnIndex).size()); - for (Date value : row.getDateList(columnIndex)) { - funnelValue(Code.DATE, value, into); - } - break; - case FLOAT64: - into.putInt(row.getDoubleList(columnIndex).size()); - for (Double value : row.getDoubleList(columnIndex)) { - funnelValue(Code.FLOAT64, value, into); - } - break; - case INT64: - into.putInt(row.getLongList(columnIndex).size()); - for (Long value : row.getLongList(columnIndex)) { - funnelValue(Code.INT64, value, into); - } - break; - case STRING: - into.putInt(row.getStringList(columnIndex).size()); - for (String value : row.getStringList(columnIndex)) { - funnelValue(Code.STRING, value, into); - } - break; - case TIMESTAMP: - into.putInt(row.getTimestampList(columnIndex).size()); - for (Timestamp value : row.getTimestampList(columnIndex)) { - funnelValue(Code.TIMESTAMP, value, into); - } - break; - - case ARRAY: - case STRUCT: - default: - throw new IllegalArgumentException("unsupported array element type"); - } - funnelValue(Code.STRING, "EndArray", into); - } - - private void funnelValue(Code type, T value, PrimitiveSink into) { - // Include the type name in case the type of a column has changed. - into.putUnencodedChars(type.name()); - if (value == null) { - if (type == Code.BYTES || type == Code.STRING) { - // Put length -1 to distinguish from the string value 'null'. - into.putInt(-1); - } - into.putUnencodedChars(NULL); - } else { - switch (type) { - case BOOL: - into.putBoolean((Boolean) value); - break; - case BYTES: - ByteArray byteArray = (ByteArray) value; - into.putInt(byteArray.length()); - into.putBytes(byteArray.toByteArray()); - break; - case DATE: - Date date = (Date) value; - into.putInt(date.getYear()).putInt(date.getMonth()).putInt(date.getDayOfMonth()); - break; - case FLOAT64: - into.putDouble((Double) value); - break; - case INT64: - into.putLong((Long) value); - break; - case STRING: - String stringValue = (String) value; - into.putInt(stringValue.length()); - into.putUnencodedChars(stringValue); - break; - case TIMESTAMP: - Timestamp timestamp = (Timestamp) value; - into.putLong(timestamp.getSeconds()).putInt(timestamp.getNanos()); - break; - case ARRAY: - case STRUCT: - default: - throw new IllegalArgumentException("invalid type for single value"); - } - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatement.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatement.java deleted file mode 100644 index 7bd31407a34..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatement.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ResultSet; -import java.util.List; - -/** - * A {@link ClientSideStatement} is a statement that is not sent to Google Cloud Spanner, but that - * is executed locally to for example set a certain state of a {@link Connection} or get a property - * of a {@link Connection}. - */ -interface ClientSideStatement { - - /** - * @return a list of example statements for this {@link ClientSideStatement}. If these statements - * are parsed, they will all result this in this {@link ClientSideStatement}. - */ - List getExampleStatements(); - - /** - * @return a list of statements that need to be executed on a new connection before the example - * statements may be executed on a connection. For GET READ_TIMESTAMP this would for example - * be a couple of statements that generate a read-only transaction. - */ - List getExamplePrerequisiteStatements(); - - /** - * @return true if this {@link ClientSideStatement} will return a {@link ResultSet}. - */ - boolean isQuery(); - - /** @return true if this {@link ClientSideStatement} will return an update count. */ - boolean isUpdate(); - - /** - * Execute this {@link ClientSideStatement} on the given {@link ConnectionStatementExecutor}. The - * executor calls the appropriate method(s) on the {@link Connection}. The statement argument is - * used to parse any additional properties that might be needed for the execution. - * - * @param executor The {@link ConnectionStatementExecutor} that will be used to call a method on - * the {@link Connection}. - * @param statement The original sql statement that has been parsed to this {@link - * ClientSideStatement}. This statement is used to get any additional arguments that are - * needed for the execution of the {@link ClientSideStatement}. - * @return the result of the execution of the statement. - */ - StatementResult execute(ConnectionStatementExecutor executor, String statement); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementExecutor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementExecutor.java deleted file mode 100644 index d758286d16c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementExecutor.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; - -/** - * A {@link ClientSideStatementExecutor} is used to compile {@link ClientSideStatement}s from the - * json source file, and to execute these against a {@link Connection} (through a {@link - * ConnectionStatementExecutor}). - */ -interface ClientSideStatementExecutor { - - /** - * Compiles the given {@link ClientSideStatementImpl} and registers this statement with this - * executor. A statement must be compiled before it can be executed. The parser automatically - * compiles all available statements during initialization. - * - * @param statement The statement to compile. - * @throws CompileException If the statement could not be compiled. This should never happen, as - * it would indicate that an invalid statement has been defined in the source file. - */ - void compile(ClientSideStatementImpl statement) throws CompileException; - - /** - * Executes the {@link ClientSideStatementImpl} that has been compiled and registered with this - * executor on the specified connection. - * - * @param connectionExecutor The {@link ConnectionStatementExecutor} to use to execute the - * statement on a {@link Connection}. - * @param sql The sql statement that is executed. This can be used to parse any additional - * arguments that might be needed for the execution of the {@link ClientSideStatementImpl}. - * @return the result of the execution. - * @throws Exception If an error occurs while executing the statement, for example if an invalid - * argument has been specified in the sql statement, or if the statement is invalid for the - * current state of the {@link Connection}. - */ - StatementResult execute(ConnectionStatementExecutor connectionExecutor, String sql) - throws Exception; -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementImpl.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementImpl.java deleted file mode 100644 index 551ab5aa3a8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementImpl.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import com.google.common.base.Preconditions; -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.List; -import java.util.regex.Pattern; - -/** - * Implementation of the {@link ClientSideStatement} interface. The instances of this class are - * imported from the file 'ClientSideStatements.json' in the resources folder. - */ -class ClientSideStatementImpl implements ClientSideStatement { - - /** - * Statements that set a value, such as SET AUTOCOMMIT ON|OFF, must specify a {@link - * ClientSideSetStatementImpl} that defines how the value is set. - */ - static class ClientSideSetStatementImpl { - /** The property name that is to be set, e.g. AUTOCOMMIT. */ - private String propertyName; - /** The separator between the property and the value (i.e. '=' or '\s+'). */ - private String separator; - /** Regex specifying the range of allowed values for the property. */ - private String allowedValues; - /** The class name of the {@link ClientSideStatementValueConverter} to use. */ - private String converterName; - - String getPropertyName() { - return propertyName; - } - - String getSeparator() { - return separator; - } - - String getAllowedValues() { - return allowedValues; - } - - String getConverterName() { - return converterName; - } - } - - static class CompileException extends Exception { - private static final long serialVersionUID = 1L; - private final ClientSideStatementImpl statement; - - CompileException(Throwable cause, ClientSideStatementImpl statement) { - super(cause); - this.statement = statement; - } - - @Override - public String getMessage() { - return "Could not compile statement " + this.statement.name; - } - } - - static class ExecuteException extends RuntimeException { - private static final long serialVersionUID = 1L; - private final ClientSideStatementImpl statement; - private final String sql; - - private ExecuteException(Throwable cause, ClientSideStatementImpl statement, String sql) { - super(cause); - this.statement = statement; - this.sql = sql; - } - - @Override - public String getMessage() { - return "Could not execute statement " + this.statement.name + " (" + sql + ")"; - } - } - - /** The name of this statement. Used in error and info messages. */ - private String name; - - /** - * The class name of the {@link ClientSideStatementExecutor} that should be used for this - * statement. - */ - private String executorName; - - /** The result type of this statement. */ - private ResultType resultType; - - /** The regular expression that should be used to recognize this class of statements. */ - private String regex; - - /** - * The method name of the {@link ConnectionStatementExecutor} that should be called when this - * statement is executed, for example 'statementSetAutocommit'. - */ - private String method; - - /** A list of example statements that is used for testing. */ - private List exampleStatements; - - /** - * A list of statements that need to be executed before the example statements may be executed. - */ - private List examplePrerequisiteStatements; - - /** - * If this statement sets a value, the statement definition should also contain a {@link - * ClientSideSetStatementImpl} definition that defines how the value that is to be set should be - * parsed. - */ - private ClientSideSetStatementImpl setStatement; - - /** The compiled regex pattern for recognizing this statement. */ - private Pattern pattern; - - /** A reference to the executor that should be used. */ - private ClientSideStatementExecutor executor; - - /** - * Compiles this {@link ClientSideStatementImpl}. Throws a {@link CompileException} if the - * compilation fails. This should never happen, and if it does, it is a sign of a invalid - * statement definition in the ClientSideStatements.json file. - */ - ClientSideStatementImpl compile() throws CompileException { - try { - this.pattern = Pattern.compile(regex); - this.executor = - (ClientSideStatementExecutor) - Class.forName(getClass().getPackage().getName() + "." + executorName).newInstance(); - this.executor.compile(this); - return this; - } catch (Exception e) { - throw new CompileException(e, this); - } - } - - @Override - public StatementResult execute(ConnectionStatementExecutor connection, String statement) { - Preconditions.checkState(executor != null, "This statement has not been compiled"); - try { - return executor.execute(connection, statement); - } catch (SpannerException e) { - throw e; - } catch (InvocationTargetException e) { - if (e.getCause() instanceof SpannerException) { - throw (SpannerException) e.getCause(); - } - throw new ExecuteException(e.getCause(), this, statement); - } catch (Exception e) { - throw new ExecuteException(e, this, statement); - } - } - - @Override - public boolean isQuery() { - return resultType == ResultType.RESULT_SET; - } - - @Override - public boolean isUpdate() { - return resultType == ResultType.UPDATE_COUNT; - } - - boolean matches(String statement) { - Preconditions.checkState(pattern != null, "This statement has not been compiled"); - return pattern.matcher(statement).matches(); - } - - @Override - public String toString() { - return name; - } - - Pattern getPattern() { - return pattern; - } - - String getMethodName() { - return method; - } - - @Override - public List getExampleStatements() { - return Collections.unmodifiableList(exampleStatements); - } - - @Override - public List getExamplePrerequisiteStatements() { - if (examplePrerequisiteStatements == null) { - return Collections.emptyList(); - } - return Collections.unmodifiableList(examplePrerequisiteStatements); - } - - ClientSideSetStatementImpl getSetStatement() { - return setStatement; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementNoParamExecutor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementNoParamExecutor.java deleted file mode 100644 index d2ca7fde9d0..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementNoParamExecutor.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import java.lang.reflect.Method; - -/** - * Executor to use for statements that do not set a value and do not have any parameters, such as - * SHOW AUTOCOMMIT. The executor just calls a method with no parameters. - */ -class ClientSideStatementNoParamExecutor implements ClientSideStatementExecutor { - private Method method; - - ClientSideStatementNoParamExecutor() {} - - @Override - public void compile(ClientSideStatementImpl statement) throws CompileException { - try { - this.method = ConnectionStatementExecutor.class.getDeclaredMethod(statement.getMethodName()); - } catch (NoSuchMethodException | SecurityException e) { - throw new CompileException(e, statement); - } - } - - @Override - public StatementResult execute(ConnectionStatementExecutor connection, String statement) - throws Exception { - return (StatementResult) method.invoke(connection); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementSetExecutor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementSetExecutor.java deleted file mode 100644 index aaf01eaaa85..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementSetExecutor.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.common.base.Preconditions; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Executor for {@link ClientSideStatement}s that sets a value for a property, such as SET - * AUTOCOMMIT=TRUE. - */ -class ClientSideStatementSetExecutor implements ClientSideStatementExecutor { - private ClientSideStatementImpl statement; - private Method method; - private ClientSideStatementValueConverter converter; - private Pattern allowedValuesPattern; - - @SuppressWarnings("unchecked") - @Override - public void compile(ClientSideStatementImpl statement) throws CompileException { - Preconditions.checkNotNull(statement.getSetStatement()); - try { - this.statement = statement; - this.allowedValuesPattern = - Pattern.compile( - String.format( - "(?is)\\A\\s*set\\s+%s\\s*%s\\s*%s\\s*\\z", - statement.getSetStatement().getPropertyName(), - statement.getSetStatement().getSeparator(), - statement.getSetStatement().getAllowedValues())); - Class> converterClass = - (Class>) - Class.forName( - getClass().getPackage().getName() - + "." - + statement.getSetStatement().getConverterName()); - Constructor> constructor = - converterClass.getConstructor(String.class); - this.converter = constructor.newInstance(statement.getSetStatement().getAllowedValues()); - this.method = - ConnectionStatementExecutor.class.getDeclaredMethod( - statement.getMethodName(), converter.getParameterClass()); - } catch (Exception e) { - throw new CompileException(e, statement); - } - } - - @Override - public StatementResult execute(ConnectionStatementExecutor connection, String sql) - throws Exception { - return (StatementResult) method.invoke(connection, getParameterValue(sql)); - } - - T getParameterValue(String sql) { - Matcher matcher = allowedValuesPattern.matcher(sql); - if (matcher.find() && matcher.groupCount() >= 1) { - String value = matcher.group(1); - T res = converter.convert(value); - if (res != null) { - return res; - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - String.format( - "Unknown value for %s: %s", - this.statement.getSetStatement().getPropertyName(), value)); - } else { - Matcher invalidMatcher = this.statement.getPattern().matcher(sql); - if (invalidMatcher.find() && invalidMatcher.groupCount() == 1) { - String invalidValue = invalidMatcher.group(1); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - String.format( - "Unknown value for %s: %s", - this.statement.getSetStatement().getPropertyName(), invalidValue)); - } - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, String.format("Unknown statement: %s", sql)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverter.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverter.java deleted file mode 100644 index 13b404cfe59..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -/** - * Interface for converters that are used by {@link ClientSideStatement} that sets a value that need - * to be converted from a string to a specific type. Implementing classes must have a public - * constructor that takes a String parameter. The String parameter will contain a regular expression - * for the allowed values for the property. - */ -interface ClientSideStatementValueConverter { - - /** The type to convert to. */ - Class getParameterClass(); - - /** - * The actual convert method. Should return null for values that could not be - * converted. - */ - T convert(String value); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverters.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverters.java deleted file mode 100644 index ddeb394268f..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatementValueConverters.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.protobuf.Duration; -import com.google.protobuf.util.Durations; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** Contains all {@link ClientSideStatementValueConverter} implementations. */ -class ClientSideStatementValueConverters { - /** Map for mapping case-insensitive strings to enums. */ - private static final class CaseInsensitiveEnumMap> { - private final Map map = new HashMap<>(); - - /** Create an map using the name of the enum elements as keys. */ - private CaseInsensitiveEnumMap(Class elementType) { - this( - elementType, - new Function() { - @Override - public String apply(E input) { - return input.name(); - } - }); - } - - /** Create a map using the specific function to get the key per enum value. */ - private CaseInsensitiveEnumMap(Class elementType, Function keyFunction) { - Preconditions.checkNotNull(elementType); - Preconditions.checkNotNull(keyFunction); - EnumSet set = EnumSet.allOf(elementType); - for (E e : set) { - if (map.put(keyFunction.apply(e).toUpperCase(), e) != null) { - throw new IllegalArgumentException( - "Enum contains multiple elements with the same case-insensitive key"); - } - } - } - - private E get(String value) { - Preconditions.checkNotNull(value); - return map.get(value.toUpperCase()); - } - } - - /** Converter from string to {@link Boolean} */ - static class BooleanConverter implements ClientSideStatementValueConverter { - - public BooleanConverter(String allowedValues) {} - - @Override - public Class getParameterClass() { - return Boolean.class; - } - - @Override - public Boolean convert(String value) { - if ("true".equalsIgnoreCase(value)) { - return Boolean.TRUE; - } - if ("false".equalsIgnoreCase(value)) { - return Boolean.FALSE; - } - return null; - } - } - - /** Converter from string to {@link Duration}. */ - static class DurationConverter implements ClientSideStatementValueConverter { - private final Pattern allowedValues; - - public DurationConverter(String allowedValues) { - // Remove the parentheses from the beginning and end. - this.allowedValues = - Pattern.compile( - "(?is)\\A" + allowedValues.substring(1, allowedValues.length() - 1) + "\\z"); - } - - @Override - public Class getParameterClass() { - return Duration.class; - } - - @Override - public Duration convert(String value) { - Matcher matcher = allowedValues.matcher(value); - if (matcher.find()) { - if (matcher.group(0).equalsIgnoreCase("null")) { - return Durations.fromNanos(0L); - } else { - Duration duration = - ReadOnlyStalenessUtil.createDuration( - Long.valueOf(matcher.group(1)), - ReadOnlyStalenessUtil.parseTimeUnit(matcher.group(2))); - if (duration.getSeconds() == 0L && duration.getNanos() == 0) { - return null; - } - return duration; - } - } - return null; - } - } - - /** Converter from string to possible values for read only staleness ({@link TimestampBound}). */ - static class ReadOnlyStalenessConverter - implements ClientSideStatementValueConverter { - private final Pattern allowedValues; - private final CaseInsensitiveEnumMap values = new CaseInsensitiveEnumMap<>(Mode.class); - - public ReadOnlyStalenessConverter(String allowedValues) { - // Remove the single quotes at the beginning and end. - this.allowedValues = - Pattern.compile( - "(?is)\\A" + allowedValues.substring(1, allowedValues.length() - 1) + "\\z"); - } - - @Override - public Class getParameterClass() { - return TimestampBound.class; - } - - @Override - public TimestampBound convert(String value) { - Matcher matcher = allowedValues.matcher(value); - if (matcher.find() && matcher.groupCount() >= 1) { - Mode mode = null; - int groupIndex = 0; - for (int group = 1; group <= matcher.groupCount(); group++) { - if (matcher.group(group) != null) { - mode = values.get(matcher.group(group)); - if (mode != null) { - groupIndex = group; - break; - } - } - } - switch (mode) { - case STRONG: - return TimestampBound.strong(); - case READ_TIMESTAMP: - return TimestampBound.ofReadTimestamp( - ReadOnlyStalenessUtil.parseRfc3339(matcher.group(groupIndex + 1))); - case MIN_READ_TIMESTAMP: - return TimestampBound.ofMinReadTimestamp( - ReadOnlyStalenessUtil.parseRfc3339(matcher.group(groupIndex + 1))); - case EXACT_STALENESS: - try { - return TimestampBound.ofExactStaleness( - Long.valueOf(matcher.group(groupIndex + 2)), - ReadOnlyStalenessUtil.parseTimeUnit(matcher.group(groupIndex + 3))); - } catch (IllegalArgumentException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, e.getMessage()); - } - case MAX_STALENESS: - try { - return TimestampBound.ofMaxStaleness( - Long.valueOf(matcher.group(groupIndex + 2)), - ReadOnlyStalenessUtil.parseTimeUnit(matcher.group(groupIndex + 3))); - } catch (IllegalArgumentException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, e.getMessage()); - } - default: - // fall through to allow the calling method to handle this - } - } - return null; - } - } - - /** Converter for converting strings to {@link AutocommitDmlMode} values. */ - static class AutocommitDmlModeConverter - implements ClientSideStatementValueConverter { - private final CaseInsensitiveEnumMap values = - new CaseInsensitiveEnumMap<>(AutocommitDmlMode.class); - - public AutocommitDmlModeConverter(String allowedValues) {} - - @Override - public Class getParameterClass() { - return AutocommitDmlMode.class; - } - - @Override - public AutocommitDmlMode convert(String value) { - return values.get(value); - } - } - - /** Converter for converting string values to {@link TransactionMode} values. */ - static class TransactionModeConverter - implements ClientSideStatementValueConverter { - private final CaseInsensitiveEnumMap values = - new CaseInsensitiveEnumMap<>( - TransactionMode.class, - new Function() { - @Override - public String apply(TransactionMode input) { - return input.getStatementString(); - } - }); - - public TransactionModeConverter(String allowedValues) {} - - @Override - public Class getParameterClass() { - return TransactionMode.class; - } - - @Override - public TransactionMode convert(String value) { - // Transaction mode may contain multiple spaces. - String valueWithSingleSpaces = value.replaceAll("\\s+", " "); - return values.get(valueWithSingleSpaces); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatements.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatements.java deleted file mode 100644 index 3f3d872fc66..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ClientSideStatements.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.gson.Gson; -import java.io.InputStreamReader; -import java.util.Set; - -/** This class reads and parses the {@link ClientSideStatement}s from the json file. */ -class ClientSideStatements { - private static final String STATEMENTS_DEFINITION_FILE = "ClientSideStatements.json"; - static final ClientSideStatements INSTANCE = importStatements(); - - /** - * Reads statement definitions from ClientSideStatements.json and parses these as Java objects. - */ - private static ClientSideStatements importStatements() { - Gson gson = new Gson(); - return gson.fromJson( - new InputStreamReader( - ClientSideStatements.class.getResourceAsStream(STATEMENTS_DEFINITION_FILE)), - ClientSideStatements.class); - } - - private Set statements; - - private ClientSideStatements() {} - - /** Compiles and returns all statements from the resource file. */ - Set getCompiledStatements() throws CompileException { - for (ClientSideStatementImpl statement : statements) { - statement.compile(); - } - return statements; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java deleted file mode 100644 index d4c6629b7e8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ResultSet; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.Iterator; - -/** - * JDBC connection with a number of additional Cloud Spanner specific methods. JDBC connections that - * are returned by the Cloud Spanner {@link JdbcDriver} will implement this interface. - * - *

Calling {@link Connection#unwrap(Class)} with {@link CloudSpannerJdbcConnection#getClass()} as - * input on a {@link Connection} returned by the Cloud Spanner JDBC Driver will return a {@link - * CloudSpannerJdbcConnection} instance. - */ -public interface CloudSpannerJdbcConnection extends Connection { - - /** - * @return the commit {@link Timestamp} of the last read/write transaction. If the last - * transaction was not a read/write transaction, or a read/write transaction that did not - * return a commit timestamp because the transaction was not committed, the method will throw - * a {@link SQLException}. - */ - Timestamp getCommitTimestamp() throws SQLException; - - /** - * @return the read {@link Timestamp} of the last read-only transaction. If the last transaction - * was not a read-only transaction, or a read-only transaction that did not return a read - * timestamp because no data was read, the method will throw a {@link SQLException}. - */ - Timestamp getReadTimestamp() throws SQLException; - - /** - * @return true if this connection will automatically retry read/write transactions - * that abort. This method may only be called when the connection is in read/write - * transactional mode and no transaction has been started yet. - */ - boolean isRetryAbortsInternally() throws SQLException; - - /** - * Sets whether this connection will internally retry read/write transactions that abort. The - * default is true. When internal retry is enabled, the {@link Connection} will keep - * track of a running SHA256 checksum of all {@link ResultSet}s that have been returned from Cloud - * Spanner. If the checksum that is calculated during an internal retry differs from the original - * checksum, the transaction will abort with an {@link - * AbortedDueToConcurrentModificationException}. - * - *

Note that retries of a read/write transaction that calls a non-deterministic function on - * Cloud Spanner, such as CURRENT_TIMESTAMP(), will never be successful, as the data returned - * during the retry will always be different from the original transaction. - * - *

It is also highly recommended that all queries in a read/write transaction have an ORDER BY - * clause that guarantees that the data is returned in the same order as in the original - * transaction if the transaction is internally retried. The most efficient way to achieve this is - * to always include the primary key columns at the end of the ORDER BY clause. - * - *

This method may only be called when the connection is in read/write transactional mode and - * no transaction has been started yet. - * - * @param retryAbortsInternally Set to true to internally retry transactions that are - * aborted by Spanner. When set to false, any database call on a transaction that - * has been aborted by Cloud Spanner will throw an {@link AbortedException} instead of being - * retried. Set this to false if your application already uses retry loops to handle {@link - * AbortedException}s. - */ - void setRetryAbortsInternally(boolean retryAbortsInternally) throws SQLException; - - /** - * Writes the specified mutation directly to the database and commits the change. The value is - * readable after the successful completion of this method. Writing multiple mutations to a - * database by calling this method multiple times mode is inefficient, as each call will need a - * round trip to the database. Instead, you should consider writing the mutations together by - * calling {@link CloudSpannerJdbcConnection#write(Iterable)}. - * - *

Calling this method is only allowed in autocommit mode. See {@link - * CloudSpannerJdbcConnection#bufferedWrite(Iterable)} for writing mutations in transactions. - * - * @param mutation The {@link Mutation} to write to the database. - * @throws SQLException if the {@link Connection} is not in autocommit mode or if the {@link - * Connection} is closed. - */ - void write(Mutation mutation) throws SQLException; - - /** - * Writes the specified mutations directly to the database and commits the changes. The values are - * readable after the successful completion of this method. - * - *

Calling this method is only allowed in autocommit mode. See {@link - * CloudSpannerJdbcConnection#bufferedWrite(Iterable)} for writing mutations in transactions. - * - * @param mutations The {@link Mutation}s to write to the database. - * @throws SQLException if the {@link Connection} is not in autocommit mode or if the {@link - * Connection} is closed. - */ - void write(Iterable mutations) throws SQLException; - - /** - * Buffers the given mutation locally on the current transaction of this {@link Connection}. The - * mutation will be written to the database at the next call to {@link Connection#commit()}. The - * value will not be readable on this {@link Connection} before the transaction is committed. - * - *

Calling this method is only allowed when not in autocommit mode. See {@link - * CloudSpannerJdbcConnection#write(Mutation)} for writing mutations in autocommit mode. - * - * @param mutation the {@link Mutation} to buffer for writing to the database on the next commit. - * @throws SQLException if the {@link Connection} is in autocommit mode or the {@link Connection} - * is closed. - */ - void bufferedWrite(Mutation mutation) throws SQLException; - - /** - * Buffers the given mutations locally on the current transaction of this {@link Connection}. The - * mutations will be written to the database at the next call to {@link Connection#commit()}. The - * values will not be readable on this {@link Connection} before the transaction is committed. - * - *

Calling this method is only allowed when not in autocommit mode. See {@link - * CloudSpannerJdbcConnection#write(Iterable)} for writing mutations in autocommit mode. - * - * @param mutations the {@link Mutation}s to buffer for writing to the database on the next - * commit. - * @throws SQLException if the {@link Connection} is in autocommit mode or the {@link Connection} - * is closed. - */ - void bufferedWrite(Iterable mutations) throws SQLException; - - /** - * @return a connection URL that can be used to create a new {@link Connection} that is equal to - * the initial state of this connection. If this connection was initially opened in read-only - * mode, and later changed to read-write, this will not be reflected in the connection URL - * that is returned. - */ - String getConnectionUrl(); - - /** - * @see - * com.google.cloud.spanner.jdbc.Connection#addTransactionRetryListener(TransactionRetryListener) - * @throws SQLException if the {@link Connection} is closed. - */ - void addTransactionRetryListener(TransactionRetryListener listener) throws SQLException; - - /** - * @see - * com.google.cloud.spanner.jdbc.Connection#removeTransactionRetryListener(TransactionRetryListener) - * @throws SQLException if the {@link Connection} is closed. - */ - boolean removeTransactionRetryListener(TransactionRetryListener listener) throws SQLException; - - /** - * @see com.google.cloud.spanner.jdbc.Connection#getTransactionRetryListeners() - * @throws SQLException if the {@link Connection} is closed. - */ - Iterator getTransactionRetryListeners() throws SQLException; -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/Connection.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/Connection.java deleted file mode 100644 index 0ae8ed5cd86..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/Connection.java +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import java.util.Iterator; -import java.util.concurrent.TimeUnit; - -/** - * A connection to a Cloud Spanner database. Connections are not designed to be thread-safe. The - * only exception is the {@link Connection#cancel()} method that may be called by any other thread - * to stop the execution of the current statement on the connection. - * - *

Connections accept a number of additional SQL statements for setting or changing the state of - * a {@link Connection}. These statements can only be executed using the {@link - * Connection#execute(Statement)} method: - * - *

    - *
  • SHOW AUTOCOMMIT: Returns the current value of AUTOCOMMIT of this - * connection as a {@link ResultSet} - *
  • SET AUTOCOMMIT=TRUE|FALSE: Sets the value of AUTOCOMMIT for this - * connection - *
  • SHOW READONLY: Returns the current value of READONLY of this - * connection as a {@link ResultSet} - *
  • SET READONLY=TRUE|FALSE: Sets the value of READONLY for this - * connection - *
  • SHOW RETRY_ABORTS_INTERNALLY: Returns the current value of - * RETRY_ABORTS_INTERNALLY of this connection as a {@link ResultSet} - *
  • SET RETRY_ABORTS_INTERNALLY=TRUE|FALSE: Sets the value of - * RETRY_ABORTS_INTERNALLY for this connection - *
  • SHOW AUTOCOMMIT_DML_MODE: Returns the current value of - * AUTOCOMMIT_DML_MODE of this connection as a {@link ResultSet} - *
  • SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL' | 'PARTITIONED_NON_ATOMIC': Sets the - * value of AUTOCOMMIT_DML_MODE for this connection - *
  • SHOW STATEMENT_TIMEOUT: Returns the current value of STATEMENT_TIMEOUT - * of this connection as a {@link ResultSet} - *
  • SET STATEMENT_TIMEOUT='<int64>s|ms|us|ns' | NULL: Sets the value of - * STATEMENT_TIMEOUT for this connection. The supported {@link TimeUnit}s are: - *
      - *
    • s - Seconds - *
    • ms - Milliseconds - *
    • us - Microseconds - *
    • ns - Nanoseconds - *
    - * Setting the STATEMENT_TIMEOUT to NULL will clear the value for the STATEMENT_TIMEOUT on the - * connection. - *
  • SHOW READ_TIMESTAMP: Returns the last READ_TIMESTAMP of this - * connection as a {@link ResultSet} - *
  • SHOW COMMIT_TIMESTAMP: Returns the last COMMIT_TIMESTAMP of this - * connection as a {@link ResultSet} - *
  • SHOW READ_ONLY_STALENESS: Returns the current value of - * READ_ONLY_STALENESS of this connection as a {@link ResultSet} - *
  • - * SET READ_ONLY_STALENESS='STRONG' | 'MIN_READ_TIMESTAMP <timestamp>' | 'READ_TIMESTAMP <timestamp>' | 'MAX_STALENESS <int64>s|ms|mus|ns' | 'EXACT_STALENESS (<int64>s|ms|mus|ns)' - * : Sets the value of READ_ONLY_STALENESS for this connection. - *
  • BEGIN [TRANSACTION]: Begins a new transaction. This statement is optional when - * the connection is not in autocommit mode, as a new transaction will automatically be - * started when a query or update statement is issued. In autocommit mode, this statement will - * temporarily put the connection in transactional mode, and return the connection to - * autocommit mode when COMMIT [TRANSACTION] or ROLLBACK [TRANSACTION] - * is executed - *
  • COMMIT [TRANSACTION]: Commits the current transaction - *
  • ROLLBACK [TRANSACTION]: Rollbacks the current transaction - *
  • SET TRANSACTION READ ONLY|READ WRITE: Sets the type for the current - * transaction. May only be executed before a transaction is actually running (i.e. before any - * statements have been executed in the transaction) - *
  • START BATCH DDL: Starts a batch of DDL statements. May only be executed when - * no transaction has been started and the connection is in read/write mode. The connection - * will only accept DDL statements while a DDL batch is active. - *
  • START BATCH DML: Starts a batch of DML statements. May only be executed when - * the connection is in read/write mode. The connection will only accept DML statements while - * a DML batch is active. - *
  • RUN BATCH: Ends the current batch, sends the batched DML or DDL statements to - * Spanner and blocks until all statements have been executed or an error occurs. May only be - * executed when a (possibly empty) batch is active. The statement will return the update - * counts of the batched statements as {@link ResultSet} with an ARRAY<INT64> column. In - * case of a DDL batch, this array will always be empty. - *
  • ABORT BATCH: Ends the current batch and removes any DML or DDL statements from - * the buffer without sending any statements to Spanner. May only be executed when a (possibly - * empty) batch is active. - *
- * - * Note that Cloud Spanner could abort read/write transactions in the background, and that - * any database call during a read/write transaction could fail with an {@link - * AbortedException}. This also includes calls to {@link ResultSet#next()}. - * - *

If {@link Connection#isRetryAbortsInternally()} is true, then the connection will - * silently handle any {@link AbortedException}s by internally re-acquiring all transactional locks - * and verifying (via the use of cryptographic checksums) that no underlying data has changed. If a - * change to the underlying data is detected, then an {@link - * AbortedDueToConcurrentModificationException} error will be thrown. If your application already - * uses retry loops to handle these Aborted errors, then it will be most efficient to set {@link - * Connection#isRetryAbortsInternally()} to false. - * - *

Use {@link ConnectionOptions} to create a {@link Connection}. - */ -interface Connection extends AutoCloseable { - - /** Closes this connection. This is a no-op if the {@link Connection} has alread been closed. */ - @Override - void close(); - - /** @return true if this connection has been closed. */ - boolean isClosed(); - - /** - * Sets autocommit on/off for this {@link Connection}. Connections in autocommit mode will apply - * any changes to the database directly without waiting for an explicit commit. DDL- and DML - * statements as well as {@link Mutation}s are sent directly to Spanner, and committed - * automatically unless the statement caused an error. The statement is retried in case of an - * {@link AbortedException}. All other errors will cause the underlying transaction to be rolled - * back. - * - *

A {@link Connection} that is in autocommit and read/write mode will allow all types of - * statements: Queries, DML, DDL, and Mutations (writes). If the connection is in read-only mode, - * only queries will be allowed. - * - *

{@link Connection}s in autocommit mode may also accept partitioned DML statements. See - * {@link Connection#setAutocommitDmlMode(AutocommitDmlMode)} for more information. - * - * @param autocommit true/false to turn autocommit on/off - */ - void setAutocommit(boolean autocommit); - - /** @return true if this connection is in autocommit mode */ - boolean isAutocommit(); - - /** - * Sets this connection to read-only or read-write. This method may only be called when no - * transaction is active. A connection that is in read-only mode, will never allow any kind of - * changes to the database to be submitted. - * - * @param readOnly true/false to turn read-only mode on/off - */ - void setReadOnly(boolean readOnly); - - /** @return true if this connection is in read-only mode */ - boolean isReadOnly(); - - /** - * Sets the duration the connection should wait before automatically aborting the execution of a - * statement. The default is no timeout. Statement timeouts are applied all types of statements, - * both in autocommit and transactional mode. They also apply to {@link Connection#commit()} and - * {@link Connection#rollback()} statements. - * - *

A DML statement in autocommit mode may or may not have actually been applied to the - * database, depending on when the timeout occurred. - * - *

A DML statement in a transaction that times out may still have been applied to the - * transaction. If you still decide to commit the transaction after such a timeout, the DML - * statement may or may not have been part of the transaction, depending on whether the timeout - * occurred before or after the statement was (successfully) sent to Spanner. You should therefore - * either always rollback a transaction that had a DML statement that timed out, or you should - * accept that the timed out statement still might have been applied to the database. - * - *

DDL statements and DML statements in {@link AutocommitDmlMode#PARTITIONED_NON_ATOMIC} mode - * cannot be rolled back. If such a statement times out, it may or may not have been applied to - * the database. The same applies to commit and rollback statements. - * - *

Statements that time out will throw a {@link SpannerException} with error code {@link - * ErrorCode#DEADLINE_EXCEEDED}. - * - * @param timeout The number of {@link TimeUnit}s before a statement is automatically aborted by - * the connection. Zero or negative values are not allowed. The maximum allowed value is - * 315,576,000,000 seconds. Use {@link Connection#clearStatementTimeout()} to remove a timeout - * value that has been set. - * @param unit The {@link TimeUnit} to specify the timeout value in. Must be one of {@link - * TimeUnit#NANOSECONDS}, {@link TimeUnit#MICROSECONDS}, {@link TimeUnit#MILLISECONDS}, {@link - * TimeUnit#SECONDS}. - */ - void setStatementTimeout(long timeout, TimeUnit unit); - - /** - * Clears the statement timeout value for this connection. This is a no-op if there is currently - * no statement timeout set on this connection. - */ - void clearStatementTimeout(); - - /** - * @param unit The {@link TimeUnit} to get the timeout value in. Must be one of {@link - * TimeUnit#NANOSECONDS}, {@link TimeUnit#MICROSECONDS}, {@link TimeUnit#MILLISECONDS}, {@link - * TimeUnit#SECONDS} - * @return the current statement timeout value or 0 if no timeout value has been set. - */ - long getStatementTimeout(TimeUnit unit); - - /** @return true if this {@link Connection} has a statement timeout value. */ - boolean hasStatementTimeout(); - - /** - * Cancels the currently running statement on this {@link Connection} (if any). If canceling the - * statement execution succeeds, the statement will be terminated and a {@link SpannerException} - * with code {@link ErrorCode#CANCELLED} will be thrown. The result of the statement will be the - * same as when a statement times out (see {@link Connection#setStatementTimeout(long, TimeUnit)} - * for more information). - * - *

Canceling a DDL statement in autocommit mode or a RUN BATCH statement of a DDL batch will - * cause the connection to try to cancel the execution of the DDL statement(s). This is not - * guaranteed to cancel the execution of the statement(s) on Cloud Spanner. See - * https://cloud.google.com/spanner/docs/reference/rpc/google.longrunning#google.longrunning.Operations.CancelOperation - * for more information. - * - *

Canceling a DML statement that is running in {@link - * AutocommitDmlMode#PARTITIONED_NON_ATOMIC} mode will not cancel a statement on Cloud Spanner - * that is already being executed, and its effects will still be applied to the database. - */ - void cancel(); - - /** - * Begins a new transaction for this connection. - * - *

    - *
  • Calling this method on a connection that has no transaction and that is - * not in autocommit mode, will register a new transaction that has not yet - * started on this connection - *
  • Calling this method on a connection that has no transaction and that is - * in autocommit mode, will register a new transaction that has not yet started on this - * connection, and temporarily turn off autocommit mode until the next commit/rollback - *
  • Calling this method on a connection that already has a transaction that has not yet - * started, will cause a {@link SpannerException} - *
  • Calling this method on a connection that already has a transaction that has started, will - * cause a {@link SpannerException} (no nested transactions) - *
- */ - void beginTransaction(); - - /** - * Sets the transaction mode to use for current transaction. This method may only be called when - * in a transaction, and before the transaction is actually started, i.e. before any statements - * have been executed in the transaction. - * - * @param transactionMode The transaction mode to use for the current transaction. - *
    - *
  • {@link TransactionMode#READ_ONLY_TRANSACTION} will create a read-only transaction and - * prevent any changes to written to the database through this transaction. The read - * timestamp to be used will be determined based on the current readOnlyStaleness - * setting of this connection. It is recommended to use {@link - * TransactionMode#READ_ONLY_TRANSACTION} instead of {@link - * TransactionMode#READ_WRITE_TRANSACTION} when possible, as read-only transactions do - * not acquire locks on Cloud Spanner, and read-only transactions never abort. - *
  • {@link TransactionMode#READ_WRITE_TRANSACTION} this value is only allowed when the - * connection is not in read-only mode and will create a read-write transaction. If - * {@link Connection#isRetryAbortsInternally()} is true, each read/write - * transaction will keep track of a running SHA256 checksum for each {@link ResultSet} - * that is returned in order to be able to retry the transaction in case the transaction - * is aborted by Spanner. - *
- */ - void setTransactionMode(TransactionMode transactionMode); - - /** - * @return the transaction mode of the current transaction. This method may only be called when - * the connection is in a transaction. - */ - TransactionMode getTransactionMode(); - - /** - * @return true if this connection will automatically retry read/write transactions - * that abort. This method may only be called when the connection is in read/write - * transactional mode and no transaction has been started yet. - */ - boolean isRetryAbortsInternally(); - - /** - * Sets whether this connection will internally retry read/write transactions that abort. The - * default is true. When internal retry is enabled, the {@link Connection} will keep - * track of a running SHA256 checksum of all {@link ResultSet}s that have been returned from Cloud - * Spanner. If the checksum that is calculated during an internal retry differs from the original - * checksum, the transaction will abort with an {@link - * AbortedDueToConcurrentModificationException}. - * - *

Note that retries of a read/write transaction that calls a non-deterministic function on - * Cloud Spanner, such as CURRENT_TIMESTAMP(), will never be successful, as the data returned - * during the retry will always be different from the original transaction. - * - *

It is also highly recommended that all queries in a read/write transaction have an ORDER BY - * clause that guarantees that the data is returned in the same order as in the original - * transaction if the transaction is internally retried. The most efficient way to achieve this is - * to always include the primary key columns at the end of the ORDER BY clause. - * - *

This method may only be called when the connection is in read/write transactional mode and - * no transaction has been started yet. - * - * @param retryAbortsInternally Set to true to internally retry transactions that are - * aborted by Spanner. When set to false, any database call on a transaction that - * has been aborted by Cloud Spanner will throw an {@link AbortedException} instead of being - * retried. Set this to false if your application already uses retry loops to handle {@link - * AbortedException}s. - */ - void setRetryAbortsInternally(boolean retryAbortsInternally); - - /** - * Add a {@link TransactionRetryListener} to this {@link Connection} for testing and logging - * purposes. The method {@link TransactionRetryListener#retryStarting(Timestamp, long, int)} will - * be called before an automatic retry is started for a read/write transaction on this connection. - * The method {@link TransactionRetryListener#retryFinished(Timestamp, long, int, - * TransactionRetryListener.RetryResult)} will be called after the retry has finished. - * - * @param listener The listener to add to this connection. - */ - void addTransactionRetryListener(TransactionRetryListener listener); - - /** - * Removes one existing {@link TransactionRetryListener} from this {@link Connection}, if it is - * present (optional operation). - * - * @param listener The listener to remove from the connection. - * @return true if a listener was removed from the connection. - */ - boolean removeTransactionRetryListener(TransactionRetryListener listener); - - /** - * @return an unmodifiable iterator of the {@link TransactionRetryListener}s registered for this - * connection. - */ - Iterator getTransactionRetryListeners(); - - /** - * Sets the mode for executing DML statements in autocommit mode for this connection. This setting - * is only used when the connection is in autocommit mode, and may only be set while the - * transaction is in autocommit mode and not in a temporary transaction. The autocommit - * transaction mode is reset to its default value of {@link AutocommitDmlMode#TRANSACTIONAL} when - * autocommit mode is changed on the connection. - * - * @param mode The DML autocommit mode to use - *

    - *
  • {@link AutocommitDmlMode#TRANSACTIONAL} DML statements are executed as single - * read-write transaction. After successful execution, the DML statement is guaranteed - * to have been applied exactly once to the database - *
  • {@link AutocommitDmlMode#PARTITIONED_NON_ATOMIC} DML statements are executed as - * partitioned DML transactions. If an error occurs during the execution of the DML - * statement, it is possible that the statement has been applied to some but not all of - * the rows specified in the statement. - *
- */ - void setAutocommitDmlMode(AutocommitDmlMode mode); - - /** - * @return the current {@link AutocommitDmlMode} setting for this connection. This method may only - * be called on a connection that is in autocommit mode and not while in a temporary - * transaction. - */ - AutocommitDmlMode getAutocommitDmlMode(); - - /** - * Sets the staleness to use for the current read-only transaction. This method may only be called - * when the transaction mode of the current transaction is {@link - * TransactionMode#READ_ONLY_TRANSACTION} and there is no transaction that has started, or when - * the connection is in read-only and autocommit mode. - * - * @param staleness The staleness to use for the current but not yet started read-only transaction - */ - void setReadOnlyStaleness(TimestampBound staleness); - - /** - * @return the read-only staleness setting for the current read-only transaction. This method may - * only be called when the current transaction is a read-only transaction, or when the - * connection is in read-only and autocommit mode. - */ - TimestampBound getReadOnlyStaleness(); - - /** - * Commits the current transaction of this connection. All mutations that have been buffered - * during the current transaction will be written to the database. - * - *

If the connection is in autocommit mode, and there is a temporary transaction active on this - * connection, calling this method will cause the connection to go back to autocommit mode after - * calling this method. - * - *

This method will throw a {@link SpannerException} with code {@link - * ErrorCode#DEADLINE_EXCEEDED} if a statement timeout has been set on this connection, and the - * commit operation takes longer than this timeout. - * - *

    - *
  • Calling this method on a connection in autocommit mode and with no temporary transaction, - * will cause an exception - *
  • Calling this method while a DDL batch is active will cause an exception - *
  • Calling this method on a connection with a transaction that has not yet started, will end - * that transaction and any properties that might have been set on that transaction, and - * return the connection to its previous state. This means that if a transaction is created - * and set to read-only, and then committed before any statements have been executed, the - * read-only transaction is ended and any subsequent statements will be executed in a new - * transaction. If the connection is in read-write mode, the default for new transactions - * will be {@link TransactionMode#READ_WRITE_TRANSACTION}. Committing an empty transaction - * also does not generate a read timestamp or a commit timestamp, and calling one of the - * methods {@link Connection#getReadTimestamp()} or {@link Connection#getCommitTimestamp()} - * will cause an exception. - *
  • Calling this method on a connection with a {@link TransactionMode#READ_ONLY_TRANSACTION} - * transaction will end that transaction. If the connection is in read-write mode, any - * subsequent transaction will by default be a {@link - * TransactionMode#READ_WRITE_TRANSACTION} transaction, unless any following transaction is - * explicitly set to {@link TransactionMode#READ_ONLY_TRANSACTION} - *
  • Calling this method on a connection with a {@link TransactionMode#READ_WRITE_TRANSACTION} - * transaction will send all buffered mutations to the database, commit any DML statements - * that have been executed during this transaction and end the transaction. - *
- */ - void commit(); - - /** - * Rollbacks the current transaction of this connection. All mutations or DDL statements that have - * been buffered during the current transaction will be removed from the buffer. - * - *

If the connection is in autocommit mode, and there is a temporary transaction active on this - * connection, calling this method will cause the connection to go back to autocommit mode after - * calling this method. - * - *

    - *
  • Calling this method on a connection in autocommit mode and with no temporary transaction - * will cause an exception - *
  • Calling this method while a DDL batch is active will cause an exception - *
  • Calling this method on a connection with a transaction that has not yet started, will end - * that transaction and any properties that might have been set on that transaction, and - * return the connection to its previous state. This means that if a transaction is created - * and set to read-only, and then rolled back before any statements have been executed, the - * read-only transaction is ended and any subsequent statements will be executed in a new - * transaction. If the connection is in read-write mode, the default for new transactions - * will be {@link TransactionMode#READ_WRITE_TRANSACTION}. - *
  • Calling this method on a connection with a {@link TransactionMode#READ_ONLY_TRANSACTION} - * transaction will end that transaction. If the connection is in read-write mode, any - * subsequent transaction will by default be a {@link - * TransactionMode#READ_WRITE_TRANSACTION} transaction, unless any following transaction is - * explicitly set to {@link TransactionMode#READ_ONLY_TRANSACTION} - *
  • Calling this method on a connection with a {@link TransactionMode#READ_WRITE_TRANSACTION} - * transaction will clear all buffered mutations, rollback any DML statements that have been - * executed during this transaction and end the transaction. - *
- */ - void rollback(); - - /** - * @return true if this connection has a transaction (that has not necessarily - * started). This method will only return false when the {@link Connection} is in autocommit - * mode and no explicit transaction has been started by calling {@link - * Connection#beginTransaction()}. If the {@link Connection} is not in autocommit mode, there - * will always be a transaction. - */ - boolean isInTransaction(); - - /** - * @return true if this connection has a transaction that has started. A transaction - * is automatically started by the first statement that is executed in the transaction. - */ - boolean isTransactionStarted(); - - /** - * Returns the read timestamp of the current/last {@link TransactionMode#READ_ONLY_TRANSACTION} - * transaction, or the read timestamp of the last query in autocommit mode. - * - *
    - *
  • When in autocommit mode: The method will return the read timestamp of the last statement - * if the last statement was a query. - *
  • When in a {@link TransactionMode#READ_ONLY_TRANSACTION} transaction that has started (a - * query has been executed), or that has just committed: The read timestamp of the - * transaction. If the read-only transaction was committed without ever executing a query, - * calling this method after the commit will also throw a {@link SpannerException} - *
  • In all other cases the method will throw a {@link SpannerException}. - *
- * - * @return the read timestamp of the current/last read-only transaction. - */ - Timestamp getReadTimestamp(); - - /** - * @return the commit timestamp of the last {@link TransactionMode#READ_WRITE_TRANSACTION} - * transaction. This method will throw a {@link SpannerException} if there is no last {@link - * TransactionMode#READ_WRITE_TRANSACTION} transaction (i.e. the last transaction was a {@link - * TransactionMode#READ_ONLY_TRANSACTION}), or if the last {@link - * TransactionMode#READ_WRITE_TRANSACTION} transaction rolled back. It will also throw a - * {@link SpannerException} if the last {@link TransactionMode#READ_WRITE_TRANSACTION} - * transaction was empty when committed. - */ - Timestamp getCommitTimestamp(); - - /** - * Starts a new DDL batch on this connection. A DDL batch allows several DDL statements to be - * grouped into a batch that can be executed as a group. DDL statements that are issued during the - * batch are buffered locally and will return immediately with an OK. It is not guaranteed that a - * DDL statement that has been issued during a batch will eventually succeed when running the - * batch. Aborting a DDL batch will clear the DDL buffer and will have made no changes to the - * database. Running a DDL batch will send all buffered DDL statements to Spanner, and Spanner - * will try to execute these. The result will be OK if all the statements executed successfully. - * If a statement cannot be executed, Spanner will stop execution at that point and return an - * error message for the statement that could not be executed. Preceding statements of the batch - * may have been executed. - * - *

This method may only be called when the connection is in read/write mode, autocommit mode is - * enabled or no read/write transaction has been started, and there is not already another batch - * active. The connection will only accept DDL statements while a DDL batch is active. - */ - void startBatchDdl(); - - /** - * Starts a new DML batch on this connection. A DML batch allows several DML statements to be - * grouped into a batch that can be executed as a group. DML statements that are issued during the - * batch are buffered locally and will return immediately with an OK. It is not guaranteed that a - * DML statement that has been issued during a batch will eventually succeed when running the - * batch. Aborting a DML batch will clear the DML buffer and will have made no changes to the - * database. Running a DML batch will send all buffered DML statements to Spanner, and Spanner - * will try to execute these. The result will be OK if all the statements executed successfully. - * If a statement cannot be executed, Spanner will stop execution at that point and return {@link - * SpannerBatchUpdateException} for the statement that could not be executed. Preceding statements - * of the batch will have been executed, and the update counts of those statements can be - * retrieved through {@link SpannerBatchUpdateException#getUpdateCounts()}. - * - *

This method may only be called when the connection is in read/write mode, autocommit mode is - * enabled or no read/write transaction has been started, and there is not already another batch - * active. The connection will only accept DML statements while a DML batch is active. - */ - void startBatchDml(); - - /** - * Sends all buffered DML or DDL statements of the current batch to the database, waits for these - * to be executed and ends the current batch. The method will throw an exception for the first - * statement that cannot be executed, or return successfully if all statements could be executed. - * If an exception is thrown for a statement in the batch, the preceding statements in the same - * batch may still have been applied to the database. - * - *

This method may only be called when a (possibly empty) batch is active. - * - * @return the update counts in case of a DML batch. Returns an array containing 1 for each - * successful statement and 0 for each failed statement or statement that was not executed DDL - * in case of a DDL batch. - */ - long[] runBatch(); - - /** - * Clears all buffered statements in the current batch and ends the batch. - * - *

This method may only be called when a (possibly empty) batch is active. - */ - void abortBatch(); - - /** @return true if a DDL batch is active on this connection. */ - boolean isDdlBatchActive(); - - /** @return true if a DML batch is active on this connection. */ - boolean isDmlBatchActive(); - - /** - * Executes the given statement if allowed in the current {@link TransactionMode} and connection - * state. The returned value depends on the type of statement: - * - *

    - *
  • Queries will return a {@link ResultSet} - *
  • DML statements will return an update count - *
  • DDL statements will return a {@link ResultType#NO_RESULT} - *
  • Connection and transaction statements (SET AUTOCOMMIT=TRUE|FALSE, SHOW AUTOCOMMIT, SET - * TRANSACTION READ ONLY, etc) will return either a {@link ResultSet} or {@link - * ResultType#NO_RESULT}, depending on the type of statement (SHOW or SET) - *
- * - * @param statement The statement to execute - * @return the result of the statement - */ - StatementResult execute(Statement statement); - - /** - * Executes the given statement as a query and returns the result as a {@link ResultSet}. This - * method blocks and waits for a response from Spanner. If the statement does not contain a valid - * query, the method will throw a {@link SpannerException}. - * - * @param query The query statement to execute - * @param options the options to configure the query - * @return a {@link ResultSet} with the results of the query - */ - ResultSet executeQuery(Statement query, QueryOption... options); - - /** - * Analyzes a query and returns query plan and/or query execution statistics information. - * - *

The query plan and query statistics information is contained in {@link - * com.google.spanner.v1.ResultSetStats} that can be accessed by calling {@link - * ResultSet#getStats()} on the returned {@code ResultSet}. - * - *

-   * 
-   * {@code
-   * ResultSet resultSet =
-   *     connection.analyzeQuery(
-   *         Statement.of("SELECT SingerId, AlbumId, MarketingBudget FROM Albums"),
-   *         ReadContext.QueryAnalyzeMode.PROFILE);
-   * while (resultSet.next()) {
-   *   // Discard the results. We're only processing because getStats() below requires it.
-   * }
-   * ResultSetStats stats = resultSet.getStats();
-   * }
-   * 
-   * 
- * - * @param query the query statement to execute - * @param queryMode the mode in which to execute the query - */ - ResultSet analyzeQuery(Statement query, QueryAnalyzeMode queryMode); - - /** - * Executes the given statement as a DML statement. If the statement does not contain a valid DML - * statement, the method will throw a {@link SpannerException}. - * - * @param update The update statement to execute - * @return the number of records that were inserted/updated/deleted by this statement - */ - long executeUpdate(Statement update); - - /** - * Executes a list of DML statements in a single request. The statements will be executed in order - * and the semantics is the same as if each statement is executed by {@link - * Connection#executeUpdate(Statement)} in a loop. This method returns an array of long integers, - * each representing the number of rows modified by each statement. - * - *

If an individual statement fails, execution stops and a {@code SpannerBatchUpdateException} - * is returned, which includes the error and the number of rows affected by the statements that - * are run prior to the error. - * - *

For example, if statements contains 3 statements, and the 2nd one is not a valid DML. This - * method throws a {@code SpannerBatchUpdateException} that contains the error message from the - * 2nd statement, and an array of length 1 that contains the number of rows modified by the 1st - * statement. The 3rd statement will not run. Executes the given statements as DML statements in - * one batch. If one of the statements does not contain a valid DML statement, the method will - * throw a {@link SpannerException}. - * - * @param updates The update statements that will be executed as one batch. - * @return an array containing the update counts per statement. - */ - long[] executeBatchUpdate(Iterable updates); - - /** - * Writes the specified mutation directly to the database and commits the change. The value is - * readable after the successful completion of this method. Writing multiple mutations to a - * database by calling this method multiple times mode is inefficient, as each call will need a - * round trip to the database. Instead, you should consider writing the mutations together by - * calling {@link Connection#write(Iterable)}. - * - *

Calling this method is only allowed in autocommit mode. See {@link - * Connection#bufferedWrite(Iterable)} for writing mutations in transactions. - * - * @param mutation The {@link Mutation} to write to the database - * @throws SpannerException if the {@link Connection} is not in autocommit mode - */ - void write(Mutation mutation); - - /** - * Writes the specified mutations directly to the database and commits the changes. The values are - * readable after the successful completion of this method. - * - *

Calling this method is only allowed in autocommit mode. See {@link - * Connection#bufferedWrite(Iterable)} for writing mutations in transactions. - * - * @param mutations The {@link Mutation}s to write to the database - * @throws SpannerException if the {@link Connection} is not in autocommit mode - */ - void write(Iterable mutations); - - /** - * Buffers the given mutation locally on the current transaction of this {@link Connection}. The - * mutation will be written to the database at the next call to {@link Connection#commit()}. The - * value will not be readable on this {@link Connection} before the transaction is committed. - * - *

Calling this method is only allowed when not in autocommit mode. See {@link - * Connection#write(Mutation)} for writing mutations in autocommit mode. - * - * @param mutation the {@link Mutation} to buffer for writing to the database on the next commit - * @throws SpannerException if the {@link Connection} is in autocommit mode - */ - void bufferedWrite(Mutation mutation); - - /** - * Buffers the given mutations locally on the current transaction of this {@link Connection}. The - * mutations will be written to the database at the next call to {@link Connection#commit()}. The - * values will not be readable on this {@link Connection} before the transaction is committed. - * - *

Calling this method is only allowed when not in autocommit mode. See {@link - * Connection#write(Iterable)} for writing mutations in autocommit mode. - * - * @param mutations the {@link Mutation}s to buffer for writing to the database on the next commit - * @throws SpannerException if the {@link Connection} is in autocommit mode - */ - void bufferedWrite(Iterable mutations); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionImpl.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionImpl.java deleted file mode 100644 index 8490dfcd5f9..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionImpl.java +++ /dev/null @@ -1,1001 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.jdbc.StatementExecutor.StatementTimeout; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Stack; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import org.threeten.bp.Instant; - -/** Implementation for {@link Connection}, the generic Spanner connection API (not JDBC). */ -class ConnectionImpl implements Connection { - private static final String CLOSED_ERROR_MSG = "This connection is closed"; - private static final String ONLY_ALLOWED_IN_AUTOCOMMIT = - "This method may only be called while in autocommit mode"; - private static final String NOT_ALLOWED_IN_AUTOCOMMIT = - "This method may not be called while in autocommit mode"; - - /** - * Exception that is used to register the stacktrace of the code that opened a {@link Connection}. - * This exception is logged if the application closes without first closing the connection. - */ - static class LeakedConnectionException extends RuntimeException { - private static final long serialVersionUID = 7119433786832158700L; - - private LeakedConnectionException() { - super("Connection was opened at " + Instant.now()); - } - } - - private volatile LeakedConnectionException leakedException = new LeakedConnectionException(); - private final SpannerPool spannerPool; - private final StatementParser parser = StatementParser.INSTANCE; - /** - * The {@link ConnectionStatementExecutor} is responsible for translating parsed {@link - * ClientSideStatement}s into actual method calls on this {@link ConnectionImpl}. I.e. the {@link - * ClientSideStatement} 'SET AUTOCOMMIT ON' will be translated into the method call {@link - * ConnectionImpl#setAutocommit(boolean)} with value true. - */ - private final ConnectionStatementExecutor connectionStatementExecutor = - new ConnectionStatementExecutorImpl(this); - - /** Simple thread factory that is used for fire-and-forget rollbacks. */ - static final class DaemonThreadFactory implements ThreadFactory { - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r); - t.setName("connection-rollback-executor"); - t.setDaemon(true); - return t; - } - } - - /** - * Statements are executed using a separate thread in order to be able to cancel these. Statements - * are automatically cancelled if the configured {@link ConnectionImpl#statementTimeout} is - * exceeded. In autocommit mode, the connection will try to rollback the effects of an update - * statement, but this is not guaranteed to actually succeed. - */ - private final StatementExecutor statementExecutor; - - /** - * The {@link ConnectionOptions} that were used to create this {@link ConnectionImpl}. This is - * retained as it is used for getting a {@link Spanner} object and removing this connection from - * the {@link SpannerPool}. - */ - private final ConnectionOptions options; - - /** The supported batch modes. */ - enum BatchMode { - NONE, - DDL, - DML; - } - - /** - * This query option is used internally to indicate that a query is executed by the library itself - * to fetch metadata. These queries are specifically allowed to be executed even when a DDL batch - * is active. - */ - static final class InternalMetadataQuery implements QueryOption { - static final InternalMetadataQuery INSTANCE = new InternalMetadataQuery(); - - private InternalMetadataQuery() {} - } - - /** The combination of all transaction modes and batch modes. */ - enum UnitOfWorkType { - READ_ONLY_TRANSACTION { - @Override - TransactionMode getTransactionMode() { - return TransactionMode.READ_ONLY_TRANSACTION; - } - }, - READ_WRITE_TRANSACTION { - @Override - TransactionMode getTransactionMode() { - return TransactionMode.READ_WRITE_TRANSACTION; - } - }, - DML_BATCH { - @Override - TransactionMode getTransactionMode() { - return TransactionMode.READ_WRITE_TRANSACTION; - } - }, - DDL_BATCH { - @Override - TransactionMode getTransactionMode() { - return null; - } - }; - - abstract TransactionMode getTransactionMode(); - - static UnitOfWorkType of(TransactionMode transactionMode) { - switch (transactionMode) { - case READ_ONLY_TRANSACTION: - return UnitOfWorkType.READ_ONLY_TRANSACTION; - case READ_WRITE_TRANSACTION: - return UnitOfWorkType.READ_WRITE_TRANSACTION; - default: - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "Unknown transaction mode: " + transactionMode); - } - } - } - - private StatementExecutor.StatementTimeout statementTimeout = - new StatementExecutor.StatementTimeout(); - private boolean closed = false; - - private final Spanner spanner; - private DdlClient ddlClient; - private DatabaseClient dbClient; - private boolean autocommit; - private boolean readOnly; - - private UnitOfWork currentUnitOfWork = null; - /** - * The {@link ConnectionImpl#inTransaction} field is only used in autocommit mode to indicate that - * the user has explicitly started a transaction. - */ - private boolean inTransaction = false; - /** - * This field is used to indicate that a transaction begin has been indicated. This is done by - * calling beginTransaction or by setting a transaction property while not in autocommit mode. - */ - private boolean transactionBeginMarked = false; - - private BatchMode batchMode; - private UnitOfWorkType unitOfWorkType; - private final Stack transactionStack = new Stack<>(); - private boolean retryAbortsInternally; - private final List transactionRetryListeners = new ArrayList<>(); - private AutocommitDmlMode autocommitDmlMode = AutocommitDmlMode.TRANSACTIONAL; - private TimestampBound readOnlyStaleness = TimestampBound.strong(); - - /** Create a connection and register it in the SpannerPool. */ - ConnectionImpl(ConnectionOptions options) { - Preconditions.checkNotNull(options); - this.statementExecutor = new StatementExecutor(options.getStatementExecutionInterceptors()); - this.spannerPool = SpannerPool.INSTANCE; - this.options = options; - this.spanner = spannerPool.getSpanner(options, this); - this.dbClient = spanner.getDatabaseClient(options.getDatabaseId()); - this.retryAbortsInternally = options.isRetryAbortsInternally(); - this.readOnly = options.isReadOnly(); - this.autocommit = options.isAutocommit(); - this.ddlClient = createDdlClient(); - setDefaultTransactionOptions(); - } - - /** Constructor only for test purposes. */ - @VisibleForTesting - ConnectionImpl( - ConnectionOptions options, - SpannerPool spannerPool, - DdlClient ddlClient, - DatabaseClient dbClient) { - Preconditions.checkNotNull(options); - Preconditions.checkNotNull(spannerPool); - Preconditions.checkNotNull(ddlClient); - Preconditions.checkNotNull(dbClient); - this.statementExecutor = - new StatementExecutor(Collections.emptyList()); - this.spannerPool = spannerPool; - this.options = options; - this.spanner = spannerPool.getSpanner(options, this); - this.ddlClient = ddlClient; - this.dbClient = dbClient; - setReadOnly(options.isReadOnly()); - setAutocommit(options.isAutocommit()); - setDefaultTransactionOptions(); - } - - private DdlClient createDdlClient() { - return DdlClient.newBuilder() - .setDatabaseAdminClient(spanner.getDatabaseAdminClient()) - .setInstanceId(options.getInstanceId()) - .setDatabaseName(options.getDatabaseName()) - .build(); - } - - @Override - public void close() { - if (!isClosed()) { - try { - if (isTransactionStarted()) { - try { - rollback(); - } catch (Exception e) { - // Ignore as we are closing the connection. - } - } - statementExecutor.shutdownNow(); - spannerPool.removeConnection(options, this); - leakedException = null; - } finally { - this.closed = true; - } - } - } - - /** Get the current unit-of-work type of this connection. */ - UnitOfWorkType getUnitOfWorkType() { - return unitOfWorkType; - } - - /** Get the current batch mode of this connection. */ - BatchMode getBatchMode() { - return batchMode; - } - - /** @return true if this connection is in a batch. */ - boolean isInBatch() { - return batchMode != BatchMode.NONE; - } - - /** Get the call stack from when the {@link Connection} was opened. */ - LeakedConnectionException getLeakedException() { - return leakedException; - } - - @Override - public boolean isClosed() { - return closed; - } - - @Override - public void setAutocommit(boolean autocommit) { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isBatchActive(), "Cannot set autocommit while in a batch"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), "Cannot set autocommit while a transaction is active"); - ConnectionPreconditions.checkState( - !(isAutocommit() && isInTransaction()), - "Cannot set autocommit while in a temporary transaction"); - ConnectionPreconditions.checkState( - !transactionBeginMarked, "Cannot set autocommit when a transaction has begun"); - this.autocommit = autocommit; - clearLastTransactionAndSetDefaultTransactionOptions(); - // Reset the readOnlyStaleness value if it is no longer compatible with the new autocommit - // value. - if (!autocommit - && (readOnlyStaleness.getMode() == Mode.MAX_STALENESS - || readOnlyStaleness.getMode() == Mode.MIN_READ_TIMESTAMP)) { - readOnlyStaleness = TimestampBound.strong(); - } - } - - @Override - public boolean isAutocommit() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return internalIsAutocommit(); - } - - private boolean internalIsAutocommit() { - return this.autocommit; - } - - @Override - public void setReadOnly(boolean readOnly) { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isBatchActive(), "Cannot set read-only while in a batch"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), "Cannot set read-only while a transaction is active"); - ConnectionPreconditions.checkState( - !(isAutocommit() && isInTransaction()), - "Cannot set read-only while in a temporary transaction"); - ConnectionPreconditions.checkState( - !transactionBeginMarked, "Cannot set read-only when a transaction has begun"); - this.readOnly = readOnly; - clearLastTransactionAndSetDefaultTransactionOptions(); - } - - @Override - public boolean isReadOnly() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.readOnly; - } - - private void clearLastTransactionAndSetDefaultTransactionOptions() { - setDefaultTransactionOptions(); - this.currentUnitOfWork = null; - } - - @Override - public void setAutocommitDmlMode(AutocommitDmlMode mode) { - Preconditions.checkNotNull(mode); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "Cannot set autocommit DML mode while in a batch"); - ConnectionPreconditions.checkState( - !isInTransaction() && isAutocommit(), - "Cannot set autocommit DML mode while not in autocommit mode or while a transaction is active"); - ConnectionPreconditions.checkState( - !isReadOnly(), "Cannot set autocommit DML mode for a read-only connection"); - this.autocommitDmlMode = mode; - } - - @Override - public AutocommitDmlMode getAutocommitDmlMode() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "Cannot get autocommit DML mode while in a batch"); - return this.autocommitDmlMode; - } - - @Override - public void setReadOnlyStaleness(TimestampBound staleness) { - Preconditions.checkNotNull(staleness); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isBatchActive(), "Cannot set read-only while in a batch"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), - "Cannot set read-only staleness when a transaction has been started"); - if (staleness.getMode() == Mode.MAX_STALENESS - || staleness.getMode() == Mode.MIN_READ_TIMESTAMP) { - // These values are only allowed in autocommit mode. - ConnectionPreconditions.checkState( - isAutocommit() && !inTransaction, - "MAX_STALENESS and MIN_READ_TIMESTAMP are only allowed in autocommit mode"); - } - this.readOnlyStaleness = staleness; - } - - @Override - public TimestampBound getReadOnlyStaleness() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isBatchActive(), "Cannot get read-only while in a batch"); - return this.readOnlyStaleness; - } - - @Override - public void setStatementTimeout(long timeout, TimeUnit unit) { - Preconditions.checkArgument(timeout > 0L, "Zero or negative timeout values are not allowed"); - Preconditions.checkArgument( - StatementTimeout.isValidTimeoutUnit(unit), - "Time unit must be one of NANOSECONDS, MICROSECONDS, MILLISECONDS or SECONDS"); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - this.statementTimeout.setTimeoutValue(timeout, unit); - } - - @Override - public void clearStatementTimeout() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - this.statementTimeout.clearTimeoutValue(); - } - - @Override - public long getStatementTimeout(TimeUnit unit) { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - Preconditions.checkArgument( - StatementTimeout.isValidTimeoutUnit(unit), - "Time unit must be one of NANOSECONDS, MICROSECONDS, MILLISECONDS or SECONDS"); - return this.statementTimeout.getTimeoutValue(unit); - } - - @Override - public boolean hasStatementTimeout() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.statementTimeout.hasTimeout(); - } - - @Override - public void cancel() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - if (this.currentUnitOfWork != null) { - currentUnitOfWork.cancel(); - } - } - - @Override - public TransactionMode getTransactionMode() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isDdlBatchActive(), "This connection is in a DDL batch"); - ConnectionPreconditions.checkState(isInTransaction(), "This connection has no transaction"); - return unitOfWorkType.getTransactionMode(); - } - - @Override - public void setTransactionMode(TransactionMode transactionMode) { - Preconditions.checkNotNull(transactionMode); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "Cannot set transaction mode while in a batch"); - ConnectionPreconditions.checkState(isInTransaction(), "This connection has no transaction"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), - "The transaction mode cannot be set after the transaction has started"); - ConnectionPreconditions.checkState( - !isReadOnly() || transactionMode == TransactionMode.READ_ONLY_TRANSACTION, - "The transaction mode can only be READ_ONLY when the connection is in read_only mode"); - - this.transactionBeginMarked = true; - this.unitOfWorkType = UnitOfWorkType.of(transactionMode); - } - - /** - * Throws an {@link SpannerException} with code {@link ErrorCode#FAILED_PRECONDITION} if the - * current state of this connection does not allow changing the setting for retryAbortsInternally. - */ - private void checkSetRetryAbortsInternallyAvailable() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(isInTransaction(), "This connection has no transaction"); - ConnectionPreconditions.checkState( - getTransactionMode() == TransactionMode.READ_WRITE_TRANSACTION, - "RetryAbortsInternally is only available for read-write transactions"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), - "RetryAbortsInternally cannot be set after the transaction has started"); - } - - @Override - public boolean isRetryAbortsInternally() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return retryAbortsInternally; - } - - @Override - public void setRetryAbortsInternally(boolean retryAbortsInternally) { - checkSetRetryAbortsInternallyAvailable(); - this.retryAbortsInternally = retryAbortsInternally; - } - - @Override - public void addTransactionRetryListener(TransactionRetryListener listener) { - Preconditions.checkNotNull(listener); - transactionRetryListeners.add(listener); - } - - @Override - public boolean removeTransactionRetryListener(TransactionRetryListener listener) { - Preconditions.checkNotNull(listener); - return transactionRetryListeners.remove(listener); - } - - @Override - public Iterator getTransactionRetryListeners() { - return Collections.unmodifiableList(transactionRetryListeners).iterator(); - } - - @Override - public boolean isInTransaction() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return internalIsInTransaction(); - } - - /** Returns true if this connection currently is in a transaction (and not a batch). */ - private boolean internalIsInTransaction() { - return !isDdlBatchActive() && (!internalIsAutocommit() || inTransaction); - } - - @Override - public boolean isTransactionStarted() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return internalIsTransactionStarted(); - } - - private boolean internalIsTransactionStarted() { - if (internalIsAutocommit() && !inTransaction) { - return false; - } - return internalIsInTransaction() - && this.currentUnitOfWork != null - && this.currentUnitOfWork.getState() == UnitOfWorkState.STARTED; - } - - @Override - public Timestamp getReadTimestamp() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - this.currentUnitOfWork != null, "There is no transaction on this connection"); - return this.currentUnitOfWork.getReadTimestamp(); - } - - Timestamp getReadTimestampOrNull() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.currentUnitOfWork == null ? null : this.currentUnitOfWork.getReadTimestampOrNull(); - } - - @Override - public Timestamp getCommitTimestamp() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - this.currentUnitOfWork != null, "There is no transaction on this connection"); - return this.currentUnitOfWork.getCommitTimestamp(); - } - - Timestamp getCommitTimestampOrNull() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.currentUnitOfWork == null - ? null - : this.currentUnitOfWork.getCommitTimestampOrNull(); - } - - /** Resets this connection to its default transaction options. */ - private void setDefaultTransactionOptions() { - if (transactionStack.isEmpty()) { - unitOfWorkType = - isReadOnly() - ? UnitOfWorkType.READ_ONLY_TRANSACTION - : UnitOfWorkType.READ_WRITE_TRANSACTION; - batchMode = BatchMode.NONE; - } else { - popUnitOfWorkFromTransactionStack(); - } - } - - @Override - public void beginTransaction() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "This connection has an active batch and cannot begin a transaction"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), - "Beginning a new transaction is not allowed when a transaction is already running"); - ConnectionPreconditions.checkState(!transactionBeginMarked, "A transaction has already begun"); - - transactionBeginMarked = true; - clearLastTransactionAndSetDefaultTransactionOptions(); - if (isAutocommit()) { - inTransaction = true; - } - } - - /** Internal interface for ending a transaction (commit/rollback). */ - private static interface EndTransactionMethod { - public void end(UnitOfWork t); - } - - private static final class Commit implements EndTransactionMethod { - @Override - public void end(UnitOfWork t) { - t.commit(); - } - } - - private final Commit commit = new Commit(); - - @Override - public void commit() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - endCurrentTransaction(commit); - } - - private static final class Rollback implements EndTransactionMethod { - @Override - public void end(UnitOfWork t) { - t.rollback(); - } - } - - private final Rollback rollback = new Rollback(); - - @Override - public void rollback() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - endCurrentTransaction(rollback); - } - - private void endCurrentTransaction(EndTransactionMethod endTransactionMethod) { - ConnectionPreconditions.checkState(!isBatchActive(), "This connection has an active batch"); - ConnectionPreconditions.checkState(isInTransaction(), "This connection has no transaction"); - try { - if (isTransactionStarted()) { - endTransactionMethod.end(getCurrentUnitOfWorkOrStartNewUnitOfWork()); - } else { - this.currentUnitOfWork = null; - } - } finally { - transactionBeginMarked = false; - if (isAutocommit()) { - inTransaction = false; - } - setDefaultTransactionOptions(); - } - } - - @Override - public StatementResult execute(Statement statement) { - Preconditions.checkNotNull(statement); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ParsedStatement parsedStatement = parser.parse(statement); - switch (parsedStatement.getType()) { - case CLIENT_SIDE: - return parsedStatement - .getClientSideStatement() - .execute(connectionStatementExecutor, parsedStatement.getSqlWithoutComments()); - case QUERY: - return StatementResultImpl.of(internalExecuteQuery(parsedStatement, AnalyzeMode.NONE)); - case UPDATE: - return StatementResultImpl.of(internalExecuteUpdate(parsedStatement)); - case DDL: - executeDdl(parsedStatement); - return StatementResultImpl.noResult(); - case UNKNOWN: - default: - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - "Unknown statement: " + parsedStatement.getSqlWithoutComments()); - } - - @Override - public ResultSet executeQuery(Statement query, QueryOption... options) { - return parseAndExecuteQuery(query, AnalyzeMode.NONE, options); - } - - @Override - public ResultSet analyzeQuery(Statement query, QueryAnalyzeMode queryMode) { - Preconditions.checkNotNull(queryMode); - return parseAndExecuteQuery(query, AnalyzeMode.of(queryMode)); - } - - /** - * Parses the given statement as a query and executes it. Throws a {@link SpannerException} if the - * statement is not a query. - */ - private ResultSet parseAndExecuteQuery( - Statement query, AnalyzeMode analyzeMode, QueryOption... options) { - Preconditions.checkNotNull(query); - Preconditions.checkNotNull(analyzeMode); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ParsedStatement parsedStatement = parser.parse(query); - if (parsedStatement.isQuery()) { - switch (parsedStatement.getType()) { - case CLIENT_SIDE: - return parsedStatement - .getClientSideStatement() - .execute(connectionStatementExecutor, parsedStatement.getSqlWithoutComments()) - .getResultSet(); - case QUERY: - return internalExecuteQuery(parsedStatement, analyzeMode, options); - case UPDATE: - case DDL: - case UNKNOWN: - default: - } - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - "Statement is not a query: " + parsedStatement.getSqlWithoutComments()); - } - - @Override - public long executeUpdate(Statement update) { - Preconditions.checkNotNull(update); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ParsedStatement parsedStatement = parser.parse(update); - if (parsedStatement.isUpdate()) { - switch (parsedStatement.getType()) { - case UPDATE: - return internalExecuteUpdate(parsedStatement); - case CLIENT_SIDE: - case QUERY: - case DDL: - case UNKNOWN: - default: - } - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - "Statement is not an update statement: " + parsedStatement.getSqlWithoutComments()); - } - - @Override - public long[] executeBatchUpdate(Iterable updates) { - Preconditions.checkNotNull(updates); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - // Check that there are only DML statements in the input. - List parsedStatements = new LinkedList<>(); - for (Statement update : updates) { - ParsedStatement parsedStatement = parser.parse(update); - if (parsedStatement.isUpdate()) { - switch (parsedStatement.getType()) { - case UPDATE: - parsedStatements.add(parsedStatement); - break; - case CLIENT_SIDE: - case QUERY: - case DDL: - case UNKNOWN: - default: - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - "The batch update list contains a statement that is not an update statement: " - + parsedStatement.getSqlWithoutComments()); - } - } - } - return internalExecuteBatchUpdate(parsedStatements); - } - - private ResultSet internalExecuteQuery( - final ParsedStatement statement, - final AnalyzeMode analyzeMode, - final QueryOption... options) { - Preconditions.checkArgument( - statement.getType() == StatementType.QUERY, "Statement must be a query"); - UnitOfWork transaction = getCurrentUnitOfWorkOrStartNewUnitOfWork(); - try { - return transaction.executeQuery(statement, analyzeMode, options); - } catch (SpannerException e) { - // In case of a timed out or cancelled query we need to replace the executor to ensure that we - // have an executor that is not busy executing a statement. Although we try to cancel the - // current statement, it is not guaranteed to actually stop the execution directly. - if (e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED - || e.getErrorCode() == ErrorCode.CANCELLED) { - this.statementExecutor.recreate(); - } - throw e; - } - } - - private long internalExecuteUpdate(final ParsedStatement update) { - Preconditions.checkArgument( - update.getType() == StatementType.UPDATE, "Statement must be an update"); - UnitOfWork transaction = getCurrentUnitOfWorkOrStartNewUnitOfWork(); - try { - return transaction.executeUpdate(update); - } catch (SpannerException e) { - // In case of a timed out or cancelled query we need to replace the executor to ensure that we - // have an executor that is not busy executing a statement. Although we try to cancel the - // current statement, it is not guaranteed to actually stop the execution directly. - if (e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED - || e.getErrorCode() == ErrorCode.CANCELLED) { - this.statementExecutor.recreate(); - } - throw e; - } - } - - private long[] internalExecuteBatchUpdate(final List updates) { - UnitOfWork transaction = getCurrentUnitOfWorkOrStartNewUnitOfWork(); - try { - return transaction.executeBatchUpdate(updates); - } catch (SpannerException e) { - // In case of a timed out or cancelled query we need to replace the executor to ensure that we - // have an executor that is not busy executing a statement. Although we try to cancel the - // current statement, it is not guaranteed to actually stop the execution directly. - if (e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED - || e.getErrorCode() == ErrorCode.CANCELLED) { - this.statementExecutor.recreate(); - } - throw e; - } - } - - /** - * Returns the current {@link UnitOfWork} of this connection, or creates a new one based on the - * current transaction settings of the connection and returns that. - */ - private UnitOfWork getCurrentUnitOfWorkOrStartNewUnitOfWork() { - if (this.currentUnitOfWork == null || !this.currentUnitOfWork.isActive()) { - this.currentUnitOfWork = createNewUnitOfWork(); - } - return this.currentUnitOfWork; - } - - private UnitOfWork createNewUnitOfWork() { - if (isAutocommit() && !isInTransaction() && !isInBatch()) { - return SingleUseTransaction.newBuilder() - .setDdlClient(ddlClient) - .setDatabaseClient(dbClient) - .setReadOnly(isReadOnly()) - .setReadOnlyStaleness(readOnlyStaleness) - .setAutocommitDmlMode(autocommitDmlMode) - .setStatementTimeout(statementTimeout) - .withStatementExecutor(statementExecutor) - .build(); - } else { - switch (getUnitOfWorkType()) { - case READ_ONLY_TRANSACTION: - return ReadOnlyTransaction.newBuilder() - .setDatabaseClient(dbClient) - .setReadOnlyStaleness(readOnlyStaleness) - .setStatementTimeout(statementTimeout) - .withStatementExecutor(statementExecutor) - .build(); - case READ_WRITE_TRANSACTION: - return ReadWriteTransaction.newBuilder() - .setDatabaseClient(dbClient) - .setRetryAbortsInternally(retryAbortsInternally) - .setTransactionRetryListeners(transactionRetryListeners) - .setStatementTimeout(statementTimeout) - .withStatementExecutor(statementExecutor) - .build(); - case DML_BATCH: - // A DML batch can run inside the current transaction. It should therefore only - // temporarily replace the current transaction. - pushCurrentUnitOfWorkToTransactionStack(); - return DmlBatch.newBuilder() - .setTransaction(currentUnitOfWork) - .setStatementTimeout(statementTimeout) - .withStatementExecutor(statementExecutor) - .build(); - case DDL_BATCH: - return DdlBatch.newBuilder() - .setDdlClient(ddlClient) - .setDatabaseClient(dbClient) - .setStatementTimeout(statementTimeout) - .withStatementExecutor(statementExecutor) - .build(); - default: - } - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "This connection does not have an active transaction and the state of this connection does not allow any new transactions to be started"); - } - - /** Pushes the current unit of work to the stack of nested transactions. */ - private void pushCurrentUnitOfWorkToTransactionStack() { - Preconditions.checkState(currentUnitOfWork != null, "There is no current transaction"); - transactionStack.push(currentUnitOfWork); - } - - /** Set the {@link UnitOfWork} of this connection back to the previous {@link UnitOfWork}. */ - private void popUnitOfWorkFromTransactionStack() { - Preconditions.checkState( - !transactionStack.isEmpty(), "There is no unit of work in the transaction stack"); - this.currentUnitOfWork = transactionStack.pop(); - } - - private void executeDdl(ParsedStatement ddl) { - getCurrentUnitOfWorkOrStartNewUnitOfWork().executeDdl(ddl); - } - - @Override - public void write(Mutation mutation) { - Preconditions.checkNotNull(mutation); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(isAutocommit(), ONLY_ALLOWED_IN_AUTOCOMMIT); - getCurrentUnitOfWorkOrStartNewUnitOfWork().write(mutation); - } - - @Override - public void write(Iterable mutations) { - Preconditions.checkNotNull(mutations); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(isAutocommit(), ONLY_ALLOWED_IN_AUTOCOMMIT); - getCurrentUnitOfWorkOrStartNewUnitOfWork().write(mutations); - } - - @Override - public void bufferedWrite(Mutation mutation) { - Preconditions.checkNotNull(mutation); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isAutocommit(), NOT_ALLOWED_IN_AUTOCOMMIT); - getCurrentUnitOfWorkOrStartNewUnitOfWork().write(mutation); - } - - @Override - public void bufferedWrite(Iterable mutations) { - Preconditions.checkNotNull(mutations); - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(!isAutocommit(), NOT_ALLOWED_IN_AUTOCOMMIT); - getCurrentUnitOfWorkOrStartNewUnitOfWork().write(mutations); - } - - @Override - public void startBatchDdl() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "Cannot start a DDL batch when a batch is already active"); - ConnectionPreconditions.checkState( - !isReadOnly(), "Cannot start a DDL batch when the connection is in read-only mode"); - ConnectionPreconditions.checkState( - !isTransactionStarted(), "Cannot start a DDL batch while a transaction is active"); - ConnectionPreconditions.checkState( - !(isAutocommit() && isInTransaction()), - "Cannot start a DDL batch while in a temporary transaction"); - ConnectionPreconditions.checkState( - !transactionBeginMarked, "Cannot start a DDL batch when a transaction has begun"); - this.batchMode = BatchMode.DDL; - this.unitOfWorkType = UnitOfWorkType.DDL_BATCH; - this.currentUnitOfWork = createNewUnitOfWork(); - } - - @Override - public void startBatchDml() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState( - !isBatchActive(), "Cannot start a DML batch when a batch is already active"); - ConnectionPreconditions.checkState( - !isReadOnly(), "Cannot start a DML batch when the connection is in read-only mode"); - ConnectionPreconditions.checkState( - !(isInTransaction() && getTransactionMode() == TransactionMode.READ_ONLY_TRANSACTION), - "Cannot start a DML batch when a read-only transaction is in progress"); - // Make sure that there is a current unit of work that the batch can use. - getCurrentUnitOfWorkOrStartNewUnitOfWork(); - // Then create the DML batch. - this.batchMode = BatchMode.DML; - this.unitOfWorkType = UnitOfWorkType.DML_BATCH; - this.currentUnitOfWork = createNewUnitOfWork(); - } - - @Override - public long[] runBatch() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(isBatchActive(), "This connection has no active batch"); - try { - if (this.currentUnitOfWork != null) { - return this.currentUnitOfWork.runBatch(); - } - return new long[0]; - } finally { - this.batchMode = BatchMode.NONE; - setDefaultTransactionOptions(); - } - } - - @Override - public void abortBatch() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - ConnectionPreconditions.checkState(isBatchActive(), "This connection has no active batch"); - try { - if (this.currentUnitOfWork != null) { - this.currentUnitOfWork.abortBatch(); - } - } finally { - this.batchMode = BatchMode.NONE; - setDefaultTransactionOptions(); - } - } - - private boolean isBatchActive() { - return isDdlBatchActive() || isDmlBatchActive(); - } - - @Override - public boolean isDdlBatchActive() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.batchMode == BatchMode.DDL; - } - - @Override - public boolean isDmlBatchActive() { - ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); - return this.batchMode == BatchMode.DML; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionOptions.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionOptions.java deleted file mode 100644 index 3b03aca5e82..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionOptions.java +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.auth.Credentials; -import com.google.auth.oauth2.GoogleCredentials; -import com.google.auth.oauth2.ServiceAccountCredentials; -import com.google.cloud.NoCredentials; -import com.google.cloud.ServiceOptions; -import com.google.cloud.spanner.DatabaseId; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.SpannerOptions; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.common.collect.Sets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Options for creating a {@link Connection} to a Google Cloud Spanner database. - * - *

Usage: - * - *

- * 
- * {@code
- * ConnectionOptions options = ConnectionOptions.newBuilder()
- *       .setUri("cloudspanner:/projects/my_project_id/instances/my_instance_id/databases/my_database_name?autocommit=false")
- *       .setCredentialsUrl("/home/cloudspanner-keys/my-key.json")
- *       .build();
- * try(Connection connection = options.getConnection()) {
- *   try(ResultSet rs = connection.executeQuery(Statement.of("SELECT SingerId, AlbumId, MarketingBudget FROM Albums"))) {
- *     while(rs.next()) {
- *       // do something
- *     }
- *   }
- * }
- * }
- * 
- * 
- */ -class ConnectionOptions { - /** Supported connection properties that can be included in the connection URI. */ - public static class ConnectionProperty { - private static final String[] BOOLEAN_VALUES = new String[] {"true", "false"}; - private final String name; - private final String description; - private final String defaultValue; - private final String[] validValues; - private final int hashCode; - - private static ConnectionProperty createStringProperty(String name, String description) { - return new ConnectionProperty(name, description, "", null); - } - - private static ConnectionProperty createBooleanProperty( - String name, String description, boolean defaultValue) { - return new ConnectionProperty( - name, description, String.valueOf(defaultValue), BOOLEAN_VALUES); - } - - private static ConnectionProperty createEmptyProperty(String name) { - return new ConnectionProperty(name, "", "", null); - } - - private ConnectionProperty( - String name, String description, String defaultValue, String[] validValues) { - Preconditions.checkNotNull(name); - Preconditions.checkNotNull(description); - Preconditions.checkNotNull(defaultValue); - this.name = name; - this.description = description; - this.defaultValue = defaultValue; - this.validValues = validValues; - this.hashCode = name.toLowerCase().hashCode(); - } - - @Override - public int hashCode() { - return hashCode; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof ConnectionProperty)) { - return false; - } - return ((ConnectionProperty) o).name.equalsIgnoreCase(this.name); - } - - /** @return the name of this connection property. */ - public String getName() { - return name; - } - - /** @return the description of this connection property. */ - public String getDescription() { - return description; - } - - /** @return the default value of this connection property. */ - public String getDefaultValue() { - return defaultValue; - } - - /** - * @return the valid values for this connection property. null indicates no - * restriction. - */ - public String[] getValidValues() { - return validValues; - } - } - - private static final boolean DEFAULT_USE_PLAIN_TEXT = false; - static final boolean DEFAULT_AUTOCOMMIT = true; - static final boolean DEFAULT_READONLY = false; - static final boolean DEFAULT_RETRY_ABORTS_INTERNALLY = true; - private static final String DEFAULT_CREDENTIALS = null; - private static final String DEFAULT_NUM_CHANNELS = null; - private static final String DEFAULT_USER_AGENT = null; - - private static final String PLAIN_TEXT_PROTOCOL = "http:"; - private static final String HOST_PROTOCOL = "https:"; - private static final String DEFAULT_HOST = "https://spanner.googleapis.com"; - /** Use plain text is only for local testing purposes. */ - private static final String USE_PLAIN_TEXT_PROPERTY_NAME = "usePlainText"; - /** Name of the 'autocommit' connection property. */ - public static final String AUTOCOMMIT_PROPERTY_NAME = "autocommit"; - /** Name of the 'readonly' connection property. */ - public static final String READONLY_PROPERTY_NAME = "readonly"; - /** Name of the 'retry aborts internally' connection property. */ - public static final String RETRY_ABORTS_INTERNALLY_PROPERTY_NAME = "retryAbortsInternally"; - /** Name of the 'credentials' connection property. */ - public static final String CREDENTIALS_PROPERTY_NAME = "credentials"; - /** Name of the 'numChannels' connection property. */ - public static final String NUM_CHANNELS_PROPERTY_NAME = "numChannels"; - /** Custom user agent string is only for other Google libraries. */ - private static final String USER_AGENT_PROPERTY_NAME = "userAgent"; - - /** All valid connection properties. */ - public static final Set VALID_PROPERTIES = - Collections.unmodifiableSet( - new HashSet<>( - Arrays.asList( - ConnectionProperty.createBooleanProperty( - AUTOCOMMIT_PROPERTY_NAME, "", DEFAULT_AUTOCOMMIT), - ConnectionProperty.createBooleanProperty( - READONLY_PROPERTY_NAME, "", DEFAULT_READONLY), - ConnectionProperty.createBooleanProperty( - RETRY_ABORTS_INTERNALLY_PROPERTY_NAME, "", DEFAULT_RETRY_ABORTS_INTERNALLY), - ConnectionProperty.createStringProperty(CREDENTIALS_PROPERTY_NAME, ""), - ConnectionProperty.createStringProperty(NUM_CHANNELS_PROPERTY_NAME, ""), - ConnectionProperty.createBooleanProperty( - USE_PLAIN_TEXT_PROPERTY_NAME, "", DEFAULT_USE_PLAIN_TEXT), - ConnectionProperty.createStringProperty(USER_AGENT_PROPERTY_NAME, "")))); - - private static final Set INTERNAL_PROPERTIES = - Collections.unmodifiableSet( - new HashSet<>( - Arrays.asList( - ConnectionProperty.createStringProperty(USER_AGENT_PROPERTY_NAME, "")))); - private static final Set INTERNAL_VALID_PROPERTIES = - Sets.union(VALID_PROPERTIES, INTERNAL_PROPERTIES); - - /** - * Gets the default project-id for the current environment as defined by {@link - * ServiceOptions#getDefaultProjectId()}, and if none could be found, the project-id of the given - * credentials if it contains any. - * - * @param credentials The credentials to use to get the default project-id if none could be found - * in the environment. - * @return the default project-id. - */ - public static String getDefaultProjectId(Credentials credentials) { - String projectId = SpannerOptions.getDefaultProjectId(); - if (projectId == null - && credentials != null - && credentials instanceof ServiceAccountCredentials) { - projectId = ((ServiceAccountCredentials) credentials).getProjectId(); - } - return projectId; - } - - /** - * Closes all {@link Spanner} instances that have been opened by connections - * during the lifetime of this JVM. Call this method at the end of your application to free up - * resources. You must close all {@link Connection}s that have been opened by your application - * before calling this method. Failing to do so, will cause this method to throw a {@link - * SpannerException}. - * - *

This method is also automatically called by a shutdown hook (see {@link - * Runtime#addShutdownHook(Thread)}) when the JVM is shutdown gracefully. - */ - public static void closeSpanner() { - SpannerPool.INSTANCE.checkAndCloseSpanners(); - } - - /** Builder for {@link ConnectionOptions} instances. */ - public static class Builder { - private String uri; - private String credentialsUrl; - private Credentials credentials; - private List statementExecutionInterceptors = - Collections.emptyList(); - - private Builder() {} - - /** Spanner {@link ConnectionOptions} URI format. */ - public static final String SPANNER_URI_FORMAT = - "(?:cloudspanner:)(?//[\\w.-]+(?:\\.[\\w\\.-]+)*[\\w\\-\\._~:/?#\\[\\]@!\\$&'\\(\\)\\*\\+,;=.]+)?/projects/(?(([a-z]|[-]|[0-9])+|(DEFAULT_PROJECT_ID)))(/instances/(?([a-z]|[-]|[0-9])+)(/databases/(?([a-z]|[-]|[_]|[0-9])+))?)?(?:[?|;].*)?"; - - private static final String SPANNER_URI_REGEX = "(?is)^" + SPANNER_URI_FORMAT + "$"; - private static final Pattern SPANNER_URI_PATTERN = Pattern.compile(SPANNER_URI_REGEX); - private static final String HOST_GROUP = "HOSTGROUP"; - private static final String PROJECT_GROUP = "PROJECTGROUP"; - private static final String INSTANCE_GROUP = "INSTANCEGROUP"; - private static final String DATABASE_GROUP = "DATABASEGROUP"; - private static final String DEFAULT_PROJECT_ID_PLACEHOLDER = "DEFAULT_PROJECT_ID"; - - private boolean isValidUri(String uri) { - return SPANNER_URI_PATTERN.matcher(uri).matches(); - } - - /** - * Sets the URI of the Cloud Spanner database to connect to. A connection URI must be specified - * in this format: - * - *

-     * cloudspanner:[//host[:port]]/projects/project-id[/instances/instance-id[/databases/database-name]][\?property-name=property-value[;property-name=property-value]*]?
-     * 
- * - * The property-value strings should be url-encoded. - * - *

The project-id part of the URI may be filled with the placeholder DEFAULT_PROJECT_ID. This - * placeholder will be replaced by the default project id of the environment that is requesting - * a connection. - * - *

The supported properties are: - * - *

    - *
  • credentials (String): URL for the credentials file to use for the connection. This - * property is only used if no credentials have been specified using the {@link - * ConnectionOptions.Builder#setCredentialsUrl(String)} method. If you do not specify any - * credentials at all, the default credentials of the environment as returned by {@link - * GoogleCredentials#getApplicationDefault()} will be used. - *
  • autocommit (boolean): Sets the initial autocommit mode for the connection. Default is - * true. - *
  • readonly (boolean): Sets the initial readonly mode for the connection. Default is - * false. - *
  • retryAbortsInternally (boolean): Sets the initial retryAbortsInternally mode for the - * connection. Default is true. - *
- * - * @param uri The URI of the Spanner database to connect to. - * @return this builder - */ - public Builder setUri(String uri) { - Preconditions.checkArgument( - isValidUri(uri), - "The specified URI is not a valid Cloud Spanner connection URI. Please specify a URI in the format \"cloudspanner:[//host[:port]]/projects/project-id[/instances/instance-id[/databases/database-name]][\\?property-name=property-value[;property-name=property-value]*]?\""); - checkValidProperties(uri); - this.uri = uri; - return this; - } - - /** - * Sets the URL of the credentials file to use for this connection. The URL may be a reference - * to a file on the local file system, or to a file on Google Cloud Storage. References to - * Google Cloud Storage files are only allowed when the application is running on Google Cloud - * and the environment has access to the specified storage location. It also requires that the - * Google Cloud Storage client library is present on the class path. The Google Cloud Storage - * library is not automatically added as a dependency by the JDBC driver. - * - *

If you do not specify a credentialsUrl (either by using this setter, or by specifying on - * the connection URI), the credentials returned by {@link - * GoogleCredentials#getApplicationDefault()} will be used for the connection. - * - * @param credentialsUrl A valid file or Google Cloud Storage URL for the credentials file to be - * used. - * @return this builder - */ - public Builder setCredentialsUrl(String credentialsUrl) { - this.credentialsUrl = credentialsUrl; - return this; - } - - @VisibleForTesting - Builder setStatementExecutionInterceptors(List interceptors) { - this.statementExecutionInterceptors = interceptors; - return this; - } - - @VisibleForTesting - Builder setCredentials(Credentials credentials) { - this.credentials = credentials; - return this; - } - - /** @return the {@link ConnectionOptions} */ - public ConnectionOptions build() { - Preconditions.checkState(this.uri != null, "Connection URI is required"); - return new ConnectionOptions(this); - } - } - - /** - * Create a {@link Builder} for {@link ConnectionOptions}. Use this method to create {@link - * ConnectionOptions} that can be used to obtain a {@link Connection}. - * - * @return a new {@link Builder} - */ - public static Builder newBuilder() { - return new Builder(); - } - - private final String uri; - private final String credentialsUrl; - - private final boolean usePlainText; - private final String host; - private final String projectId; - private final String instanceId; - private final String databaseName; - private final Credentials credentials; - private final Integer numChannels; - private final String userAgent; - - private final boolean autocommit; - private final boolean readOnly; - private final boolean retryAbortsInternally; - private final List statementExecutionInterceptors; - - private ConnectionOptions(Builder builder) { - Matcher matcher = Builder.SPANNER_URI_PATTERN.matcher(builder.uri); - Preconditions.checkArgument( - matcher.find(), String.format("Invalid connection URI specified: %s", builder.uri)); - checkValidProperties(builder.uri); - - this.uri = builder.uri; - this.credentialsUrl = - builder.credentialsUrl != null ? builder.credentialsUrl : parseCredentials(builder.uri); - this.usePlainText = parseUsePlainText(this.uri); - this.userAgent = parseUserAgent(this.uri); - - this.host = - matcher.group(Builder.HOST_GROUP) == null - ? DEFAULT_HOST - : (usePlainText ? PLAIN_TEXT_PROTOCOL : HOST_PROTOCOL) - + matcher.group(Builder.HOST_GROUP); - this.instanceId = matcher.group(Builder.INSTANCE_GROUP); - this.databaseName = matcher.group(Builder.DATABASE_GROUP); - // Using credentials on a plain text connection is not allowed, so if the user has not specified - // any credentials and is using a plain text connection, we should not try to get the - // credentials from the environment, but default to NoCredentials. - if (builder.credentials == null && this.credentialsUrl == null && this.usePlainText) { - this.credentials = NoCredentials.getInstance(); - } else { - this.credentials = - builder.credentials == null - ? getCredentialsService().createCredentials(this.credentialsUrl) - : builder.credentials; - } - String numChannelsValue = parseNumChannels(builder.uri); - if (numChannelsValue != null) { - try { - this.numChannels = Integer.valueOf(numChannelsValue); - } catch (NumberFormatException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, - "Invalid numChannels value specified: " + numChannelsValue, - e); - } - } else { - this.numChannels = null; - } - - String projectId = matcher.group(Builder.PROJECT_GROUP); - if (Builder.DEFAULT_PROJECT_ID_PLACEHOLDER.equalsIgnoreCase(projectId)) { - projectId = getDefaultProjectId(this.credentials); - } - this.projectId = projectId; - - this.autocommit = parseAutocommit(this.uri); - this.readOnly = parseReadOnly(this.uri); - this.retryAbortsInternally = parseRetryAbortsInternally(this.uri); - this.statementExecutionInterceptors = - Collections.unmodifiableList(builder.statementExecutionInterceptors); - } - - @VisibleForTesting - CredentialsService getCredentialsService() { - return CredentialsService.INSTANCE; - } - - @VisibleForTesting - static boolean parseUsePlainText(String uri) { - String value = parseUriProperty(uri, USE_PLAIN_TEXT_PROPERTY_NAME); - return value != null ? Boolean.valueOf(value) : DEFAULT_USE_PLAIN_TEXT; - } - - @VisibleForTesting - static boolean parseAutocommit(String uri) { - String value = parseUriProperty(uri, AUTOCOMMIT_PROPERTY_NAME); - return value != null ? Boolean.valueOf(value) : DEFAULT_AUTOCOMMIT; - } - - @VisibleForTesting - static boolean parseReadOnly(String uri) { - String value = parseUriProperty(uri, READONLY_PROPERTY_NAME); - return value != null ? Boolean.valueOf(value) : DEFAULT_READONLY; - } - - @VisibleForTesting - static boolean parseRetryAbortsInternally(String uri) { - String value = parseUriProperty(uri, RETRY_ABORTS_INTERNALLY_PROPERTY_NAME); - return value != null ? Boolean.valueOf(value) : DEFAULT_RETRY_ABORTS_INTERNALLY; - } - - @VisibleForTesting - static String parseCredentials(String uri) { - String value = parseUriProperty(uri, CREDENTIALS_PROPERTY_NAME); - return value != null ? value : DEFAULT_CREDENTIALS; - } - - @VisibleForTesting - static String parseNumChannels(String uri) { - String value = parseUriProperty(uri, NUM_CHANNELS_PROPERTY_NAME); - return value != null ? value : DEFAULT_NUM_CHANNELS; - } - - @VisibleForTesting - static String parseUserAgent(String uri) { - String value = parseUriProperty(uri, USER_AGENT_PROPERTY_NAME); - return value != null ? value : DEFAULT_USER_AGENT; - } - - @VisibleForTesting - static String parseUriProperty(String uri, String property) { - Pattern pattern = Pattern.compile(String.format("(?is)(?:;|\\?)%s=(.*?)(?:;|$)", property)); - Matcher matcher = pattern.matcher(uri); - if (matcher.find() && matcher.groupCount() == 1) { - return matcher.group(1); - } - return null; - } - - /** Check that only valid properties have been specified. */ - @VisibleForTesting - static void checkValidProperties(String uri) { - String invalidProperties = ""; - List properties = parseProperties(uri); - for (String property : properties) { - if (!INTERNAL_VALID_PROPERTIES.contains(ConnectionProperty.createEmptyProperty(property))) { - if (invalidProperties.length() > 0) { - invalidProperties = invalidProperties + ", "; - } - invalidProperties = invalidProperties + property; - } - } - Preconditions.checkArgument( - invalidProperties.isEmpty(), - "Invalid properties found in connection URI: " + invalidProperties.toString()); - } - - @VisibleForTesting - static List parseProperties(String uri) { - Pattern pattern = Pattern.compile("(?is)(?:\\?|;)(?.*?)=(?:.*?)"); - Matcher matcher = pattern.matcher(uri); - List res = new ArrayList<>(); - while (matcher.find() && matcher.group("PROPERTY") != null) { - res.add(matcher.group("PROPERTY")); - } - return res; - } - - /** - * Create a new {@link Connection} from this {@link ConnectionOptions}. Calling this method - * multiple times for the same {@link ConnectionOptions} will return multiple instances of {@link - * Connection}s to the same database. - * - * @return a new {@link Connection} to the database referenced by this {@link ConnectionOptions} - */ - public Connection getConnection() { - return new ConnectionImpl(this); - } - - /** The URI of this {@link ConnectionOptions} */ - public String getUri() { - return uri; - } - - /** The credentials URL of this {@link ConnectionOptions} */ - public String getCredentialsUrl() { - return credentialsUrl; - } - - /** The number of channels to use for the connection. */ - public Integer getNumChannels() { - return numChannels; - } - - /** The host and port number that this {@link ConnectionOptions} will connect to */ - public String getHost() { - return host; - } - - /** The Google Project ID that this {@link ConnectionOptions} will connect to */ - public String getProjectId() { - return projectId; - } - - /** The Spanner Instance ID that this {@link ConnectionOptions} will connect to */ - public String getInstanceId() { - return instanceId; - } - - /** The Spanner database name that this {@link ConnectionOptions} will connect to */ - public String getDatabaseName() { - return databaseName; - } - - /** The Spanner {@link DatabaseId} that this {@link ConnectionOptions} will connect to */ - public DatabaseId getDatabaseId() { - Preconditions.checkState(projectId != null, "Project ID is not specified"); - Preconditions.checkState(instanceId != null, "Instance ID is not specified"); - Preconditions.checkState(databaseName != null, "Database name is not specified"); - return DatabaseId.of(projectId, instanceId, databaseName); - } - - /** - * The {@link Credentials} of this {@link ConnectionOptions}. This is either the credentials - * specified in the credentialsUrl or the default Google application credentials - */ - public Credentials getCredentials() { - return credentials; - } - - /** The initial autocommit value for connections created by this {@link ConnectionOptions} */ - public boolean isAutocommit() { - return autocommit; - } - - /** The initial readonly value for connections created by this {@link ConnectionOptions} */ - public boolean isReadOnly() { - return readOnly; - } - - /** - * The initial retryAbortsInternally value for connections created by this {@link - * ConnectionOptions} - */ - public boolean isRetryAbortsInternally() { - return retryAbortsInternally; - } - - /** Use http instead of https. Only valid for (local) test servers. */ - boolean isUsePlainText() { - return usePlainText; - } - - /** - * The (custom) user agent string to use for this connection. If null, then the - * default JDBC user agent string will be used. - */ - String getUserAgent() { - return userAgent; - } - - /** Interceptors that should be executed after each statement */ - List getStatementExecutionInterceptors() { - return statementExecutionInterceptors; - } - - @Override - public String toString() { - return getUri(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionPreconditions.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionPreconditions.java deleted file mode 100644 index 02f3953352e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionPreconditions.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import javax.annotation.Nullable; - -/** - * Static convenience methods that help a method or constructor in the Connection API to check - * whether it was invoked correctly. - */ -class ConnectionPreconditions { - /** - * Ensures the truth of an expression involving the state of the calling instance, but not - * involving any parameters to the calling method. - * - * @param expression a boolean expression - * @param errorMessage the exception message to use if the check fails; will be converted to a - * string using {@link String#valueOf(Object)}. - * @throws SpannerException with {@link ErrorCode#FAILED_PRECONDITION} if {@code expression} is - * false. - */ - static void checkState(boolean expression, @Nullable Object errorMessage) { - if (!expression) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, String.valueOf(errorMessage)); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutor.java deleted file mode 100644 index 4e79f25455a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.TimestampBound; -import com.google.protobuf.Duration; - -/** - * The Cloud Spanner JDBC driver supports a number of client side statements that are interpreted by - * the driver and that can modify the current state of a connection, or report the current state of - * a connection. Each of the methods in this interface correspond with one such client side - * statement. - * - *

The methods in this interface are called by the different {@link ClientSideStatement}s. These - * method calls are then forwarded into the appropriate method of a {@link Connection} instance. - * - *

The client side statements are defined in the ClientSideStatements.json file. - */ -interface ConnectionStatementExecutor { - - StatementResult statementSetAutocommit(Boolean autocommit); - - StatementResult statementShowAutocommit(); - - StatementResult statementSetReadOnly(Boolean readOnly); - - StatementResult statementShowReadOnly(); - - StatementResult statementSetRetryAbortsInternally(Boolean retryAbortsInternally); - - StatementResult statementShowRetryAbortsInternally(); - - StatementResult statementSetAutocommitDmlMode(AutocommitDmlMode mode); - - StatementResult statementShowAutocommitDmlMode(); - - StatementResult statementSetStatementTimeout(Duration duration); - - StatementResult statementShowStatementTimeout(); - - StatementResult statementShowReadTimestamp(); - - StatementResult statementShowCommitTimestamp(); - - StatementResult statementSetReadOnlyStaleness(TimestampBound staleness); - - StatementResult statementShowReadOnlyStaleness(); - - StatementResult statementBeginTransaction(); - - StatementResult statementCommit(); - - StatementResult statementRollback(); - - StatementResult statementSetTransactionMode(TransactionMode mode); - - StatementResult statementStartBatchDdl(); - - StatementResult statementStartBatchDml(); - - StatementResult statementRunBatch(); - - StatementResult statementAbortBatch(); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorImpl.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorImpl.java deleted file mode 100644 index 7f7a5cf3ae7..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorImpl.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.ABORT_BATCH; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.BEGIN; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.COMMIT; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.ROLLBACK; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.RUN_BATCH; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_AUTOCOMMIT; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_AUTOCOMMIT_DML_MODE; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_READONLY; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_READ_ONLY_STALENESS; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_RETRY_ABORTS_INTERNALLY; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_STATEMENT_TIMEOUT; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SET_TRANSACTION_MODE; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_AUTOCOMMIT; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_AUTOCOMMIT_DML_MODE; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_COMMIT_TIMESTAMP; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_READONLY; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_READ_ONLY_STALENESS; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_READ_TIMESTAMP; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_RETRY_ABORTS_INTERNALLY; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.SHOW_STATEMENT_TIMEOUT; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.START_BATCH_DDL; -import static com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType.START_BATCH_DML; -import static com.google.cloud.spanner.jdbc.StatementResultImpl.noResult; -import static com.google.cloud.spanner.jdbc.StatementResultImpl.resultSet; - -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.DurationValueGetter; -import com.google.common.base.Preconditions; -import com.google.protobuf.Duration; -import java.util.concurrent.TimeUnit; - -/** - * The methods in this class are called by the different {@link ClientSideStatement}s. These method - * calls are then forwarded into a {@link Connection}. - */ -class ConnectionStatementExecutorImpl implements ConnectionStatementExecutor { - static final class StatementTimeoutGetter implements DurationValueGetter { - private final Connection connection; - - public StatementTimeoutGetter(Connection connection) { - this.connection = connection; - } - - @Override - public long getDuration(TimeUnit unit) { - return connection.getStatementTimeout(unit); - } - - @Override - public boolean hasDuration() { - return connection.hasStatementTimeout(); - } - } - - /** The connection to execute the statements on. */ - private final ConnectionImpl connection; - - ConnectionStatementExecutorImpl(ConnectionImpl connection) { - this.connection = connection; - } - - ConnectionImpl getConnection() { - return connection; - } - - @Override - public StatementResult statementSetAutocommit(Boolean autocommit) { - Preconditions.checkNotNull(autocommit); - getConnection().setAutocommit(autocommit); - return noResult(SET_AUTOCOMMIT); - } - - @Override - public StatementResult statementShowAutocommit() { - return resultSet("AUTOCOMMIT", getConnection().isAutocommit(), SHOW_AUTOCOMMIT); - } - - @Override - public StatementResult statementSetReadOnly(Boolean readOnly) { - Preconditions.checkNotNull(readOnly); - getConnection().setReadOnly(readOnly); - return noResult(SET_READONLY); - } - - @Override - public StatementResult statementShowReadOnly() { - return StatementResultImpl.resultSet("READONLY", getConnection().isReadOnly(), SHOW_READONLY); - } - - @Override - public StatementResult statementSetRetryAbortsInternally(Boolean retryAbortsInternally) { - Preconditions.checkNotNull(retryAbortsInternally); - getConnection().setRetryAbortsInternally(retryAbortsInternally); - return noResult(SET_RETRY_ABORTS_INTERNALLY); - } - - @Override - public StatementResult statementShowRetryAbortsInternally() { - return StatementResultImpl.resultSet( - "RETRY_ABORTS_INTERNALLY", - getConnection().isRetryAbortsInternally(), - SHOW_RETRY_ABORTS_INTERNALLY); - } - - @Override - public StatementResult statementSetAutocommitDmlMode(AutocommitDmlMode mode) { - getConnection().setAutocommitDmlMode(mode); - return noResult(SET_AUTOCOMMIT_DML_MODE); - } - - @Override - public StatementResult statementShowAutocommitDmlMode() { - return resultSet( - "AUTOCOMMIT_DML_MODE", getConnection().getAutocommitDmlMode(), SHOW_AUTOCOMMIT_DML_MODE); - } - - @Override - public StatementResult statementSetStatementTimeout(Duration duration) { - if (duration.getSeconds() == 0L && duration.getNanos() == 0) { - getConnection().clearStatementTimeout(); - } else { - TimeUnit unit = - ReadOnlyStalenessUtil.getAppropriateTimeUnit( - new ReadOnlyStalenessUtil.DurationGetter(duration)); - getConnection() - .setStatementTimeout(ReadOnlyStalenessUtil.durationToUnits(duration, unit), unit); - } - return noResult(SET_STATEMENT_TIMEOUT); - } - - @Override - public StatementResult statementShowStatementTimeout() { - return resultSet( - "STATEMENT_TIMEOUT", - getConnection().hasStatementTimeout() - ? ReadOnlyStalenessUtil.durationToString(new StatementTimeoutGetter(getConnection())) - : null, - SHOW_STATEMENT_TIMEOUT); - } - - @Override - public StatementResult statementShowReadTimestamp() { - return resultSet( - "READ_TIMESTAMP", getConnection().getReadTimestampOrNull(), SHOW_READ_TIMESTAMP); - } - - @Override - public StatementResult statementShowCommitTimestamp() { - return resultSet( - "COMMIT_TIMESTAMP", getConnection().getCommitTimestampOrNull(), SHOW_COMMIT_TIMESTAMP); - } - - @Override - public StatementResult statementSetReadOnlyStaleness(TimestampBound staleness) { - getConnection().setReadOnlyStaleness(staleness); - return noResult(SET_READ_ONLY_STALENESS); - } - - @Override - public StatementResult statementShowReadOnlyStaleness() { - TimestampBound staleness = getConnection().getReadOnlyStaleness(); - return resultSet( - "READ_ONLY_STALENESS", - ReadOnlyStalenessUtil.timestampBoundToString(staleness), - SHOW_READ_ONLY_STALENESS); - } - - @Override - public StatementResult statementBeginTransaction() { - getConnection().beginTransaction(); - return noResult(BEGIN); - } - - @Override - public StatementResult statementCommit() { - getConnection().commit(); - return noResult(COMMIT); - } - - @Override - public StatementResult statementRollback() { - getConnection().rollback(); - return noResult(ROLLBACK); - } - - @Override - public StatementResult statementSetTransactionMode(TransactionMode mode) { - getConnection().setTransactionMode(mode); - return noResult(SET_TRANSACTION_MODE); - } - - @Override - public StatementResult statementStartBatchDdl() { - getConnection().startBatchDdl(); - return noResult(START_BATCH_DDL); - } - - @Override - public StatementResult statementStartBatchDml() { - getConnection().startBatchDml(); - return noResult(START_BATCH_DML); - } - - @Override - public StatementResult statementRunBatch() { - long[] updateCounts = getConnection().runBatch(); - return resultSet("UPDATE_COUNTS", updateCounts, RUN_BATCH); - } - - @Override - public StatementResult statementAbortBatch() { - getConnection().abortBatch(); - return noResult(ABORT_BATCH); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CredentialsService.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CredentialsService.java deleted file mode 100644 index 1bb314e794d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/CredentialsService.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** Service class for getting credentials from key files. */ -class CredentialsService { - static final String GCS_NOT_SUPPORTED_MSG = - "Credentials that is stored on Google Cloud Storage is no longer supported. Download the credentials to a local file and reference the local file in the connection URL."; - static final CredentialsService INSTANCE = new CredentialsService(); - - CredentialsService() {} - - /** - * Create credentials from the given URL pointing to a credentials json file. This may be a local - * file or a file on Google Cloud Storage. Credentials on Google Cloud Storage can only be used if - * the application is running in an environment where application default credentials have been - * set. - * - * @param credentialsUrl The URL of the credentials file to read. If null, then this - * method will return the application default credentials of the environment. - * @return the {@link GoogleCredentials} object pointed to by the URL. - * @throws SpannerException If the URL does not point to a valid credentials file, or if the file - * cannot be accessed. - */ - GoogleCredentials createCredentials(String credentialsUrl) { - try { - if (credentialsUrl == null) { - return internalGetApplicationDefault(); - } else { - return getCredentialsFromUrl(credentialsUrl); - } - } catch (IOException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "Invalid credentials path specified", e); - } - } - - @VisibleForTesting - GoogleCredentials internalGetApplicationDefault() throws IOException { - return GoogleCredentials.getApplicationDefault(); - } - - private GoogleCredentials getCredentialsFromUrl(String credentialsUrl) throws IOException { - Preconditions.checkNotNull(credentialsUrl); - Preconditions.checkArgument( - credentialsUrl.length() > 0, "credentialsUrl may not be an empty string"); - if (credentialsUrl.startsWith("gs://")) { - throw new IOException(GCS_NOT_SUPPORTED_MSG); - } else { - return getCredentialsFromLocalFile(credentialsUrl); - } - } - - private GoogleCredentials getCredentialsFromLocalFile(String filePath) throws IOException { - File credentialsFile = new File(filePath); - if (!credentialsFile.isFile()) { - throw new IOException( - String.format("Error reading credential file %s: File does not exist", filePath)); - } - try (InputStream credentialsStream = new FileInputStream(credentialsFile)) { - return GoogleCredentials.fromStream(credentialsStream); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlBatch.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlBatch.java deleted file mode 100644 index 3431b29624b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlBatch.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ConnectionImpl.InternalMetadataQuery; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import org.apache.commons.lang3.ArrayUtils; - -/** - * {@link UnitOfWork} that is used when a DDL batch is started. These batches only accept DDL - * statements. All DDL statements are buffered locally and sent to Spanner when runBatch() is - * called. Running a {@link DdlBatch} is not an atomic operation. If the execution fails, then some - * (possibly empty) prefix of the statements in the batch have been successfully applied to the - * database, and the others have not. Note that the statements that succeed may not all happen at - * the same time, but they will always happen in order. - */ -class DdlBatch extends AbstractBaseUnitOfWork { - private final DdlClient ddlClient; - private final DatabaseClient dbClient; - private final List statements = new ArrayList<>(); - private UnitOfWorkState state = UnitOfWorkState.STARTED; - - static class Builder extends AbstractBaseUnitOfWork.Builder { - private DdlClient ddlClient; - private DatabaseClient dbClient; - - private Builder() {} - - Builder setDdlClient(DdlClient client) { - Preconditions.checkNotNull(client); - this.ddlClient = client; - return this; - } - - Builder setDatabaseClient(DatabaseClient client) { - Preconditions.checkNotNull(client); - this.dbClient = client; - return this; - } - - @Override - DdlBatch build() { - Preconditions.checkState(ddlClient != null, "No DdlClient specified"); - Preconditions.checkState(dbClient != null, "No DbClient specified"); - return new DdlBatch(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private DdlBatch(Builder builder) { - super(builder); - this.ddlClient = builder.ddlClient; - this.dbClient = builder.dbClient; - } - - @Override - public Type getType() { - return Type.BATCH; - } - - @Override - public UnitOfWorkState getState() { - return this.state; - } - - @Override - public boolean isActive() { - return getState().isActive(); - } - - @Override - public boolean isReadOnly() { - return false; - } - - @Override - public ResultSet executeQuery( - final ParsedStatement statement, AnalyzeMode analyzeMode, QueryOption... options) { - if (options != null) { - for (int i = 0; i < options.length; i++) { - if (options[i] instanceof InternalMetadataQuery) { - Preconditions.checkNotNull(statement); - Preconditions.checkArgument(statement.isQuery(), "Statement is not a query"); - Preconditions.checkArgument( - analyzeMode == AnalyzeMode.NONE, "Analyze is not allowed for DDL batch"); - // Queries marked with internal metadata queries are allowed during a DDL batch. - // These can only be generated by library internal methods and may be used to check - // whether a database object such as table or an index exists. - final QueryOption[] internalOptions = ArrayUtils.remove(options, i); - Callable callable = - new Callable() { - @Override - public ResultSet call() throws Exception { - return DirectExecuteResultSet.ofResultSet( - dbClient.singleUse().executeQuery(statement.getStatement(), internalOptions)); - } - }; - return asyncExecuteStatement(statement, callable); - } - } - } - // Queries are by default not allowed on DDL batches. - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing queries is not allowed for DDL batches."); - } - - @Override - public Timestamp getReadTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "There is no read timestamp available for DDL batches."); - } - - @Override - public Timestamp getReadTimestampOrNull() { - return null; - } - - @Override - public Timestamp getCommitTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "There is no commit timestamp available for DDL batches."); - } - - @Override - public Timestamp getCommitTimestampOrNull() { - return null; - } - - @Override - public void executeDdl(ParsedStatement ddl) { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, - "The batch is no longer active and cannot be used for further statements"); - Preconditions.checkArgument( - ddl.getType() == StatementType.DDL, - "Only DDL statements are allowed. \"" - + ddl.getSqlWithoutComments() - + "\" is not a DDL-statement."); - statements.add(ddl.getSqlWithoutComments()); - } - - @Override - public long executeUpdate(ParsedStatement update) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing updates is not allowed for DDL batches."); - } - - @Override - public long[] executeBatchUpdate(Iterable updates) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing batch updates is not allowed for DDL batches."); - } - - @Override - public void write(Mutation mutation) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Writing mutations is not allowed for DDL batches."); - } - - @Override - public void write(Iterable mutations) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Writing mutations is not allowed for DDL batches."); - } - - /** - * Create a {@link ParsedStatement} that we can use as input for the generic execute method when - * the {@link #runBatch()} method is executed. This method uses the generic execute method that - * allows statements to be cancelled and to timeout, which requires the input to be a {@link - * ParsedStatement}. - */ - private static final ParsedStatement RUN_BATCH = - StatementParser.INSTANCE.parse(Statement.of("RUN BATCH")); - - @Override - public long[] runBatch() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, "The batch is no longer active and cannot be ran"); - try { - if (!statements.isEmpty()) { - // create a statement that can be passed in to the execute method - Callable callable = - new Callable() { - @Override - public UpdateDatabaseDdlMetadata call() throws Exception { - OperationFuture operation = - ddlClient.executeDdl(statements); - try { - // Wait until the operation has finished. - operation.get(); - // Return metadata. - return operation.getMetadata().get(); - } catch (ExecutionException e) { - SpannerException spannerException = extractSpannerCause(e); - long[] updateCounts = extractUpdateCounts(operation.getMetadata().get()); - throw SpannerExceptionFactory.newSpannerBatchUpdateException( - spannerException == null - ? ErrorCode.UNKNOWN - : spannerException.getErrorCode(), - e.getMessage(), - updateCounts); - } catch (InterruptedException e) { - long[] updateCounts = extractUpdateCounts(operation.getMetadata().get()); - throw SpannerExceptionFactory.newSpannerBatchUpdateException( - ErrorCode.CANCELLED, e.getMessage(), updateCounts); - } - } - }; - asyncExecuteStatement(RUN_BATCH, callable); - } - this.state = UnitOfWorkState.RAN; - long[] updateCounts = new long[statements.size()]; - Arrays.fill(updateCounts, 1L); - return updateCounts; - } catch (SpannerException e) { - this.state = UnitOfWorkState.RUN_FAILED; - throw e; - } - } - - private SpannerException extractSpannerCause(ExecutionException e) { - Throwable cause = e.getCause(); - Set causes = new HashSet<>(); - while (cause != null && !causes.contains(cause)) { - if (cause instanceof SpannerException) { - return (SpannerException) cause; - } - causes.add(cause); - cause = cause.getCause(); - } - return null; - } - - @VisibleForTesting - long[] extractUpdateCounts(UpdateDatabaseDdlMetadata metadata) { - long[] updateCounts = new long[metadata.getStatementsCount()]; - for (int i = 0; i < updateCounts.length; i++) { - if (metadata.getCommitTimestampsCount() > i && metadata.getCommitTimestamps(i) != null) { - updateCounts[i] = 1L; - } else { - updateCounts[i] = 0L; - } - } - return updateCounts; - } - - @Override - public void abortBatch() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, "The batch is no longer active and cannot be aborted."); - this.state = UnitOfWorkState.ABORTED; - } - - @Override - public void commit() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Commit is not allowed for DDL batches."); - } - - @Override - public void rollback() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Rollback is not allowed for DDL batches."); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlClient.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlClient.java deleted file mode 100644 index 5f921d7b43f..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DdlClient.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.spanner.DatabaseAdminClient; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import java.util.Arrays; -import java.util.List; - -/** - * Convenience class for executing Data Definition Language statements on transactions that support - * DDL statements, i.e. DdlBatchTransaction and SingleUseTransaction. - */ -class DdlClient { - private final DatabaseAdminClient dbAdminClient; - private final String instanceId; - private final String databaseName; - - static class Builder { - private DatabaseAdminClient dbAdminClient; - private String instanceId; - private String databaseName; - - private Builder() {} - - Builder setDatabaseAdminClient(DatabaseAdminClient client) { - Preconditions.checkNotNull(client); - this.dbAdminClient = client; - return this; - } - - Builder setInstanceId(String instanceId) { - Preconditions.checkArgument( - !Strings.isNullOrEmpty(instanceId), "Empty instanceId is not allowed"); - this.instanceId = instanceId; - return this; - } - - Builder setDatabaseName(String name) { - Preconditions.checkArgument( - !Strings.isNullOrEmpty(name), "Empty database name is not allowed"); - this.databaseName = name; - return this; - } - - DdlClient build() { - Preconditions.checkState(dbAdminClient != null, "No DatabaseAdminClient specified"); - Preconditions.checkState(!Strings.isNullOrEmpty(instanceId), "No InstanceId specified"); - Preconditions.checkArgument( - !Strings.isNullOrEmpty(databaseName), "No database name specified"); - return new DdlClient(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private DdlClient(Builder builder) { - this.dbAdminClient = builder.dbAdminClient; - this.instanceId = builder.instanceId; - this.databaseName = builder.databaseName; - } - - /** Execute a single DDL statement. */ - OperationFuture executeDdl(String ddl) { - return executeDdl(Arrays.asList(ddl)); - } - - /** Execute a list of DDL statements as one operation. */ - OperationFuture executeDdl(List statements) { - return dbAdminClient.updateDatabaseDdl(instanceId, databaseName, statements, null); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSet.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSet.java deleted file mode 100644 index 90ca044166e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSet.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.ByteArray; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.common.base.Preconditions; -import com.google.spanner.v1.ResultSetStats; -import java.util.List; - -/** - * {@link ResultSet} implementation used by the Spanner connection API to ensure that the query for - * a {@link ResultSet} is executed directly when it is created. This is done by calling {@link - * ResultSet#next()} directly after creation. This ensures that a statement timeout can be applied - * to the actual query execution. It also ensures that any invalid query will throw an exception at - * execution instead of the first next() call by a client. - */ -class DirectExecuteResultSet implements ResultSet { - private static final String MISSING_NEXT_CALL = "Must be preceded by a next() call"; - private final ResultSet delegate; - private boolean nextCalledByClient = false; - private final boolean initialNextResult; - private boolean nextHasReturnedFalse = false; - - /** - * Creates a new {@link DirectExecuteResultSet} from the given delegate {@link ResultSet}. This - * automatically executes the query of the given delegate {@link ResultSet} by calling next() on - * the delegate. The delegate must not have been used (i.e. next() must not have been called on - * it). - * - * @param delegate The underlying {@link ResultSet} for this {@link DirectExecuteResultSet}. - * @return a {@link DirectExecuteResultSet} that has already executed the query associated with - * the delegate {@link ResultSet}. - */ - static DirectExecuteResultSet ofResultSet(ResultSet delegate) { - return new DirectExecuteResultSet(delegate); - } - - DirectExecuteResultSet(ResultSet delegate) { - Preconditions.checkNotNull(delegate); - this.delegate = delegate; - initialNextResult = delegate.next(); - } - - @Override - public boolean next() throws SpannerException { - if (nextCalledByClient) { - boolean res = delegate.next(); - nextHasReturnedFalse = !res; - return res; - } - nextCalledByClient = true; - nextHasReturnedFalse = !initialNextResult; - return initialNextResult; - } - - @Override - public Struct getCurrentRowAsStruct() { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getCurrentRowAsStruct(); - } - - @Override - public void close() { - delegate.close(); - } - - @Override - public ResultSetStats getStats() { - if (nextHasReturnedFalse) { - return delegate.getStats(); - } - return null; - } - - @Override - public Type getType() { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getType(); - } - - @Override - public int getColumnCount() { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getColumnCount(); - } - - @Override - public int getColumnIndex(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getColumnIndex(columnName); - } - - @Override - public Type getColumnType(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getColumnType(columnIndex); - } - - @Override - public Type getColumnType(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getColumnType(columnName); - } - - @Override - public boolean isNull(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.isNull(columnIndex); - } - - @Override - public boolean isNull(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.isNull(columnName); - } - - @Override - public boolean getBoolean(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBoolean(columnIndex); - } - - @Override - public boolean getBoolean(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBoolean(columnName); - } - - @Override - public long getLong(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLong(columnIndex); - } - - @Override - public long getLong(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLong(columnName); - } - - @Override - public double getDouble(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDouble(columnIndex); - } - - @Override - public double getDouble(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDouble(columnName); - } - - @Override - public String getString(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getString(columnIndex); - } - - @Override - public String getString(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getString(columnName); - } - - @Override - public ByteArray getBytes(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBytes(columnIndex); - } - - @Override - public ByteArray getBytes(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBytes(columnName); - } - - @Override - public Timestamp getTimestamp(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getTimestamp(columnIndex); - } - - @Override - public Timestamp getTimestamp(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getTimestamp(columnName); - } - - @Override - public Date getDate(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDate(columnIndex); - } - - @Override - public Date getDate(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDate(columnName); - } - - @Override - public boolean[] getBooleanArray(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBooleanArray(columnIndex); - } - - @Override - public boolean[] getBooleanArray(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBooleanArray(columnName); - } - - @Override - public List getBooleanList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBooleanList(columnIndex); - } - - @Override - public List getBooleanList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBooleanList(columnName); - } - - @Override - public long[] getLongArray(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLongArray(columnIndex); - } - - @Override - public long[] getLongArray(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLongArray(columnName); - } - - @Override - public List getLongList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLongList(columnIndex); - } - - @Override - public List getLongList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getLongList(columnName); - } - - @Override - public double[] getDoubleArray(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDoubleArray(columnIndex); - } - - @Override - public double[] getDoubleArray(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDoubleArray(columnName); - } - - @Override - public List getDoubleList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDoubleList(columnIndex); - } - - @Override - public List getDoubleList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDoubleList(columnName); - } - - @Override - public List getStringList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getStringList(columnIndex); - } - - @Override - public List getStringList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getStringList(columnName); - } - - @Override - public List getBytesList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBytesList(columnIndex); - } - - @Override - public List getBytesList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getBytesList(columnName); - } - - @Override - public List getTimestampList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getTimestampList(columnIndex); - } - - @Override - public List getTimestampList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getTimestampList(columnName); - } - - @Override - public List getDateList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDateList(columnIndex); - } - - @Override - public List getDateList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getDateList(columnName); - } - - @Override - public List getStructList(int columnIndex) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getStructList(columnIndex); - } - - @Override - public List getStructList(String columnName) { - Preconditions.checkState(nextCalledByClient, MISSING_NEXT_CALL); - return delegate.getStructList(columnName); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof DirectExecuteResultSet)) { - return false; - } - return ((DirectExecuteResultSet) o).delegate.equals(delegate); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DmlBatch.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DmlBatch.java deleted file mode 100644 index 55da9fb1bc6..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/DmlBatch.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.common.base.Preconditions; -import java.util.ArrayList; -import java.util.List; - -/** - * {@link UnitOfWork} that is used when a DML batch is started. These batches only accept DML - * statements. All DML statements are buffered locally and sent to Spanner when runBatch() is - * called. - */ -class DmlBatch extends AbstractBaseUnitOfWork { - private final UnitOfWork transaction; - private final List statements = new ArrayList<>(); - private UnitOfWorkState state = UnitOfWorkState.STARTED; - - static class Builder extends AbstractBaseUnitOfWork.Builder { - private UnitOfWork transaction; - - private Builder() {} - - Builder setTransaction(UnitOfWork transaction) { - Preconditions.checkNotNull(transaction); - this.transaction = transaction; - return this; - } - - @Override - DmlBatch build() { - Preconditions.checkState(transaction != null, "No transaction specified"); - return new DmlBatch(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private DmlBatch(Builder builder) { - super(builder); - this.transaction = builder.transaction; - } - - @Override - public Type getType() { - return Type.BATCH; - } - - @Override - public UnitOfWorkState getState() { - return this.state; - } - - @Override - public boolean isActive() { - return getState().isActive(); - } - - @Override - public boolean isReadOnly() { - return false; - } - - @Override - public ResultSet executeQuery( - ParsedStatement statement, AnalyzeMode analyzeMode, QueryOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing queries is not allowed for DML batches."); - } - - @Override - public Timestamp getReadTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "There is no read timestamp available for DML batches."); - } - - @Override - public Timestamp getReadTimestampOrNull() { - return null; - } - - @Override - public Timestamp getCommitTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "There is no commit timestamp available for DML batches."); - } - - @Override - public Timestamp getCommitTimestampOrNull() { - return null; - } - - @Override - public void executeDdl(ParsedStatement ddl) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing DDL statements is not allowed for DML batches."); - } - - @Override - public long executeUpdate(ParsedStatement update) { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, - "The batch is no longer active and cannot be used for further statements"); - Preconditions.checkArgument( - update.getType() == StatementType.UPDATE, - "Only DML statements are allowed. \"" - + update.getSqlWithoutComments() - + "\" is not a DML-statement."); - statements.add(update); - return -1L; - } - - @Override - public long[] executeBatchUpdate(Iterable updates) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Executing batch updates is not allowed for DML batches."); - } - - @Override - public void write(Mutation mutation) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Writing mutations is not allowed for DML batches."); - } - - @Override - public void write(Iterable mutations) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Writing mutations is not allowed for DML batches."); - } - - @Override - public long[] runBatch() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, "The batch is no longer active and cannot be ran"); - try { - long[] res; - if (statements.isEmpty()) { - res = new long[0]; - } else { - res = transaction.executeBatchUpdate(statements); - } - this.state = UnitOfWorkState.RAN; - return res; - } catch (SpannerException e) { - this.state = UnitOfWorkState.RUN_FAILED; - throw e; - } - } - - @Override - public void abortBatch() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, "The batch is no longer active and cannot be aborted."); - this.state = UnitOfWorkState.ABORTED; - } - - @Override - public void commit() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Commit is not allowed for DML batches."); - } - - @Override - public void rollback() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Rollback is not allowed for DML batches."); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedBatchUpdate.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedBatchUpdate.java deleted file mode 100644 index d96d98a829a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedBatchUpdate.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.common.base.Preconditions; -import java.util.Arrays; -import java.util.Objects; - -/** - * A batch update that failed with a {@link SpannerException} on a {@link ReadWriteTransaction}. The - * batch update can be retried if the transaction is aborted, and should throw the same exception - * during retry as during the original transaction. - */ -final class FailedBatchUpdate implements RetriableStatement { - private final ReadWriteTransaction transaction; - private final SpannerException exception; - private final Iterable statements; - - FailedBatchUpdate( - ReadWriteTransaction transaction, - SpannerException exception, - Iterable statements) { - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(exception); - Preconditions.checkNotNull(statements); - this.transaction = transaction; - this.exception = exception; - this.statements = statements; - } - - @Override - public void retry(AbortedException aborted) throws AbortedException { - transaction - .getStatementExecutor() - .invokeInterceptors( - ReadWriteTransaction.EXECUTE_BATCH_UPDATE_STATEMENT, - StatementExecutionStep.RETRY_STATEMENT, - transaction); - try { - transaction.getReadContext().batchUpdate(statements); - } catch (SpannerBatchUpdateException e) { - // Check that we got the same exception as in the original transaction. - if (exception instanceof SpannerBatchUpdateException - && e.getErrorCode() == exception.getErrorCode() - && Objects.equals(e.getMessage(), exception.getMessage())) { - // Check that the returned update counts are equal. - if (Arrays.equals( - e.getUpdateCounts(), ((SpannerBatchUpdateException) exception).getUpdateCounts())) { - return; - } - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } catch (SpannerException e) { - // Check that we got the same exception as in the original transaction. - if (e.getErrorCode() == exception.getErrorCode() - && Objects.equals(e.getMessage(), exception.getMessage())) { - return; - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedQuery.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedQuery.java deleted file mode 100644 index 4e2a3ecda87..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedQuery.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; -import java.util.Objects; - -/** - * A query that failed with a {@link SpannerException} on a {@link ReadWriteTransaction}. The query - * can be retried if the transaction is aborted, and should throw the same exception during retry as - * during the original transaction. - */ -final class FailedQuery implements RetriableStatement { - private final ReadWriteTransaction transaction; - private final SpannerException exception; - private final ParsedStatement statement; - private final AnalyzeMode analyzeMode; - private final QueryOption[] options; - - FailedQuery( - ReadWriteTransaction transaction, - SpannerException exception, - ParsedStatement statement, - AnalyzeMode analyzeMode, - QueryOption... options) { - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(exception); - Preconditions.checkNotNull(statement); - this.transaction = transaction; - this.exception = exception; - this.statement = statement; - this.analyzeMode = analyzeMode; - this.options = options; - } - - @Override - public void retry(AbortedException aborted) throws AbortedException { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - try { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - try (ResultSet rs = - DirectExecuteResultSet.ofResultSet( - transaction.internalExecuteQuery(statement, analyzeMode, options))) { - // Do nothing with the results, we are only interested in whether the statement throws the - // same exception as in the original transaction. - } - } catch (SpannerException e) { - // Check that we got the same exception as in the original transaction - if (e.getErrorCode() == exception.getErrorCode() - && Objects.equals(e.getMessage(), exception.getMessage())) { - return; - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedUpdate.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedUpdate.java deleted file mode 100644 index 1974f0ccdbb..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/FailedUpdate.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; -import java.util.Objects; - -/** - * An update that failed with a {@link SpannerException} on a {@link ReadWriteTransaction}. The - * update can be retried if the transaction is aborted, and should throw the same exception during - * retry as during the original transaction. - */ -final class FailedUpdate implements RetriableStatement { - private final ReadWriteTransaction transaction; - private final SpannerException exception; - private final ParsedStatement statement; - - FailedUpdate( - ReadWriteTransaction transaction, SpannerException exception, ParsedStatement statement) { - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(exception); - Preconditions.checkNotNull(statement); - this.transaction = transaction; - this.exception = exception; - this.statement = statement; - } - - @Override - public void retry(AbortedException aborted) throws AbortedException { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - try { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - transaction.getReadContext().executeUpdate(statement.getStatement()); - } catch (SpannerException e) { - // Check that we got the same exception as in the original transaction. - if (e.getErrorCode() == exception.getErrorCode() - && Objects.equals(e.getMessage(), exception.getMessage())) { - return; - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcArray.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcArray.java deleted file mode 100644 index 67d8e0c1572..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcArray.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.rpc.Code; -import java.sql.Array; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** Implementation of java.sql.Array for Google Cloud Spanner */ -class JdbcArray implements Array { - private static final String FREE_EXCEPTION = - "free() has been called, array is no longer available"; - - private final JdbcDataType type; - private Object data; - private boolean freed = false; - - /** - * Create a JDBC {@link Array} from the given type name and array elements. - * - * @param typeName The Google Cloud Spanner type name to be used as the base type of the array. - * @param elements The elements to store in the array. - * @return the initialized {@link Array}. - * @throws SQLException if the type name is not a valid Cloud Spanner type or if the contents of - * the elements array is not compatible with the base type of the array. - */ - static JdbcArray createArray(String typeName, Object[] elements) throws SQLException { - for (JdbcDataType type : JdbcDataType.values()) { - if (type.getTypeName().equalsIgnoreCase(typeName)) { - return new JdbcArray(type, elements); - } - } - throw JdbcSqlExceptionFactory.of( - "Data type " + typeName + " is unknown", Code.INVALID_ARGUMENT); - } - - /** - * Create a JDBC {@link Array} from the given type name and list. - * - * @param typeName The Google Cloud Spanner type name to be used as the base type of the array. - * @param elements The elements to store in the array. - * @return the initialized {@link Array}. - * @throws SQLException if the type name is not a valid Cloud Spanner type or if the contents of - * the elements array is not compatible with the base type of the array. - */ - static JdbcArray createArray(JdbcDataType type, List elements) { - return new JdbcArray(type, elements); - } - - private JdbcArray(JdbcDataType type, Object[] elements) throws SQLException { - this.type = type; - if (elements != null) { - this.data = java.lang.reflect.Array.newInstance(type.getJavaClass(), elements.length); - try { - System.arraycopy(elements, 0, this.data, 0, elements.length); - } catch (Exception e) { - throw JdbcSqlExceptionFactory.of( - "Could not copy array elements. Make sure the supplied array only contains elements of class " - + type.getJavaClass().getName(), - Code.UNKNOWN, - e); - } - } - } - - private JdbcArray(JdbcDataType type, List elements) { - this.type = type; - if (elements != null) { - this.data = java.lang.reflect.Array.newInstance(type.getJavaClass(), elements.size()); - elements.toArray((Object[]) data); - } - } - - private void checkFree() throws SQLException { - if (freed) { - throw JdbcSqlExceptionFactory.of(FREE_EXCEPTION, Code.FAILED_PRECONDITION); - } - } - - @Override - public String getBaseTypeName() throws SQLException { - checkFree(); - return type.getTypeName(); - } - - @Override - public int getBaseType() throws SQLException { - checkFree(); - return type.getSqlType(); - } - - @Override - public Object getArray() throws SQLException { - checkFree(); - return data; - } - - @Override - public Object getArray(Map> map) throws SQLException { - checkFree(); - return data; - } - - @Override - public Object getArray(long index, int count) throws SQLException { - checkFree(); - return getArray(index, count, null); - } - - @Override - public Object getArray(long index, int count, Map> map) throws SQLException { - checkFree(); - if (data != null) { - Object res = java.lang.reflect.Array.newInstance(type.getJavaClass(), count); - System.arraycopy(data, (int) index - 1, res, 0, count); - return res; - } - return null; - } - - private static final String RESULTSET_NOT_SUPPORTED = - "Getting a ResultSet from an array is not supported"; - - @Override - public ResultSet getResultSet() throws SQLException { - throw new SQLFeatureNotSupportedException(RESULTSET_NOT_SUPPORTED); - } - - @Override - public ResultSet getResultSet(Map> map) throws SQLException { - throw new SQLFeatureNotSupportedException(RESULTSET_NOT_SUPPORTED); - } - - @Override - public ResultSet getResultSet(long index, int count) throws SQLException { - throw new SQLFeatureNotSupportedException(RESULTSET_NOT_SUPPORTED); - } - - @Override - public ResultSet getResultSet(long index, int count, Map> map) - throws SQLException { - throw new SQLFeatureNotSupportedException(RESULTSET_NOT_SUPPORTED); - } - - @Override - public void free() throws SQLException { - this.freed = true; - this.data = null; - } - - @Override - public String toString() { - if (data == null) { - return "null"; - } - boolean first = true; - StringBuilder builder = new StringBuilder("{"); - for (Object o : (Object[]) data) { - if (!first) { - builder.append(","); - } - first = false; - if (o == null) { - builder.append("null"); - } else { - builder.append(o.toString()); - } - } - builder.append("}"); - return builder.toString(); - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof JdbcArray)) return false; - JdbcArray array = (JdbcArray) other; - return this.type == array.type - && Arrays.deepEquals((Object[]) this.data, (Object[]) array.data); - } - - @Override - public int hashCode() { - return this.type.hashCode() ^ Arrays.deepHashCode((Object[]) data); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcBlob.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcBlob.java deleted file mode 100644 index 071e3258c02..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcBlob.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.common.base.Preconditions; -import com.google.rpc.Code; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.Blob; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Simple {@link Blob} implementation for Google Cloud Spanner. The value is mapped to a byte array - * in memory. The {@link Blob} data type can be used in combination with the BYTES Cloud Spanner - * data type. - */ -class JdbcBlob implements Blob { - private byte[] value = new byte[0]; - - /** Creates an empty blob. */ - JdbcBlob() {} - - /** Creates a blob with the specified bytes as its value. */ - JdbcBlob(byte[] value) { - this.value = value; - } - - private void checkPosition(long pos) { - Preconditions.checkArgument( - pos + 1 <= Integer.MAX_VALUE, - "position larger than " + Integer.MAX_VALUE + " is not supported"); - } - - private void checkLength(long length) { - Preconditions.checkArgument( - length <= Integer.MAX_VALUE, - "length larger than " + Integer.MAX_VALUE + " is not supported"); - } - - private void checkPositionPlusLength(long pos, long length) { - Preconditions.checkArgument( - pos + 1 + length <= Integer.MAX_VALUE, - "position+length larger than " + Integer.MAX_VALUE + " is not supported"); - } - - @Override - public long length() throws SQLException { - return value.length; - } - - @Override - public byte[] getBytes(long pos, int length) throws SQLException { - JdbcPreconditions.checkArgument(pos > 0L, "pos must be >= 1"); - JdbcPreconditions.checkArgument(length >= 0, "length must be >= 0"); - checkPosition(pos); - checkPositionPlusLength(pos, length); - int end = (int) pos + length - 1; - int blobLength = (int) length(); - if (end > blobLength) { - length = blobLength - (int) pos + 1; - } - byte[] res = new byte[length]; - System.arraycopy(value, (int) pos - 1, res, 0, length); - return res; - } - - @Override - public InputStream getBinaryStream() throws SQLException { - return new ByteArrayInputStream(value); - } - - @Override - public long position(byte[] pattern, long start) throws SQLException { - JdbcPreconditions.checkArgument( - pattern != null && pattern.length > 0, "pattern must not be empty"); - JdbcPreconditions.checkArgument(start > 0L, "start must be >= 1"); - checkPosition(start); - for (int outerIndex = (int) start - 1; outerIndex < value.length; outerIndex++) { - int innerIndex = 0; - int valueIndex = outerIndex; - while (valueIndex < value.length - && innerIndex < pattern.length - && value[valueIndex] == pattern[innerIndex]) { - innerIndex++; - valueIndex++; - } - if (innerIndex == pattern.length) { - return outerIndex + 1; - } - } - return -1; - } - - @Override - public long position(Blob pattern, long start) throws SQLException { - JdbcPreconditions.checkArgument(pattern != null, "pattern must not be empty"); - JdbcPreconditions.checkArgument(start > 0L, "start must be >= 1"); - checkPosition(start); - byte[] buffer = new byte[1024]; - int totalSize = 0; - List totalBytes = new ArrayList<>(); - try (InputStream is = pattern.getBinaryStream()) { - int bytesRead = 0; - while ((bytesRead = is.read(buffer)) > -1) { - if (bytesRead == buffer.length) { - totalBytes.add(buffer); - } else { - byte[] dest = new byte[bytesRead]; - System.arraycopy(buffer, 0, dest, 0, bytesRead); - totalBytes.add(dest); - } - totalSize += bytesRead; - buffer = new byte[1024]; - } - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of("reading blob failed", Code.UNKNOWN, e); - } - byte[] bytePattern = new byte[totalSize]; - int index = 0; - for (byte[] b : totalBytes) { - System.arraycopy(b, 0, bytePattern, index, b.length); - index += b.length; - } - return position(bytePattern, start); - } - - private void setLength(int length) { - int prevLength = value.length; - byte[] newValue = new byte[length]; - System.arraycopy(value, 0, newValue, 0, Math.min(prevLength, newValue.length)); - value = newValue; - } - - @Override - public int setBytes(long pos, byte[] bytes) throws SQLException { - JdbcPreconditions.checkArgument(bytes != null, "bytes must be non-null"); - JdbcPreconditions.checkArgument(pos > 0L, "pos must be >= 1"); - checkPosition(pos); - int end = (int) pos + bytes.length - 1; - if (end >= value.length) { - setLength(end); - } - System.arraycopy(bytes, 0, value, (int) pos - 1, bytes.length); - return bytes.length; - } - - @Override - public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { - JdbcPreconditions.checkArgument(bytes != null, "bytes must be non-null"); - JdbcPreconditions.checkArgument(pos > 0L, "pos must be >= 1"); - JdbcPreconditions.checkArgument(offset >= 0, "offset must be >= 0"); - JdbcPreconditions.checkArgument(len >= 0, "len must be >= 0"); - checkPosition(pos); - if (offset > bytes.length) { - offset = 0; - len = 0; - } else { - if (offset + len > bytes.length) { - len = bytes.length - offset; - } - } - int end = (int) pos + len - 1; - if (end >= value.length) { - setLength(end); - } - System.arraycopy(bytes, offset, value, (int) pos - 1, len); - return len; - } - - private final class BlobOutputStream extends OutputStream { - private byte[] buffer = new byte[1024]; - private int currentPos = 0; - private int blobPosition; - - private BlobOutputStream(int pos) { - blobPosition = pos; - } - - @Override - public void write(int b) throws IOException { - if (currentPos >= buffer.length) { - byte[] newBuffer = new byte[buffer.length * 2]; - System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); - buffer = newBuffer; - } - buffer[currentPos] = (byte) b; - currentPos++; - } - - @Override - public void flush() throws IOException { - try { - setBytes(blobPosition, buffer, 0, currentPos); - blobPosition += currentPos; - currentPos = 0; - Arrays.fill(buffer, (byte) 0); - } catch (SQLException e) { - throw new IOException(e); - } - } - - @Override - public void close() throws IOException { - flush(); - } - } - - @Override - public OutputStream setBinaryStream(long pos) throws SQLException { - JdbcPreconditions.checkArgument(pos > 0L, "pos must be >= 1"); - checkPosition(pos); - return new BlobOutputStream((int) pos); - } - - @Override - public void truncate(long len) throws SQLException { - JdbcPreconditions.checkArgument(len >= 0, "len must be >= 0"); - checkLength(len); - setLength((int) len); - } - - @Override - public void free() throws SQLException { - setLength(0); - } - - @Override - public InputStream getBinaryStream(long pos, long length) throws SQLException { - JdbcPreconditions.checkArgument(pos > 0, "pos must be >= 1"); - JdbcPreconditions.checkArgument(length >= 0, "length must be >= 0"); - checkPosition(pos); - checkPositionPlusLength(pos, length); - if (pos + length > value.length) { - length = value.length - pos + 1; - } - byte[] buffer = new byte[(int) length]; - System.arraycopy(value, (int) pos - 1, buffer, 0, (int) length); - return new ByteArrayInputStream(buffer); - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof JdbcBlob)) return false; - JdbcBlob blob = (JdbcBlob) other; - return Arrays.equals(this.value, blob.value); - } - - @Override - public int hashCode() { - return Arrays.hashCode(value); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcClob.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcClob.java deleted file mode 100644 index 40e26733a56..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcClob.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.common.base.Preconditions; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.sql.Clob; -import java.sql.NClob; -import java.sql.SQLException; - -/** - * Simple implementation of {@link Clob} and {@link NClob} for Google Cloud Spanner. The value is - * mapped to a {@link StringBuilder} in memory. {@link Clob} and {@link NClob} can be used with the - * STRING data type of Cloud Spanner. - */ -class JdbcClob implements NClob { - private StringBuilder value = new StringBuilder(); - - JdbcClob() {} - - JdbcClob(String value) { - this.value.append(value); - } - - private void checkPosition(long pos) { - Preconditions.checkArgument( - pos + 1 <= Integer.MAX_VALUE, - "position larger than " + Integer.MAX_VALUE + " is not supported"); - } - - private void checkLength(long length) { - Preconditions.checkArgument( - length <= Integer.MAX_VALUE, - "length larger than " + Integer.MAX_VALUE + " is not supported"); - } - - private void checkPositionPlusLength(long pos, long length) { - Preconditions.checkArgument( - pos + 1 + length <= Integer.MAX_VALUE, - "position+length larger than " + Integer.MAX_VALUE + " is not supported"); - } - - private StringBuilder repeat(char c, long length) { - checkLength(length); - StringBuilder res = new StringBuilder((int) length); - for (int i = 0; i < length; i++) { - res.append(c); - } - return res; - } - - @Override - public long length() throws SQLException { - return value.length(); - } - - @Override - public String getSubString(long pos, int length) throws SQLException { - JdbcPreconditions.checkArgument(pos >= 1, "Start position must be >= 1"); - JdbcPreconditions.checkArgument(length >= 0, "Length must be >= 0"); - checkPosition(pos); - checkPositionPlusLength(pos, length); - if (pos > length()) { - return ""; - } - int end = (int) pos + length - 1; - if (end >= value.length()) { - end = value.length(); - } - return value.substring((int) pos - 1, end); - } - - @Override - public Reader getCharacterStream() throws SQLException { - return new StringReader(value.toString()); - } - - @Override - public InputStream getAsciiStream() throws SQLException { - return new ByteArrayInputStream(StandardCharsets.US_ASCII.encode(value.toString()).array()); - } - - @Override - public long position(String searchStr, long start) throws SQLException { - JdbcPreconditions.checkArgument(start >= 1, "Start position must be >= 1"); - JdbcPreconditions.checkArgument(searchStr != null, "searchStr may not be null"); - checkPosition(start); - int res = value.indexOf(searchStr, (int) start - 1); - if (res == -1) { - return res; - } - return res + 1; - } - - @Override - public long position(Clob searchStr, long start) throws SQLException { - JdbcPreconditions.checkArgument(start >= 1, "Start position must be >= 1"); - JdbcPreconditions.checkArgument(searchStr != null, "searchStr may not be null"); - checkPosition(start); - checkPositionPlusLength(start, searchStr.length()); - int res = value.indexOf(searchStr.getSubString(1L, (int) searchStr.length()), (int) start - 1); - if (res == -1) { - return res; - } - return res + 1; - } - - @Override - public int setString(long pos, String str) throws SQLException { - JdbcPreconditions.checkArgument(str != null, "str is null"); - JdbcPreconditions.checkArgument(pos >= 1, "Position must be >= 1"); - checkPosition(pos); - if ((pos - 1) > length()) { - value.append(repeat(' ', pos - length() - 1)); - } - value.replace((int) pos - 1, (int) pos + str.length() - 1, str); - return str.length(); - } - - @Override - public int setString(long pos, String str, int offset, int len) throws SQLException { - JdbcPreconditions.checkArgument(str != null, "str is null"); - JdbcPreconditions.checkArgument(pos >= 1, "Position must be >= 1"); - JdbcPreconditions.checkArgument(offset >= 1, "Offset must be >= 1"); - JdbcPreconditions.checkArgument( - offset + len - 1 <= str.length(), "offset + len is greater than str.length()"); - checkPosition(pos); - return setString(pos, str.substring(offset - 1, offset + len - 1)); - } - - private class ClobWriter extends StringWriter { - private final long startPos; - - private ClobWriter(long startPos) { - this.startPos = startPos; - } - - @Override - public void flush() { - try { - setString(startPos, getBuffer().toString()); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - @Override - public void close() { - flush(); - } - } - - @Override - public OutputStream setAsciiStream(long pos) throws SQLException { - throw JdbcSqlExceptionFactory.unsupported( - "setAsciiStream is not supported. Use setCharacterStream instead"); - } - - @Override - public Writer setCharacterStream(long pos) throws SQLException { - JdbcPreconditions.checkArgument(pos >= 1, "pos must be >= 1"); - return new ClobWriter(pos); - } - - @Override - public void truncate(long len) throws SQLException { - JdbcPreconditions.checkArgument(len >= 0, "len must be >= 0"); - checkLength(len); - value.setLength((int) len); - } - - @Override - public void free() throws SQLException { - value = new StringBuilder(); - } - - @Override - public Reader getCharacterStream(long pos, long length) throws SQLException { - JdbcPreconditions.checkArgument(pos >= 1, "pos must be >= 1"); - JdbcPreconditions.checkArgument(length >= 0, "length must be >= 0"); - checkPosition(pos); - checkPositionPlusLength(pos, length); - return new StringReader( - value.substring((int) pos - 1, (int) pos + (int) length - 1).toString()); - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof JdbcClob)) return false; - JdbcClob blob = (JdbcClob) other; - return value.toString().equals(blob.value.toString()); - } - - @Override - public int hashCode() { - return value.toString().hashCode(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java deleted file mode 100644 index 08b2a823b61..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.SpannerException; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** Jdbc Connection class for Google Cloud Spanner */ -class JdbcConnection extends AbstractJdbcConnection { - private static final String ONLY_RS_FORWARD_ONLY = - "Only result sets of type TYPE_FORWARD_ONLY are supported"; - private static final String ONLY_CONCUR_READ_ONLY = - "Only result sets with concurrency CONCUR_READ_ONLY are supported"; - private static final String ONLY_CLOSE_CURSORS_AT_COMMIT = - "Only result sets with holdability CLOSE_CURSORS_AT_COMMIT are supported"; - static final String ONLY_NO_GENERATED_KEYS = "Only NO_GENERATED_KEYS are supported"; - static final String IS_VALID_QUERY = "SELECT 1"; - - private Map> typeMap = new HashMap<>(); - - JdbcConnection(String connectionUrl, ConnectionOptions options) { - super(connectionUrl, options); - } - - @Override - public Statement createStatement() throws SQLException { - checkClosed(); - return new JdbcStatement(this); - } - - @Override - public JdbcPreparedStatement prepareStatement(String sql) throws SQLException { - checkClosed(); - return new JdbcPreparedStatement(this, sql); - } - - @Override - public String nativeSQL(String sql) throws SQLException { - checkClosed(); - return JdbcParameterStore.convertPositionalParametersToNamedParameters( - StatementParser.removeCommentsAndTrim(sql)) - .sqlWithNamedParameters; - } - - @Override - public void setAutoCommit(boolean autoCommit) throws SQLException { - checkClosed(); - try { - // According to the JDBC spec's we need to commit the current transaction when changing - // autocommit mode. - if (getSpannerConnection().isAutocommit() != autoCommit - && getSpannerConnection().isTransactionStarted()) { - commit(); - } - getSpannerConnection().setAutocommit(autoCommit); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public boolean getAutoCommit() throws SQLException { - checkClosed(); - return getSpannerConnection().isAutocommit(); - } - - @Override - public void commit() throws SQLException { - checkClosed(); - try { - getSpannerConnection().commit(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void rollback() throws SQLException { - checkClosed(); - try { - getSpannerConnection().rollback(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void close() throws SQLException { - try { - getSpannerConnection().close(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public boolean isClosed() throws SQLException { - return getSpannerConnection().isClosed(); - } - - @Override - public DatabaseMetaData getMetaData() throws SQLException { - checkClosed(); - return new JdbcDatabaseMetaData(this); - } - - @Override - public void setReadOnly(boolean readOnly) throws SQLException { - checkClosed(); - try { - getSpannerConnection().setReadOnly(readOnly); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public boolean isReadOnly() throws SQLException { - checkClosed(); - return getSpannerConnection().isReadOnly(); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) - throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetType == ResultSet.TYPE_FORWARD_ONLY, ONLY_RS_FORWARD_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetConcurrency == ResultSet.CONCUR_READ_ONLY, ONLY_CONCUR_READ_ONLY); - return createStatement(); - } - - @Override - public Statement createStatement( - int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetType == ResultSet.TYPE_FORWARD_ONLY, ONLY_RS_FORWARD_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetConcurrency == ResultSet.CONCUR_READ_ONLY, ONLY_CONCUR_READ_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT, ONLY_CLOSE_CURSORS_AT_COMMIT); - return createStatement(); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetType == ResultSet.TYPE_FORWARD_ONLY, ONLY_RS_FORWARD_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetConcurrency == ResultSet.CONCUR_READ_ONLY, ONLY_CONCUR_READ_ONLY); - return prepareStatement(sql); - } - - @Override - public PreparedStatement prepareStatement( - String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) - throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetType == ResultSet.TYPE_FORWARD_ONLY, ONLY_RS_FORWARD_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetConcurrency == ResultSet.CONCUR_READ_ONLY, ONLY_CONCUR_READ_ONLY); - JdbcPreconditions.checkSqlFeatureSupported( - resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT, ONLY_CLOSE_CURSORS_AT_COMMIT); - return prepareStatement(sql); - } - - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - autoGeneratedKeys == Statement.NO_GENERATED_KEYS, ONLY_NO_GENERATED_KEYS); - return prepareStatement(sql); - } - - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - checkClosed(); - return prepareStatement(sql); - } - - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - checkClosed(); - return prepareStatement(sql); - } - - @Override - public Map> getTypeMap() throws SQLException { - checkClosed(); - return new HashMap<>(typeMap); - } - - @Override - public void setTypeMap(Map> map) throws SQLException { - checkClosed(); - this.typeMap = new HashMap<>(map); - } - - @Override - public boolean isValid(int timeout) throws SQLException { - JdbcPreconditions.checkArgument(timeout >= 0, "timeout must be >= 0"); - if (!isClosed()) { - try { - Statement statement = createStatement(); - statement.setQueryTimeout(timeout); - try (ResultSet rs = statement.executeQuery(IS_VALID_QUERY)) { - if (rs.next()) { - if (rs.getLong(1) == 1L) { - return true; - } - } - } - } catch (SQLException e) { - // ignore - } - } - return false; - } - - @Override - public Blob createBlob() throws SQLException { - checkClosed(); - return new JdbcBlob(); - } - - @Override - public Clob createClob() throws SQLException { - checkClosed(); - return new JdbcClob(); - } - - @Override - public NClob createNClob() throws SQLException { - checkClosed(); - return new JdbcClob(); - } - - @Override - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - checkClosed(); - return JdbcArray.createArray(typeName, elements); - } - - @Override - public void setCatalog(String catalog) throws SQLException { - // This method could be changed to allow the user to change to another database. - // For now we only support setting an empty string in order to support frameworks - // and applications that set this when no catalog has been specified in the connection - // URL. - checkClosed(); - JdbcPreconditions.checkArgument("".equals(catalog), "Only catalog \"\" is supported"); - } - - @Override - public String getCatalog() throws SQLException { - checkClosed(); - return getConnectionOptions().getDatabaseName(); - } - - @Override - public void setSchema(String schema) throws SQLException { - checkClosed(); - // Cloud Spanner does not support schemas, but does contain a pseudo 'empty string' schema that - // might be set by frameworks and applications that read the database metadata. - JdbcPreconditions.checkArgument("".equals(schema), "Only schema \"\" is supported"); - } - - @Override - public String getSchema() throws SQLException { - checkClosed(); - return ""; - } - - @Override - public Timestamp getCommitTimestamp() throws SQLException { - checkClosed(); - try { - return getSpannerConnection().getCommitTimestamp().toSqlTimestamp(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public Timestamp getReadTimestamp() throws SQLException { - checkClosed(); - try { - return getSpannerConnection().getReadTimestamp().toSqlTimestamp(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public boolean isRetryAbortsInternally() throws SQLException { - checkClosed(); - try { - return getSpannerConnection().isRetryAbortsInternally(); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void setRetryAbortsInternally(boolean retryAbortsInternally) throws SQLException { - checkClosed(); - try { - getSpannerConnection().setRetryAbortsInternally(retryAbortsInternally); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void write(Mutation mutation) throws SQLException { - checkClosed(); - try { - getSpannerConnection().write(mutation); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void write(Iterable mutations) throws SQLException { - checkClosed(); - try { - getSpannerConnection().write(mutations); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void bufferedWrite(Mutation mutation) throws SQLException { - checkClosed(); - try { - getSpannerConnection().bufferedWrite(mutation); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void bufferedWrite(Iterable mutations) throws SQLException { - checkClosed(); - try { - getSpannerConnection().bufferedWrite(mutations); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - } - - @Override - public void addTransactionRetryListener(TransactionRetryListener listener) throws SQLException { - checkClosed(); - getSpannerConnection().addTransactionRetryListener(listener); - } - - @Override - public boolean removeTransactionRetryListener(TransactionRetryListener listener) - throws SQLException { - checkClosed(); - return getSpannerConnection().removeTransactionRetryListener(listener); - } - - @Override - public Iterator getTransactionRetryListeners() throws SQLException { - checkClosed(); - return getSpannerConnection().getTransactionRetryListeners(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConstants.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConstants.java deleted file mode 100644 index a8cca8abc40..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcConstants.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import java.sql.ResultSet; -import java.sql.Statement; - -/** Constants for special values used by the Cloud Spanner JDBC driver. */ -public final class JdbcConstants { - /** - * Special value that is used to indicate that a statement returned a {@link ResultSet}. The - * method {@link Statement#getUpdateCount()} will return this value if the previous statement that - * was executed with {@link Statement#execute(String)} returned a {@link ResultSet}. - */ - public static final int STATEMENT_RESULT_SET = -1; - /** - * Special value that is used to indicate that a statement had no result. The method {@link - * Statement#getUpdateCount()} will return this value if the previous statement that was executed - * with {@link Statement#execute(String)} returned {@link ResultType#NO_RESULT}, such as DDL - * statements {@link ResultType}. - */ - public static final int STATEMENT_NO_RESULT = -2; - - /** No instantiation */ - private JdbcConstants() {} -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataSource.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataSource.java deleted file mode 100644 index 31a4ad44e75..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataSource.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.rpc.Code; -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.Properties; -import java.util.logging.Logger; -import javax.sql.DataSource; - -/** {@link DataSource} implementation for Google Cloud Spanner. */ -public class JdbcDataSource extends AbstractJdbcWrapper implements DataSource { - private String url; - private String credentials; - private Boolean autocommit; - private Boolean readonly; - private Boolean retryAbortsInternally; - - /** Make sure the JDBC driver class is loaded. */ - static { - try { - Class.forName("com.google.cloud.spanner.jdbc.JdbcDriver"); - } catch (ClassNotFoundException e) { - throw new IllegalStateException( - "JdbcDataSource failed to load com.google.cloud.spanner.jdbc.JdbcDriver", e); - } - } - - @Override - public PrintWriter getLogWriter() throws SQLException { - return null; - } - - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - // no-op - } - - @Override - public void setLoginTimeout(int seconds) throws SQLException { - // no-op - } - - @Override - public int getLoginTimeout() throws SQLException { - return 0; - } - - @Override - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw JdbcSqlExceptionFactory.unsupported("java.util.logging is not used"); - } - - @Override - public Connection getConnection() throws SQLException { - if (getUrl() == null) { - throw JdbcSqlExceptionFactory.of( - "There is no URL specified for this data source", Code.FAILED_PRECONDITION); - } - if (!JdbcDriver.getRegisteredDriver().acceptsURL(getUrl())) { - throw JdbcSqlExceptionFactory.of( - "The URL " + getUrl() + " is not valid for the data source " + getClass().getName(), - Code.FAILED_PRECONDITION); - } - return DriverManager.getConnection(getUrl(), createProperties()); - } - - @Override - public Connection getConnection(String username, String password) throws SQLException { - return getConnection(); - } - - private Properties createProperties() { - Properties props = new Properties(); - if (this.credentials != null) { - props.setProperty(ConnectionOptions.CREDENTIALS_PROPERTY_NAME, this.credentials); - } - if (this.autocommit != null) { - props.setProperty( - ConnectionOptions.AUTOCOMMIT_PROPERTY_NAME, String.valueOf(this.autocommit)); - } - if (this.readonly != null) { - props.setProperty(ConnectionOptions.READONLY_PROPERTY_NAME, String.valueOf(this.readonly)); - } - if (this.retryAbortsInternally != null) { - props.setProperty( - ConnectionOptions.RETRY_ABORTS_INTERNALLY_PROPERTY_NAME, - String.valueOf(this.retryAbortsInternally)); - } - return props; - } - - @Override - public boolean isClosed() throws SQLException { - return false; - } - - /** @return the JDBC URL to use for this {@link DataSource}. */ - public String getUrl() { - return url; - } - - /** @param url The JDBC URL to use for this {@link DataSource}. */ - public void setUrl(String url) { - this.url = url; - } - - /** - * @return the credentials URL to use for this {@link DataSource}. If a credentials URL is - * specified in both the connection URL and using this property, the value in the connection - * URL will be used. - */ - public String getCredentials() { - return credentials; - } - - /** - * @param credentials The credentials URL to use for this {@link DataSource}. If a credentials URL - * is specified in both the connection URL and using this property, the value in the - * connection URL will be used. - */ - public void setCredentials(String credentials) { - this.credentials = credentials; - } - - /** - * @return the initial autocommit setting to use for this {@link DataSource}. If autocommit is - * specified in both the connection URL and using this property, the value in the connection - * URL will be used. - */ - public Boolean getAutocommit() { - return autocommit; - } - - /** - * @param autocommit The initial autocommit setting to use for this {@link DataSource}. If - * autocommit is specified in both the connection URL and using this property, the value in - * the connection URL will be used. - */ - public void setAutocommit(Boolean autocommit) { - this.autocommit = autocommit; - } - - /** - * @return the initial readonly setting to use for this {@link DataSource}. If readonly is - * specified in both the connection URL and using this property, the value in the connection - * URL will be used. - */ - public Boolean getReadonly() { - return readonly; - } - - /** - * @param readonly The initial readonly setting to use for this {@link DataSource}. If readonly is - * specified in both the connection URL and using this property, the value in the connection - * URL will be used. - */ - public void setReadonly(Boolean readonly) { - this.readonly = readonly; - } - - /** - * @return the initial retryAbortsInternally setting to use for this {@link DataSource}. If - * retryAbortsInternally is specified in both the connection URL and using this property, the - * value in the connection URL will be used. - */ - public Boolean getRetryAbortsInternally() { - return retryAbortsInternally; - } - - /** - * @param retryAbortsInternally The initial retryAbortsInternally setting to use for this {@link - * DataSource}. If retryAbortsInternally is specified in both the connection URL and using - * this property, the value in the connection URL will be used. - */ - public void setRetryAbortsInternally(Boolean retryAbortsInternally) { - this.retryAbortsInternally = retryAbortsInternally; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataType.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataType.java deleted file mode 100644 index 1c984c74d49..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDataType.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.Code; -import java.sql.Date; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** Enum for mapping Cloud Spanner data types to Java classes and JDBC SQL {@link Types}. */ -enum JdbcDataType { - BOOL { - @Override - public int getSqlType() { - return Types.BOOLEAN; - } - - @Override - public Class getJavaClass() { - return Boolean.class; - } - - @Override - public Code getCode() { - return Code.BOOL; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return rs.getBooleanList(columnIndex); - } - - @Override - public Type getSpannerType() { - return Type.bool(); - } - }, - BYTES { - @Override - public int getSqlType() { - return Types.BINARY; - } - - @Override - public Class getJavaClass() { - return byte[].class; - } - - @Override - public Code getCode() { - return Code.BYTES; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return JdbcTypeConverter.toJavaByteArrays(rs.getBytesList(columnIndex)); - } - - @Override - public Type getSpannerType() { - return Type.bytes(); - } - }, - DATE { - @Override - public int getSqlType() { - return Types.DATE; - } - - @Override - public Class getJavaClass() { - return Date.class; - } - - @Override - public Code getCode() { - return Code.DATE; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return JdbcTypeConverter.toSqlDates(rs.getDateList(columnIndex)); - } - - @Override - public Type getSpannerType() { - return Type.date(); - } - }, - FLOAT64 { - private Set> classes = new HashSet>(Arrays.asList(Float.class, Double.class)); - - @Override - public int getSqlType() { - return Types.DOUBLE; - } - - @Override - public Class getJavaClass() { - return Double.class; - } - - @Override - public Set> getSupportedJavaClasses() { - return classes; - } - - @Override - public Code getCode() { - return Code.FLOAT64; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return rs.getDoubleList(columnIndex); - } - - @Override - public Type getSpannerType() { - return Type.float64(); - } - }, - INT64 { - private Set> classes = - new HashSet>(Arrays.asList(Byte.class, Integer.class, Long.class)); - - @Override - public int getSqlType() { - return Types.BIGINT; - } - - @Override - public Class getJavaClass() { - return Long.class; - } - - @Override - public Set> getSupportedJavaClasses() { - return classes; - } - - @Override - public Code getCode() { - return Code.INT64; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return rs.getLongList(columnIndex); - } - - @Override - public Type getSpannerType() { - return Type.int64(); - } - }, - STRING { - @Override - public int getSqlType() { - return Types.NVARCHAR; - } - - @Override - public Class getJavaClass() { - return String.class; - } - - @Override - public Code getCode() { - return Code.STRING; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return rs.getStringList(columnIndex); - } - - @Override - public Type getSpannerType() { - return Type.string(); - } - }, - TIMESTAMP { - @Override - public int getSqlType() { - return Types.TIMESTAMP; - } - - @Override - public Class getJavaClass() { - return Timestamp.class; - } - - @Override - public Code getCode() { - return Code.TIMESTAMP; - } - - @Override - public List getArrayElements(ResultSet rs, int columnIndex) { - return JdbcTypeConverter.toSqlTimestamps(rs.getTimestampList(columnIndex)); - } - - @Override - public Type getSpannerType() { - return Type.timestamp(); - } - }; - - public abstract int getSqlType(); - - public abstract Code getCode(); - - public abstract Type getSpannerType(); - - /** - * @param rs the result set to look up the elements - * @param columnIndex zero based column index - * @return The corresponding array elements of the type in the given result set - */ - public abstract List getArrayElements(ResultSet rs, int columnIndex); - - public String getTypeName() { - return name(); - } - - public abstract Class getJavaClass(); - - public Set> getSupportedJavaClasses() { - return Collections.singleton(getJavaClass()); - } - - public static JdbcDataType getType(Class clazz) { - for (JdbcDataType type : JdbcDataType.values()) { - if (type.getSupportedJavaClasses().contains(clazz)) return type; - } - return null; - } - - public static JdbcDataType getType(Code code) { - for (JdbcDataType type : JdbcDataType.values()) { - if (type.getCode() == code) return type; - } - return null; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java deleted file mode 100644 index a15ad721ee4..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java +++ /dev/null @@ -1,1542 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.auth.Credentials; -import com.google.auth.ServiceAccountSigner; -import com.google.auth.oauth2.UserCredentials; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.cloud.spanner.jdbc.ConnectionImpl.InternalMetadataQuery; -import com.google.common.annotations.VisibleForTesting; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Arrays; -import java.util.Collections; -import java.util.Scanner; - -/** {@link DatabaseMetaData} implementation for Cloud Spanner */ -class JdbcDatabaseMetaData extends AbstractJdbcWrapper implements DatabaseMetaData { - private static final int JDBC_MAJOR_VERSION = 4; - private static final int JDBC_MINOR_VERSION = 1; - private static final int DATABASE_MAJOR_VERSION = 1; - private static final int DATABASE_MINOR_VERSION = 0; - private static final String PRODUCT_NAME = "Google Cloud Spanner"; - - @VisibleForTesting - static String readSqlFromFile(String filename) { - InputStream in = JdbcDatabaseMetaData.class.getResourceAsStream(filename); - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - StringBuilder builder = new StringBuilder(); - try (Scanner scanner = new Scanner(reader)) { - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - builder.append(line).append("\n"); - } - scanner.close(); - } - return builder.toString(); - } - - private JdbcConnection connection; - - JdbcDatabaseMetaData(JdbcConnection connection) { - this.connection = connection; - } - - @Override - public boolean isClosed() { - return false; - } - - @Override - public boolean allProceduresAreCallable() throws SQLException { - return true; - } - - @Override - public boolean allTablesAreSelectable() throws SQLException { - return true; - } - - @Override - public String getURL() throws SQLException { - return connection.getConnectionUrl(); - } - - @Override - public String getUserName() throws SQLException { - Credentials credentials = connection.getConnectionOptions().getCredentials(); - if (credentials != null) { - if (credentials instanceof ServiceAccountSigner) { - return ((ServiceAccountSigner) credentials).getAccount(); - } else if (credentials instanceof UserCredentials) { - return ((UserCredentials) credentials).getClientId(); - } - } - return ""; - } - - @Override - public boolean isReadOnly() throws SQLException { - return false; - } - - @Override - public boolean nullsAreSortedHigh() throws SQLException { - return false; - } - - @Override - public boolean nullsAreSortedLow() throws SQLException { - return true; - } - - @Override - public boolean nullsAreSortedAtStart() throws SQLException { - return false; - } - - @Override - public boolean nullsAreSortedAtEnd() throws SQLException { - return false; - } - - @Override - public String getDatabaseProductName() throws SQLException { - return PRODUCT_NAME; - } - - @Override - public String getDatabaseProductVersion() throws SQLException { - return getDatabaseMajorVersion() + "." + getDatabaseMinorVersion(); - } - - @Override - public String getDriverName() throws SQLException { - return JdbcDriver.class.getName(); - } - - @Override - public String getDriverVersion() throws SQLException { - return getDriverMajorVersion() + "." + getDriverMinorVersion(); - } - - @Override - public int getDriverMajorVersion() { - return JdbcDriver.MAJOR_VERSION; - } - - @Override - public int getDriverMinorVersion() { - return JdbcDriver.MINOR_VERSION; - } - - @Override - public boolean usesLocalFiles() throws SQLException { - return false; - } - - @Override - public boolean usesLocalFilePerTable() throws SQLException { - return false; - } - - @Override - public boolean supportsMixedCaseIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesUpperCaseIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesLowerCaseIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesMixedCaseIdentifiers() throws SQLException { - return true; - } - - @Override - public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { - return false; - } - - @Override - public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { - return true; - } - - @Override - public String getIdentifierQuoteString() throws SQLException { - return "`"; - } - - @Override - public String getSQLKeywords() throws SQLException { - return "ASSERT_ROWS_MODIFIED,ENUM,GROUPS,HASH,IGNORE,LOOKUP,PROTO,RESPECT,STRUCT,WINDOW"; - } - - @Override - public String getNumericFunctions() throws SQLException { - return "ABS,SIGN,IS_INF,IS_NAN,IEEE_DIVIDE,SQRT,POW,POWER,EXP,LN,LOG,LOG10,GREATEST,LEAST,DIV,MOD,ROUND,TRUNC,CEIL,CEILING,FLOOR,COS,COSH,ACOS,ACOSH,SIN,SINH,ASIN,ASINH,TAN,TANH,ATAN,ATANH,ATAN2,FARM_FINGERPRINT,SHA1,SHA256,SHA512"; - } - - @Override - public String getStringFunctions() throws SQLException { - return "BYTE_LENGTH,CHAR_LENGTH,CHARACTER_LENGTH,CODE_POINTS_TO_BYTES,CODE_POINTS_TO_STRING,CONCAT,ENDS_WITH,FORMAT,FROM_BASE64,FROM_HEX,LENGTH,LPAD,LOWER,LTRIM,REGEXP_CONTAINS,REGEXP_EXTRACT,REGEXP_EXTRACT_ALL,REGEXP_REPLACE,REPLACE,REPEAT,REVERSE,RPAD,RTRIM,SAFE_CONVERT_BYTES_TO_STRING,SPLIT,STARTS_WITH,STRPOS,SUBSTR,TO_BASE64,TO_CODE_POINTS,TO_HEX,TRIM,UPPER,JSON_QUERY,JSON_VALUE"; - } - - @Override - public String getSystemFunctions() throws SQLException { - return ""; - } - - @Override - public String getTimeDateFunctions() throws SQLException { - return "CURRENT_DATE,EXTRACT,DATE,DATE_ADD,DATE_SUB,DATE_DIFF,DATE_TRUNC,DATE_FROM_UNIX_DATE,FORMAT_DATE,PARSE_DATE,UNIX_DATE,CURRENT_TIMESTAMP,STRING,TIMESTAMP,TIMESTAMP_ADD,TIMESTAMP_SUB,TIMESTAMP_DIFF,TIMESTAMP_TRUNC,FORMAT_TIMESTAMP,PARSE_TIMESTAMP,TIMESTAMP_SECONDS,TIMESTAMP_MILLIS,TIMESTAMP_MICROS,UNIX_SECONDS,UNIX_MILLIS,UNIX_MICROS"; - } - - @Override - public String getSearchStringEscape() throws SQLException { - return "\\"; - } - - @Override - public String getExtraNameCharacters() throws SQLException { - return ""; - } - - @Override - public boolean supportsAlterTableWithAddColumn() throws SQLException { - return true; - } - - @Override - public boolean supportsAlterTableWithDropColumn() throws SQLException { - return true; - } - - @Override - public boolean supportsColumnAliasing() throws SQLException { - return true; - } - - @Override - public boolean nullPlusNonNullIsNull() throws SQLException { - return true; - } - - @Override - public boolean supportsConvert() throws SQLException { - return false; - } - - @Override - public boolean supportsConvert(int fromType, int toType) throws SQLException { - return false; - } - - @Override - public boolean supportsTableCorrelationNames() throws SQLException { - return true; - } - - @Override - public boolean supportsDifferentTableCorrelationNames() throws SQLException { - return false; - } - - @Override - public boolean supportsExpressionsInOrderBy() throws SQLException { - return true; - } - - @Override - public boolean supportsOrderByUnrelated() throws SQLException { - return true; - } - - @Override - public boolean supportsGroupBy() throws SQLException { - return true; - } - - @Override - public boolean supportsGroupByUnrelated() throws SQLException { - return true; - } - - @Override - public boolean supportsGroupByBeyondSelect() throws SQLException { - return true; - } - - @Override - public boolean supportsLikeEscapeClause() throws SQLException { - return true; - } - - @Override - public boolean supportsMultipleResultSets() throws SQLException { - return true; - } - - @Override - public boolean supportsMultipleTransactions() throws SQLException { - return true; - } - - @Override - public boolean supportsNonNullableColumns() throws SQLException { - return true; - } - - @Override - public boolean supportsMinimumSQLGrammar() throws SQLException { - return false; - } - - @Override - public boolean supportsCoreSQLGrammar() throws SQLException { - return false; - } - - @Override - public boolean supportsExtendedSQLGrammar() throws SQLException { - return false; - } - - @Override - public boolean supportsANSI92EntryLevelSQL() throws SQLException { - return false; - } - - @Override - public boolean supportsANSI92IntermediateSQL() throws SQLException { - return false; - } - - @Override - public boolean supportsANSI92FullSQL() throws SQLException { - return false; - } - - @Override - public boolean supportsIntegrityEnhancementFacility() throws SQLException { - return false; - } - - @Override - public boolean supportsOuterJoins() throws SQLException { - return true; - } - - @Override - public boolean supportsFullOuterJoins() throws SQLException { - return true; - } - - @Override - public boolean supportsLimitedOuterJoins() throws SQLException { - return true; - } - - @Override - public String getSchemaTerm() throws SQLException { - return "SCHEMA"; - } - - @Override - public String getProcedureTerm() throws SQLException { - return "PROCEDURE"; - } - - @Override - public String getCatalogTerm() throws SQLException { - // Spanner does not support catalogs, but the term is included for compatibility with the SQL - // standard - return "CATALOG"; - } - - @Override - public boolean isCatalogAtStart() throws SQLException { - return false; - } - - @Override - public String getCatalogSeparator() throws SQLException { - return "."; - } - - @Override - public boolean supportsSchemasInDataManipulation() throws SQLException { - return false; - } - - @Override - public boolean supportsSchemasInProcedureCalls() throws SQLException { - return false; - } - - @Override - public boolean supportsSchemasInTableDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsSchemasInIndexDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsCatalogsInDataManipulation() throws SQLException { - return false; - } - - @Override - public boolean supportsCatalogsInProcedureCalls() throws SQLException { - return false; - } - - @Override - public boolean supportsCatalogsInTableDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsCatalogsInIndexDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { - return false; - } - - @Override - public boolean supportsPositionedDelete() throws SQLException { - return false; - } - - @Override - public boolean supportsPositionedUpdate() throws SQLException { - return false; - } - - @Override - public boolean supportsSelectForUpdate() throws SQLException { - return false; - } - - @Override - public boolean supportsStoredProcedures() throws SQLException { - return false; - } - - @Override - public boolean supportsSubqueriesInComparisons() throws SQLException { - return true; - } - - @Override - public boolean supportsSubqueriesInExists() throws SQLException { - return true; - } - - @Override - public boolean supportsSubqueriesInIns() throws SQLException { - return true; - } - - @Override - public boolean supportsSubqueriesInQuantifieds() throws SQLException { - return true; - } - - @Override - public boolean supportsCorrelatedSubqueries() throws SQLException { - return true; - } - - @Override - public boolean supportsUnion() throws SQLException { - // Note that Cloud Spanner requires the user to specify 'UNION DISTINCT' or 'UNION ALL' in a - // query. 'UNION DISTINCT' is equal to the SQL operation 'UNION'. - return true; - } - - @Override - public boolean supportsUnionAll() throws SQLException { - return true; - } - - @Override - public boolean supportsOpenCursorsAcrossCommit() throws SQLException { - return false; - } - - @Override - public boolean supportsOpenCursorsAcrossRollback() throws SQLException { - return false; - } - - @Override - public boolean supportsOpenStatementsAcrossCommit() throws SQLException { - return true; - } - - @Override - public boolean supportsOpenStatementsAcrossRollback() throws SQLException { - return true; - } - - @Override - public int getMaxBinaryLiteralLength() throws SQLException { - return 0; - } - - @Override - public int getMaxCharLiteralLength() throws SQLException { - return 0; - } - - @Override - public int getMaxColumnNameLength() throws SQLException { - return 128; - } - - @Override - public int getMaxColumnsInGroupBy() throws SQLException { - return 1000; - } - - @Override - public int getMaxColumnsInIndex() throws SQLException { - return 16; - } - - @Override - public int getMaxColumnsInOrderBy() throws SQLException { - return 0; - } - - @Override - public int getMaxColumnsInSelect() throws SQLException { - return 0; - } - - @Override - public int getMaxColumnsInTable() throws SQLException { - return 1024; - } - - @Override - public int getMaxConnections() throws SQLException { - // there is a max number of sessions, but that is not the same as the max number of connections - return 0; - } - - @Override - public int getMaxCursorNameLength() throws SQLException { - return 0; - } - - @Override - public int getMaxIndexLength() throws SQLException { - return 8000; - } - - @Override - public int getMaxSchemaNameLength() throws SQLException { - return 0; - } - - @Override - public int getMaxProcedureNameLength() throws SQLException { - return 0; - } - - @Override - public int getMaxCatalogNameLength() throws SQLException { - return 0; - } - - @Override - public int getMaxRowSize() throws SQLException { - return 1024 * 10000000; - } - - @Override - public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { - return true; - } - - @Override - public int getMaxStatementLength() throws SQLException { - return 1000000; - } - - @Override - public int getMaxStatements() throws SQLException { - return 0; - } - - @Override - public int getMaxTableNameLength() throws SQLException { - return 128; - } - - @Override - public int getMaxTablesInSelect() throws SQLException { - return 0; - } - - @Override - public int getMaxUserNameLength() throws SQLException { - return 0; - } - - @Override - public int getDefaultTransactionIsolation() throws SQLException { - return Connection.TRANSACTION_SERIALIZABLE; - } - - @Override - public boolean supportsTransactions() throws SQLException { - return true; - } - - @Override - public boolean supportsTransactionIsolationLevel(int level) throws SQLException { - return Connection.TRANSACTION_SERIALIZABLE == level; - } - - @Override - public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { - return false; - } - - @Override - public boolean supportsDataManipulationTransactionsOnly() throws SQLException { - return true; - } - - @Override - public boolean dataDefinitionCausesTransactionCommit() throws SQLException { - return false; - } - - @Override - public boolean dataDefinitionIgnoredInTransactions() throws SQLException { - return false; - } - - @Override - public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("PROCEDURE_CAT", Type.string()), - StructField.of("PROCEDURE_SCHEM", Type.string()), - StructField.of("PROCEDURE_NAME", Type.string()), - StructField.of("reserved1", Type.string()), - StructField.of("reserved2", Type.string()), - StructField.of("reserved3", Type.string()), - StructField.of("REMARKS", Type.string()), - StructField.of("PROCEDURE_TYPE", Type.int64()), - StructField.of("SPECIFIC_NAME", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getProcedureColumns( - String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("PROCEDURE_CAT", Type.string()), - StructField.of("PROCEDURE_SCHEM", Type.string()), - StructField.of("PROCEDURE_NAME", Type.string()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("COLUMN_TYPE", Type.int64()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("PRECISION", Type.string()), - StructField.of("LENGTH", Type.int64()), - StructField.of("SCALE", Type.int64()), - StructField.of("RADIX", Type.int64()), - StructField.of("NULLABLE", Type.int64()), - StructField.of("REMARKS", Type.string()), - StructField.of("COLUMN_DEF", Type.string()), - StructField.of("SQL_DATA_TYPE", Type.int64()), - StructField.of("SQL_DATETIME_SUB", Type.int64()), - StructField.of("CHAR_OCTET_LENGTH", Type.int64()), - StructField.of("ORDINAL_POSITION", Type.int64()), - StructField.of("IS_NULLABLE", Type.string()), - StructField.of("SPECIFIC_NAME", Type.string())), - Collections.emptyList())); - } - - private JdbcPreparedStatement prepareStatementReplaceNullWithAnyString( - String sql, String... params) throws SQLException { - JdbcPreparedStatement statement = connection.prepareStatement(sql); - int paramIndex = 1; - for (String param : params) { - if (param == null) { - statement.setString(paramIndex, "%"); - } else { - statement.setString(paramIndex, param.toUpperCase()); - } - paramIndex++; - } - return statement; - } - - @Override - public ResultSet getTables( - String catalog, String schemaPattern, String tableNamePattern, String[] types) - throws SQLException { - String sql = readSqlFromFile("DatabaseMetaData_GetTables.sql"); - String type1; - String type2; - if (types == null || types.length == 0) { - type1 = "TABLE"; - type2 = "VIEW"; - } else if (types.length == 1) { - type1 = types[0]; - type2 = "NON_EXISTENT_TYPE"; - } else { - type1 = types[0]; - type2 = types[1]; - } - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString( - sql, catalog, schemaPattern, tableNamePattern, type1, type2); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getSchemas() throws SQLException { - return getSchemas(null, null); - } - - @Override - public ResultSet getCatalogs() throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct(StructField.of("TABLE_CAT", Type.string())), - Arrays.asList(Struct.newBuilder().set("TABLE_CAT").to("").build()))); - } - - @Override - public ResultSet getTableTypes() throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct(StructField.of("TABLE_TYPE", Type.string())), - Arrays.asList( - Struct.newBuilder().set("TABLE_TYPE").to("TABLE").build(), - Struct.newBuilder().set("TABLE_TYPE").to("VIEW").build()))); - } - - @Override - public ResultSet getColumns( - String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) - throws SQLException { - String sql = readSqlFromFile("DatabaseMetaData_GetColumns.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString( - sql, catalog, schemaPattern, tableNamePattern, columnNamePattern); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getColumnPrivileges( - String catalog, String schema, String table, String columnNamePattern) throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TABLE_CAT", Type.string()), - StructField.of("TABLE_SCHEM", Type.string()), - StructField.of("TABLE_NAME", Type.string()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("GRANTOR", Type.string()), - StructField.of("GRANTEE", Type.string()), - StructField.of("PRIVILEGE", Type.string()), - StructField.of("IS_GRANTABLE", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TABLE_CAT", Type.string()), - StructField.of("TABLE_SCHEM", Type.string()), - StructField.of("TABLE_NAME", Type.string()), - StructField.of("GRANTOR", Type.string()), - StructField.of("GRANTEE", Type.string()), - StructField.of("PRIVILEGE", Type.string()), - StructField.of("IS_GRANTABLE", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getBestRowIdentifier( - String catalog, String schema, String table, int scope, boolean nullable) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("SCOPE", Type.int64()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("COLUMN_SIZE", Type.int64()), - StructField.of("BUFFER_LENGTH", Type.int64()), - StructField.of("DECIMAL_DIGITS", Type.int64()), - StructField.of("PSEUDO_COLUMN", Type.int64())), - Collections.emptyList())); - } - - @Override - public ResultSet getVersionColumns(String catalog, String schema, String table) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("SCOPE", Type.int64()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("COLUMN_SIZE", Type.int64()), - StructField.of("BUFFER_LENGTH", Type.int64()), - StructField.of("DECIMAL_DIGITS", Type.int64()), - StructField.of("PSEUDO_COLUMN", Type.int64())), - Collections.emptyList())); - } - - @Override - public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { - JdbcPreconditions.checkArgument(table != null, "table may not be null"); - String sql = readSqlFromFile("DatabaseMetaData_GetPrimaryKeys.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString(sql, catalog, schema, table); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getImportedKeys(String catalog, String schema, String table) - throws SQLException { - JdbcPreconditions.checkArgument(table != null, "table may not be null"); - String sql = readSqlFromFile("DatabaseMetaData_GetImportedKeys.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString(sql, catalog, schema, table); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getExportedKeys(String catalog, String schema, String table) - throws SQLException { - JdbcPreconditions.checkArgument(table != null, "table may not be null"); - String sql = readSqlFromFile("DatabaseMetaData_GetExportedKeys.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString(sql, catalog, schema, table); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getCrossReference( - String parentCatalog, - String parentSchema, - String parentTable, - String foreignCatalog, - String foreignSchema, - String foreignTable) - throws SQLException { - String sql = readSqlFromFile("DatabaseMetaData_GetCrossReferences.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString( - sql, - parentCatalog, - parentSchema, - parentTable, - foreignCatalog, - foreignSchema, - foreignTable); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public ResultSet getTypeInfo() throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TYPE_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("PRECISION", Type.int64()), - StructField.of("LITERAL_PREFIX", Type.string()), - StructField.of("LITERAL_SUFFIX", Type.string()), - StructField.of("CREATE_PARAMS", Type.string()), - StructField.of("NULLABLE", Type.int64()), - StructField.of("CASE_SENSITIVE", Type.bool()), - StructField.of("SEARCHABLE", Type.int64()), - StructField.of("UNSIGNED_ATTRIBUTE", Type.bool()), - StructField.of("FIXED_PREC_SCALE", Type.bool()), - StructField.of("AUTO_INCREMENT", Type.bool()), - StructField.of("LOCAL_TYPE_NAME", Type.string()), - StructField.of("MINIMUM_SCALE", Type.int64()), - StructField.of("MAXIMUM_SCALE", Type.int64()), - StructField.of("SQL_DATA_TYPE", Type.int64()), - StructField.of("SQL_DATETIME_SUB", Type.int64()), - StructField.of("NUM_PREC_RADIX", Type.int64())), - Arrays.asList( - Struct.newBuilder() - .set("TYPE_NAME") - .to("STRING") - .set("DATA_TYPE") - .to(Types.NVARCHAR) // -9 - .set("PRECISION") - .to(2621440L) - .set("LITERAL_PREFIX") - .to((String) null) - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to("(length)") - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(true) - .set("SEARCHABLE") - .to(DatabaseMetaData.typeSearchable) - .set("UNSIGNED_ATTRIBUTE") - .to(true) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("STRING") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to((Long) null) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("INT64") - .set("DATA_TYPE") - .to(Types.BIGINT) // -5 - .set("PRECISION") - .to(19L) - .set("LITERAL_PREFIX") - .to((String) null) - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to((String) null) - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(false) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("INT64") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to(10) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("BYTES") - .set("DATA_TYPE") - .to(Types.BINARY) // -2 - .set("PRECISION") - .to(10485760L) - .set("LITERAL_PREFIX") - .to((String) null) - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to("(length)") - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(true) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("BYTES") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to((Long) null) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("FLOAT64") - .set("DATA_TYPE") - .to(Types.DOUBLE) // 8 - .set("PRECISION") - .to(15L) - .set("LITERAL_PREFIX") - .to((String) null) - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to((String) null) - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(false) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("FLOAT64") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to(2) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("BOOL") - .set("DATA_TYPE") - .to(Types.BOOLEAN) // 16 - .set("PRECISION") - .to((Long) null) - .set("LITERAL_PREFIX") - .to((String) null) - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to((String) null) - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(true) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("BOOL") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to((Long) null) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("DATE") - .set("DATA_TYPE") - .to(Types.DATE) // 91 - .set("PRECISION") - .to(10L) - .set("LITERAL_PREFIX") - .to("DATE ") - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to((String) null) - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(true) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("DATE") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to((Long) null) - .build(), - Struct.newBuilder() - .set("TYPE_NAME") - .to("TIMESTAMP") - .set("DATA_TYPE") - .to(Types.TIMESTAMP) // 93 - .set("PRECISION") - .to(35L) - .set("LITERAL_PREFIX") - .to("TIMESTAMP ") - .set("LITERAL_SUFFIX") - .to((String) null) - .set("CREATE_PARAMS") - .to((String) null) - .set("NULLABLE") - .to(DatabaseMetaData.typeNullable) - .set("CASE_SENSITIVE") - .to(false) - .set("SEARCHABLE") - .to(DatabaseMetaData.typePredBasic) - .set("UNSIGNED_ATTRIBUTE") - .to(true) - .set("FIXED_PREC_SCALE") - .to(false) - .set("AUTO_INCREMENT") - .to(false) - .set("LOCAL_TYPE_NAME") - .to("TIMESTAMP") - .set("MINIMUM_SCALE") - .to(0) - .set("MAXIMUM_SCALE") - .to(0) - .set("SQL_DATA_TYPE") - .to((Long) null) - .set("SQL_DATETIME_SUB") - .to((Long) null) - .set("NUM_PREC_RADIX") - .to((Long) null) - .build()))); - } - - @Override - public ResultSet getIndexInfo( - String catalog, String schema, String table, boolean unique, boolean approximate) - throws SQLException { - return getIndexInfo(catalog, schema, table, null, unique); - } - - public ResultSet getIndexInfo(String catalog, String schema, String indexName) - throws SQLException { - return getIndexInfo(catalog, schema, null, indexName, false); - } - - private ResultSet getIndexInfo( - String catalog, String schema, String table, String indexName, boolean unique) - throws SQLException { - String sql = readSqlFromFile("DatabaseMetaData_GetIndexInfo.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString( - sql, catalog, schema, table, indexName, unique ? "YES" : "%"); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public boolean supportsResultSetType(int type) throws SQLException { - return type == ResultSet.TYPE_FORWARD_ONLY; - } - - @Override - public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { - return type == ResultSet.TYPE_FORWARD_ONLY && concurrency == ResultSet.CONCUR_READ_ONLY; - } - - @Override - public boolean ownUpdatesAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean ownDeletesAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean ownInsertsAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean othersUpdatesAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean othersDeletesAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean othersInsertsAreVisible(int type) throws SQLException { - return false; - } - - @Override - public boolean updatesAreDetected(int type) throws SQLException { - return false; - } - - @Override - public boolean deletesAreDetected(int type) throws SQLException { - return false; - } - - @Override - public boolean insertsAreDetected(int type) throws SQLException { - return false; - } - - @Override - public boolean supportsBatchUpdates() throws SQLException { - return true; - } - - @Override - public ResultSet getUDTs( - String catalog, String schemaPattern, String typeNamePattern, int[] types) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TYPE_CAT", Type.string()), - StructField.of("TYPE_SCHEM", Type.string()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("CLASS_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("REMARKS", Type.string()), - StructField.of("BASE_TYPE", Type.int64())), - Collections.emptyList())); - } - - @Override - public Connection getConnection() throws SQLException { - return connection; - } - - @Override - public boolean supportsSavepoints() throws SQLException { - return false; - } - - @Override - public boolean supportsNamedParameters() throws SQLException { - return false; - } - - @Override - public boolean supportsMultipleOpenResults() throws SQLException { - return true; - } - - @Override - public boolean supportsGetGeneratedKeys() throws SQLException { - return false; - } - - @Override - public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TYPE_CAT", Type.string()), - StructField.of("TYPE_SCHEM", Type.string()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("SUPERTYPE_CAT", Type.string()), - StructField.of("SUPERTYPE_SCHEM", Type.string()), - StructField.of("SUPERTYPE_NAME", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TABLE_CAT", Type.string()), - StructField.of("TABLE_SCHEM", Type.string()), - StructField.of("TABLE_NAME", Type.string()), - StructField.of("SUPERTABLE_NAME", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getAttributes( - String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TYPE_CAT", Type.string()), - StructField.of("TYPE_SCHEM", Type.string()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("ATTR_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("ATTR_TYPE_NAME", Type.string()), - StructField.of("ATTR_SIZE", Type.int64()), - StructField.of("DECIMAL_DIGITS", Type.int64()), - StructField.of("NUM_PREC_RADIX", Type.int64()), - StructField.of("NULLABLE", Type.int64()), - StructField.of("REMARKS", Type.string()), - StructField.of("ATTR_DEF", Type.string()), - StructField.of("SQL_DATA_TYPE", Type.int64()), - StructField.of("SQL_DATETIME_SUB", Type.int64()), - StructField.of("CHAR_OCTET_LENGTH", Type.int64()), - StructField.of("ORDINAL_POSITION", Type.int64()), - StructField.of("IS_NULLABLE", Type.string()), - StructField.of("SCOPE_CATALOG", Type.string()), - StructField.of("SCOPE_SCHEMA", Type.string()), - StructField.of("SCOPE_TABLE", Type.string()), - StructField.of("SOURCE_DATA_TYPE", Type.int64())), - Collections.emptyList())); - } - - @Override - public boolean supportsResultSetHoldability(int holdability) throws SQLException { - return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT; - } - - @Override - public int getResultSetHoldability() throws SQLException { - return ResultSet.CLOSE_CURSORS_AT_COMMIT; - } - - @Override - public int getDatabaseMajorVersion() throws SQLException { - return DATABASE_MAJOR_VERSION; - } - - @Override - public int getDatabaseMinorVersion() throws SQLException { - return DATABASE_MINOR_VERSION; - } - - @Override - public int getJDBCMajorVersion() throws SQLException { - return JDBC_MAJOR_VERSION; - } - - @Override - public int getJDBCMinorVersion() throws SQLException { - return JDBC_MINOR_VERSION; - } - - @Override - public int getSQLStateType() throws SQLException { - return sqlStateSQL; - } - - @Override - public boolean locatorsUpdateCopy() throws SQLException { - return true; - } - - @Override - public boolean supportsStatementPooling() throws SQLException { - return false; - } - - @Override - public RowIdLifetime getRowIdLifetime() throws SQLException { - return RowIdLifetime.ROWID_UNSUPPORTED; - } - - @Override - public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { - String sql = readSqlFromFile("DatabaseMetaData_GetSchemas.sql"); - JdbcPreparedStatement statement = - prepareStatementReplaceNullWithAnyString(sql, catalog, schemaPattern); - return statement.executeQueryWithOptions(InternalMetadataQuery.INSTANCE); - } - - @Override - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { - return false; - } - - @Override - public boolean autoCommitFailureClosesAllResultSets() throws SQLException { - return false; - } - - @Override - public ResultSet getClientInfoProperties() throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("NAME", Type.string()), - StructField.of("MAX_LEN", Type.string()), - StructField.of("DEFAULT_VALUE", Type.string()), - StructField.of("DESCRIPTION", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) - throws SQLException { - // TODO: return system functions - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("FUNCTION_CAT", Type.string()), - StructField.of("FUNCTION_SCHEM", Type.string()), - StructField.of("FUNCTION_NAME", Type.string()), - StructField.of("REMARKS", Type.string()), - StructField.of("FUNCTION_TYPE", Type.int64()), - StructField.of("SPECIFIC_NAME", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getFunctionColumns( - String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) - throws SQLException { - // TODO: return system functions - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("FUNCTION_CAT", Type.string()), - StructField.of("FUNCTION_SCHEM", Type.string()), - StructField.of("FUNCTION_NAME", Type.string()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("COLUMN_TYPE", Type.int64()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("TYPE_NAME", Type.string()), - StructField.of("PRECISION", Type.int64()), - StructField.of("LENGTH", Type.int64()), - StructField.of("SCALE", Type.int64()), - StructField.of("RADIX", Type.int64()), - StructField.of("NULLABLE", Type.int64()), - StructField.of("REMARKS", Type.string()), - StructField.of("CHAR_OCTET_LENGTH", Type.int64()), - StructField.of("ORDINAL_POSITION", Type.int64()), - StructField.of("IS_NULLABLE", Type.string()), - StructField.of("SPECIFIC_NAME", Type.string())), - Collections.emptyList())); - } - - @Override - public ResultSet getPseudoColumns( - String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) - throws SQLException { - return JdbcResultSet.of( - ResultSets.forRows( - Type.struct( - StructField.of("TABLE_CAT", Type.string()), - StructField.of("TABLE_SCHEM", Type.string()), - StructField.of("TABLE_NAME", Type.string()), - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("DATA_TYPE", Type.int64()), - StructField.of("COLUMN_SIZE", Type.int64()), - StructField.of("DECIMAL_DIGITS", Type.int64()), - StructField.of("NUM_PREC_RADIX", Type.int64()), - StructField.of("COLUMN_USAGE", Type.string()), - StructField.of("REMARKS", Type.string()), - StructField.of("CHAR_OCTET_LENGTH", Type.int64()), - StructField.of("IS_NULLABLE", Type.string())), - Collections.emptyList())); - } - - @Override - public boolean generatedKeyAlwaysReturned() throws SQLException { - return false; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDriver.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDriver.java deleted file mode 100644 index 80ee2cc6d14..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcDriver.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.core.InternalApi; -import com.google.auth.oauth2.GoogleCredentials; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.jdbc.ConnectionOptions.ConnectionProperty; -import com.google.rpc.Code; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.DriverManager; -import java.sql.DriverPropertyInfo; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * JDBC {@link Driver} for Google Cloud Spanner. - * - *

Usage: - * - *

- * 
- * {@code
- * String url = "jdbc:cloudspanner:/projects/my_project_id/"
- *            + "instances/my_instance_id/databases/my_database_name?"
- *            + "credentials=/home/cloudspanner-keys/my-key.json;autocommit=false";
- * try (Connection connection = DriverManager.getConnection(url)) {
- *   try(ResultSet rs = connection.createStatement().executeQuery("SELECT SingerId, AlbumId, MarketingBudget FROM Albums")) {
- *     while(rs.next()) {
- *       // do something
- *     }
- *   }
- * }
- * }
- * 
- * 
- * - * The connection that is returned will implement the interface {@link CloudSpannerJdbcConnection}. - * The JDBC connection URL must be specified in the following format: - * - *
- * jdbc:cloudspanner:[//host[:port]]/projects/project-id[/instances/instance-id[/databases/database-name]][\?property-name=property-value[;property-name=property-value]*]?
- * 
- * - * The property-value strings should be url-encoded. - * - *

The project-id part of the URI may be filled with the placeholder DEFAULT_PROJECT_ID. This - * placeholder will be replaced by the default project id of the environment that is requesting a - * connection. - * - *

The supported properties are: - * - *

    - *
  • credentials (String): URL for the credentials file to use for the connection. If you do not - * specify any credentials at all, the default credentials of the environment as returned by - * {@link GoogleCredentials#getApplicationDefault()} will be used. - *
  • autocommit (boolean): Sets the initial autocommit mode for the connection. Default is true. - *
  • readonly (boolean): Sets the initial readonly mode for the connection. Default is false. - *
  • retryAbortsInternally (boolean): Sets the initial retryAbortsInternally mode for the - * connection. Default is true. @see {@link - * com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection#setRetryAbortsInternally(boolean)} - * for more information. - *
- */ -public class JdbcDriver implements Driver { - private static final String JDBC_API_CLIENT_LIB_TOKEN = "sp-jdbc"; - static final int MAJOR_VERSION = 1; - static final int MINOR_VERSION = 0; - private static final String JDBC_URL_FORMAT = - "jdbc:" + ConnectionOptions.Builder.SPANNER_URI_FORMAT; - private static final Pattern URL_PATTERN = Pattern.compile(JDBC_URL_FORMAT); - - @InternalApi - public static String getClientLibToken() { - return JDBC_API_CLIENT_LIB_TOKEN; - } - - static { - try { - register(); - } catch (SQLException e) { - java.sql.DriverManager.println("Registering driver failed: " + e.getMessage()); - } - } - - private static JdbcDriver registeredDriver; - - static void register() throws SQLException { - if (isRegistered()) { - throw new IllegalStateException( - "Driver is already registered. It can only be registered once."); - } - JdbcDriver registeredDriver = new JdbcDriver(); - DriverManager.registerDriver(registeredDriver); - JdbcDriver.registeredDriver = registeredDriver; - } - - /** - * According to JDBC specification, this driver is registered against {@link DriverManager} when - * the class is loaded. To avoid leaks, this method allow unregistering the driver so that the - * class can be gc'ed if necessary. - * - * @throws IllegalStateException if the driver is not registered - * @throws SQLException if deregistering the driver fails - */ - static void deregister() throws SQLException { - if (!isRegistered()) { - throw new IllegalStateException( - "Driver is not registered (or it has not been registered using Driver.register() method)"); - } - ConnectionOptions.closeSpanner(); - DriverManager.deregisterDriver(registeredDriver); - registeredDriver = null; - } - - /** @return {@code true} if the driver is registered against {@link DriverManager} */ - static boolean isRegistered() { - return registeredDriver != null; - } - - /** - * @return the registered JDBC driver for Cloud Spanner. - * @throws SQLException if the driver has not been registered. - */ - static JdbcDriver getRegisteredDriver() throws SQLException { - if (isRegistered()) { - return registeredDriver; - } - throw JdbcSqlExceptionFactory.of( - "The driver has not been registered", Code.FAILED_PRECONDITION); - } - - public JdbcDriver() {} - - @Override - public Connection connect(String url, Properties info) throws SQLException { - if (url != null && url.startsWith("jdbc:cloudspanner")) { - try { - Matcher matcher = URL_PATTERN.matcher(url); - if (matcher.matches()) { - // strip 'jdbc:' from the URL, add any extra properties and pass on to the generic - // Connection API - String connectionUri = appendPropertiesToUrl(url.substring(5), info); - ConnectionOptions options = ConnectionOptions.newBuilder().setUri(connectionUri).build(); - return new JdbcConnection(url, options); - } - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } catch (IllegalArgumentException e) { - throw JdbcSqlExceptionFactory.of(e.getMessage(), Code.INVALID_ARGUMENT, e); - } catch (Exception e) { - throw JdbcSqlExceptionFactory.of(e.getMessage(), Code.UNKNOWN, e); - } - throw JdbcSqlExceptionFactory.of("invalid url: " + url, Code.INVALID_ARGUMENT); - } - return null; - } - - private String appendPropertiesToUrl(String url, Properties info) { - StringBuilder res = new StringBuilder(url); - for (Entry entry : info.entrySet()) { - if (entry.getValue() != null && !"".equals(entry.getValue())) { - res.append(";").append(entry.getKey()).append("=").append(entry.getValue()); - } - } - return res.toString(); - } - - @Override - public boolean acceptsURL(String url) throws SQLException { - return URL_PATTERN.matcher(url).matches(); - } - - @Override - public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { - String connectionUri = appendPropertiesToUrl(url.substring(5), info); - DriverPropertyInfo[] res = new DriverPropertyInfo[ConnectionOptions.VALID_PROPERTIES.size()]; - int i = 0; - for (ConnectionProperty prop : ConnectionOptions.VALID_PROPERTIES) { - res[i] = - new DriverPropertyInfo( - prop.getName(), - parseUriProperty(connectionUri, prop.getName(), prop.getDefaultValue())); - res[i].description = prop.getDescription(); - res[i].choices = prop.getValidValues(); - i++; - } - return res; - } - - private String parseUriProperty(String uri, String property, String defaultValue) { - Pattern pattern = Pattern.compile(String.format("(?is)(?:;|\\?)%s=(.*?)(?:;|$)", property)); - Matcher matcher = pattern.matcher(uri); - if (matcher.find() && matcher.groupCount() == 1) { - return matcher.group(1); - } - return defaultValue; - } - - @Override - public int getMajorVersion() { - return 1; - } - - @Override - public int getMinorVersion() { - return 0; - } - - @Override - public boolean jdbcCompliant() { - return false; - } - - @Override - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterMetaData.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterMetaData.java deleted file mode 100644 index f78f1f03dc6..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterMetaData.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.JdbcParameterStore.ParametersInfo; -import java.math.BigDecimal; -import java.sql.Date; -import java.sql.ParameterMetaData; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; - -/** {@link ParameterMetaData} implementation for Cloud Spanner */ -class JdbcParameterMetaData extends AbstractJdbcWrapper implements ParameterMetaData { - private final JdbcPreparedStatement statement; - - JdbcParameterMetaData(JdbcPreparedStatement statement) throws SQLException { - this.statement = statement; - statement.getParameters().fetchMetaData(statement.getConnection()); - } - - @Override - public boolean isClosed() { - return false; - } - - @Override - public int getParameterCount() throws SQLException { - ParametersInfo info = statement.getParametersInfo(); - return info.numberOfParameters; - } - - @Override - public int isNullable(int param) throws SQLException { - Integer nullable = statement.getParameters().getNullable(param); - return nullable == null ? parameterNullableUnknown : nullable.intValue(); - } - - @Override - public boolean isSigned(int param) throws SQLException { - int type = getParameterType(param); - return type == Types.DOUBLE - || type == Types.FLOAT - || type == Types.BIGINT - || type == Types.INTEGER - || type == Types.SMALLINT - || type == Types.TINYINT - || type == Types.DECIMAL - || type == Types.NUMERIC; - } - - @Override - public int getPrecision(int param) throws SQLException { - Integer length = statement.getParameters().getScaleOrLength(param); - return length == null ? 0 : length.intValue(); - } - - @Override - public int getScale(int param) throws SQLException { - return 0; - } - - @Override - public int getParameterType(int param) throws SQLException { - Integer type = statement.getParameters().getType(param); - if (type != null) return type.intValue(); - - Object value = statement.getParameters().getParameter(param); - if (value == null) { - return Types.OTHER; - } else if (Boolean.class.isAssignableFrom(value.getClass())) { - return Types.BOOLEAN; - } else if (Byte.class.isAssignableFrom(value.getClass())) { - return Types.TINYINT; - } else if (Short.class.isAssignableFrom(value.getClass())) { - return Types.SMALLINT; - } else if (Integer.class.isAssignableFrom(value.getClass())) { - return Types.INTEGER; - } else if (Long.class.isAssignableFrom(value.getClass())) { - return Types.BIGINT; - } else if (Float.class.isAssignableFrom(value.getClass())) { - return Types.FLOAT; - } else if (Double.class.isAssignableFrom(value.getClass())) { - return Types.DOUBLE; - } else if (BigDecimal.class.isAssignableFrom(value.getClass())) { - return Types.DECIMAL; - } else if (Date.class.isAssignableFrom(value.getClass())) { - return Types.DATE; - } else if (Timestamp.class.isAssignableFrom(value.getClass())) { - return Types.TIMESTAMP; - } else if (Time.class.isAssignableFrom(value.getClass())) { - return Types.TIME; - } else if (String.class.isAssignableFrom(value.getClass())) { - return Types.NVARCHAR; - } else if (byte[].class.isAssignableFrom(value.getClass())) { - return Types.BINARY; - } else { - return Types.OTHER; - } - } - - @Override - public String getParameterTypeName(int param) throws SQLException { - return getSpannerTypeName(getParameterType(param)); - } - - @Override - public String getParameterClassName(int param) throws SQLException { - Object value = statement.getParameters().getParameter(param); - if (value != null) return value.getClass().getName(); - Integer type = statement.getParameters().getType(param); - if (type != null) return getClassName(type.intValue()); - return null; - } - - @Override - public int getParameterMode(int param) throws SQLException { - return parameterModeIn; - } - - @Override - public String toString() { - StringBuilder res = new StringBuilder(); - try { - res.append("CloudSpannerPreparedStatementParameterMetaData, parameter count: ") - .append(getParameterCount()); - for (int param = 1; param <= getParameterCount(); param++) { - res.append("\nParameter ") - .append(param) - .append(":\n\t Class name: ") - .append(getParameterClassName(param)); - res.append(",\n\t Parameter type name: ").append(getParameterTypeName(param)); - res.append(",\n\t Parameter type: ").append(getParameterType(param)); - res.append(",\n\t Parameter precision: ").append(getPrecision(param)); - res.append(",\n\t Parameter scale: ").append(getScale(param)); - res.append(",\n\t Parameter signed: ").append(isSigned(param)); - res.append(",\n\t Parameter nullable: ").append(isNullable(param)); - res.append(",\n\t Parameter mode: ").append(getParameterMode(param)); - } - } catch (SQLException e) { - res.append("Error while fetching parameter metadata: ").append(e.getMessage()); - } - return res.toString(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterStore.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterStore.java deleted file mode 100644 index 5a139a9df0d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcParameterStore.java +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.ByteArray; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Statement.Builder; -import com.google.cloud.spanner.ValueBinder; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.common.io.CharStreams; -import com.google.rpc.Code; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.Date; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** This class handles the parameters of a {@link PreparedStatement}. */ -class JdbcParameterStore { - /** - * The initial size of the arrays that hold the parameter values. The array will automatically be - * extended when needed. - */ - private static final int INITIAL_PARAMETERS_ARRAY_SIZE = 10; - - private static final class JdbcParameter { - private Object value; - private Integer type; - private Integer nullable; - private Integer scaleOrLength; - private String column; - } - - private ArrayList parametersList = new ArrayList<>(INITIAL_PARAMETERS_ARRAY_SIZE); - - /** Name of the table that the parameters will be used to query/update. Can be null. */ - private String table; - - /** - * The highest parameter index in use. Parameter values do not need to be set in order, it could - * be that a parameter with for example index 10 is set first, and that the preceding parameters - * are set at a later time. - */ - private int highestIndex = 0; - - JdbcParameterStore() {} - - void clearParameters() { - parametersList = new ArrayList<>(INITIAL_PARAMETERS_ARRAY_SIZE); - highestIndex = 0; - table = null; - } - - /** Get parameter value. Index is 1-based. */ - Object getParameter(int parameterIndex) { - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) return null; - return parametersList.get(arrayIndex).value; - } - - /** Get parameter type code according to the values in {@link Types}. Index is 1-based. */ - Integer getType(int parameterIndex) { - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) return null; - return parametersList.get(arrayIndex).type; - } - - Integer getNullable(int parameterIndex) { - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) return null; - return parametersList.get(arrayIndex).nullable; - } - - Integer getScaleOrLength(int parameterIndex) { - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) return null; - return parametersList.get(arrayIndex).scaleOrLength; - } - - String getColumn(int parameterIndex) { - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) return null; - return parametersList.get(arrayIndex).column; - } - - String getTable() { - return table; - } - - void setTable(String table) { - this.table = table; - } - - void setColumn(int parameterIndex, String column) throws SQLException { - setParameter( - parameterIndex, - getParameter(parameterIndex), - getType(parameterIndex), - getScaleOrLength(parameterIndex), - column); - } - - void setType(int parameterIndex, Integer type) throws SQLException { - setParameter( - parameterIndex, - getParameter(parameterIndex), - type, - getScaleOrLength(parameterIndex), - getColumn(parameterIndex)); - } - - void setParameter(int parameterIndex, Object value, Integer sqlType) throws SQLException { - setParameter(parameterIndex, value, sqlType, null); - } - - void setParameter(int parameterIndex, Object value, Integer sqlType, Integer scaleOrLength) - throws SQLException { - setParameter(parameterIndex, value, sqlType, scaleOrLength, null); - } - - void setParameter( - int parameterIndex, Object value, Integer sqlType, Integer scaleOrLength, String column) - throws SQLException { - // check that only valid type/value combinations are entered - if (sqlType != null) { - checkTypeAndValueSupported(value, sqlType); - } - // set the parameter - highestIndex = Math.max(parameterIndex, highestIndex); - int arrayIndex = parameterIndex - 1; - if (arrayIndex >= parametersList.size() || parametersList.get(arrayIndex) == null) { - parametersList.ensureCapacity(parameterIndex); - while (parametersList.size() < parameterIndex) { - parametersList.add(null); - } - parametersList.set(arrayIndex, new JdbcParameter()); - } - JdbcParameter param = parametersList.get(arrayIndex); - param.value = value; - param.type = sqlType; - param.scaleOrLength = scaleOrLength; - param.column = column; - } - - private void checkTypeAndValueSupported(Object value, int sqlType) throws SQLException { - if (!isTypeSupported(sqlType)) { - throw JdbcSqlExceptionFactory.of( - "Type " + sqlType + " is not supported", Code.INVALID_ARGUMENT); - } - if (!isValidTypeAndValue(value, sqlType)) { - throw JdbcSqlExceptionFactory.of( - value + " is not a valid value for type " + sqlType, Code.INVALID_ARGUMENT); - } - } - - private boolean isTypeSupported(int sqlType) { - switch (sqlType) { - case Types.BIT: - case Types.BOOLEAN: - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - case Types.FLOAT: - case Types.REAL: - case Types.DOUBLE: - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NVARCHAR: - case Types.LONGNVARCHAR: - case Types.DATE: - case Types.TIME: - case Types.TIMESTAMP: - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - case Types.ARRAY: - case Types.BLOB: - case Types.CLOB: - case Types.NCLOB: - return true; - case Types.NUMERIC: - case Types.DECIMAL: - // currently not supported as Cloud Spanner does not have any decimal data type. - return false; - } - return false; - } - - private boolean isValidTypeAndValue(Object value, int sqlType) { - if (value == null) { - return true; - } - switch (sqlType) { - case Types.BIT: - case Types.BOOLEAN: - return value instanceof Boolean || value instanceof Number; - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - case Types.FLOAT: - case Types.REAL: - case Types.DOUBLE: - return value instanceof Number; - case Types.NUMERIC: - case Types.DECIMAL: - // currently not supported as Cloud Spanner does not have any decimal data type. - return false; - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NVARCHAR: - case Types.LONGNVARCHAR: - return value instanceof String - || value instanceof InputStream - || value instanceof Reader - || value instanceof URL; - case Types.DATE: - case Types.TIME: - case Types.TIMESTAMP: - return value instanceof Date || value instanceof Time || value instanceof Timestamp; - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - return value instanceof byte[] || value instanceof InputStream; - case Types.ARRAY: - return value instanceof Array; - case Types.BLOB: - return value instanceof Blob || value instanceof InputStream; - case Types.CLOB: - return value instanceof Clob || value instanceof Reader; - case Types.NCLOB: - return value instanceof NClob || value instanceof Reader; - } - return false; - } - - /** Return the highest param index in use in this store. */ - int getHighestIndex() { - return highestIndex; - } - - /** Fetch parameter metadata from the database. */ - void fetchMetaData(Connection connection) throws SQLException { - if (table != null && !"".equals(table)) { - try (ResultSet rsCols = connection.getMetaData().getColumns(null, null, table, null)) { - while (rsCols.next()) { - String col = rsCols.getString("COLUMN_NAME"); - int arrayIndex = getParameterArrayIndex(col); - if (arrayIndex > -1) { - JdbcParameter param = parametersList.get(arrayIndex); - if (param != null) { - param.scaleOrLength = rsCols.getInt("COLUMN_SIZE"); - param.type = rsCols.getInt("DATA_TYPE"); - param.nullable = rsCols.getInt("NULLABLE"); - } - } - } - } - } - } - - private int getParameterArrayIndex(String columnName) { - if (columnName != null) { - for (int index = 0; index < highestIndex; index++) { - JdbcParameter param = parametersList.get(index); - if (param != null && param.column != null) { - if (columnName.equalsIgnoreCase(param.column)) { - return index; - } - } - } - } - return -1; - } - - /** Parameter information with positional parameters translated to named parameters. */ - static class ParametersInfo { - final int numberOfParameters; - final String sqlWithNamedParameters; - - private ParametersInfo(int numberOfParameters, String sqlWithNamedParameters) { - this.numberOfParameters = numberOfParameters; - this.sqlWithNamedParameters = sqlWithNamedParameters; - } - } - - /** - * Converts all positional parameters (?) in the given sql string into named parameters. The - * parameters are named @p1, @p2, etc. This method is used when converting a JDBC statement that - * uses positional parameters to a Cloud Spanner {@link Statement} instance that requires named - * parameters. The input SQL string may not contain any comments. - * - * @param sql The sql string without comments that should be converted - * @return A {@link ParametersInfo} object containing a string with named parameters instead of - * positional parameters and the number of parameters. - * @throws JdbcSqlExceptionImpl If the input sql string contains an unclosed string/byte literal. - */ - static ParametersInfo convertPositionalParametersToNamedParameters(String sql) - throws SQLException { - final char POS_PARAM = '?'; - final char SINGLE_QUOTE = '\''; - final char DOUBLE_QUOTE = '"'; - final char BACKTICK_QUOTE = '`'; - boolean isInQuoted = false; - char startQuote = 0; - boolean lastCharWasEscapeChar = false; - boolean isTripleQuoted = false; - int paramIndex = 1; - StringBuilder named = new StringBuilder(sql.length() + countOccurrencesOf(POS_PARAM, sql)); - for (int index = 0; index < sql.length(); index++) { - char c = sql.charAt(index); - if (isInQuoted) { - if ((c == '\n' || c == '\r') && !isTripleQuoted) { - throw JdbcSqlExceptionFactory.of( - "SQL statement contains an unclosed literal: " + sql, Code.INVALID_ARGUMENT); - } else if (c == startQuote) { - if (lastCharWasEscapeChar) { - lastCharWasEscapeChar = false; - } else if (isTripleQuoted) { - if (sql.length() > index + 2 - && sql.charAt(index + 1) == startQuote - && sql.charAt(index + 2) == startQuote) { - isInQuoted = false; - startQuote = 0; - isTripleQuoted = false; - } - } else { - isInQuoted = false; - startQuote = 0; - } - } else if (c == '\\') { - lastCharWasEscapeChar = true; - } else { - lastCharWasEscapeChar = false; - } - named.append(c); - } else { - if (c == POS_PARAM) { - named.append("@p" + paramIndex); - paramIndex++; - } else { - if (c == SINGLE_QUOTE || c == DOUBLE_QUOTE || c == BACKTICK_QUOTE) { - isInQuoted = true; - startQuote = c; - // check whether it is a triple-quote - if (sql.length() > index + 2 - && sql.charAt(index + 1) == startQuote - && sql.charAt(index + 2) == startQuote) { - isTripleQuoted = true; - } - } - named.append(c); - } - } - } - if (isInQuoted) { - throw JdbcSqlExceptionFactory.of( - "SQL statement contains an unclosed literal: " + sql, Code.INVALID_ARGUMENT); - } - return new ParametersInfo(paramIndex - 1, named.toString()); - } - - /** Convenience method that is used to estimate the number of parameters in a SQL statement. */ - private static int countOccurrencesOf(char c, String string) { - int res = 0; - for (int i = 0; i < string.length(); i++) { - if (string.charAt(i) == c) { - res++; - } - } - return res; - } - - /** Bind a JDBC parameter to a parameter on a Spanner {@link Statement}. */ - Builder bindParameterValue(ValueBinder binder, int index) throws SQLException { - return setValue(binder, getParameter(index), getType(index)); - } - - /** Set a value from a JDBC parameter on a Spanner {@link Statement}. */ - Builder setValue(ValueBinder binder, Object value, Integer sqlType) throws SQLException { - Builder res; - if (sqlType != null && sqlType == Types.ARRAY) { - if (value instanceof Array) { - Array array = (Array) value; - value = array.getArray(); - sqlType = array.getBaseType(); - } - res = setArrayValue(binder, sqlType, value); - } else { - res = setSingleValue(binder, value, sqlType); - } - if (res == null && value != null) { - throw JdbcSqlExceptionFactory.of( - "Unsupported parameter type: " + value.getClass().getName() + " - " + value.toString(), - Code.INVALID_ARGUMENT); - } - return res; - } - - private Builder setSingleValue(ValueBinder binder, Object value, Integer sqlType) - throws SQLException { - if (value == null) { - return setNullValue(binder, sqlType); - } else if (sqlType == null || sqlType == Integer.valueOf(Types.OTHER)) { - return setParamWithUnknownType(binder, value); - } else { - return setParamWithKnownType(binder, value, sqlType); - } - } - - /** Set a JDBC parameter value on a Spanner {@link Statement} with a known SQL type. */ - private Builder setParamWithKnownType(ValueBinder binder, Object value, Integer sqlType) - throws SQLException { - switch (sqlType) { - case Types.BIT: - case Types.BOOLEAN: - if (value instanceof Boolean) { - return binder.to((Boolean) value); - } else if (value instanceof Number) { - return binder.to(((Number) value).longValue() != 0L); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid boolean", Code.INVALID_ARGUMENT); - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - if (value instanceof Number) { - return binder.to(((Number) value).longValue()); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid long", Code.INVALID_ARGUMENT); - case Types.FLOAT: - case Types.REAL: - case Types.DOUBLE: - if (value instanceof Number) { - return binder.to(((Number) value).doubleValue()); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid double", Code.INVALID_ARGUMENT); - case Types.NUMERIC: - case Types.DECIMAL: - // currently not supported as Cloud Spanner does not have any decimal data type. - throw JdbcSqlExceptionFactory.of( - "DECIMAL/NUMERIC values are not supported", Code.INVALID_ARGUMENT); - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NVARCHAR: - case Types.LONGNVARCHAR: - if (value instanceof String) { - return binder.to((String) value); - } else if (value instanceof InputStream) { - InputStreamReader reader = - new InputStreamReader((InputStream) value, StandardCharsets.US_ASCII); - try { - return binder.to(CharStreams.toString(reader)); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set string from input stream", Code.INVALID_ARGUMENT, e); - } - } else if (value instanceof Reader) { - try { - return binder.to(CharStreams.toString((Reader) value)); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set string from reader", Code.INVALID_ARGUMENT, e); - } - } else if (value instanceof URL) { - return binder.to(((URL) value).toString()); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid string", Code.INVALID_ARGUMENT); - case Types.DATE: - if (value instanceof Date) { - return binder.to(JdbcTypeConverter.toGoogleDate((Date) value)); - } else if (value instanceof Time) { - return binder.to(JdbcTypeConverter.toGoogleDate((Time) value)); - } else if (value instanceof Timestamp) { - return binder.to(JdbcTypeConverter.toGoogleDate((Timestamp) value)); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid date", Code.INVALID_ARGUMENT); - case Types.TIME: - case Types.TIMESTAMP: - if (value instanceof Date) { - return binder.to(JdbcTypeConverter.toGoogleTimestamp((Date) value)); - } else if (value instanceof Time) { - return binder.to(JdbcTypeConverter.toGoogleTimestamp((Time) value)); - } else if (value instanceof Timestamp) { - return binder.to(JdbcTypeConverter.toGoogleTimestamp((Timestamp) value)); - } - throw JdbcSqlExceptionFactory.of( - value + " is not a valid timestamp", Code.INVALID_ARGUMENT); - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - if (value instanceof byte[]) { - return binder.to(ByteArray.copyFrom((byte[]) value)); - } else if (value instanceof InputStream) { - try { - return binder.to(ByteArray.copyFrom((InputStream) value)); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "Could not copy bytes from input stream: " + e.getMessage(), - Code.INVALID_ARGUMENT, - e); - } - } - throw JdbcSqlExceptionFactory.of( - value + " is not a valid byte array", Code.INVALID_ARGUMENT); - case Types.ARRAY: - if (value instanceof Array) { - Array jdbcArray = (Array) value; - return setArrayValue(binder, sqlType, jdbcArray == null ? null : jdbcArray.getArray()); - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid array", Code.INVALID_ARGUMENT); - case Types.BLOB: - if (value instanceof Blob) { - try { - return binder.to(ByteArray.copyFrom(((Blob) value).getBinaryStream())); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set bytes from blob", Code.INVALID_ARGUMENT, e); - } - } else if (value instanceof InputStream) { - try { - return binder.to(ByteArray.copyFrom((InputStream) value)); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set bytes from input stream", Code.INVALID_ARGUMENT, e); - } - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid blob", Code.INVALID_ARGUMENT); - case Types.CLOB: - case Types.NCLOB: - if (value instanceof Clob) { - try { - return binder.to(CharStreams.toString(((Clob) value).getCharacterStream())); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set string from clob", Code.INVALID_ARGUMENT, e); - } - } else if (value instanceof Reader) { - try { - return binder.to(CharStreams.toString((Reader) value)); - } catch (IOException e) { - throw JdbcSqlExceptionFactory.of( - "could not set string from reader", Code.INVALID_ARGUMENT, e); - } - } - throw JdbcSqlExceptionFactory.of(value + " is not a valid clob", Code.INVALID_ARGUMENT); - } - return null; - } - - /** Set the parameter value based purely on the type of the value. */ - private Builder setParamWithUnknownType(ValueBinder binder, Object value) - throws SQLException { - if (Boolean.class.isAssignableFrom(value.getClass())) { - return binder.to((Boolean) value); - } else if (Byte.class.isAssignableFrom(value.getClass())) { - return binder.to(((Byte) value).longValue()); - } else if (Short.class.isAssignableFrom(value.getClass())) { - return binder.to(((Short) value).longValue()); - } else if (Integer.class.isAssignableFrom(value.getClass())) { - return binder.to(((Integer) value).longValue()); - } else if (Long.class.isAssignableFrom(value.getClass())) { - return binder.to(((Long) value).longValue()); - } else if (Float.class.isAssignableFrom(value.getClass())) { - return binder.to(((Float) value).doubleValue()); - } else if (Double.class.isAssignableFrom(value.getClass())) { - return binder.to(((Double) value).doubleValue()); - } else if (BigDecimal.class.isAssignableFrom(value.getClass())) { - // currently not supported - return null; - } else if (Date.class.isAssignableFrom(value.getClass())) { - Date dateValue = (Date) value; - return binder.to(JdbcTypeConverter.toGoogleDate(dateValue)); - } else if (Timestamp.class.isAssignableFrom(value.getClass())) { - return binder.to(JdbcTypeConverter.toGoogleTimestamp((Timestamp) value)); - } else if (Time.class.isAssignableFrom(value.getClass())) { - Time timeValue = (Time) value; - return binder.to(JdbcTypeConverter.toGoogleTimestamp(new Timestamp(timeValue.getTime()))); - } else if (String.class.isAssignableFrom(value.getClass())) { - String stringVal = (String) value; - return binder.to(stringVal); - } else if (Reader.class.isAssignableFrom(value.getClass())) { - try { - Reader readable = (Reader) value; - return binder.to(CharStreams.toString(readable)); - } catch (IOException e) { - throw new IllegalArgumentException("Could not read from readable", e); - } - } else if (Clob.class.isAssignableFrom(value.getClass()) - || NClob.class.isAssignableFrom(value.getClass())) { - try { - Clob clob = (Clob) value; - return binder.to(CharStreams.toString(clob.getCharacterStream())); - } catch (IOException e) { - throw new IllegalArgumentException("Could not read from readable", e); - } - } else if (Character.class.isAssignableFrom(value.getClass())) { - return binder.to(((Character) value).toString()); - } else if (Character[].class.isAssignableFrom(value.getClass())) { - List list = Arrays.asList((Character[]) value); - StringBuilder s = new StringBuilder(); - for (Character c : list) { - s.append(c.charValue()); - } - return binder.to(s.toString()); - } else if (char[].class.isAssignableFrom(value.getClass())) { - return binder.to(String.valueOf((char[]) value)); - } else if (URL.class.isAssignableFrom(value.getClass())) { - return binder.to(((URL) value).toString()); - } else if (byte[].class.isAssignableFrom(value.getClass())) { - return binder.to(ByteArray.copyFrom((byte[]) value)); - } else if (InputStream.class.isAssignableFrom(value.getClass())) { - try { - return binder.to(ByteArray.copyFrom((InputStream) value)); - } catch (IOException e) { - throw new IllegalArgumentException( - "Could not copy bytes from input stream: " + e.getMessage(), e); - } - } else if (Blob.class.isAssignableFrom(value.getClass())) { - try { - return binder.to(ByteArray.copyFrom(((Blob) value).getBinaryStream())); - } catch (IOException e) { - throw new IllegalArgumentException( - "Could not copy bytes from input stream: " + e.getMessage(), e); - } - } else if (Array.class.isAssignableFrom(value.getClass())) { - try { - Array jdbcArray = (Array) value; - if (value != null) { - return setArrayValue(binder, jdbcArray.getBaseType(), jdbcArray.getArray()); - } - } catch (SQLException e) { - throw new IllegalArgumentException( - "Unsupported parameter type: " + value.getClass().getName() + " - " + value.toString()); - } - } - return null; - } - - private Builder setArrayValue(ValueBinder binder, int type, Object value) - throws SQLException { - if (value == null) { - switch (type) { - case Types.BIT: - case Types.BOOLEAN: - return binder.toBoolArray((boolean[]) null); - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - return binder.toInt64Array((long[]) null); - case Types.FLOAT: - case Types.REAL: - case Types.DOUBLE: - return binder.toFloat64Array((double[]) null); - case Types.NUMERIC: - case Types.DECIMAL: - throw JdbcSqlExceptionFactory.of( - "DECIMAL/NUMERIC values are not supported", Code.INVALID_ARGUMENT); - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NVARCHAR: - case Types.LONGNVARCHAR: - case Types.CLOB: - case Types.NCLOB: - return binder.toStringArray((Iterable) null); - case Types.DATE: - return binder.toDateArray((Iterable) null); - case Types.TIME: - case Types.TIMESTAMP: - return binder.toTimestampArray((Iterable) null); - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - case Types.BLOB: - return binder.toBytesArray((Iterable) null); - } - throw JdbcSqlExceptionFactory.unsupported("Unknown/unsupported array base type: " + type); - } - - if (boolean[].class.isAssignableFrom(value.getClass())) { - return binder.toBoolArray((boolean[]) value); - } else if (Boolean[].class.isAssignableFrom(value.getClass())) { - return binder.toBoolArray(Arrays.asList((Boolean[]) value)); - } else if (short[].class.isAssignableFrom(value.getClass())) { - long[] l = new long[((short[]) value).length]; - for (int i = 0; i < l.length; i++) { - l[i] = ((short[]) value)[i]; - } - return binder.toInt64Array(l); - } else if (Short[].class.isAssignableFrom(value.getClass())) { - return binder.toInt64Array(toLongList((Short[]) value)); - } else if (int[].class.isAssignableFrom(value.getClass())) { - long[] l = new long[((int[]) value).length]; - for (int i = 0; i < l.length; i++) { - l[i] = ((int[]) value)[i]; - } - return binder.toInt64Array(l); - } else if (Integer[].class.isAssignableFrom(value.getClass())) { - return binder.toInt64Array(toLongList((Integer[]) value)); - } else if (long[].class.isAssignableFrom(value.getClass())) { - return binder.toInt64Array((long[]) value); - } else if (Long[].class.isAssignableFrom(value.getClass())) { - return binder.toInt64Array(toLongList((Long[]) value)); - } else if (float[].class.isAssignableFrom(value.getClass())) { - double[] l = new double[((float[]) value).length]; - for (int i = 0; i < l.length; i++) { - l[i] = ((float[]) value)[i]; - } - return binder.toFloat64Array(l); - } else if (Float[].class.isAssignableFrom(value.getClass())) { - return binder.toFloat64Array(toDoubleList((Float[]) value)); - } else if (double[].class.isAssignableFrom(value.getClass())) { - return binder.toFloat64Array((double[]) value); - } else if (Double[].class.isAssignableFrom(value.getClass())) { - return binder.toFloat64Array(toDoubleList((Double[]) value)); - } else if (BigDecimal[].class.isAssignableFrom(value.getClass())) { - // currently not supported - return null; - } else if (Date[].class.isAssignableFrom(value.getClass())) { - return binder.toDateArray(JdbcTypeConverter.toGoogleDates((Date[]) value)); - } else if (Timestamp[].class.isAssignableFrom(value.getClass())) { - return binder.toTimestampArray(JdbcTypeConverter.toGoogleTimestamps((Timestamp[]) value)); - } else if (String[].class.isAssignableFrom(value.getClass())) { - return binder.toStringArray(Arrays.asList((String[]) value)); - } else if (byte[][].class.isAssignableFrom(value.getClass())) { - return binder.toBytesArray(JdbcTypeConverter.toGoogleBytes((byte[][]) value)); - } - return null; - } - - private List toLongList(Number[] input) { - List res = new ArrayList<>(input.length); - for (int i = 0; i < input.length; i++) { - res.add(input[i] == null ? null : input[i].longValue()); - } - return res; - } - - private List toDoubleList(Number[] input) { - List res = new ArrayList<>(input.length); - for (int i = 0; i < input.length; i++) { - res.add(input[i] == null ? null : input[i].doubleValue()); - } - return res; - } - - /** - * Sets a null value with a specific SQL type. If the sqlType is null, the value will be set as a - * String. - */ - private Builder setNullValue(ValueBinder binder, Integer sqlType) throws SQLException { - if (sqlType == null) { - return binder.to((String) null); - } - switch (sqlType) { - case Types.BIGINT: - return binder.to((Long) null); - case Types.BINARY: - return binder.to((ByteArray) null); - case Types.BLOB: - return binder.to((ByteArray) null); - case Types.BOOLEAN: - return binder.to((Boolean) null); - case Types.CHAR: - return binder.to((String) null); - case Types.CLOB: - return binder.to((String) null); - case Types.DATE: - return binder.to((com.google.cloud.Date) null); - case Types.NUMERIC: - case Types.DECIMAL: - // currently not supported - throw JdbcSqlExceptionFactory.of( - "DECIMAL/NUMERIC values are not supported", Code.INVALID_ARGUMENT); - case Types.DOUBLE: - return binder.to((Double) null); - case Types.FLOAT: - return binder.to((Double) null); - case Types.INTEGER: - return binder.to((Long) null); - case Types.LONGNVARCHAR: - return binder.to((String) null); - case Types.LONGVARBINARY: - return binder.to((ByteArray) null); - case Types.LONGVARCHAR: - return binder.to((String) null); - case Types.NCHAR: - return binder.to((String) null); - case Types.NCLOB: - return binder.to((String) null); - case Types.NVARCHAR: - return binder.to((String) null); - case Types.REAL: - return binder.to((Double) null); - case Types.SMALLINT: - return binder.to((Long) null); - case Types.SQLXML: - return binder.to((String) null); - case Types.TIME: - return binder.to((com.google.cloud.Timestamp) null); - case Types.TIMESTAMP: - return binder.to((com.google.cloud.Timestamp) null); - case Types.TINYINT: - return binder.to((Long) null); - case Types.VARBINARY: - return binder.to((ByteArray) null); - case Types.VARCHAR: - return binder.to((String) null); - default: - throw new IllegalArgumentException("Unsupported sql type for setting to null: " + sqlType); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreconditions.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreconditions.java deleted file mode 100644 index a516e68b7da..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreconditions.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.rpc.Code; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import javax.annotation.Nullable; - -/** - * Convenience class for throwing {@link SQLException}s when a certain condition has not been met. - */ -class JdbcPreconditions { - - /** - * Ensures the truth of an expression involving a parameter to a method. - * - * @param expression the boolean expression that should be true. - * @param value the parameter value that is being checked. - * @throws JdbcSqlException with {@link Code#INVALID_ARGUMENT} if {@code expression} is false - */ - static void checkArgument(boolean expression, Object value) throws SQLException { - if (!expression) { - throw JdbcSqlExceptionFactory.of("invalid argument: " + value, Code.INVALID_ARGUMENT); - } - } - - /** - * Ensures the truth of an expression involving the state of the calling instance, but not - * involving any parameters to the calling method. - * - * @param expression a boolean expression - * @param errorMessage the exception message to use if the check fails; will be converted to a - * string using {@link String#valueOf(Object)} - * @throws JdbcSqlException with {@link Code#FAILED_PRECONDITION} if {@code expression} is false - */ - static void checkState(boolean expression, @Nullable Object errorMessage) throws SQLException { - if (!expression) { - throw JdbcSqlExceptionFactory.of(String.valueOf(errorMessage), Code.FAILED_PRECONDITION); - } - } - - /** - * Ensures the support of a certain JDBC feature. - * - * @param expression the boolean expression that indicates whether the feature is supported. - * @param message the exception message to use if the feature is not supported. - * @throws SQLFeatureNotSupportedException if the feature is not supported. - */ - static void checkSqlFeatureSupported(boolean expression, String message) - throws SQLFeatureNotSupportedException { - if (!expression) { - throw JdbcSqlExceptionFactory.unsupported(message); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatement.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatement.java deleted file mode 100644 index 4d5cfe88955..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatement.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.JdbcParameterStore.ParametersInfo; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -/** Implementation of {@link PreparedStatement} for Cloud Spanner. */ -class JdbcPreparedStatement extends AbstractJdbcPreparedStatement { - private final String sql; - private final String sqlWithoutComments; - private final ParametersInfo parameters; - - JdbcPreparedStatement(JdbcConnection connection, String sql) throws SQLException { - super(connection); - this.sql = sql; - this.sqlWithoutComments = StatementParser.removeCommentsAndTrim(this.sql); - this.parameters = - JdbcParameterStore.convertPositionalParametersToNamedParameters(sqlWithoutComments); - } - - ParametersInfo getParametersInfo() throws SQLException { - return parameters; - } - - private Statement createStatement() throws SQLException { - ParametersInfo paramInfo = getParametersInfo(); - Statement.Builder builder = Statement.newBuilder(paramInfo.sqlWithNamedParameters); - for (int index = 1; index <= getParameters().getHighestIndex(); index++) { - getParameters().bindParameterValue(builder.bind("p" + index), index); - } - return builder.build(); - } - - @Override - public ResultSet executeQuery() throws SQLException { - checkClosed(); - return executeQuery(createStatement()); - } - - ResultSet executeQueryWithOptions(QueryOption... options) throws SQLException { - checkClosed(); - return executeQuery(createStatement(), options); - } - - @Override - public int executeUpdate() throws SQLException { - checkClosed(); - return executeUpdate(createStatement()); - } - - @Override - public boolean execute() throws SQLException { - checkClosed(); - return executeStatement(createStatement()); - } - - @Override - public void addBatch() throws SQLException { - checkClosed(); - checkAndSetBatchType(sql); - batchedStatements.add(createStatement()); - } - - @Override - public JdbcParameterMetaData getParameterMetaData() throws SQLException { - checkClosed(); - return new JdbcParameterMetaData(this); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSet.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSet.java deleted file mode 100644 index 00c6361ff47..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSet.java +++ /dev/null @@ -1,682 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.Code; -import com.google.common.base.Preconditions; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.List; -import java.util.Map; - -/** Implementation of {@link ResultSet} for Cloud Spanner */ -class JdbcResultSet extends AbstractJdbcResultSet { - - static JdbcResultSet of(com.google.cloud.spanner.ResultSet resultSet) { - Preconditions.checkNotNull(resultSet); - return new JdbcResultSet(null, resultSet); - } - - static JdbcResultSet of(Statement statement, com.google.cloud.spanner.ResultSet resultSet) { - Preconditions.checkNotNull(statement); - Preconditions.checkNotNull(resultSet); - return new JdbcResultSet(statement, resultSet); - } - - private boolean closed = false; - private final Statement statement; - private boolean wasNull = false; - private boolean nextReturnedFalse = false; - private boolean nextCalledForMetaData = false; - private boolean nextCalledForMetaDataResult = false; - private long currentRow = 0L; - - private JdbcResultSet(Statement statement, com.google.cloud.spanner.ResultSet spanner) { - super(spanner); - this.statement = statement; - } - - void checkClosedAndValidRow() throws SQLException { - checkClosed(); - if (currentRow == 0L) { - throw JdbcSqlExceptionFactory.of( - "ResultSet is before first row. Call next() first.", - com.google.rpc.Code.FAILED_PRECONDITION); - } - if (nextReturnedFalse) { - throw JdbcSqlExceptionFactory.of( - "ResultSet is after last row. There is no more data available.", - com.google.rpc.Code.FAILED_PRECONDITION); - } - } - - @Override - public boolean next() throws SQLException { - checkClosed(); - currentRow++; - if (nextCalledForMetaData) { - nextReturnedFalse = !nextCalledForMetaDataResult; - nextCalledForMetaData = false; - } else { - nextReturnedFalse = !spanner.next(); - } - - return !nextReturnedFalse; - } - - @Override - public void close() throws SQLException { - spanner.close(); - this.closed = true; - } - - @Override - public boolean wasNull() throws SQLException { - checkClosedAndValidRow(); - return wasNull; - } - - private boolean isNull(int columnIndex) { - wasNull = spanner.isNull(columnIndex - 1); - return wasNull; - } - - private boolean isNull(String columnName) { - wasNull = spanner.isNull(columnName); - return wasNull; - } - - @Override - public String getString(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) ? null : spanner.getString(columnIndex - 1); - } - - @Override - public boolean getBoolean(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) ? false : spanner.getBoolean(columnIndex - 1); - } - - @Override - public byte getByte(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnIndex) ? 0L : spanner.getLong(columnIndex - 1); - return checkedCastToByte(val); - } - - @Override - public short getShort(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnIndex) ? 0L : spanner.getLong(columnIndex - 1); - return checkedCastToShort(val); - } - - @Override - public int getInt(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnIndex) ? 0L : spanner.getLong(columnIndex - 1); - return checkedCastToInt(val); - } - - @Override - public long getLong(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) ? 0L : spanner.getLong(columnIndex - 1); - } - - @Override - public float getFloat(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - double val = isNull(columnIndex) ? 0D : spanner.getDouble(columnIndex - 1); - return checkedCastToFloat(val); - } - - @Override - public double getDouble(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) ? 0D : spanner.getDouble(columnIndex - 1); - } - - @Override - public byte[] getBytes(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) ? null : spanner.getBytes(columnIndex - 1).toByteArray(); - } - - @Override - public Date getDate(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.toSqlDate(spanner.getDate(columnIndex - 1)); - } - - @Override - public Time getTime(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.toSqlTime(spanner.getTimestamp(columnIndex - 1)); - } - - @Override - public Timestamp getTimestamp(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.toSqlTimestamp(spanner.getTimestamp(columnIndex - 1)); - } - - private InputStream getInputStream(String val, Charset charset) { - if (val == null) return null; - byte[] b = val.getBytes(charset); - return new ByteArrayInputStream(b); - } - - @Override - public InputStream getAsciiStream(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return getInputStream(getString(columnIndex), StandardCharsets.US_ASCII); - } - - @Override - public InputStream getUnicodeStream(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return getInputStream(getString(columnIndex), StandardCharsets.UTF_16LE); - } - - @Override - public InputStream getBinaryStream(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - byte[] val = getBytes(columnIndex); - return val == null ? null : new ByteArrayInputStream(val); - } - - @Override - public String getString(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? null : spanner.getString(columnLabel); - } - - @Override - public boolean getBoolean(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? false : spanner.getBoolean(columnLabel); - } - - @Override - public byte getByte(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnLabel) ? 0L : spanner.getLong(columnLabel); - return checkedCastToByte(val); - } - - @Override - public short getShort(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnLabel) ? 0L : spanner.getLong(columnLabel); - return checkedCastToShort(val); - } - - @Override - public int getInt(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - long val = isNull(columnLabel) ? 0L : spanner.getLong(columnLabel); - return checkedCastToInt(val); - } - - @Override - public long getLong(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? 0L : spanner.getLong(columnLabel); - } - - @Override - public float getFloat(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - double val = isNull(columnLabel) ? 0D : spanner.getDouble(columnLabel); - return checkedCastToFloat(val); - } - - @Override - public double getDouble(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? 0D : spanner.getDouble(columnLabel); - } - - @Override - public byte[] getBytes(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? null : spanner.getBytes(columnLabel).toByteArray(); - } - - @Override - public Date getDate(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) ? null : JdbcTypeConverter.toSqlDate(spanner.getDate(columnLabel)); - } - - @Override - public Time getTime(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) - ? null - : JdbcTypeConverter.toSqlTime(spanner.getTimestamp(columnLabel)); - } - - @Override - public Timestamp getTimestamp(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) - ? null - : JdbcTypeConverter.toSqlTimestamp(spanner.getTimestamp(columnLabel)); - } - - @Override - public InputStream getAsciiStream(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getInputStream(getString(columnLabel), StandardCharsets.US_ASCII); - } - - @Override - public InputStream getUnicodeStream(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getInputStream(getString(columnLabel), StandardCharsets.UTF_16LE); - } - - @Override - public InputStream getBinaryStream(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - byte[] val = getBytes(columnLabel); - return val == null ? null : new ByteArrayInputStream(val); - } - - @Override - public JdbcResultSetMetaData getMetaData() throws SQLException { - checkClosed(); - if (isBeforeFirst()) { - // do a call to next() on the underlying resultset to initialize metadata - nextCalledForMetaData = true; - nextCalledForMetaDataResult = spanner.next(); - } - return new JdbcResultSetMetaData(this, statement); - } - - @Override - public Object getObject(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - Type type = spanner.getColumnType(columnLabel); - return isNull(columnLabel) ? null : getObject(type, columnLabel); - } - - @Override - public Object getObject(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - Type type = spanner.getColumnType(columnIndex - 1); - return isNull(columnIndex) ? null : getObject(type, columnIndex); - } - - private Object getObject(Type type, String columnLabel) throws SQLException { - return getObject(type, spanner.getColumnIndex(columnLabel) + 1); - } - - private Object getObject(Type type, int columnIndex) throws SQLException { - if (type == Type.bool()) return getBoolean(columnIndex); - if (type == Type.bytes()) return getBytes(columnIndex); - if (type == Type.date()) return getDate(columnIndex); - if (type == Type.float64()) return getDouble(columnIndex); - if (type == Type.int64()) return getLong(columnIndex); - if (type == Type.string()) return getString(columnIndex); - if (type == Type.timestamp()) return getTimestamp(columnIndex); - if (type.getCode() == Code.ARRAY) return getArray(columnIndex); - throw JdbcSqlExceptionFactory.of( - "Unknown type: " + type.toString(), com.google.rpc.Code.INVALID_ARGUMENT); - } - - @Override - public int findColumn(String columnLabel) throws SQLException { - checkClosed(); - try { - return spanner.getColumnIndex(columnLabel) + 1; - } catch (IllegalArgumentException e) { - throw JdbcSqlExceptionFactory.of( - "no column with label " + columnLabel + " found", com.google.rpc.Code.INVALID_ARGUMENT); - } - } - - @Override - public Reader getCharacterStream(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnIndex); - return val == null ? null : new StringReader(val); - } - - @Override - public Reader getCharacterStream(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnLabel); - return val == null ? null : new StringReader(val); - } - - @Override - public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return getBigDecimal(columnIndex, false, 0); - } - - @Override - public BigDecimal getBigDecimal(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getBigDecimal(spanner.getColumnIndex(columnLabel) + 1, false, 0); - } - - @Override - public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - checkClosedAndValidRow(); - return getBigDecimal(columnIndex, true, scale); - } - - @Override - public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { - checkClosedAndValidRow(); - return getBigDecimal(spanner.getColumnIndex(columnLabel) + 1, true, scale); - } - - private BigDecimal getBigDecimal(int columnIndex, boolean fixedScale, int scale) - throws SQLException { - Type type = spanner.getColumnType(columnIndex - 1); - BigDecimal res; - if (isNull(columnIndex)) { - res = null; - } else { - if (type.getCode() == Code.STRING) { - try { - res = new BigDecimal(spanner.getString(columnIndex - 1)); - } catch (NumberFormatException e) { - throw JdbcSqlExceptionFactory.of( - "The column does not contain a valid BigDecimal", - com.google.rpc.Code.INVALID_ARGUMENT, - e); - } - } else if (type.getCode() == Code.INT64) { - res = BigDecimal.valueOf(spanner.getLong(columnIndex - 1)); - } else if (type.getCode() == Code.FLOAT64) { - res = BigDecimal.valueOf(spanner.getDouble(columnIndex - 1)); - } else { - throw JdbcSqlExceptionFactory.of( - "The column does not contain a valid BigDecimal", com.google.rpc.Code.INVALID_ARGUMENT); - } - if (fixedScale) { - res = res.setScale(scale, RoundingMode.HALF_UP); - } - } - return res; - } - - @Override - public boolean isBeforeFirst() throws SQLException { - checkClosed(); - return currentRow == 0L; - } - - @Override - public boolean isAfterLast() throws SQLException { - checkClosed(); - return nextReturnedFalse; - } - - @Override - public boolean isFirst() throws SQLException { - checkClosed(); - return currentRow == 1L; - } - - @Override - public int getRow() throws SQLException { - checkClosed(); - return checkedCastToInt(currentRow); - } - - @Override - public Statement getStatement() throws SQLException { - checkClosed(); - return statement; - } - - @Override - public Array getArray(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getArray(findColumn(columnLabel)); - } - - @Override - public Array getArray(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - if (isNull(columnIndex)) return null; - Type type = spanner.getColumnType(columnIndex - 1); - if (type.getCode() != Code.ARRAY) - throw JdbcSqlExceptionFactory.of( - "Column with index " + columnIndex + " does not contain an array", - com.google.rpc.Code.INVALID_ARGUMENT); - JdbcDataType dataType = JdbcDataType.getType(type.getArrayElementType().getCode()); - List elements = dataType.getArrayElements(spanner, columnIndex - 1); - - return JdbcArray.createArray(dataType, elements); - } - - @Override - public Date getDate(int columnIndex, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.toSqlDate(spanner.getDate(columnIndex - 1), cal); - } - - @Override - public Date getDate(String columnLabel, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) - ? null - : JdbcTypeConverter.toSqlDate(spanner.getDate(columnLabel), cal); - } - - @Override - public Time getTime(int columnIndex, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.toSqlTime(spanner.getTimestamp(columnIndex - 1), cal); - } - - @Override - public Time getTime(String columnLabel, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) - ? null - : JdbcTypeConverter.toSqlTime(spanner.getTimestamp(columnLabel), cal); - } - - @Override - public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnIndex) - ? null - : JdbcTypeConverter.getAsSqlTimestamp(spanner.getTimestamp(columnIndex - 1), cal); - } - - @Override - public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { - checkClosedAndValidRow(); - return isNull(columnLabel) - ? null - : JdbcTypeConverter.getAsSqlTimestamp(spanner.getTimestamp(columnLabel), cal); - } - - @Override - public URL getURL(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - try { - return isNull(columnIndex) ? null : new URL(spanner.getString(columnIndex - 1)); - } catch (MalformedURLException e) { - throw JdbcSqlExceptionFactory.of( - "Invalid URL: " + spanner.getString(columnIndex - 1), - com.google.rpc.Code.INVALID_ARGUMENT); - } - } - - @Override - public URL getURL(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getURL(findColumn(columnLabel)); - } - - @Override - public int getHoldability() throws SQLException { - checkClosed(); - return CLOSE_CURSORS_AT_COMMIT; - } - - @Override - public boolean isClosed() throws SQLException { - return closed; - } - - @Override - public String getNString(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return getString(columnIndex); - } - - @Override - public String getNString(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getString(columnLabel); - } - - @Override - public Reader getNCharacterStream(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - return getCharacterStream(columnIndex); - } - - @Override - public Reader getNCharacterStream(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - return getCharacterStream(columnLabel); - } - - @Override - public T getObject(int columnIndex, Class type) throws SQLException { - checkClosedAndValidRow(); - return convertObject(getObject(columnIndex), type, spanner.getColumnType(columnIndex - 1)); - } - - @Override - public T getObject(String columnLabel, Class type) throws SQLException { - checkClosedAndValidRow(); - return convertObject(getObject(columnLabel), type, spanner.getColumnType(columnLabel)); - } - - @Override - public Object getObject(int columnIndex, Map> map) throws SQLException { - checkClosedAndValidRow(); - return convertObject(getObject(columnIndex), map, spanner.getColumnType(columnIndex - 1)); - } - - @Override - public Object getObject(String columnLabel, Map> map) throws SQLException { - checkClosedAndValidRow(); - return convertObject(getObject(columnLabel), map, spanner.getColumnType(columnLabel)); - } - - @Override - public Blob getBlob(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - byte[] val = getBytes(columnIndex); - return val == null ? null : new JdbcBlob(val); - } - - @Override - public Blob getBlob(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - byte[] val = getBytes(columnLabel); - return val == null ? null : new JdbcBlob(val); - } - - @Override - public Clob getClob(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnIndex); - return val == null ? null : new JdbcClob(val); - } - - @Override - public Clob getClob(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnLabel); - return val == null ? null : new JdbcClob(val); - } - - @Override - public NClob getNClob(int columnIndex) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnIndex); - return val == null ? null : new JdbcClob(val); - } - - @Override - public NClob getNClob(String columnLabel) throws SQLException { - checkClosedAndValidRow(); - String val = getString(columnLabel); - return val == null ? null : new JdbcClob(val); - } - - @SuppressWarnings("unchecked") - private T convertObject(Object o, Class javaType, Type type) throws SQLException { - return (T) JdbcTypeConverter.convert(o, type, javaType); - } - - private Object convertObject(Object o, Map> map, Type type) throws SQLException { - if (map == null) - throw JdbcSqlExceptionFactory.of("Map may not be null", com.google.rpc.Code.INVALID_ARGUMENT); - if (o == null) return null; - Class javaType = map.get(type.getCode().name()); - if (javaType == null) return o; - return JdbcTypeConverter.convert(o, type, javaType); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaData.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaData.java deleted file mode 100644 index 4292c922551..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaData.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ResultSet; -import com.google.common.base.Preconditions; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Types; - -/** Implementation of {@link ResultSetMetaData} for Cloud Spanner */ -class JdbcResultSetMetaData extends AbstractJdbcWrapper implements ResultSetMetaData { - /** - * The default column display size for columns with a data type of variable size that is used when - * the actual column size is not known. - */ - private static final int DEFAULT_COL_DISPLAY_SIZE_FOR_VARIABLE_LENGTH_COLS = 50; - - private final ResultSet spannerResultSet; - private final Statement statement; - - JdbcResultSetMetaData(JdbcResultSet jdbcResultSet, Statement statement) { - Preconditions.checkNotNull(jdbcResultSet); - this.spannerResultSet = jdbcResultSet.spanner; - this.statement = statement; - } - - @Override - public boolean isClosed() { - return false; - } - - @Override - public int getColumnCount() throws SQLException { - return spannerResultSet.getColumnCount(); - } - - @Override - public boolean isAutoIncrement(int column) throws SQLException { - return false; - } - - @Override - public boolean isCaseSensitive(int column) throws SQLException { - int type = getColumnType(column); - return type == Types.NVARCHAR || type == Types.BINARY; - } - - @Override - public boolean isSearchable(int column) throws SQLException { - return true; - } - - @Override - public boolean isCurrency(int column) throws SQLException { - return false; - } - - @Override - public int isNullable(int column) throws SQLException { - return columnNullableUnknown; - } - - @Override - public boolean isSigned(int column) throws SQLException { - int type = getColumnType(column); - return type == Types.DOUBLE || type == Types.BIGINT; - } - - @Override - public int getColumnDisplaySize(int column) throws SQLException { - int colType = getColumnType(column); - switch (colType) { - case Types.ARRAY: - return DEFAULT_COL_DISPLAY_SIZE_FOR_VARIABLE_LENGTH_COLS; - case Types.BOOLEAN: - return 5; - case Types.BINARY: - int binaryLength = getPrecision(column); - return binaryLength == 0 ? DEFAULT_COL_DISPLAY_SIZE_FOR_VARIABLE_LENGTH_COLS : binaryLength; - case Types.DATE: - return 10; - case Types.DOUBLE: - return 14; - case Types.BIGINT: - return 10; - case Types.NVARCHAR: - int length = getPrecision(column); - return length == 0 ? DEFAULT_COL_DISPLAY_SIZE_FOR_VARIABLE_LENGTH_COLS : length; - case Types.TIMESTAMP: - return 16; - default: - return 10; - } - } - - @Override - public String getColumnLabel(int column) throws SQLException { - return spannerResultSet.getType().getStructFields().get(column - 1).getName(); - } - - @Override - public String getColumnName(int column) throws SQLException { - return spannerResultSet.getType().getStructFields().get(column - 1).getName(); - } - - @Override - public String getSchemaName(int column) throws SQLException { - return statement.getConnection().getSchema(); - } - - @Override - public int getPrecision(int column) throws SQLException { - int colType = getColumnType(column); - switch (colType) { - case Types.BOOLEAN: - return 1; - case Types.DATE: - return 10; - case Types.DOUBLE: - return 14; - case Types.BIGINT: - return 10; - case Types.TIMESTAMP: - return 24; - default: - // For column types with variable size, such as text columns, we should return the length - // in characters. We could try to fetch it from INFORMATION_SCHEMA, but that would mean - // parsing the SQL statement client side in order to figure out which column it actually - // is. For now we just return the default column display size. - return DEFAULT_COL_DISPLAY_SIZE_FOR_VARIABLE_LENGTH_COLS; - } - } - - @Override - public int getScale(int column) throws SQLException { - int colType = getColumnType(column); - if (colType == Types.DOUBLE) return 15; - return 0; - } - - @Override - public String getTableName(int column) throws SQLException { - return ""; - } - - @Override - public String getCatalogName(int column) throws SQLException { - return statement.getConnection().getCatalog(); - } - - @Override - public int getColumnType(int column) throws SQLException { - return extractColumnType(spannerResultSet.getColumnType(column - 1)); - } - - @Override - public String getColumnTypeName(int column) throws SQLException { - return spannerResultSet.getColumnType(column - 1).getCode().name(); - } - - @Override - public boolean isReadOnly(int column) throws SQLException { - return false; - } - - @Override - public boolean isWritable(int column) throws SQLException { - return !isReadOnly(column); - } - - @Override - public boolean isDefinitelyWritable(int column) throws SQLException { - return false; - } - - @Override - public String getColumnClassName(int column) throws SQLException { - return getClassName(spannerResultSet.getColumnType(column - 1)); - } - - @Override - public String toString() { - StringBuilder res = new StringBuilder(); - try { - for (int col = 1; col <= getColumnCount(); col++) { - res.append("Col ").append(col).append(": "); - res.append(getColumnName(col)).append(" ").append(getColumnTypeName(col)); - res.append("\n"); - } - } catch (SQLException e) { - return "An error occurred while generating string: " + e.getMessage(); - } - return res.toString(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlException.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlException.java deleted file mode 100644 index c36b8134a8d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.rpc.Code; -import java.sql.SQLException; - -/** - * Base interface for all Cloud Spanner {@link SQLException}s. All {@link SQLException}s that are - * thrown by the Cloud Spanner JDBC driver implement this interface. - */ -public interface JdbcSqlException { - - /** @see Throwable#getMessage() */ - String getMessage(); - - /** @see Throwable#getCause() */ - Throwable getCause(); - - /** @see SQLException#getSQLState() */ - String getSQLState(); - - /** Returns the gRPC error code as an int */ - int getErrorCode(); - - /** Returns the corresponding gRPC code for this exception */ - Code getCode(); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlExceptionFactory.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlExceptionFactory.java deleted file mode 100644 index a6fc2bfaa30..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcSqlExceptionFactory.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedDueToConcurrentModificationException; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.rpc.Code; -import java.sql.BatchUpdateException; -import java.sql.ClientInfoStatus; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLTimeoutException; -import java.util.Collections; - -/** Factory class for creating {@link SQLException}s for Cloud Spanner */ -public final class JdbcSqlExceptionFactory { - - /** Base {@link SQLException} for Cloud Spanner */ - public static class JdbcSqlExceptionImpl extends SQLException implements JdbcSqlException { - private static final long serialVersionUID = 235381453830069910L; - private final Code code; - - private JdbcSqlExceptionImpl(String message, Code code) { - super(message, null, code.getNumber(), null); - this.code = code; - } - - private JdbcSqlExceptionImpl(String message, Code code, Throwable cause) { - super(message, null, code.getNumber(), cause); - this.code = code; - } - - private JdbcSqlExceptionImpl(SpannerException e) { - super(e.getMessage(), null, e.getCode(), e); - this.code = Code.forNumber(e.getCode()); - } - - private JdbcSqlExceptionImpl(String message, SpannerException e) { - super(message, null, e.getCode(), e); - this.code = Code.forNumber(e.getCode()); - } - - @Override - public Code getCode() { - return code; - } - } - - /** Specific {@link SQLException} that is thrown when a statement times out */ - public static class JdbcSqlTimeoutException extends SQLTimeoutException - implements JdbcSqlException { - private static final long serialVersionUID = 2363793358642102814L; - - private JdbcSqlTimeoutException(String message) { - super(message, "Timed out", Code.DEADLINE_EXCEEDED_VALUE); - } - - @Override - public Code getCode() { - return Code.DEADLINE_EXCEEDED; - } - } - - /** Specific {@link SQLException} that is thrown when setting client info on a connection */ - public static class JdbcSqlClientInfoException extends SQLClientInfoException - implements JdbcSqlException { - private static final long serialVersionUID = 5341238042343668540L; - private final Code code; - - private JdbcSqlClientInfoException(String message, Code code) { - super(message, Collections.emptyMap()); - this.code = code; - } - - @Override - public Code getCode() { - return code; - } - } - - /** Specific {@link SQLException} that is thrown for unsupported methods and values */ - public static class JdbcSqlFeatureNotSupportedException extends SQLFeatureNotSupportedException - implements JdbcSqlException { - private static final long serialVersionUID = 2363793358642102814L; - - private JdbcSqlFeatureNotSupportedException(String message) { - super(message, "not supported", Code.UNIMPLEMENTED_VALUE); - } - - @Override - public Code getCode() { - return Code.UNIMPLEMENTED; - } - } - - /** - * Specific {@link SQLException} that is thrown when a {@link SpannerBatchUpdateException} occurs. - */ - public static class JdbcSqlBatchUpdateException extends BatchUpdateException - implements JdbcSqlException { - private static final long serialVersionUID = 8894995110837971444L; - private final Code code; - - private JdbcSqlBatchUpdateException(int[] updateCounts, SpannerBatchUpdateException cause) { - super(cause.getMessage(), updateCounts, cause); - this.code = Code.forNumber(cause.getCode()); - } - - @Override - public Code getCode() { - return code; - } - } - - /** - * Specific {@link SQLException} that is thrown when a transaction was aborted and could not be - * successfully retried. - */ - public static class JdbcAbortedException extends JdbcSqlExceptionImpl { - private JdbcAbortedException(AbortedException cause) { - super(cause); - } - - private JdbcAbortedException(String message) { - super(message, Code.ABORTED); - } - - private JdbcAbortedException(String message, AbortedException cause) { - super(message, cause); - } - - @Override - public synchronized AbortedException getCause() { - return (AbortedException) super.getCause(); - } - } - - /** - * Specific {@link SQLException} that is thrown when a transaction was aborted and could not be - * retried due to a concurrent modification. - */ - public static class JdbcAbortedDueToConcurrentModificationException extends JdbcAbortedException { - private JdbcAbortedDueToConcurrentModificationException( - AbortedDueToConcurrentModificationException cause) { - super(cause); - } - - private JdbcAbortedDueToConcurrentModificationException( - String message, AbortedDueToConcurrentModificationException cause) { - super(message, cause); - } - - @Override - public synchronized AbortedDueToConcurrentModificationException getCause() { - return (AbortedDueToConcurrentModificationException) super.getCause(); - } - - public SpannerException getDatabaseErrorDuringRetry() { - return getCause().getDatabaseErrorDuringRetry(); - } - } - - /** Creates a {@link JdbcSqlException} from the given {@link SpannerException}. */ - static SQLException of(SpannerException e) { - switch (e.getErrorCode()) { - case ABORTED: - if (e instanceof AbortedDueToConcurrentModificationException) { - return new JdbcAbortedDueToConcurrentModificationException( - (AbortedDueToConcurrentModificationException) e); - } else if (e instanceof AbortedException) { - return new JdbcAbortedException((AbortedException) e); - } - case DEADLINE_EXCEEDED: - return new JdbcSqlTimeoutException(e.getMessage()); - case ALREADY_EXISTS: - case CANCELLED: - case DATA_LOSS: - case FAILED_PRECONDITION: - case INTERNAL: - case INVALID_ARGUMENT: - case NOT_FOUND: - case OUT_OF_RANGE: - case PERMISSION_DENIED: - case RESOURCE_EXHAUSTED: - case UNAUTHENTICATED: - case UNAVAILABLE: - case UNIMPLEMENTED: - case UNKNOWN: - default: - } - return new JdbcSqlExceptionImpl(e); - } - - /** Creates a {@link JdbcSqlException} with the given message and error code. */ - static SQLException of(String message, Code code) { - switch (code) { - case ABORTED: - return new JdbcAbortedException(code.name() + ": " + message); - case DEADLINE_EXCEEDED: - return new JdbcSqlTimeoutException(code.name() + ": " + message); - case ALREADY_EXISTS: - case CANCELLED: - case DATA_LOSS: - case FAILED_PRECONDITION: - case INTERNAL: - case INVALID_ARGUMENT: - case NOT_FOUND: - case OUT_OF_RANGE: - case PERMISSION_DENIED: - case RESOURCE_EXHAUSTED: - case UNAUTHENTICATED: - case UNAVAILABLE: - case UNIMPLEMENTED: - case UNKNOWN: - default: - } - return new JdbcSqlExceptionImpl(code.name() + ": " + message, code); - } - - /** Creates a {@link JdbcSqlException} with the given message and cause. */ - static SQLException of(String message, SpannerException e) { - switch (e.getErrorCode()) { - case ABORTED: - if (e instanceof AbortedDueToConcurrentModificationException) { - return new JdbcAbortedDueToConcurrentModificationException( - message, (AbortedDueToConcurrentModificationException) e); - } else if (e instanceof AbortedException) { - return new JdbcAbortedException(message, (AbortedException) e); - } - case DEADLINE_EXCEEDED: - return new JdbcSqlTimeoutException(e.getErrorCode().name() + ": " + message); - case ALREADY_EXISTS: - case CANCELLED: - case DATA_LOSS: - case FAILED_PRECONDITION: - case INTERNAL: - case INVALID_ARGUMENT: - case NOT_FOUND: - case OUT_OF_RANGE: - case PERMISSION_DENIED: - case RESOURCE_EXHAUSTED: - case UNAUTHENTICATED: - case UNAVAILABLE: - case UNIMPLEMENTED: - case UNKNOWN: - default: - } - return new JdbcSqlExceptionImpl(e.getErrorCode().name() + ": " + message, e); - } - - /** Creates a {@link JdbcSqlException} with the given message, error code and cause. */ - static SQLException of(String message, Code code, Throwable cause) { - switch (code) { - case ABORTED: - if (cause instanceof AbortedDueToConcurrentModificationException) { - return new JdbcAbortedDueToConcurrentModificationException( - message, (AbortedDueToConcurrentModificationException) cause); - } else if (cause instanceof AbortedException) { - return new JdbcAbortedException(message, (AbortedException) cause); - } - case DEADLINE_EXCEEDED: - return new JdbcSqlTimeoutException(code.name() + ": " + message); - case ALREADY_EXISTS: - case CANCELLED: - case DATA_LOSS: - case FAILED_PRECONDITION: - case INTERNAL: - case INVALID_ARGUMENT: - case NOT_FOUND: - case OUT_OF_RANGE: - case PERMISSION_DENIED: - case RESOURCE_EXHAUSTED: - case UNAUTHENTICATED: - case UNAVAILABLE: - case UNIMPLEMENTED: - case UNKNOWN: - default: - } - return new JdbcSqlExceptionImpl(code.name() + ": " + message, code, cause); - } - - /** Creates a {@link JdbcSqlException} for unsupported methods/values. */ - static SQLFeatureNotSupportedException unsupported(String message) { - return new JdbcSqlFeatureNotSupportedException(message); - } - - /** Creates a {@link JdbcSqlException} for client info exceptions. */ - static SQLClientInfoException clientInfoException(String message, Code code) { - return new JdbcSqlClientInfoException(code.name() + ": " + message, code); - } - - /** Creates a {@link JdbcSqlException} for batch update exceptions. */ - static BatchUpdateException batchException( - int[] updateCounts, SpannerBatchUpdateException cause) { - return new JdbcSqlBatchUpdateException(updateCounts, cause); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcStatement.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcStatement.java deleted file mode 100644 index e87558e68e9..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcStatement.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.rpc.Code; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** Implementation of {@link java.sql.Statement} for Google Cloud Spanner. */ -class JdbcStatement extends AbstractJdbcStatement { - enum BatchType { - NONE, - DML, - DDL; - } - - private ResultSet currentResultSet; - private long currentUpdateCount; - private int fetchSize; - private BatchType currentBatchType = BatchType.NONE; - final List batchedStatements = new ArrayList<>(); - - JdbcStatement(JdbcConnection connection) { - super(connection); - } - - @Override - public ResultSet executeQuery(String sql) throws SQLException { - checkClosed(); - return executeQuery(Statement.of(sql)); - } - - /** - * @see java.sql.Statement#executeUpdate(String) - *

This method allows both DML and DDL statements to be executed. It assumes that the user - * knows what kind of statement is being executed, and the method will therefore return 0 for - * both DML statements that changed 0 rows as well as for all DDL statements. - */ - @Override - public int executeUpdate(String sql) throws SQLException { - checkClosed(); - Statement statement = Statement.of(sql); - StatementResult result = execute(statement); - switch (result.getResultType()) { - case RESULT_SET: - throw JdbcSqlExceptionFactory.of( - "The statement is not an update or DDL statement", Code.INVALID_ARGUMENT); - case UPDATE_COUNT: - if (result.getUpdateCount() > Integer.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - "update count too large: " + result.getUpdateCount(), Code.OUT_OF_RANGE); - } - return result.getUpdateCount().intValue(); - case NO_RESULT: - return 0; - default: - throw JdbcSqlExceptionFactory.of( - "unknown result: " + result.getResultType(), Code.FAILED_PRECONDITION); - } - } - - @Override - public boolean execute(String sql) throws SQLException { - checkClosed(); - return executeStatement(Statement.of(sql)); - } - - boolean executeStatement(Statement statement) throws SQLException { - StatementResult result = execute(statement); - switch (result.getResultType()) { - case RESULT_SET: - currentResultSet = JdbcResultSet.of(this, result.getResultSet()); - currentUpdateCount = JdbcConstants.STATEMENT_RESULT_SET; - return true; - case UPDATE_COUNT: - currentResultSet = null; - currentUpdateCount = result.getUpdateCount(); - return false; - case NO_RESULT: - currentResultSet = null; - currentUpdateCount = JdbcConstants.STATEMENT_NO_RESULT; - return false; - default: - throw JdbcSqlExceptionFactory.of( - "unknown result: " + result.getResultType(), Code.FAILED_PRECONDITION); - } - } - - @Override - public ResultSet getResultSet() throws SQLException { - checkClosed(); - return currentResultSet; - } - - /** - * Returns the update count of the last update statement. Will return {@link - * JdbcConstants#STATEMENT_RESULT_SET} if the last statement returned a {@link ResultSet} and will - * return {@link JdbcConstants#STATEMENT_NO_RESULT} if the last statement did not have any return - * value, such as for example DDL statements. - */ - @Override - public int getUpdateCount() throws SQLException { - checkClosed(); - if (currentUpdateCount > Integer.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - "update count too large: " + currentUpdateCount, Code.OUT_OF_RANGE); - } - return (int) currentUpdateCount; - } - - @Override - public boolean getMoreResults() throws SQLException { - checkClosed(); - return getMoreResults(CLOSE_CURRENT_RESULT); - } - - @Override - public boolean getMoreResults(int current) throws SQLException { - checkClosed(); - if (currentResultSet != null - && !currentResultSet.isClosed() - && (current == CLOSE_CURRENT_RESULT || current == CLOSE_ALL_RESULTS)) { - currentResultSet.close(); - } - currentResultSet = null; - currentUpdateCount = -1L; - return false; - } - - /** This value is set as the value for {@link Options#prefetchChunks(int)} */ - @Override - public void setFetchSize(int rows) throws SQLException { - checkClosed(); - this.fetchSize = rows; - } - - /** This value is set as the value for {@link Options#prefetchChunks(int)} */ - @Override - public int getFetchSize() throws SQLException { - checkClosed(); - return fetchSize; - } - - /** - * Determine the batch type (DML/DDL) based on the sql statement. - * - * @throws SQLException if the sql statement is not allowed for batching. - */ - private BatchType determineStatementBatchType(String sql) throws SQLException { - String sqlWithoutComments = StatementParser.removeCommentsAndTrim(sql); - if (StatementParser.INSTANCE.isDdlStatement(sqlWithoutComments)) { - return BatchType.DDL; - } else if (StatementParser.INSTANCE.isUpdateStatement(sqlWithoutComments)) { - return BatchType.DML; - } - throw JdbcSqlExceptionFactory.of( - "The statement is not suitable for batching. Only DML and DDL statements are allowed for batching.", - Code.INVALID_ARGUMENT); - } - - /** - * Check that the sql statement is of the same type as the current batch on this statement. If - * there is no active batch on this statement, a batch will be started with the type that is - * determined from the sql statement (DML/DDL). - * - * @throws SQLException if the sql statement is of a different type than the already active batch - * on this statement, if the statement is not allowed for batching (i.e. it is a query or a - * client side statement) or if the connection of this statement has an active batch. - */ - void checkAndSetBatchType(String sql) throws SQLException { - checkConnectionHasNoActiveBatch(); - BatchType type = determineStatementBatchType(sql); - if (this.currentBatchType == BatchType.NONE) { - this.currentBatchType = type; - } else if (this.currentBatchType != type) { - throw JdbcSqlExceptionFactory.of( - "Mixing DML and DDL statements in a batch is not allowed.", Code.INVALID_ARGUMENT); - } - } - - private void checkConnectionHasNoActiveBatch() throws SQLException { - if (getConnection().getSpannerConnection().isDdlBatchActive() - || getConnection().getSpannerConnection().isDmlBatchActive()) { - throw JdbcSqlExceptionFactory.of( - "Calling addBatch() is not allowed when a DML or DDL batch has been started on the connection.", - Code.FAILED_PRECONDITION); - } - } - - @Override - public void addBatch(String sql) throws SQLException { - checkClosed(); - checkAndSetBatchType(sql); - batchedStatements.add(Statement.of(sql)); - } - - @Override - public void clearBatch() throws SQLException { - checkClosed(); - checkConnectionHasNoActiveBatch(); - batchedStatements.clear(); - this.currentBatchType = BatchType.NONE; - } - - @Override - public int[] executeBatch() throws SQLException { - checkClosed(); - checkConnectionHasNoActiveBatch(); - try { - switch (this.currentBatchType) { - case DML: - try { - long[] updateCounts = - getConnection().getSpannerConnection().executeBatchUpdate(batchedStatements); - int[] res = convertUpdateCounts(updateCounts); - return res; - } catch (SpannerBatchUpdateException e) { - int[] updateCounts = convertUpdateCounts(e.getUpdateCounts()); - throw JdbcSqlExceptionFactory.batchException(updateCounts, e); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - case DDL: - try { - getConnection().getSpannerConnection().startBatchDdl(); - for (Statement statement : batchedStatements) { - execute(statement); - } - getConnection().getSpannerConnection().runBatch(); - int[] res = new int[batchedStatements.size()]; - Arrays.fill(res, java.sql.Statement.SUCCESS_NO_INFO); - return res; - } catch (SpannerBatchUpdateException e) { - int[] res = new int[batchedStatements.size()]; - Arrays.fill(res, java.sql.Statement.EXECUTE_FAILED); - convertUpdateCountsToSuccessNoInfo(e.getUpdateCounts(), res); - throw JdbcSqlExceptionFactory.batchException(res, e); - } catch (SpannerException e) { - throw JdbcSqlExceptionFactory.of(e); - } - case NONE: - // There is no batch on this statement, this is a no-op. - return new int[0]; - default: - throw JdbcSqlExceptionFactory.unsupported( - String.format("Unknown batch type: %s", this.currentBatchType.name())); - } - } finally { - batchedStatements.clear(); - this.currentBatchType = BatchType.NONE; - } - } - - @VisibleForTesting - int[] convertUpdateCounts(long[] updateCounts) throws SQLException { - int[] res = new int[updateCounts.length]; - for (int index = 0; index < updateCounts.length; index++) { - if (updateCounts[index] > Integer.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format("Update count too large for int: %d", updateCounts[index]), - Code.OUT_OF_RANGE); - } - res[index] = (int) updateCounts[index]; - } - return res; - } - - @VisibleForTesting - void convertUpdateCountsToSuccessNoInfo(long[] updateCounts, int[] res) throws SQLException { - Preconditions.checkNotNull(updateCounts); - Preconditions.checkNotNull(res); - Preconditions.checkArgument(res.length >= updateCounts.length); - for (int index = 0; index < updateCounts.length; index++) { - if (updateCounts[index] > Integer.MAX_VALUE) { - throw JdbcSqlExceptionFactory.of( - String.format("Update count too large for int: %d", updateCounts[index]), - Code.OUT_OF_RANGE); - } - if (updateCounts[index] > 0L) { - res[index] = java.sql.Statement.SUCCESS_NO_INFO; - } else { - res[index] = java.sql.Statement.EXECUTE_FAILED; - } - } - } - - @Override - public ResultSet getGeneratedKeys() throws SQLException { - checkClosed(); - // Return an empty result set instead of throwing an exception, to facilitate any application - // that might not check on beforehand whether the driver supports any generated keys. - com.google.cloud.spanner.ResultSet rs = - ResultSets.forRows( - Type.struct( - StructField.of("COLUMN_NAME", Type.string()), - StructField.of("VALUE", Type.int64())), - Collections.emptyList()); - return JdbcResultSet.of(rs); - } - - @Override - public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - autoGeneratedKeys == java.sql.Statement.NO_GENERATED_KEYS, - JdbcConnection.ONLY_NO_GENERATED_KEYS); - return executeUpdate(sql); - } - - @Override - public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { - checkClosed(); - return executeUpdate(sql); - } - - @Override - public int executeUpdate(String sql, String[] columnNames) throws SQLException { - checkClosed(); - return executeUpdate(sql); - } - - @Override - public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { - checkClosed(); - JdbcPreconditions.checkSqlFeatureSupported( - autoGeneratedKeys == java.sql.Statement.NO_GENERATED_KEYS, - JdbcConnection.ONLY_NO_GENERATED_KEYS); - return execute(sql); - } - - @Override - public boolean execute(String sql, int[] columnIndexes) throws SQLException { - checkClosed(); - return execute(sql); - } - - @Override - public boolean execute(String sql, String[] columnNames) throws SQLException { - checkClosed(); - return execute(sql); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcTypeConverter.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcTypeConverter.java deleted file mode 100644 index a11cb5e899a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/JdbcTypeConverter.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.ByteArray; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.Code; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.sql.Array; -import java.sql.SQLException; -import java.sql.Time; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.threeten.bp.Instant; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; - -/** Convenience class for converting values between Java, JDBC and Cloud Spanner. */ -class JdbcTypeConverter { - private static final DateTimeFormatter TIMESTAMP_FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME; - private static final Charset UTF8 = Charset.forName("UTF8"); - - /** - * Converts the given value from the Google {@link Type} to the Java {@link Class} type. The input - * value and the {@link Type} must be consistent with each other. - * - * @param value The value to convert. This value must be in the default type used for a Cloud - * Spanner database type. I.e. if the type argument is {@link Type#string()}, then the input - * value must be an instance of {@link java.lang.String}. - * @param type The type in the database. - * @param targetType The java class target type to convert to. - * @return The converted value. - * @throws SQLException if the given value cannot be converted to the specified type, or if the - * input value and input type are not consistent with each other. - */ - static Object convert(Object value, Type type, Class targetType) throws SQLException { - JdbcPreconditions.checkArgument(type != null, "type may not be null"); - JdbcPreconditions.checkArgument(targetType != null, "targetType may not be null"); - checkValidTypeAndValueForConvert(type, value); - - if (value == null) return null; - try { - if (targetType.equals(String.class)) { - if (type.getCode() == Code.BYTES) return new String((byte[]) value, UTF8); - if (type.getCode() == Code.TIMESTAMP) { - Timestamp timestamp = Timestamp.of((java.sql.Timestamp) value); - return TIMESTAMP_FORMAT.format( - ZonedDateTime.ofInstant( - Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()), - ZoneId.systemDefault())); - } - return value.toString(); - } - if (targetType.equals(byte[].class)) { - if (type.getCode() == Code.BYTES) return value; - if (type.getCode() == Code.STRING) return ((String) value).getBytes(UTF8); - } - if (targetType.equals(Boolean.class)) { - if (type.getCode() == Code.BOOL) return value; - if (type.getCode() == Code.INT64) return Boolean.valueOf((Long) value != 0); - if (type.getCode() == Code.FLOAT64) return Boolean.valueOf((Double) value != 0d); - } - if (targetType.equals(BigDecimal.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? BigDecimal.ONE : BigDecimal.ZERO; - if (type.getCode() == Code.INT64) return BigDecimal.valueOf((Long) value); - } - if (targetType.equals(Long.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? 1L : 0L; - if (type.getCode() == Code.INT64) return value; - } - if (targetType.equals(Integer.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? 1 : 0; - if (type.getCode() == Code.INT64) return AbstractJdbcWrapper.checkedCastToInt((Long) value); - } - if (targetType.equals(Short.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? 1 : 0; - if (type.getCode() == Code.INT64) - return AbstractJdbcWrapper.checkedCastToShort((Long) value); - } - if (targetType.equals(Byte.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? 1 : 0; - if (type.getCode() == Code.INT64) - return AbstractJdbcWrapper.checkedCastToByte((Long) value); - } - if (targetType.equals(BigInteger.class)) { - if (type.getCode() == Code.BOOL) return (Boolean) value ? BigInteger.ONE : BigInteger.ZERO; - if (type.getCode() == Code.INT64) return BigInteger.valueOf((Long) value); - } - if (targetType.equals(Float.class)) { - if (type.getCode() == Code.BOOL) - return (Boolean) value ? Float.valueOf(1f) : Float.valueOf(0f); - if (type.getCode() == Code.FLOAT64) - return AbstractJdbcWrapper.checkedCastToFloat((Double) value); - } - if (targetType.equals(Double.class)) { - if (type.getCode() == Code.BOOL) - return (Boolean) value ? Double.valueOf(1d) : Double.valueOf(0d); - if (type.getCode() == Code.FLOAT64) return value; - } - if (targetType.equals(java.sql.Date.class)) { - if (type.getCode() == Code.DATE) return value; - } - if (targetType.equals(java.sql.Timestamp.class)) { - if (type.getCode() == Code.TIMESTAMP) return value; - } - if (targetType.equals(java.sql.Array.class)) { - if (type.getCode() == Code.ARRAY) return value; - } - } catch (SQLException e) { - throw e; - } catch (Exception e) { - throw JdbcSqlExceptionFactory.of( - "Cannot convert " + value + " to " + targetType.getName(), - com.google.rpc.Code.INVALID_ARGUMENT, - e); - } - throw JdbcSqlExceptionFactory.of( - "Cannot convert " + type.getCode().name() + " to " + targetType.getName(), - com.google.rpc.Code.INVALID_ARGUMENT); - } - - private static void checkValidTypeAndValueForConvert(Type type, Object value) - throws SQLException { - if (value == null) return; - JdbcPreconditions.checkArgument( - (type.getCode() == Code.ARRAY && Array.class.isAssignableFrom(value.getClass())) - || type.getCode() != Code.ARRAY, - "input type is array, but input value is not an instance of java.sql.Array"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.BOOL && value.getClass().equals(Boolean.class)) - || type.getCode() != Code.BOOL, - "input type is bool, but input value is not an instance of Boolean"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.BYTES && value.getClass().equals(byte[].class)) - || type.getCode() != Code.BYTES, - "input type is bytes, but input value is not an instance of byte[]"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.DATE && value.getClass().equals(java.sql.Date.class)) - || type.getCode() != Code.DATE, - "input type is date, but input value is not an instance of java.sql.Date"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.FLOAT64 && value.getClass().equals(Double.class)) - || type.getCode() != Code.FLOAT64, - "input type is float64, but input value is not an instance of Double"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.INT64 && value.getClass().equals(Long.class)) - || type.getCode() != Code.INT64, - "input type is int64, but input value is not an instance of Long"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.STRING && value.getClass().equals(String.class)) - || type.getCode() != Code.STRING, - "input type is string, but input value is not an instance of String"); - JdbcPreconditions.checkArgument( - (type.getCode() == Code.TIMESTAMP && value.getClass().equals(java.sql.Timestamp.class)) - || type.getCode() != Code.TIMESTAMP, - "input type is timestamp, but input value is not an instance of java.sql.Timestamp"); - } - - @SuppressWarnings("deprecation") - static Date toGoogleDate(java.sql.Date date) { - return date == null - ? null - : Date.fromYearMonthDay(date.getYear() + 1900, date.getMonth() + 1, date.getDate()); - } - - static Date toGoogleDate(java.sql.Time date) { - return Date.fromYearMonthDay(1970, 1, 1); - } - - @SuppressWarnings("deprecation") - static Date toGoogleDate(java.sql.Timestamp date) { - return date == null - ? null - : Date.fromYearMonthDay(date.getYear() + 1900, date.getMonth() + 1, date.getDate()); - } - - static List toGoogleDates(java.sql.Date[] dates) { - List res = new ArrayList<>(dates.length); - for (int index = 0; index < dates.length; index++) res.add(toGoogleDate(dates[index])); - return res; - } - - static java.sql.Date toSqlDate(Date date) { - return toSqlDate(date, Calendar.getInstance()); - } - - static java.sql.Date toSqlDate(Date date, Calendar cal) { - if (date != null) { - cal.set(date.getYear(), date.getMonth() - 1, date.getDayOfMonth(), 0, 0, 0); - cal.clear(Calendar.MILLISECOND); - return new java.sql.Date(cal.getTimeInMillis()); - } - return null; - } - - static List toSqlDates(List dates) { - List res = new ArrayList<>(dates.size()); - for (Date date : dates) res.add(toSqlDate(date)); - return res; - } - - static java.sql.Timestamp toSqlTimestamp(Timestamp ts) { - return ts == null ? null : ts.toSqlTimestamp(); - } - - static java.sql.Timestamp getAsSqlTimestamp(Timestamp ts, Calendar cal) { - return ts == null ? null : getTimestampInCalendar(ts.toSqlTimestamp(), cal); - } - - static java.sql.Timestamp getTimestampInCalendar(java.sql.Timestamp sqlTs, Calendar cal) { - return getOrSetTimestampInCalendar(sqlTs, cal, GetOrSetTimestampInCalendar.GET); - } - - static java.sql.Timestamp setTimestampInCalendar(java.sql.Timestamp sqlTs, Calendar cal) { - return getOrSetTimestampInCalendar(sqlTs, cal, GetOrSetTimestampInCalendar.SET); - } - - private enum GetOrSetTimestampInCalendar { - GET, - SET; - } - - private static java.sql.Timestamp getOrSetTimestampInCalendar( - java.sql.Timestamp sqlTs, Calendar cal, GetOrSetTimestampInCalendar getOrSet) { - if (sqlTs != null) { - // Get a calendar in the requested timezone - Calendar newCal = Calendar.getInstance(cal.getTimeZone()); - // set the millisecond time on this calendar from the timestamp - newCal.setTimeInMillis(sqlTs.getTime()); - newCal.set(Calendar.MILLISECOND, 0); - // then shift the time of the calendar by the difference between UTC and the timezone of the - // given calendar - int offset = newCal.getTimeZone().getOffset(newCal.getTimeInMillis()); - newCal.add( - Calendar.MILLISECOND, getOrSet == GetOrSetTimestampInCalendar.GET ? offset : -offset); - // then use that to create a sql timestamp - java.sql.Timestamp res = new java.sql.Timestamp(newCal.getTimeInMillis()); - // set the nanosecond value that will also set the millisecond value of the timestamp - // as the nanosecond value contains all fraction of a second information - res.setNanos(sqlTs.getNanos()); - return res; - } - return null; - } - - static List toSqlTimestamps(List timestamps) { - List res = new ArrayList<>(timestamps.size()); - for (Timestamp timestamp : timestamps) { - res.add(toSqlTimestamp(timestamp)); - } - return res; - } - - static Timestamp toGoogleTimestamp(java.sql.Date ts) { - if (ts != null) { - long milliseconds = ts.getTime(); - long seconds = milliseconds / 1000l; - long nanos = (milliseconds - (seconds * 1000)) * 1000000; - return com.google.cloud.Timestamp.ofTimeSecondsAndNanos(seconds, (int) nanos); - } - return null; - } - - static Timestamp toGoogleTimestamp(java.sql.Time ts) { - if (ts != null) { - long milliseconds = ts.getTime(); - long seconds = milliseconds / 1000l; - long nanos = (milliseconds - (seconds * 1000)) * 1000000; - return com.google.cloud.Timestamp.ofTimeSecondsAndNanos(seconds, (int) nanos); - } - return null; - } - - static Timestamp toGoogleTimestamp(java.sql.Timestamp ts) { - if (ts != null) { - long milliseconds = ts.getTime(); - long seconds = milliseconds / 1000l; - int nanos = ts.getNanos(); - return com.google.cloud.Timestamp.ofTimeSecondsAndNanos(seconds, nanos); - } - return null; - } - - static List toGoogleTimestamps(java.sql.Timestamp[] timestamps) { - List res = new ArrayList<>(timestamps.length); - for (int index = 0; index < timestamps.length; index++) { - res.add(toGoogleTimestamp(timestamps[index])); - } - return res; - } - - @SuppressWarnings("deprecation") - static Time toSqlTime(Timestamp ts) { - if (ts != null) { - java.sql.Timestamp sqlTs = toSqlTimestamp(ts); - Time time = new Time(sqlTs.getHours(), sqlTs.getMinutes(), sqlTs.getSeconds()); - time.setTime( - time.getTime() + TimeUnit.MILLISECONDS.convert(sqlTs.getNanos(), TimeUnit.NANOSECONDS)); - return time; - } - return null; - } - - @SuppressWarnings("deprecation") - static Time toSqlTime(Timestamp ts, Calendar cal) { - if (ts != null) { - java.sql.Timestamp sqlTs = getAsSqlTimestamp(ts, cal); - Time time = new Time(sqlTs.getHours(), sqlTs.getMinutes(), sqlTs.getSeconds()); - time.setTime( - time.getTime() + TimeUnit.MILLISECONDS.convert(sqlTs.getNanos(), TimeUnit.NANOSECONDS)); - return time; - } - return null; - } - - static List toGoogleBytes(byte[][] bytes) { - List res = new ArrayList<>(bytes.length); - for (int index = 0; index < bytes.length; index++) { - res.add(bytes[index] == null ? null : ByteArray.copyFrom(bytes[index])); - } - return res; - } - - static List toJavaByteArrays(List bytes) { - List res = new ArrayList<>(bytes.size()); - for (ByteArray ba : bytes) { - res.add(ba == null ? null : ba.toByteArray()); - } - return res; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtil.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtil.java deleted file mode 100644 index 29166586740..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtil.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.client.util.DateTime; -import com.google.api.client.util.DateTime.SecondsAndNanos; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.protobuf.Duration; -import com.google.protobuf.util.Durations; -import java.util.concurrent.TimeUnit; - -/** - * Util class for parsing and converting ReadOnlyStaleness values to/from strings. This util is used - * to parse client side statements and values for read only staleness for read-only transactions on - * Cloud Spanner. - */ -class ReadOnlyStalenessUtil { - /** - * Parses an RFC3339 date/time value with nanosecond precision and returns this as a {@link - * Timestamp}. - */ - static Timestamp parseRfc3339(String str) throws SpannerException { - try { - SecondsAndNanos secondsAndNanos = DateTime.parseRfc3339ToSecondsAndNanos(str); - return Timestamp.ofTimeSecondsAndNanos( - secondsAndNanos.getSeconds(), secondsAndNanos.getNanos()); - } catch (NumberFormatException e) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, String.format("Invalid timestamp: %s", str), e); - } - } - - /** The abbreviations for time units that may be used for client side statements. */ - enum TimeUnitAbbreviation { - NANOSECONDS("ns", TimeUnit.NANOSECONDS), - MICROSECONDS("us", TimeUnit.MICROSECONDS), - MILLISECONDS("ms", TimeUnit.MILLISECONDS), - SECONDS("s", TimeUnit.SECONDS); - - private final String abbreviation; - private final TimeUnit unit; - - private TimeUnitAbbreviation(String abbreviation, TimeUnit unit) { - this.abbreviation = abbreviation; - this.unit = unit; - } - - String getAbbreviation() { - return abbreviation; - } - - TimeUnit getUnit() { - return unit; - } - } - - /** Get the abbreviation for the given {@link TimeUnit}. */ - static String getTimeUnitAbbreviation(TimeUnit unit) { - for (TimeUnitAbbreviation abb : TimeUnitAbbreviation.values()) { - if (abb.unit == unit) return abb.abbreviation; - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "Invalid option for time unit: " + unit); - } - - /** Get the {@link TimeUnit} corresponding with the given abbreviation. */ - static TimeUnit parseTimeUnit(String unit) { - for (TimeUnitAbbreviation abb : TimeUnitAbbreviation.values()) { - if (abb.abbreviation.equalsIgnoreCase(unit)) return abb.unit; - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "Invalid option for time unit: " + unit); - } - - /** - * Internal interface that is used to generalize getting a time duration from Cloud Spanner - * read-only staleness settings. - */ - static interface DurationValueGetter { - long getDuration(TimeUnit unit); - - boolean hasDuration(); - } - - static final class GetExactStaleness implements DurationValueGetter { - private final TimestampBound staleness; - - public GetExactStaleness(TimestampBound staleness) { - this.staleness = staleness; - } - - @Override - public long getDuration(TimeUnit unit) { - return staleness.getExactStaleness(unit); - } - - @Override - public boolean hasDuration() { - return staleness.getMode() == Mode.EXACT_STALENESS; - } - } - - static final class MaxStalenessGetter implements DurationValueGetter { - private final TimestampBound staleness; - - public MaxStalenessGetter(TimestampBound staleness) { - this.staleness = staleness; - } - - @Override - public long getDuration(TimeUnit unit) { - return staleness.getMaxStaleness(unit); - } - - @Override - public boolean hasDuration() { - return staleness.getMode() == Mode.MAX_STALENESS; - } - } - - static final class DurationGetter implements DurationValueGetter { - private final Duration duration; - - public DurationGetter(Duration duration) { - this.duration = duration; - } - - @Override - public long getDuration(TimeUnit unit) { - return durationToUnits(duration, unit); - } - - @Override - public boolean hasDuration() { - return duration.getNanos() > 0 || duration.getSeconds() > 0L; - } - } - - /** - * Converts a {@link TimestampBound} to a human readable string representation. - * - * @param staleness The staleness to convert - * @return a human readable representation of the staleness. - */ - static String timestampBoundToString(TimestampBound staleness) { - switch (staleness.getMode()) { - case STRONG: - return "STRONG"; - case READ_TIMESTAMP: - return "READ_TIMESTAMP " + staleness.getReadTimestamp().toString(); - case MIN_READ_TIMESTAMP: - return "MIN_READ_TIMESTAMP " + staleness.getMinReadTimestamp().toString(); - case EXACT_STALENESS: - return "EXACT_STALENESS " + durationToString(new GetExactStaleness(staleness)); - case MAX_STALENESS: - return "MAX_STALENESS " + durationToString(new MaxStalenessGetter(staleness)); - default: - throw new IllegalStateException("Unknown mode: " + staleness.getMode()); - } - } - - /** The {@link TimeUnit}s that are supported for timeout and staleness durations. */ - static final TimeUnit[] SUPPORTED_UNITS = - new TimeUnit[] { - TimeUnit.SECONDS, TimeUnit.MILLISECONDS, TimeUnit.MICROSECONDS, TimeUnit.NANOSECONDS - }; - - /** - * Converts a duration value to a human readable string. The method will search for the most - * appropriate {@link TimeUnit} to use to represent the value. - * - * @param function The function that should be called to get the duration in a specific {@link - * TimeUnit}. - * @return a human readable value of the duration. - */ - static String durationToString(DurationValueGetter function) { - TimeUnit unit = getAppropriateTimeUnit(function); - return String.valueOf(function.getDuration(unit)) + getTimeUnitAbbreviation(unit); - } - - /** - * Calculates the most appropriate {@link TimeUnit} to use to represent the duration that is - * returned by the given function. The most appropriate {@link TimeUnit} is the unit with the - * least precision that still retains all information of the given input. - * - * @param durationGetter The function that will return the duration in different {@link - * TimeUnit}s. - * @return the most appropriate {@link TimeUnit} to represent the duration. - */ - static TimeUnit getAppropriateTimeUnit(DurationValueGetter durationGetter) { - int index = 0; - if (durationGetter.hasDuration()) { - for (TimeUnit unit : SUPPORTED_UNITS) { - long duration = durationGetter.getDuration(unit); - if (index + 1 < SUPPORTED_UNITS.length) { - if (duration > 0L - && duration * 1000 == durationGetter.getDuration(SUPPORTED_UNITS[index + 1])) { - return unit; - } - } else { - // last unit, we have to use this one - return unit; - } - index++; - } - throw new IllegalStateException("Unsupported duration"); - } - return TimeUnit.NANOSECONDS; - } - - /** Converts a value into a duration using the specified {@link TimeUnit}. */ - static Duration createDuration(long num, TimeUnit units) { - switch (units) { - case NANOSECONDS: - return Durations.fromNanos(num); - case MICROSECONDS: - return Durations.fromMicros(num); - case MILLISECONDS: - return Durations.fromMillis(num); - case SECONDS: - return Durations.fromSeconds(num); - default: - return Durations.fromMillis(units.toMillis(num)); - } - } - - /** Converts a duration to a number using the specified {@link TimeUnit}. */ - static long durationToUnits(Duration duration, TimeUnit units) { - switch (units) { - case NANOSECONDS: - return Durations.toNanos(duration); - case MICROSECONDS: - return Durations.toMicros(duration); - case MILLISECONDS: - return Durations.toMillis(duration); - case SECONDS: - return Durations.toSeconds(duration); - default: - throw new IllegalArgumentException(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyTransaction.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyTransaction.java deleted file mode 100644 index e0c40897003..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadOnlyTransaction.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ReadContext; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; - -/** - * Transaction that is used when a {@link Connection} is in read-only mode or when the transaction - * mode is set to read-only. This transaction can only be used to execute queries. - */ -class ReadOnlyTransaction extends AbstractMultiUseTransaction { - private final DatabaseClient dbClient; - private final TimestampBound readOnlyStaleness; - private com.google.cloud.spanner.ReadOnlyTransaction transaction; - private UnitOfWorkState state = UnitOfWorkState.STARTED; - - static class Builder extends AbstractBaseUnitOfWork.Builder { - private DatabaseClient dbClient; - private TimestampBound readOnlyStaleness; - - private Builder() {} - - Builder setDatabaseClient(DatabaseClient client) { - Preconditions.checkNotNull(client); - this.dbClient = client; - return this; - } - - Builder setReadOnlyStaleness(TimestampBound staleness) { - Preconditions.checkNotNull(staleness); - this.readOnlyStaleness = staleness; - return this; - } - - @Override - ReadOnlyTransaction build() { - Preconditions.checkState(dbClient != null, "No DatabaseClient client specified"); - Preconditions.checkState(readOnlyStaleness != null, "No ReadOnlyStaleness specified"); - return new ReadOnlyTransaction(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private ReadOnlyTransaction(Builder builder) { - super(builder); - this.dbClient = builder.dbClient; - this.readOnlyStaleness = builder.readOnlyStaleness; - } - - @Override - public UnitOfWorkState getState() { - return this.state; - } - - @Override - public boolean isReadOnly() { - return true; - } - - @Override - void checkValidTransaction() { - if (transaction == null) { - transaction = dbClient.readOnlyTransaction(readOnlyStaleness); - } - } - - @Override - ReadContext getReadContext() { - ConnectionPreconditions.checkState(transaction != null, "Missing read-only transaction"); - return transaction; - } - - @Override - public Timestamp getReadTimestamp() { - ConnectionPreconditions.checkState( - transaction != null, "There is no read timestamp available for this transaction."); - ConnectionPreconditions.checkState( - state != UnitOfWorkState.ROLLED_BACK, "This transaction was rolled back"); - return transaction.getReadTimestamp(); - } - - @Override - public Timestamp getReadTimestampOrNull() { - if (transaction != null && state != UnitOfWorkState.ROLLED_BACK) { - try { - return transaction.getReadTimestamp(); - } catch (SpannerException e) { - // ignore - } - } - return null; - } - - @Override - public Timestamp getCommitTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "There is no commit timestamp available for this transaction."); - } - - @Override - public Timestamp getCommitTimestampOrNull() { - return null; - } - - @Override - public void executeDdl(ParsedStatement ddl) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "DDL statements are not allowed for read-only transactions"); - } - - @Override - public long executeUpdate(ParsedStatement update) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "Update statements are not allowed for read-only transactions"); - } - - @Override - public long[] executeBatchUpdate(Iterable updates) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Batch updates are not allowed for read-only transactions."); - } - - @Override - public void write(Mutation mutation) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Mutations are not allowed for read-only transactions"); - } - - @Override - public void write(Iterable mutations) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Mutations are not allowed for read-only transactions"); - } - - @Override - public void commit() { - if (this.transaction != null) { - this.transaction.close(); - } - this.state = UnitOfWorkState.COMMITTED; - } - - @Override - public void rollback() { - if (this.transaction != null) { - this.transaction.close(); - } - this.state = UnitOfWorkState.ROLLED_BACK; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadWriteTransaction.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadWriteTransaction.java deleted file mode 100644 index a9fcbc53883..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReadWriteTransaction.java +++ /dev/null @@ -1,762 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedDueToConcurrentModificationException; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.TransactionRetryListener.RetryResult; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Transaction that is used when a {@link Connection} is normal read/write mode (i.e. not autocommit - * and not read-only). These transactions can be automatically retried if an {@link - * AbortedException} is thrown. The transaction will keep track of a running checksum of all {@link - * ResultSet}s that have been returned, and the update counts returned by any DML statement executed - * during the transaction. As long as these checksums and update counts are equal for both the - * original transaction and the retried transaction, the retry can safely be assumed to have the - * exact same results as the original transaction. - */ -class ReadWriteTransaction extends AbstractMultiUseTransaction { - private static final Logger logger = Logger.getLogger(ReadWriteTransaction.class.getName()); - private static final AtomicLong ID_GENERATOR = new AtomicLong(); - private static final String MAX_INTERNAL_RETRIES_EXCEEDED = - "Internal transaction retry maximum exceeded"; - private static final int MAX_INTERNAL_RETRIES = 50; - private final long transactionId; - private final DatabaseClient dbClient; - private TransactionManager txManager; - private final boolean retryAbortsInternally; - private int transactionRetryAttempts; - private int successfulRetries; - private final List transactionRetryListeners; - private volatile TransactionContext txContext; - private volatile UnitOfWorkState state = UnitOfWorkState.STARTED; - private boolean timedOutOrCancelled = false; - private final List statements = new ArrayList<>(); - private final List mutations = new ArrayList<>(); - private Timestamp transactionStarted; - - static class Builder extends AbstractMultiUseTransaction.Builder { - private DatabaseClient dbClient; - private Boolean retryAbortsInternally; - private List transactionRetryListeners; - - private Builder() {} - - Builder setDatabaseClient(DatabaseClient client) { - Preconditions.checkNotNull(client); - this.dbClient = client; - return this; - } - - Builder setRetryAbortsInternally(boolean retryAbortsInternally) { - this.retryAbortsInternally = retryAbortsInternally; - return this; - } - - Builder setTransactionRetryListeners(List listeners) { - Preconditions.checkNotNull(listeners); - this.transactionRetryListeners = listeners; - return this; - } - - @Override - ReadWriteTransaction build() { - Preconditions.checkState(dbClient != null, "No DatabaseClient client specified"); - Preconditions.checkState( - retryAbortsInternally != null, "RetryAbortsInternally is not specified"); - Preconditions.checkState( - transactionRetryListeners != null, "TransactionRetryListeners are not specified"); - return new ReadWriteTransaction(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private ReadWriteTransaction(Builder builder) { - super(builder); - this.transactionId = ID_GENERATOR.incrementAndGet(); - this.dbClient = builder.dbClient; - this.retryAbortsInternally = builder.retryAbortsInternally; - this.transactionRetryListeners = builder.transactionRetryListeners; - this.txManager = dbClient.transactionManager(); - } - - @Override - public String toString() { - return new StringBuilder() - .append("ReadWriteTransaction - ID: ") - .append(transactionId) - .append("; Status: ") - .append(internalGetStateName()) - .append("; Started: ") - .append(internalGetTimeStarted()) - .append("; Retry attempts: ") - .append(transactionRetryAttempts) - .append("; Successful retries: ") - .append(successfulRetries) - .toString(); - } - - private String internalGetStateName() { - return transactionStarted == null ? "Not yet started" : getState().toString(); - } - - private String internalGetTimeStarted() { - return transactionStarted == null ? "Not yet started" : transactionStarted.toString(); - } - - @Override - public UnitOfWorkState getState() { - return this.state; - } - - @Override - public boolean isReadOnly() { - return false; - } - - @Override - void checkValidTransaction() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, - "This transaction has status " - + state.name() - + ", only " - + UnitOfWorkState.STARTED - + " is allowed."); - ConnectionPreconditions.checkState( - !timedOutOrCancelled, - "The last statement of this transaction timed out or was cancelled. " - + "The transaction is no longer usable. " - + "Rollback the transaction and start a new one."); - if (txManager.getState() == null) { - transactionStarted = Timestamp.now(); - txContext = txManager.begin(); - } - if (txManager.getState() - != com.google.cloud.spanner.TransactionManager.TransactionState.STARTED) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - String.format("Invalid transaction state: %s", txManager.getState())); - } - } - - @Override - TransactionContext getReadContext() { - ConnectionPreconditions.checkState(txContext != null, "Missing transaction context"); - return txContext; - } - - @Override - public Timestamp getReadTimestamp() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "There is no read timestamp available for read/write transactions."); - } - - @Override - public Timestamp getReadTimestampOrNull() { - return null; - } - - private boolean hasCommitTimestamp() { - return txManager.getState() - == com.google.cloud.spanner.TransactionManager.TransactionState.COMMITTED; - } - - @Override - public Timestamp getCommitTimestamp() { - ConnectionPreconditions.checkState(hasCommitTimestamp(), "This transaction has not committed."); - return txManager.getCommitTimestamp(); - } - - @Override - public Timestamp getCommitTimestampOrNull() { - return hasCommitTimestamp() ? txManager.getCommitTimestamp() : null; - } - - @Override - public void executeDdl(ParsedStatement ddl) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "DDL-statements are not allowed inside a read/write transaction."); - } - - private void handlePossibleInvalidatingException(SpannerException e) { - if (e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED - || e.getErrorCode() == ErrorCode.CANCELLED) { - this.timedOutOrCancelled = true; - } - } - - @Override - public ResultSet executeQuery( - final ParsedStatement statement, - final AnalyzeMode analyzeMode, - final QueryOption... options) { - Preconditions.checkArgument(statement.isQuery(), "Statement is not a query"); - checkValidTransaction(); - try { - if (retryAbortsInternally) { - return asyncExecuteStatement( - statement, - new Callable() { - @Override - public ResultSet call() throws Exception { - return runWithRetry( - new Callable() { - @Override - public ResultSet call() throws Exception { - try { - getStatementExecutor() - .invokeInterceptors( - statement, - StatementExecutionStep.EXECUTE_STATEMENT, - ReadWriteTransaction.this); - ResultSet delegate = - DirectExecuteResultSet.ofResultSet( - internalExecuteQuery(statement, analyzeMode, options)); - return createAndAddRetryResultSet( - delegate, statement, analyzeMode, options); - } catch (AbortedException e) { - throw e; - } catch (SpannerException e) { - createAndAddFailedQuery(e, statement, analyzeMode, options); - throw e; - } - } - }); - } - }, - InterceptorsUsage - .IGNORE_INTERCEPTORS); // ignore interceptors here as they are invoked in the - // Callable. - } else { - return super.executeQuery(statement, analyzeMode, options); - } - } catch (SpannerException e) { - handlePossibleInvalidatingException(e); - throw e; - } - } - - @Override - public long executeUpdate(final ParsedStatement update) { - Preconditions.checkNotNull(update); - Preconditions.checkArgument(update.isUpdate(), "The statement is not an update statement"); - checkValidTransaction(); - try { - if (retryAbortsInternally) { - return asyncExecuteStatement( - update, - new Callable() { - @Override - public Long call() throws Exception { - return runWithRetry( - new Callable() { - @Override - public Long call() throws Exception { - try { - getStatementExecutor() - .invokeInterceptors( - update, - StatementExecutionStep.EXECUTE_STATEMENT, - ReadWriteTransaction.this); - long updateCount = txContext.executeUpdate(update.getStatement()); - createAndAddRetriableUpdate(update, updateCount); - return updateCount; - } catch (AbortedException e) { - throw e; - } catch (SpannerException e) { - createAndAddFailedUpdate(e, update); - throw e; - } - } - }); - } - }, - InterceptorsUsage - .IGNORE_INTERCEPTORS); // ignore interceptors here as they are invoked in the - // Callable. - } else { - return asyncExecuteStatement( - update, - new Callable() { - @Override - public Long call() throws Exception { - return txContext.executeUpdate(update.getStatement()); - } - }); - } - } catch (SpannerException e) { - handlePossibleInvalidatingException(e); - throw e; - } - } - - /** - * Create a RUN BATCH statement to use with the {@link #executeBatchUpdate(Iterable)} method to - * allow it to be cancelled, time out or retried. - * - *

{@link ReadWriteTransaction} uses the generic methods {@link #executeAsync(ParsedStatement, - * Callable)} and {@link #runWithRetry(Callable)} to allow statements to be cancelled, to timeout - * and to be retried. These methods require a {@link ParsedStatement} as input. When the {@link - * #executeBatchUpdate(Iterable)} method is called, we do not have one {@link ParsedStatement}, - * and the method uses this statement instead in order to use the same logic as the other - * statements. - */ - static final ParsedStatement EXECUTE_BATCH_UPDATE_STATEMENT = - StatementParser.INSTANCE.parse(Statement.of("RUN BATCH")); - - @Override - public long[] executeBatchUpdate(final Iterable updates) { - Preconditions.checkNotNull(updates); - final List updateStatements = new LinkedList<>(); - for (ParsedStatement update : updates) { - Preconditions.checkArgument( - update.isUpdate(), - "Statement is not an update statement: " + update.getSqlWithoutComments()); - updateStatements.add(update.getStatement()); - } - checkValidTransaction(); - try { - if (retryAbortsInternally) { - return asyncExecuteStatement( - EXECUTE_BATCH_UPDATE_STATEMENT, - new Callable() { - @Override - public long[] call() throws Exception { - return runWithRetry( - new Callable() { - @Override - public long[] call() throws Exception { - try { - getStatementExecutor() - .invokeInterceptors( - EXECUTE_BATCH_UPDATE_STATEMENT, - StatementExecutionStep.EXECUTE_STATEMENT, - ReadWriteTransaction.this); - long[] updateCounts = txContext.batchUpdate(updateStatements); - createAndAddRetriableBatchUpdate(updateStatements, updateCounts); - return updateCounts; - } catch (AbortedException e) { - throw e; - } catch (SpannerException e) { - createAndAddFailedBatchUpdate(e, updateStatements); - throw e; - } - } - }); - } - }, - InterceptorsUsage - .IGNORE_INTERCEPTORS); // ignore interceptors here as they are invoked in the - // Callable. - } else { - return asyncExecuteStatement( - EXECUTE_BATCH_UPDATE_STATEMENT, - new Callable() { - @Override - public long[] call() throws Exception { - return txContext.batchUpdate(updateStatements); - } - }); - } - } catch (SpannerException e) { - handlePossibleInvalidatingException(e); - throw e; - } - } - - @Override - public void write(Mutation mutation) { - Preconditions.checkNotNull(mutation); - checkValidTransaction(); - mutations.add(mutation); - } - - @Override - public void write(Iterable mutations) { - Preconditions.checkNotNull(mutations); - checkValidTransaction(); - for (Mutation mutation : mutations) { - this.mutations.add(checkNotNull(mutation)); - } - } - - /** - * Create a COMMIT statement to use with the {@link #commit()} method to allow it to be cancelled, - * time out or retried. - * - *

{@link ReadWriteTransaction} uses the generic methods {@link #executeAsync(ParsedStatement, - * Callable)} and {@link #runWithRetry(Callable)} to allow statements to be cancelled, to timeout - * and to be retried. These methods require a {@link ParsedStatement} as input. When the {@link - * #commit()} method is called directly, we do not have a {@link ParsedStatement}, and the method - * uses this statement instead in order to use the same logic as the other statements. - */ - private static final ParsedStatement COMMIT_STATEMENT = - StatementParser.INSTANCE.parse(Statement.of("COMMIT")); - - private final Callable commitCallable = - new Callable() { - @Override - public Void call() throws Exception { - txContext.buffer(mutations); - txManager.commit(); - return null; - } - }; - - @Override - public void commit() { - checkValidTransaction(); - try { - if (retryAbortsInternally) { - asyncExecuteStatement( - COMMIT_STATEMENT, - new Callable() { - @Override - public Void call() throws Exception { - return runWithRetry( - new Callable() { - @Override - public Void call() throws Exception { - getStatementExecutor() - .invokeInterceptors( - COMMIT_STATEMENT, - StatementExecutionStep.EXECUTE_STATEMENT, - ReadWriteTransaction.this); - commitCallable.call(); - return null; - } - }); - } - }, - InterceptorsUsage.IGNORE_INTERCEPTORS); - } else { - asyncExecuteStatement(COMMIT_STATEMENT, commitCallable); - } - ReadWriteTransaction.this.state = UnitOfWorkState.COMMITTED; - } catch (SpannerException e) { - try { - txManager.close(); - } catch (Throwable t) { - // ignore - } - this.state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } - } - - /** - * Executes a database call that could throw an {@link AbortedException}. If an {@link - * AbortedException} is thrown, the transaction will automatically be retried and the checksums of - * all {@link ResultSet}s and update counts of DML statements will be checked against the original - * values of the original transaction. If the checksums and/or update counts do not match, the - * method will throw an {@link AbortedException} that cannot be retried, as the underlying data - * have actually changed. - * - *

If {@link ReadWriteTransaction#retryAbortsInternally} has been set to false, - * this method will throw an exception instead of retrying the transaction if the transaction was - * aborted. - * - * @param callable The actual database calls. - * @return the results of the database calls. - * @throws SpannerException if the database calls threw an exception, an {@link - * AbortedDueToConcurrentModificationException} if a retry of the transaction yielded - * different results than the original transaction, or an {@link AbortedException} if the - * maximum number of retries has been exceeded. - */ - T runWithRetry(Callable callable) throws SpannerException { - while (true) { - try { - return callable.call(); - } catch (final AbortedException aborted) { - if (retryAbortsInternally) { - handleAborted(aborted); - } else { - throw aborted; - } - } catch (SpannerException e) { - throw e; - } catch (Exception e) { - throw SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, e.getMessage(), e); - } - } - } - - /** - * Registers a {@link ResultSet} on this transaction that must be checked during a retry, and - * returns a retryable {@link ResultSet}. - */ - private ResultSet createAndAddRetryResultSet( - ResultSet resultSet, - ParsedStatement statement, - AnalyzeMode analyzeMode, - QueryOption... options) { - if (retryAbortsInternally) { - ChecksumResultSet checksumResultSet = - createChecksumResultSet(resultSet, statement, analyzeMode, options); - addRetryStatement(checksumResultSet); - return checksumResultSet; - } - return resultSet; - } - - /** Registers the statement as a query that should return an error during a retry. */ - private void createAndAddFailedQuery( - SpannerException e, - ParsedStatement statement, - AnalyzeMode analyzeMode, - QueryOption... options) { - if (retryAbortsInternally) { - addRetryStatement(new FailedQuery(this, e, statement, analyzeMode, options)); - } - } - - private void createAndAddRetriableUpdate(ParsedStatement update, long updateCount) { - if (retryAbortsInternally) { - addRetryStatement(new RetriableUpdate(this, update, updateCount)); - } - } - - private void createAndAddRetriableBatchUpdate(Iterable updates, long[] updateCounts) { - if (retryAbortsInternally) { - addRetryStatement(new RetriableBatchUpdate(this, updates, updateCounts)); - } - } - - /** Registers the statement as an update that should return an error during a retry. */ - private void createAndAddFailedUpdate(SpannerException e, ParsedStatement update) { - if (retryAbortsInternally) { - addRetryStatement(new FailedUpdate(this, e, update)); - } - } - - /** Registers the statements as a batch of updates that should return an error during a retry. */ - private void createAndAddFailedBatchUpdate(SpannerException e, Iterable updates) { - if (retryAbortsInternally) { - addRetryStatement(new FailedBatchUpdate(this, e, updates)); - } - } - - /** - * Adds a statement to the list of statements that should be retried if this transaction aborts. - */ - private void addRetryStatement(RetriableStatement statement) { - Preconditions.checkState( - retryAbortsInternally, "retryAbortsInternally is not enabled for this transaction"); - statements.add(statement); - } - - /** - * Handles an aborted exception by checking whether the transaction may be retried internally, and - * if so, does the retry. If retry is not allowed, or if the retry fails, the method will throw an - * {@link AbortedException}. - */ - private void handleAborted(AbortedException aborted) { - if (transactionRetryAttempts >= MAX_INTERNAL_RETRIES) { - // If the same statement in transaction keeps aborting, then we need to abort here. - throwAbortWithRetryAttemptsExceeded(); - } else if (retryAbortsInternally) { - logger.fine(toString() + ": Starting internal transaction retry"); - while (true) { - // First back off and then restart the transaction. - try { - Thread.sleep(aborted.getRetryDelayInMillis() / 1000); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.CANCELLED, "The statement was cancelled"); - } - try { - txContext = txManager.resetForRetry(); - // Inform listeners about the transaction retry that is about to start. - invokeTransactionRetryListenersOnStart(); - // Then retry all transaction statements. - transactionRetryAttempts++; - for (RetriableStatement statement : statements) { - statement.retry(aborted); - } - successfulRetries++; - invokeTransactionRetryListenersOnFinish(RetryResult.RETRY_SUCCESSFUL); - logger.fine( - toString() - + ": Internal transaction retry succeeded. Starting retry of original statement."); - // Retry succeeded, return and continue the original transaction. - break; - } catch (AbortedDueToConcurrentModificationException e) { - // Retry failed because of a concurrent modification, we have to abort. - invokeTransactionRetryListenersOnFinish( - RetryResult.RETRY_ABORTED_DUE_TO_CONCURRENT_MODIFICATION); - logger.fine( - toString() + ": Internal transaction retry aborted due to a concurrent modification"); - // Try to rollback the new transaction and ignore any exceptions. - try { - txManager.rollback(); - } catch (Throwable t) { - // ignore - } - this.state = UnitOfWorkState.ABORTED; - throw e; - } catch (AbortedException e) { - // Retry aborted, do another retry of the transaction. - if (transactionRetryAttempts >= MAX_INTERNAL_RETRIES) { - throwAbortWithRetryAttemptsExceeded(); - } - invokeTransactionRetryListenersOnFinish(RetryResult.RETRY_ABORTED_AND_RESTARTING); - logger.fine(toString() + ": Internal transaction retry aborted, trying again"); - } catch (SpannerException e) { - // unexpected exception - logger.log( - Level.FINE, - toString() + ": Internal transaction retry failed due to an unexpected exception", - e); - // Try to rollback the new transaction and ignore any exceptions. - try { - txManager.rollback(); - } catch (Throwable t) { - // ignore - } - // Set transaction state to aborted as the retry failed. - this.state = UnitOfWorkState.ABORTED; - // Re-throw underlying exception. - throw e; - } - } - } else { - try { - txManager.close(); - } catch (Throwable t) { - // ignore - } - // Internal retry is not enabled. - this.state = UnitOfWorkState.ABORTED; - throw aborted; - } - } - - private void throwAbortWithRetryAttemptsExceeded() throws SpannerException { - invokeTransactionRetryListenersOnFinish(RetryResult.RETRY_ABORTED_AND_MAX_ATTEMPTS_EXCEEDED); - logger.fine( - toString() - + ": Internal transaction retry aborted and max number of retry attempts has been exceeded"); - // Try to rollback the transaction and ignore any exceptions. - // Normally it should not be necessary to do this, but in order to be sure we never leak - // any sessions it is better to do so. - try { - txManager.rollback(); - } catch (Throwable t) { - // ignore - } - this.state = UnitOfWorkState.ABORTED; - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.ABORTED, MAX_INTERNAL_RETRIES_EXCEEDED); - } - - private void invokeTransactionRetryListenersOnStart() { - for (TransactionRetryListener listener : transactionRetryListeners) { - listener.retryStarting(transactionStarted, transactionId, transactionRetryAttempts); - } - } - - private void invokeTransactionRetryListenersOnFinish(RetryResult result) { - for (TransactionRetryListener listener : transactionRetryListeners) { - listener.retryFinished(transactionStarted, transactionId, transactionRetryAttempts, result); - } - } - - /** The {@link Statement} and {@link Callable} for rollbacks */ - private final ParsedStatement rollbackStatement = - StatementParser.INSTANCE.parse(Statement.of("ROLLBACK")); - - private final Callable rollbackCallable = - new Callable() { - @Override - public Void call() throws Exception { - txManager.rollback(); - return null; - } - }; - - @Override - public void rollback() { - ConnectionPreconditions.checkState( - state == UnitOfWorkState.STARTED, "This transaction has status " + state.name()); - try { - asyncExecuteStatement(rollbackStatement, rollbackCallable); - } finally { - // Whatever happens, we should always call close in order to return the underlying session to - // the session pool to avoid any session leaks. - try { - txManager.close(); - } catch (Throwable e) { - // ignore - } - this.state = UnitOfWorkState.ROLLED_BACK; - } - } - - /** - * A retriable statement is a query or DML statement during a read/write transaction that can be - * retried if the original transaction aborted. - */ - interface RetriableStatement { - /** - * Retry this statement in a new transaction. Throws an {@link - * AbortedDueToConcurrentModificationException} if the retry could not successfully be executed - * because of an actual concurrent modification of the underlying data. This {@link - * AbortedDueToConcurrentModificationException} cannot be retried. - */ - void retry(AbortedException aborted) throws AbortedException; - } - - /** Creates a {@link ChecksumResultSet} for this {@link ReadWriteTransaction}. */ - @VisibleForTesting - ChecksumResultSet createChecksumResultSet( - ResultSet delegate, - ParsedStatement statement, - AnalyzeMode analyzeMode, - QueryOption... options) { - return new ChecksumResultSet(this, delegate, statement, analyzeMode, options); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSet.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSet.java deleted file mode 100644 index 0a72b36951c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSet.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.ByteArray; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.common.base.Preconditions; -import com.google.spanner.v1.ResultSetStats; -import java.util.List; - -/** - * Forwarding implementation of {@link ResultSet} that forwards all calls to a delegate that can be - * replaced. This is used by the JDBC Driver when a read/write transaction is successfully retried. - * Any {@link ResultSet} that is open during a transaction retry, must be replaced by a result set - * that is fetched using the new transaction. This is achieved by wrapping the returned result sets - * in a {@link ReplaceableForwardingResultSet} that replaces its delegate after a transaction retry. - */ -class ReplaceableForwardingResultSet implements ResultSet { - private ResultSet delegate; - private boolean closed; - - ReplaceableForwardingResultSet(ResultSet delegate) { - this.delegate = Preconditions.checkNotNull(delegate); - } - - /** Replace the underlying delegate {@link ResultSet} with a new one. */ - void replaceDelegate(ResultSet delegate) { - Preconditions.checkNotNull(delegate); - checkClosed(); - if (this.delegate != null) { - this.delegate.close(); - } - this.delegate = delegate; - } - - private void checkClosed() { - if (closed) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "This ResultSet is closed"); - } - } - - boolean isClosed() { - return closed; - } - - @Override - public boolean next() throws SpannerException { - checkClosed(); - return delegate.next(); - } - - @Override - public Struct getCurrentRowAsStruct() { - checkClosed(); - return delegate.getCurrentRowAsStruct(); - } - - @Override - public void close() { - if (delegate != null) { - delegate.close(); - delegate = null; - } - closed = true; - } - - @Override - public ResultSetStats getStats() { - checkClosed(); - return delegate.getStats(); - } - - @Override - public Type getType() { - checkClosed(); - return delegate.getType(); - } - - @Override - public int getColumnCount() { - checkClosed(); - return delegate.getColumnCount(); - } - - @Override - public int getColumnIndex(String columnName) { - checkClosed(); - return delegate.getColumnIndex(columnName); - } - - @Override - public Type getColumnType(int columnIndex) { - checkClosed(); - return delegate.getColumnType(columnIndex); - } - - @Override - public Type getColumnType(String columnName) { - checkClosed(); - return delegate.getColumnType(columnName); - } - - @Override - public boolean isNull(int columnIndex) { - checkClosed(); - return delegate.isNull(columnIndex); - } - - @Override - public boolean isNull(String columnName) { - checkClosed(); - return delegate.isNull(columnName); - } - - @Override - public boolean getBoolean(int columnIndex) { - checkClosed(); - return delegate.getBoolean(columnIndex); - } - - @Override - public boolean getBoolean(String columnName) { - checkClosed(); - return delegate.getBoolean(columnName); - } - - @Override - public long getLong(int columnIndex) { - checkClosed(); - return delegate.getLong(columnIndex); - } - - @Override - public long getLong(String columnName) { - checkClosed(); - return delegate.getLong(columnName); - } - - @Override - public double getDouble(int columnIndex) { - checkClosed(); - return delegate.getDouble(columnIndex); - } - - @Override - public double getDouble(String columnName) { - checkClosed(); - return delegate.getDouble(columnName); - } - - @Override - public String getString(int columnIndex) { - checkClosed(); - return delegate.getString(columnIndex); - } - - @Override - public String getString(String columnName) { - checkClosed(); - return delegate.getString(columnName); - } - - @Override - public ByteArray getBytes(int columnIndex) { - checkClosed(); - return delegate.getBytes(columnIndex); - } - - @Override - public ByteArray getBytes(String columnName) { - checkClosed(); - return delegate.getBytes(columnName); - } - - @Override - public Timestamp getTimestamp(int columnIndex) { - checkClosed(); - return delegate.getTimestamp(columnIndex); - } - - @Override - public Timestamp getTimestamp(String columnName) { - checkClosed(); - return delegate.getTimestamp(columnName); - } - - @Override - public Date getDate(int columnIndex) { - checkClosed(); - return delegate.getDate(columnIndex); - } - - @Override - public Date getDate(String columnName) { - checkClosed(); - return delegate.getDate(columnName); - } - - @Override - public boolean[] getBooleanArray(int columnIndex) { - checkClosed(); - return delegate.getBooleanArray(columnIndex); - } - - @Override - public boolean[] getBooleanArray(String columnName) { - checkClosed(); - return delegate.getBooleanArray(columnName); - } - - @Override - public List getBooleanList(int columnIndex) { - checkClosed(); - return delegate.getBooleanList(columnIndex); - } - - @Override - public List getBooleanList(String columnName) { - checkClosed(); - return delegate.getBooleanList(columnName); - } - - @Override - public long[] getLongArray(int columnIndex) { - checkClosed(); - return delegate.getLongArray(columnIndex); - } - - @Override - public long[] getLongArray(String columnName) { - checkClosed(); - return delegate.getLongArray(columnName); - } - - @Override - public List getLongList(int columnIndex) { - checkClosed(); - return delegate.getLongList(columnIndex); - } - - @Override - public List getLongList(String columnName) { - checkClosed(); - return delegate.getLongList(columnName); - } - - @Override - public double[] getDoubleArray(int columnIndex) { - checkClosed(); - return delegate.getDoubleArray(columnIndex); - } - - @Override - public double[] getDoubleArray(String columnName) { - checkClosed(); - return delegate.getDoubleArray(columnName); - } - - @Override - public List getDoubleList(int columnIndex) { - checkClosed(); - return delegate.getDoubleList(columnIndex); - } - - @Override - public List getDoubleList(String columnName) { - checkClosed(); - return delegate.getDoubleList(columnName); - } - - @Override - public List getStringList(int columnIndex) { - checkClosed(); - return delegate.getStringList(columnIndex); - } - - @Override - public List getStringList(String columnName) { - checkClosed(); - return delegate.getStringList(columnName); - } - - @Override - public List getBytesList(int columnIndex) { - checkClosed(); - return delegate.getBytesList(columnIndex); - } - - @Override - public List getBytesList(String columnName) { - checkClosed(); - return delegate.getBytesList(columnName); - } - - @Override - public List getTimestampList(int columnIndex) { - checkClosed(); - return delegate.getTimestampList(columnIndex); - } - - @Override - public List getTimestampList(String columnName) { - checkClosed(); - return delegate.getTimestampList(columnName); - } - - @Override - public List getDateList(int columnIndex) { - checkClosed(); - return delegate.getDateList(columnIndex); - } - - @Override - public List getDateList(String columnName) { - checkClosed(); - return delegate.getDateList(columnName); - } - - @Override - public List getStructList(int columnIndex) { - checkClosed(); - return delegate.getStructList(columnIndex); - } - - @Override - public List getStructList(String columnName) { - checkClosed(); - return delegate.getStructList(columnName); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableBatchUpdate.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableBatchUpdate.java deleted file mode 100644 index 73609e8ba62..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableBatchUpdate.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.common.base.Preconditions; -import java.util.Arrays; - -/** - * Retriable batch of DML statements. The check whether the statements had the same effect during - * retry is done by comparing the number of records affected. - */ -final class RetriableBatchUpdate implements RetriableStatement { - private final ReadWriteTransaction transaction; - private final Iterable statements; - private final long[] updateCounts; - - RetriableBatchUpdate( - ReadWriteTransaction transaction, Iterable statements, long[] updateCounts) { - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(statements); - this.transaction = transaction; - this.statements = statements; - this.updateCounts = updateCounts; - } - - @Override - public void retry(AbortedException aborted) throws AbortedException { - long[] newCount = null; - try { - transaction - .getStatementExecutor() - .invokeInterceptors( - ReadWriteTransaction.EXECUTE_BATCH_UPDATE_STATEMENT, - StatementExecutionStep.RETRY_STATEMENT, - transaction); - newCount = transaction.getReadContext().batchUpdate(statements); - } catch (AbortedException e) { - // Just re-throw the AbortedException and let the retry logic determine whether another try - // should be executed or not. - throw e; - } catch (SpannerException e) { - // Unexpected database error that is different from the original transaction. - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } - if (newCount == null || !Arrays.equals(updateCounts, newCount)) { - // The update counts do not match, we cannot retry the transaction. - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableUpdate.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableUpdate.java deleted file mode 100644 index ac2b8242246..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/RetriableUpdate.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.ReadWriteTransaction.RetriableStatement; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; - -/** - * Retriable DML statement. The check whether the statement had the same effect during retry is done - * by comparing the number of records affected. - */ -final class RetriableUpdate implements RetriableStatement { - private final ReadWriteTransaction transaction; - private final ParsedStatement statement; - private final long updateCount; - - RetriableUpdate(ReadWriteTransaction transaction, ParsedStatement statement, long updateCount) { - Preconditions.checkNotNull(transaction); - Preconditions.checkNotNull(statement); - this.transaction = transaction; - this.statement = statement; - this.updateCount = updateCount; - } - - @Override - public void retry(AbortedException aborted) throws AbortedException { - long newCount = -1; - try { - transaction - .getStatementExecutor() - .invokeInterceptors(statement, StatementExecutionStep.RETRY_STATEMENT, transaction); - newCount = transaction.getReadContext().executeUpdate(statement.getStatement()); - } catch (AbortedException e) { - // Just re-throw the AbortedException and let the retry logic determine whether another try - // should be executed or not. - throw e; - } catch (SpannerException e) { - // Unexpected database error that is different from the original transaction. - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted, e); - } - if (newCount != updateCount) { - // The update counts do not match, we cannot retry the transaction. - throw SpannerExceptionFactory.newAbortedDueToConcurrentModificationException(aborted); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SingleUseTransaction.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SingleUseTransaction.java deleted file mode 100644 index a5d61d5bd77..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SingleUseTransaction.java +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ReadOnlyTransaction; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionRunner; -import com.google.cloud.spanner.TransactionRunner.TransactionCallable; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.common.base.Preconditions; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -/** - * Transaction that is used when a {@link Connection} is in autocommit mode. Each method on this - * transaction actually starts a new transaction on Spanner. The type of transaction that is started - * depends on the type of statement that is being executed. A {@link SingleUseTransaction} will - * always try to choose the most efficient type of one-time transaction that is available for the - * statement. - * - *

A {@link SingleUseTransaction} can be used to execute any type of statement on Cloud Spanner: - * - *

    - *
  • Client side statements, e.g. SHOW VARIABLE AUTOCOMMIT - *
  • Queries, e.g. SELECT * FROM FOO - *
  • DML statements, e.g. UPDATE FOO SET BAR=1 - *
  • DDL statements, e.g. CREATE TABLE FOO (...) - *
- */ -class SingleUseTransaction extends AbstractBaseUnitOfWork { - private final boolean readOnly; - private final DdlClient ddlClient; - private final DatabaseClient dbClient; - private final TimestampBound readOnlyStaleness; - private final AutocommitDmlMode autocommitDmlMode; - private Timestamp readTimestamp = null; - private volatile TransactionManager txManager; - private TransactionRunner writeTransaction; - private boolean used = false; - private UnitOfWorkState state = UnitOfWorkState.STARTED; - - static class Builder extends AbstractBaseUnitOfWork.Builder { - private DdlClient ddlClient; - private DatabaseClient dbClient; - private boolean readOnly; - private TimestampBound readOnlyStaleness; - private AutocommitDmlMode autocommitDmlMode; - - private Builder() {} - - Builder setDdlClient(DdlClient ddlClient) { - Preconditions.checkNotNull(ddlClient); - this.ddlClient = ddlClient; - return this; - } - - Builder setDatabaseClient(DatabaseClient client) { - Preconditions.checkNotNull(client); - this.dbClient = client; - return this; - } - - Builder setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - return this; - } - - Builder setReadOnlyStaleness(TimestampBound staleness) { - Preconditions.checkNotNull(staleness); - this.readOnlyStaleness = staleness; - return this; - } - - Builder setAutocommitDmlMode(AutocommitDmlMode dmlMode) { - Preconditions.checkNotNull(dmlMode); - this.autocommitDmlMode = dmlMode; - return this; - } - - @Override - SingleUseTransaction build() { - Preconditions.checkState(ddlClient != null, "No DDL client specified"); - Preconditions.checkState(dbClient != null, "No DatabaseClient client specified"); - Preconditions.checkState(readOnlyStaleness != null, "No read-only staleness specified"); - Preconditions.checkState(autocommitDmlMode != null, "No autocommit dml mode specified"); - return new SingleUseTransaction(this); - } - } - - static Builder newBuilder() { - return new Builder(); - } - - private SingleUseTransaction(Builder builder) { - super(builder); - this.ddlClient = builder.ddlClient; - this.dbClient = builder.dbClient; - this.readOnly = builder.readOnly; - this.readOnlyStaleness = builder.readOnlyStaleness; - this.autocommitDmlMode = builder.autocommitDmlMode; - } - - @Override - public Type getType() { - return Type.TRANSACTION; - } - - @Override - public UnitOfWorkState getState() { - return state; - } - - @Override - public boolean isActive() { - // Single-use transactions are never active as they can be used only once. - return false; - } - - @Override - public boolean isReadOnly() { - return readOnly; - } - - private void checkAndMarkUsed() { - Preconditions.checkState(!used, "This single-use transaction has already been used"); - used = true; - } - - @Override - public ResultSet executeQuery( - final ParsedStatement statement, - final AnalyzeMode analyzeMode, - final QueryOption... options) { - Preconditions.checkNotNull(statement); - Preconditions.checkArgument(statement.isQuery(), "Statement is not a query"); - checkAndMarkUsed(); - - final ReadOnlyTransaction currentTransaction = - dbClient.singleUseReadOnlyTransaction(readOnlyStaleness); - Callable callable = - new Callable() { - @Override - public ResultSet call() throws Exception { - try { - ResultSet rs; - if (analyzeMode == AnalyzeMode.NONE) { - rs = currentTransaction.executeQuery(statement.getStatement(), options); - } else { - rs = - currentTransaction.analyzeQuery( - statement.getStatement(), analyzeMode.getQueryAnalyzeMode()); - } - // Return a DirectExecuteResultSet, which will directly do a next() call in order to - // ensure that the query is actually sent to Spanner. - return DirectExecuteResultSet.ofResultSet(rs); - } finally { - currentTransaction.close(); - } - } - }; - try { - ResultSet res = asyncExecuteStatement(statement, callable); - readTimestamp = currentTransaction.getReadTimestamp(); - state = UnitOfWorkState.COMMITTED; - return res; - } catch (Throwable e) { - state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } finally { - currentTransaction.close(); - } - } - - @Override - public Timestamp getReadTimestamp() { - ConnectionPreconditions.checkState( - readTimestamp != null, "There is no read timestamp available for this transaction."); - return readTimestamp; - } - - @Override - public Timestamp getReadTimestampOrNull() { - return readTimestamp; - } - - private boolean hasCommitTimestamp() { - return writeTransaction != null - || (txManager != null - && txManager.getState() - == com.google.cloud.spanner.TransactionManager.TransactionState.COMMITTED); - } - - @Override - public Timestamp getCommitTimestamp() { - ConnectionPreconditions.checkState( - hasCommitTimestamp(), "There is no commit timestamp available for this transaction."); - return writeTransaction != null - ? writeTransaction.getCommitTimestamp() - : txManager.getCommitTimestamp(); - } - - @Override - public Timestamp getCommitTimestampOrNull() { - if (hasCommitTimestamp()) { - try { - return writeTransaction != null - ? writeTransaction.getCommitTimestamp() - : txManager.getCommitTimestamp(); - } catch (SpannerException e) { - // ignore - } - } - return null; - } - - @Override - public void executeDdl(final ParsedStatement ddl) { - Preconditions.checkNotNull(ddl); - Preconditions.checkArgument( - ddl.getType() == StatementType.DDL, "Statement is not a ddl statement"); - ConnectionPreconditions.checkState( - !isReadOnly(), "DDL statements are not allowed in read-only mode"); - checkAndMarkUsed(); - - try { - Callable callable = - new Callable() { - @Override - public Void call() throws Exception { - OperationFuture operation = - ddlClient.executeDdl(ddl.getSqlWithoutComments()); - return operation.get(); - } - }; - asyncExecuteStatement(ddl, callable); - state = UnitOfWorkState.COMMITTED; - } catch (Throwable e) { - state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } - } - - @Override - public long executeUpdate(final ParsedStatement update) { - Preconditions.checkNotNull(update); - Preconditions.checkArgument(update.isUpdate(), "Statement is not an update statement"); - ConnectionPreconditions.checkState( - !isReadOnly(), "Update statements are not allowed in read-only mode"); - checkAndMarkUsed(); - - long res; - try { - switch (autocommitDmlMode) { - case TRANSACTIONAL: - res = executeAsyncTransactionalUpdate(update, new TransactionalUpdateCallable(update)); - break; - case PARTITIONED_NON_ATOMIC: - res = executeAsyncPartitionedUpdate(update); - break; - default: - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Unknown dml mode: " + autocommitDmlMode); - } - } catch (Throwable e) { - state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } - state = UnitOfWorkState.COMMITTED; - return res; - } - - /** Execute an update statement as a partitioned DML statement. */ - private long executeAsyncPartitionedUpdate(final ParsedStatement update) { - Callable callable = - new Callable() { - @Override - public Long call() throws Exception { - return dbClient.executePartitionedUpdate(update.getStatement()); - } - }; - return asyncExecuteStatement(update, callable); - } - - private final ParsedStatement executeBatchUpdateStatement = - StatementParser.INSTANCE.parse(Statement.of("RUN BATCH")); - - @Override - public long[] executeBatchUpdate(Iterable updates) { - Preconditions.checkNotNull(updates); - for (ParsedStatement update : updates) { - Preconditions.checkArgument( - update.isUpdate(), - "Statement is not an update statement: " + update.getSqlWithoutComments()); - } - ConnectionPreconditions.checkState( - !isReadOnly(), "Batch update statements are not allowed in read-only mode"); - checkAndMarkUsed(); - - long[] res; - try { - switch (autocommitDmlMode) { - case TRANSACTIONAL: - res = - executeAsyncTransactionalUpdate( - executeBatchUpdateStatement, new TransactionalBatchUpdateCallable(updates)); - break; - case PARTITIONED_NON_ATOMIC: - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "Batch updates are not allowed in " + autocommitDmlMode); - default: - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Unknown dml mode: " + autocommitDmlMode); - } - } catch (SpannerBatchUpdateException e) { - // Batch update exceptions does not cause a rollback. - state = UnitOfWorkState.COMMITTED; - throw e; - } catch (Throwable e) { - state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } - state = UnitOfWorkState.COMMITTED; - return res; - } - - /** Base class for executing DML updates (both single statements and batches). */ - private abstract class AbstractUpdateCallable implements Callable { - abstract T executeUpdate(TransactionContext txContext); - - @Override - public T call() throws Exception { - try { - txManager = dbClient.transactionManager(); - // Check the interrupted state after each (possible) round-trip to the db to allow the - // statement to be cancelled. - checkInterrupted(); - try (TransactionContext txContext = txManager.begin()) { - checkInterrupted(); - T res = executeUpdate(txContext); - checkInterrupted(); - txManager.commit(); - checkInterrupted(); - return res; - } - } finally { - if (txManager != null) { - // Calling txManager.close() will rollback the transaction if it is still active, i.e. if - // an error occurred before the commit() call returned successfully. - txManager.close(); - } - } - } - } - - /** {@link Callable} for a single update statement. */ - private final class TransactionalUpdateCallable extends AbstractUpdateCallable { - private final ParsedStatement update; - - private TransactionalUpdateCallable(ParsedStatement update) { - this.update = update; - } - - @Override - Long executeUpdate(TransactionContext txContext) { - return txContext.executeUpdate(update.getStatement()); - } - } - - /** {@link Callable} for a batch update. */ - private final class TransactionalBatchUpdateCallable extends AbstractUpdateCallable { - private final List updates; - - private TransactionalBatchUpdateCallable(Iterable updates) { - this.updates = new LinkedList<>(); - for (ParsedStatement update : updates) { - this.updates.add(update.getStatement()); - } - } - - @Override - long[] executeUpdate(TransactionContext txContext) { - return txContext.batchUpdate(updates); - } - } - - private T executeAsyncTransactionalUpdate( - final ParsedStatement update, final AbstractUpdateCallable callable) { - long startedTime = System.currentTimeMillis(); - // This method uses a TransactionManager instead of the TransactionRunner in order to be able to - // handle timeouts and canceling of a statement. - while (true) { - try { - return asyncExecuteStatement(update, callable); - } catch (AbortedException e) { - try { - Thread.sleep(e.getRetryDelayInMillis() / 1000); - } catch (InterruptedException e1) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.CANCELLED, "Statement execution was interrupted", e1); - } - // Check whether the timeout time has been exceeded. - long executionTime = System.currentTimeMillis() - startedTime; - if (getStatementTimeout().hasTimeout() - && executionTime > getStatementTimeout().getTimeoutValue(TimeUnit.MILLISECONDS)) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.DEADLINE_EXCEEDED, - "Statement execution timeout occurred for " + update.getSqlWithoutComments()); - } - } - } - } - - private void checkInterrupted() throws InterruptedException { - if (Thread.currentThread().isInterrupted()) { - throw new InterruptedException(); - } - } - - @Override - public void write(final Mutation mutation) { - write(Arrays.asList(mutation)); - } - - @Override - public void write(final Iterable mutations) { - Preconditions.checkNotNull(mutations); - ConnectionPreconditions.checkState( - !isReadOnly(), "Update statements are not allowed in read-only mode"); - checkAndMarkUsed(); - - writeTransaction = dbClient.readWriteTransaction(); - try { - writeTransaction.run( - new TransactionCallable() { - @Override - public Void run(TransactionContext transaction) throws Exception { - transaction.buffer(mutations); - return null; - } - }); - } catch (Throwable e) { - state = UnitOfWorkState.COMMIT_FAILED; - throw e; - } - state = UnitOfWorkState.COMMITTED; - } - - @Override - public void commit() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Commit is not supported for single-use transactions"); - } - - @Override - public void rollback() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Rollback is not supported for single-use transactions"); - } - - @Override - public long[] runBatch() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Run batch is not supported for single-use transactions"); - } - - @Override - public void abortBatch() { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "Run batch is not supported for single-use transactions"); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SpannerPool.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SpannerPool.java deleted file mode 100644 index 771ad505c77..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/SpannerPool.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.core.ApiFunction; -import com.google.auth.Credentials; -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.SpannerOptions; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; -import io.grpc.ManagedChannelBuilder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.concurrent.GuardedBy; - -/** - * Pool for keeping track of {@link Spanner} instances needed by JDBC connections. - * - *

When a JDBC connection is opened for a Google Cloud Spanner database, a {@link Spanner} object - * can be opened in the background. The {@link SpannerPool} keeps track of which {@link Spanner} - * objects have been opened by connections during the lifetime of the JVM, which connections are - * still opened and closed, and which {@link Spanner} objects could be closed. - * - *

Call the method {@link SpannerPool#closeSpannerPool()} at the end of your application to - * gracefully shutdown all instances in the pool. - */ -public class SpannerPool { - private static final Logger logger = Logger.getLogger(SpannerPool.class.getName()); - - /** - * Closes the default {@link SpannerPool} and all {@link Spanner} instances that have been opened - * by connections and that are still open. Call this method at the end of your application to - * gracefully close all {@link Spanner} instances in the pool. Failing to call this method will - * keep your application running for 60 seconds after you close the last {@link - * java.sql.Connection} to Cloud Spanner, as this is the default timeout before the {@link - * SpannerPool} closes the unused {@link Spanner} instances. - */ - public static void closeSpannerPool() { - INSTANCE.checkAndCloseSpanners(); - } - - /** - * The minimum number of milliseconds a {@link Spanner} should not have been used for a connection - * before it is closed. - */ - private static final long DEFAULT_CLOSE_SPANNER_AFTER_MILLISECONDS_UNUSED = 60000L; - - static final SpannerPool INSTANCE = - new SpannerPool(DEFAULT_CLOSE_SPANNER_AFTER_MILLISECONDS_UNUSED); - - @VisibleForTesting - enum CheckAndCloseSpannersMode { - WARN, - ERROR; - } - - private final class CloseSpannerRunnable implements Runnable { - @Override - public void run() { - try { - checkAndCloseSpanners(CheckAndCloseSpannersMode.WARN); - } catch (Exception e) { - // ignore - } - } - } - - private final class CloseUnusedSpannersRunnable implements Runnable { - @Override - public void run() { - try { - closeUnusedSpanners(SpannerPool.this.closeSpannerAfterMillisecondsUnused); - } catch (Throwable e) { - logger.log(Level.FINE, "Scheduled call to closeUnusedSpanners failed", e); - } - } - } - - static class SpannerPoolKey { - private final String host; - private final String projectId; - private final Credentials credentials; - private final Integer numChannels; - private final boolean usePlainText; - private final String userAgent; - - private static SpannerPoolKey of(ConnectionOptions options) { - return new SpannerPoolKey(options); - } - - private SpannerPoolKey(ConnectionOptions options) { - this.host = options.getHost(); - this.projectId = options.getProjectId(); - this.credentials = options.getCredentials(); - this.numChannels = options.getNumChannels(); - this.usePlainText = options.isUsePlainText(); - this.userAgent = options.getUserAgent(); - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof SpannerPoolKey)) { - return false; - } - SpannerPoolKey other = (SpannerPoolKey) o; - return Objects.equals(this.host, other.host) - && Objects.equals(this.projectId, other.projectId) - && Objects.equals(this.credentials, other.credentials) - && Objects.equals(this.numChannels, other.numChannels) - && Objects.equals(this.usePlainText, other.usePlainText) - && Objects.equals(this.userAgent, other.userAgent); - } - - @Override - public int hashCode() { - return Objects.hash( - this.host, - this.projectId, - this.credentials, - this.numChannels, - this.usePlainText, - this.userAgent); - } - } - - /** - * The management threads of a {@link SpannerPool} are lazily initialized to prevent unnecessary - * threads to be created when the connection API is not used. - */ - private boolean initialized = false; - /** - * Thread that will be run as a shutdown hook on closing the application. This thread will close - * any Spanner instances opened by the Connection API that are still open. - */ - private Thread shutdownThread = null; - - /** - * Keep unused {@link Spanner} instances open and in the pool for this duration after all its - * {@link Connection}s have been closed. This prevents unnecessary opening and closing of {@link - * Spanner} instances. - */ - private final long closeSpannerAfterMillisecondsUnused; - - /** - * This scheduled task will close all {@link Spanner} objects that have not been used for an open - * connection for at least {@link SpannerPool#DEFAULT_CLOSE_SPANNER_AFTER_MILLISECONDS_UNUSED} - * milliseconds. - */ - private ScheduledExecutorService closerService; - - @GuardedBy("this") - private final Map spanners = new HashMap<>(); - - @GuardedBy("this") - private final Map> connections = new HashMap<>(); - - /** - * Keep track of the moment that the last connection for a specific {@link SpannerPoolKey} was - * closed, so that we can use this to determine whether a {@link Spanner} instance should be - * closed and removed from the pool. As {@link Spanner} instances are expensive to create and - * close, we do not want to do that unnecessarily. By adding a delay between the moment the last - * {@link Connection} for a {@link Spanner} was closed and the moment we close the {@link Spanner} - * instance, we prevent applications that open one or more connections for a process and close all - * these connections at the end of the process from getting a severe performance penalty from - * opening and closing {@link Spanner} instances all the time. - * - *

{@link Spanner} instances are closed and removed from the pool when the last connection was - * closed more than {@link #closeSpannerAfterMillisecondsUnused} milliseconds ago. - */ - @GuardedBy("this") - private final Map lastConnectionClosedAt = new HashMap<>(); - - @VisibleForTesting - SpannerPool() { - this(0L); - } - - @VisibleForTesting - SpannerPool(long closeSpannerAfterMillisecondsUnused) { - this.closeSpannerAfterMillisecondsUnused = closeSpannerAfterMillisecondsUnused; - } - - /** - * Gets a Spanner object for a connection with the properties specified in the {@link - * ConnectionOptions} object. The {@link SpannerPool} will manage a pool of opened Spanner objects - * for the different connections, and reuse Spanner objects whenever possible. Spanner objects - * will also be closed down when the application is closing. - * - * @param options The specification of the Spanner database to connect to. - * @param connection The {@link ConnectionImpl} that will be created. This {@link ConnectionImpl} - * will be tracked by the pool to know when a {@link Spanner} object can be closed. - * @return an opened {@link Spanner} object that can be used by a connection to communicate with - * the Spanner database. - */ - Spanner getSpanner(ConnectionOptions options, ConnectionImpl connection) { - Preconditions.checkNotNull(options); - Preconditions.checkNotNull(connection); - SpannerPoolKey key = SpannerPoolKey.of(options); - Spanner spanner; - synchronized (this) { - if (!initialized) { - initialize(); - } - if (spanners.get(key) != null) { - spanner = spanners.get(key); - } else { - spanner = createSpanner(key); - spanners.put(key, spanner); - } - List registeredConnectionsForSpanner = connections.get(key); - if (registeredConnectionsForSpanner == null) { - registeredConnectionsForSpanner = new ArrayList<>(); - connections.put(key, registeredConnectionsForSpanner); - } - registeredConnectionsForSpanner.add(connection); - lastConnectionClosedAt.remove(key); - return spanner; - } - } - - private void initialize() { - shutdownThread = new Thread(new CloseSpannerRunnable(), "SpannerPool shutdown hook"); - Runtime.getRuntime().addShutdownHook(shutdownThread); - if (this.closeSpannerAfterMillisecondsUnused > 0) { - this.closerService = - Executors.newSingleThreadScheduledExecutor( - new ThreadFactory() { - @Override - public Thread newThread(Runnable r) { - Thread thread = new Thread(r, "close-unused-spanners-worker"); - thread.setDaemon(true); - return thread; - } - }); - this.closerService.scheduleAtFixedRate( - new CloseUnusedSpannersRunnable(), - this.closeSpannerAfterMillisecondsUnused, - this.closeSpannerAfterMillisecondsUnused, - TimeUnit.MILLISECONDS); - } - initialized = true; - } - - @SuppressWarnings("rawtypes") - @VisibleForTesting - Spanner createSpanner(SpannerPoolKey key) { - SpannerOptions.Builder builder = SpannerOptions.newBuilder(); - builder - .setClientLibToken(MoreObjects.firstNonNull(key.userAgent, JdbcDriver.getClientLibToken())) - .setHost(key.host) - .setProjectId(key.projectId) - .setCredentials(key.credentials); - if (key.numChannels != null) { - builder.setNumChannels(key.numChannels); - } - if (key.usePlainText) { - // Credentials may not be sent over a plain text channel. - builder.setCredentials(NoCredentials.getInstance()); - // Set a custom channel configurator to allow http instead of https. - builder.setChannelConfigurator( - new ApiFunction() { - @Override - public ManagedChannelBuilder apply(ManagedChannelBuilder input) { - input.usePlaintext(); - return input; - } - }); - } - return builder.build().getService(); - } - - /** - * Remove the given {@link ConnectionImpl} from the list of connections that should be monitored - * by this pool. - * - * @param options The {@link ConnectionOptions} that were used to create the connection. - * @param connection The {@link ConnectionImpl} to remove from this pool.. - */ - void removeConnection(ConnectionOptions options, ConnectionImpl connection) { - Preconditions.checkNotNull(options); - Preconditions.checkNotNull(connection); - SpannerPoolKey key = SpannerPoolKey.of(options); - synchronized (this) { - if (spanners.containsKey(key) && connections.containsKey(key)) { - List registeredConnections = connections.get(key); - // Remove the connection from the pool. - if (registeredConnections == null || !registeredConnections.remove(connection)) { - logger.log( - Level.WARNING, - "There are no connections registered for ConnectionOptions " + options.toString()); - } else { - // Check if this was the last connection for this spanner key. - if (registeredConnections.isEmpty()) { - // Register the moment the last connection for this Spanner key was removed, so we know - // which Spanner objects we could close. - lastConnectionClosedAt.put(key, System.currentTimeMillis()); - } - } - } else { - logger.log( - Level.WARNING, - "There is no Spanner registered for ConnectionOptions " + options.toString()); - } - } - } - - /** - * Checks that there are no {@link Connection}s that have been created by this {@link SpannerPool} - * that are still open, and then closes all {@link Spanner} instances in the pool. If there is at - * least one unclosed {@link Connection} left in the pool, the method will throw a {@link - * SpannerException} and no {@link Spanner} instances will be closed. - */ - void checkAndCloseSpanners() { - checkAndCloseSpanners(CheckAndCloseSpannersMode.ERROR); - } - - @VisibleForTesting - void checkAndCloseSpanners(CheckAndCloseSpannersMode mode) { - List keysStillInUse = new ArrayList<>(); - synchronized (this) { - for (Entry entry : spanners.entrySet()) { - if (!lastConnectionClosedAt.containsKey(entry.getKey())) { - keysStillInUse.add(entry.getKey()); - } - } - if (keysStillInUse.isEmpty() || mode == CheckAndCloseSpannersMode.WARN) { - if (!keysStillInUse.isEmpty()) { - logLeakedConnections(keysStillInUse); - logger.log( - Level.WARNING, - "There is/are " - + keysStillInUse.size() - + " connection(s) still open." - + " Close all connections before stopping the application"); - } - // Force close all Spanner instances by passing in a value that will always be less than the - // difference between the current time and the close time of a connection. - closeUnusedSpanners(Long.MIN_VALUE); - } else { - logLeakedConnections(keysStillInUse); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "There is/are " - + keysStillInUse.size() - + " connection(s) still open. Close all connections before calling closeSpanner()"); - } - } - } - - private void logLeakedConnections(List keysStillInUse) { - synchronized (this) { - for (SpannerPoolKey key : keysStillInUse) { - for (ConnectionImpl con : connections.get(key)) { - if (!con.isClosed() && con.getLeakedException() != null) { - logger.log(Level.WARNING, "Leaked connection", con.getLeakedException()); - } - } - } - } - } - - /** - * Closes Spanner objects that are no longer in use by connections, and where the last connection - * that used it was closed more than closeSpannerAfterMillisecondsUnused seconds ago. - * The delay ensures that Spanner objects are not closed unless there's a good reason for it. - * - * @param closeSpannerAfterMillisecondsUnused The number of milliseconds a {@link Spanner} object - * should not have been used for a {@link Connection} before it is closed by this method. - */ - @VisibleForTesting - void closeUnusedSpanners(long closeSpannerAfterMillisecondsUnused) { - List keysToBeRemoved = new ArrayList<>(); - synchronized (this) { - for (Entry entry : lastConnectionClosedAt.entrySet()) { - Long closedAt = entry.getValue(); - // Check whether the last connection was closed more than - // closeSpannerAfterMillisecondsUnused milliseconds ago. - if (closedAt != null - && ((System.currentTimeMillis() - closedAt.longValue())) - > closeSpannerAfterMillisecondsUnused) { - Spanner spanner = spanners.get(entry.getKey()); - if (spanner != null) { - try { - spanner.close(); - } finally { - // Even if the close operation failed, we should remove the spanner object as it is no - // longer valid. - spanners.remove(entry.getKey()); - keysToBeRemoved.add(entry.getKey()); - } - } - } - } - for (SpannerPoolKey key : keysToBeRemoved) { - lastConnectionClosedAt.remove(key); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutionInterceptor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutionInterceptor.java deleted file mode 100644 index 227bc62961c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutionInterceptor.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; - -/** Interface for interceptors that are invoked before a statement is executed. */ -interface StatementExecutionInterceptor { - void intercept(ParsedStatement statement, StatementExecutionStep step, UnitOfWork transaction); -} - -/** - * Enum passed in to a {@link StatementExecutionInterceptor} to determine what/why a statement is - * being executed. - */ -enum StatementExecutionStep { - /** The initial execution of a statement (DML/Query). */ - EXECUTE_STATEMENT, - /** A call to {@link ResultSet#next()}. */ - CALL_NEXT_ON_RESULT_SET, - /** Execution of the statement during an internal transaction retry. */ - RETRY_STATEMENT, - /** A call to {@link ResultSet#next()} during internal transaction retry. */ - RETRY_NEXT_ON_RESULT_SET; -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutor.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutor.java deleted file mode 100644 index 994c4c44d99..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementExecutor.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.DurationValueGetter; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.google.protobuf.Duration; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - * {@link StatementExecutor} is responsible for executing statements on a {@link Connection}. - * Statements are executed using a separate executor to allow timeouts and cancellation of - * statements. - */ -class StatementExecutor { - - /** Simple holder class for statement timeout that allows us to pass the value by reference. */ - static class StatementTimeout { - /** - * Only {@link TimeUnit#NANOSECONDS}, {@link TimeUnit#MICROSECONDS}, {@link - * TimeUnit#MILLISECONDS} and {@link TimeUnit#SECONDS} may be used to specify a statement - * timeout. - */ - static boolean isValidTimeoutUnit(TimeUnit unit) { - return unit == TimeUnit.NANOSECONDS - || unit == TimeUnit.MICROSECONDS - || unit == TimeUnit.MILLISECONDS - || unit == TimeUnit.SECONDS; - } - - /** The statement timeout. */ - private Duration duration = null; - - /** Creates a {@link StatementTimeout} that will never timeout. */ - @VisibleForTesting - static StatementTimeout nullTimeout() { - return new StatementTimeout(); - } - - /** Creates a {@link StatementTimeout} with the given duration. */ - @VisibleForTesting - static StatementTimeout of(long timeout, TimeUnit unit) { - Preconditions.checkArgument(timeout > 0L); - Preconditions.checkArgument(isValidTimeoutUnit(unit)); - StatementTimeout res = new StatementTimeout(); - res.duration = ReadOnlyStalenessUtil.createDuration(timeout, unit); - return res; - } - - /** - * Does this {@link StatementTimeout} have an actual timeout (i.e. it will eventually timeout). - */ - boolean hasTimeout() { - return duration != null; - } - - void clearTimeoutValue() { - this.duration = null; - } - - void setTimeoutValue(long timeout, TimeUnit unit) { - Preconditions.checkArgument(timeout > 0L); - Preconditions.checkArgument(isValidTimeoutUnit(unit)); - this.duration = ReadOnlyStalenessUtil.createDuration(timeout, unit); - } - - long getTimeoutValue(TimeUnit unit) { - Preconditions.checkArgument(isValidTimeoutUnit(unit)); - return duration == null ? 0L : ReadOnlyStalenessUtil.durationToUnits(duration, unit); - } - - /** - * Returns the {@link TimeUnit} with the least precision that could be used to represent this - * {@link StatementTimeout} without loss of precision. - */ - TimeUnit getAppropriateTimeUnit() { - ConnectionPreconditions.checkState( - duration != null, "This StatementTimeout has no timeout value"); - return ReadOnlyStalenessUtil.getAppropriateTimeUnit( - new DurationValueGetter() { - @Override - public long getDuration(TimeUnit unit) { - return StatementTimeout.this.getTimeoutValue(unit); - } - - @Override - public boolean hasDuration() { - return StatementTimeout.this.hasTimeout(); - } - }); - } - } - - /** - * Use a {@link ThreadFactory} that produces daemon threads and sets recognizable name on the - * threads. - */ - private static final ThreadFactory THREAD_FACTORY = - new ThreadFactoryBuilder() - .setDaemon(true) - .setNameFormat("connection-executor-%d") - .setThreadFactory(MoreExecutors.platformThreadFactory()) - .build(); - - /** Creates an {@link ExecutorService} for a {@link StatementExecutor}. */ - private static ExecutorService createExecutorService() { - return new ThreadPoolExecutor( - 1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), THREAD_FACTORY); - } - - private ExecutorService executor = createExecutorService(); - - /** - * Interceptors that should be invoked before or after a statement is executed can be registered - * for a connection. This are added to this list. The interceptors are intended for test usage. - */ - private final List interceptors; - - @VisibleForTesting - StatementExecutor() { - this.interceptors = Collections.emptyList(); - } - - StatementExecutor(List interceptors) { - this.interceptors = Collections.unmodifiableList(interceptors); - } - - /** - * Recreates this {@link StatementExecutor} and its {@link ExecutorService}. This can be necessary - * if a statement times out or is cancelled, and it cannot be guaranteed that the statement - * execution can be terminated. In order to prevent the single threaded {@link ExecutorService} to - * continue to block on the timed out/cancelled statement, a new {@link ExecutorService} is - * created. - */ - void recreate() { - executor.shutdown(); - executor = createExecutorService(); - } - - /** - * Shutdown this executor now and do not wait for any statement that is being executed to finish. - */ - List shutdownNow() { - return executor.shutdownNow(); - } - - /** Execute a statement on this {@link StatementExecutor}. */ - Future submit(Callable callable) { - return executor.submit(callable); - } - - /** - * Invoke the interceptors that have been registered for this {@link StatementExecutor} for the - * given step. - */ - void invokeInterceptors( - ParsedStatement statement, StatementExecutionStep step, UnitOfWork transaction) { - for (StatementExecutionInterceptor interceptor : interceptors) { - interceptor.intercept(statement, step, transaction); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementParser.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementParser.java deleted file mode 100644 index 9ed1ecd23ba..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementParser.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSet; -import java.util.Collections; -import java.util.Set; - -/** - * Internal class for the Spanner Connection API. - * - *

Parses {@link ClientSideStatement}s and normal SQL statements. The parser is able to recognize - * the type of statement, allowing the connection API to know which method on Spanner should be - * called. The parser does not validate the validity of statements, except for {@link - * ClientSideStatement}s. This means that an invalid DML statement could be accepted by the {@link - * StatementParser} and sent to Spanner, and Spanner will then reject it with some error message. - */ -class StatementParser { - /** Singleton instance of {@link StatementParser}. */ - public static final StatementParser INSTANCE = new StatementParser(); - - /** The type of statement that has been recognized by the parser. */ - enum StatementType { - CLIENT_SIDE, - DDL, - QUERY, - UPDATE, - UNKNOWN; - } - - /** A statement that has been parsed */ - static class ParsedStatement { - private final StatementType type; - private final ClientSideStatementImpl clientSideStatement; - private final Statement statement; - private final String sqlWithoutComments; - - private static ParsedStatement clientSideStatement( - ClientSideStatementImpl clientSideStatement, - Statement statement, - String sqlWithoutComments) { - return new ParsedStatement(clientSideStatement, statement, sqlWithoutComments); - } - - private static ParsedStatement ddl(Statement statement, String sqlWithoutComments) { - return new ParsedStatement(StatementType.DDL, statement, sqlWithoutComments); - } - - private static ParsedStatement query(Statement statement, String sqlWithoutComments) { - return new ParsedStatement(StatementType.QUERY, statement, sqlWithoutComments); - } - - private static ParsedStatement update(Statement statement, String sqlWithoutComments) { - return new ParsedStatement(StatementType.UPDATE, statement, sqlWithoutComments); - } - - private static ParsedStatement unknown(Statement statement, String sqlWithoutComments) { - return new ParsedStatement(StatementType.UNKNOWN, statement, sqlWithoutComments); - } - - private ParsedStatement( - ClientSideStatementImpl clientSideStatement, - Statement statement, - String sqlWithoutComments) { - Preconditions.checkNotNull(clientSideStatement); - Preconditions.checkNotNull(statement); - this.type = StatementType.CLIENT_SIDE; - this.clientSideStatement = clientSideStatement; - this.statement = statement; - this.sqlWithoutComments = sqlWithoutComments; - } - - private ParsedStatement(StatementType type, Statement statement, String sqlWithoutComments) { - Preconditions.checkNotNull(type); - Preconditions.checkNotNull(statement); - this.type = type; - this.clientSideStatement = null; - this.statement = statement; - this.sqlWithoutComments = sqlWithoutComments; - } - - StatementType getType() { - return type; - } - - boolean isQuery() { - switch (type) { - case CLIENT_SIDE: - return getClientSideStatement().isQuery(); - case QUERY: - return true; - case UPDATE: - case DDL: - case UNKNOWN: - default: - } - return false; - } - - boolean isUpdate() { - switch (type) { - case CLIENT_SIDE: - return getClientSideStatement().isUpdate(); - case UPDATE: - return true; - case QUERY: - case DDL: - case UNKNOWN: - default: - } - return false; - } - - boolean isDdl() { - switch (type) { - case DDL: - return true; - case CLIENT_SIDE: - case UPDATE: - case QUERY: - case UNKNOWN: - default: - } - return false; - } - - Statement getStatement() { - return statement; - } - - String getSqlWithoutComments() { - return sqlWithoutComments; - } - - ClientSideStatement getClientSideStatement() { - Preconditions.checkState( - clientSideStatement != null, - "This ParsedStatement does not contain a ClientSideStatement"); - return clientSideStatement; - } - } - - private final Set ddlStatements = ImmutableSet.of("CREATE", "DROP", "ALTER"); - private final Set selectStatements = ImmutableSet.of("SELECT"); - private final Set dmlStatements = ImmutableSet.of("INSERT", "UPDATE", "DELETE"); - private final Set statements; - - /** Private constructor for singleton instance. */ - private StatementParser() { - try { - statements = - Collections.unmodifiableSet(ClientSideStatements.INSTANCE.getCompiledStatements()); - } catch (CompileException e) { - throw new RuntimeException(e); - } - } - - /** - * Parses the given statement and categorizes it as one of the possible {@link StatementType}s. - * The validity of the statement is not checked, unless it is a client-side statement. - * - * @param statement The statement to parse. - * @return the parsed and categorized statement. - */ - ParsedStatement parse(Statement statement) { - String sql = removeCommentsAndTrim(statement.getSql()); - ClientSideStatementImpl client = parseClientSideStatement(sql); - if (client != null) { - return ParsedStatement.clientSideStatement(client, statement, sql); - } else if (isQuery(sql)) { - return ParsedStatement.query(statement, sql); - } else if (isUpdateStatement(sql)) { - return ParsedStatement.update(statement, sql); - } else if (isDdlStatement(sql)) { - return ParsedStatement.ddl(statement, sql); - } - return ParsedStatement.unknown(statement, sql); - } - - /** - * Parses the given statement as a client-side statement. Client-side statements are statements - * that are never sent to Cloud Spanner, but that are interpreted by the Connection API and then - * translated into some action, such as for example starting a transaction or getting the last - * commit timestamp. - * - * @param sql The statement to try to parse as a client-side statement (without any comments). - * @return a valid {@link ClientSideStatement} or null if the statement is not a client-side - * statement. - */ - @VisibleForTesting - ClientSideStatementImpl parseClientSideStatement(String sql) { - for (ClientSideStatementImpl css : statements) { - if (css.matches(sql)) { - return css; - } - } - return null; - } - - /** - * Checks whether the given statement is (probably) a DDL statement. The method does not check the - * validity of the statement, only if it is a DDL statement based on the first word in the - * statement. - * - * @param sql The statement to check (without any comments). - * @return true if the statement is a DDL statement (i.e. starts with 'CREATE', - * 'ALTER' or 'DROP'). - */ - boolean isDdlStatement(String sql) { - return statementStartsWith(sql, ddlStatements); - } - - /** - * Checks whether the given statement is (probably) a SELECT query. The method does not check the - * validity of the statement, only if it is a SELECT statement based on the first word in the - * statement. - * - * @param sql The statement to check (without any comments). - * @return true if the statement is a SELECT statement (i.e. starts with 'SELECT'). - */ - boolean isQuery(String sql) { - // Skip any query hints at the beginning of the query. - if (sql.startsWith("@")) { - sql = removeStatementHint(sql); - } - return statementStartsWith(sql, selectStatements); - } - - /** - * Checks whether the given statement is (probably) an update statement. The method does not check - * the validity of the statement, only if it is an update statement based on the first word in the - * statement. - * - * @param sql The statement to check (without any comments). - * @return true if the statement is a DML update statement (i.e. starts with - * 'INSERT', 'UPDATE' or 'DELETE'). - */ - boolean isUpdateStatement(String sql) { - return statementStartsWith(sql, dmlStatements); - } - - private boolean statementStartsWith(String sql, Iterable checkStatements) { - Preconditions.checkNotNull(sql); - String[] tokens = sql.split("\\s+", 2); - if (tokens.length > 0) { - for (String check : checkStatements) { - if (tokens[0].equalsIgnoreCase(check)) { - return true; - } - } - } - return false; - } - - /** - * Removes comments from and trims the given sql statement. Spanner supports three types of - * comments: - * - *

    - *
  • Single line comments starting with '--' - *
  • Single line comments starting with '#' - *
  • Multi line comments between '/*' and '*/' - *
- * - * Reference: https://cloud.google.com/spanner/docs/lexical#comments - * - * @param sql The sql statement to remove comments from and to trim. - * @return the sql statement without the comments and leading and trailing spaces. - */ - static String removeCommentsAndTrim(String sql) { - Preconditions.checkNotNull(sql); - final char SINGLE_QUOTE = '\''; - final char DOUBLE_QUOTE = '"'; - final char BACKTICK_QUOTE = '`'; - final char HYPHEN = '-'; - final char DASH = '#'; - final char SLASH = '/'; - final char ASTERIKS = '*'; - boolean isInQuoted = false; - boolean isInSingleLineComment = false; - boolean isInMultiLineComment = false; - char startQuote = 0; - boolean lastCharWasEscapeChar = false; - boolean isTripleQuoted = false; - StringBuilder res = new StringBuilder(sql.length()); - int index = 0; - while (index < sql.length()) { - char c = sql.charAt(index); - if (isInQuoted) { - if ((c == '\n' || c == '\r') && !isTripleQuoted) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "SQL statement contains an unclosed literal: " + sql); - } else if (c == startQuote) { - if (lastCharWasEscapeChar) { - lastCharWasEscapeChar = false; - } else if (isTripleQuoted) { - if (sql.length() > index + 2 - && sql.charAt(index + 1) == startQuote - && sql.charAt(index + 2) == startQuote) { - isInQuoted = false; - startQuote = 0; - isTripleQuoted = false; - res.append(c).append(c); - index += 2; - } - } else { - isInQuoted = false; - startQuote = 0; - } - } else if (c == '\\') { - lastCharWasEscapeChar = true; - } else { - lastCharWasEscapeChar = false; - } - res.append(c); - } else { - // We are not in a quoted string. - if (isInSingleLineComment) { - if (c == '\n') { - isInSingleLineComment = false; - // Include the line feed in the result. - res.append(c); - } - } else if (isInMultiLineComment) { - if (sql.length() > index + 1 && c == ASTERIKS && sql.charAt(index + 1) == SLASH) { - isInMultiLineComment = false; - index++; - } - } else { - if (c == DASH - || (sql.length() > index + 1 && c == HYPHEN && sql.charAt(index + 1) == HYPHEN)) { - // This is a single line comment. - isInSingleLineComment = true; - } else if (sql.length() > index + 1 && c == SLASH && sql.charAt(index + 1) == ASTERIKS) { - isInMultiLineComment = true; - index++; - } else { - if (c == SINGLE_QUOTE || c == DOUBLE_QUOTE || c == BACKTICK_QUOTE) { - isInQuoted = true; - startQuote = c; - // Check whether it is a triple-quote. - if (sql.length() > index + 2 - && sql.charAt(index + 1) == startQuote - && sql.charAt(index + 2) == startQuote) { - isTripleQuoted = true; - res.append(c).append(c); - index += 2; - } - } - res.append(c); - } - } - } - index++; - } - if (isInQuoted) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "SQL statement contains an unclosed literal: " + sql); - } - if (res.length() > 0 && res.charAt(res.length() - 1) == ';') { - res.deleteCharAt(res.length() - 1); - } - return res.toString().trim(); - } - - /** Removes any statement hints at the beginning of the statement. */ - static String removeStatementHint(String sql) { - // Valid statement hints at the beginning of a SQL statement can only contain a fixed set of - // possible values. Although it is possible to add a @{FORCE_INDEX=...} as a statement hint, the - // only allowed value is _BASE_TABLE. This means that we can safely assume that the statement - // hint will not contain any special characters, for example a closing curly brace, and - // that we can keep the check simple by just searching for the first occurrence of a closing - // curly brace at the end of the statement hint. - int startStatementHintIndex = sql.indexOf('{'); - int endStatementHintIndex = sql.indexOf('}'); - if (startStatementHintIndex == -1 || startStatementHintIndex > endStatementHintIndex) { - // Looks like an invalid statement hint. Just ignore at this point and let the caller handle - // the invalid query. - return sql; - } - return removeCommentsAndTrim(sql.substring(endStatementHintIndex + 1)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResult.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResult.java deleted file mode 100644 index 78cde9aca76..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResult.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ResultSet; - -/** - * A result of the execution of a statement. Statements that are executed by the {@link - * Connection#execute(com.google.cloud.spanner.Statement)} method could have different types of - * return values. These are wrapped in a {@link StatementResult}. - */ -interface StatementResult { - - /** - * Enum indicating the type of result that was returned by {@link - * Connection#execute(com.google.cloud.spanner.Statement)} - */ - enum ResultType { - /** - * A result set either returned by a query on Cloud Spanner or a local result set generated by a - * client side statement. - */ - RESULT_SET, - /** An update count returned by Cloud Spanner. */ - UPDATE_COUNT, - /** - * DDL statements and client side statements that set the state of a connection return no - * result. - */ - NO_RESULT; - } - - /** The type of client side statement that was executed. */ - enum ClientSideStatementType { - SHOW_AUTOCOMMIT, - SET_AUTOCOMMIT, - SHOW_READONLY, - SET_READONLY, - SHOW_RETRY_ABORTS_INTERNALLY, - SET_RETRY_ABORTS_INTERNALLY, - SHOW_AUTOCOMMIT_DML_MODE, - SET_AUTOCOMMIT_DML_MODE, - SHOW_STATEMENT_TIMEOUT, - SET_STATEMENT_TIMEOUT, - SHOW_READ_TIMESTAMP, - SHOW_COMMIT_TIMESTAMP, - SHOW_READ_ONLY_STALENESS, - SET_READ_ONLY_STALENESS, - BEGIN, - COMMIT, - ROLLBACK, - SET_TRANSACTION_MODE, - START_BATCH_DDL, - START_BATCH_DML, - RUN_BATCH, - ABORT_BATCH; - } - - /** - * Returns the {@link ResultType} of this result. - * - * @return the result type. - */ - ResultType getResultType(); - - /** - * @return the {@link ClientSideStatementType} that was executed, or null if no such statement was - * executed. - */ - ClientSideStatementType getClientSideStatementType(); - - /** - * Returns the {@link ResultSet} held by this result. May only be called if the type of this - * result is {@link ResultType#RESULT_SET}. - * - * @return the {@link ResultSet} held by this result. - */ - ResultSet getResultSet(); - - /** - * Returns the update count held by this result. May only be called if the type of this result is - * {@link ResultType#UPDATE_COUNT}. - * - * @return the update count held by this result. - */ - Long getUpdateCount(); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResultImpl.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResultImpl.java deleted file mode 100644 index 6748311e558..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/StatementResultImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import java.util.Arrays; - -/** Implementation of {@link StatementResult} */ -class StatementResultImpl implements StatementResult { - - /** {@link StatementResult} containing a {@link ResultSet} returned by Cloud Spanner. */ - static StatementResult of(ResultSet resultSet) { - return new StatementResultImpl(resultSet, null); - } - - /** - * {@link StatementResult} containing a {@link ResultSet} created by a {@link - * ClientSideStatement}. - */ - static StatementResult of(ResultSet resultSet, ClientSideStatementType clientSideStatementType) { - return new StatementResultImpl(resultSet, clientSideStatementType); - } - - /** {@link StatementResult} containing an update count returned by Cloud Spanner. */ - static StatementResult of(Long updateCount) { - return new StatementResultImpl(updateCount); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one BOOL column and one row that is created by a {@link ClientSideStatement}. - */ - static StatementResult resultSet( - String name, Boolean value, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.bool())), - Arrays.asList(Struct.newBuilder().set(name).to(value).build())), - clientSideStatementType); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one INT64 column and one row that is created by a {@link ClientSideStatement}. - */ - static StatementResult resultSet( - String name, Long value, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.int64())), - Arrays.asList(Struct.newBuilder().set(name).to(value).build())), - clientSideStatementType); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one ARRAY column and one row that is created by a {@link ClientSideStatement}. - */ - static StatementResult resultSet( - String name, long[] values, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.array(Type.int64()))), - Arrays.asList(Struct.newBuilder().set(name).toInt64Array(values).build())), - clientSideStatementType); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one STRING column and one row that is created by a {@link ClientSideStatement}. - */ - static StatementResult resultSet( - String name, String value, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.string())), - Arrays.asList(Struct.newBuilder().set(name).to(value).build())), - clientSideStatementType); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one STRING column containing an {@link Enum} value and one row that is created by a {@link - * ClientSideStatement}. - */ - static StatementResult resultSet( - String name, Enum value, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.string())), - Arrays.asList(Struct.newBuilder().set(name).to(value.toString()).build())), - clientSideStatementType); - } - - /** - * Convenience method for creating a {@link StatementResult} containing a {@link ResultSet} with - * one TIMESTAMP column and one row that is created by a {@link ClientSideStatement}. - */ - static StatementResult resultSet( - String name, Timestamp value, ClientSideStatementType clientSideStatementType) { - return of( - ResultSets.forRows( - Type.struct(StructField.of(name, Type.timestamp())), - Arrays.asList(Struct.newBuilder().set(name).to(value).build())), - clientSideStatementType); - } - - /** {@link StatementResult} containing no results. */ - static StatementResult noResult() { - return new StatementResultImpl((ClientSideStatementType) null); - } - - /** {@link StatementResult} containing no results created by a {@link ClientSideStatement}. */ - static StatementResult noResult(ClientSideStatementType clientSideStatementType) { - return new StatementResultImpl(clientSideStatementType); - } - - private final ResultType type; - private final ClientSideStatementType clientSideStatementType; - private final ResultSet resultSet; - private final Long updateCount; - - private StatementResultImpl( - ResultSet resultSet, ClientSideStatementType clientSideStatementType) { - this.type = ResultType.RESULT_SET; - this.clientSideStatementType = clientSideStatementType; - this.resultSet = resultSet; - this.updateCount = null; - } - - private StatementResultImpl(Long updateCount) { - this.type = ResultType.UPDATE_COUNT; - this.clientSideStatementType = null; - this.resultSet = null; - this.updateCount = updateCount; - } - - private StatementResultImpl(ClientSideStatementType clientSideStatementType) { - this.type = ResultType.NO_RESULT; - this.clientSideStatementType = clientSideStatementType; - this.resultSet = null; - this.updateCount = null; - } - - @Override - public ResultType getResultType() { - return type; - } - - @Override - public ClientSideStatementType getClientSideStatementType() { - return clientSideStatementType; - } - - @Override - public ResultSet getResultSet() { - ConnectionPreconditions.checkState( - resultSet != null, "This result does not contain a ResultSet"); - return resultSet; - } - - @Override - public Long getUpdateCount() { - ConnectionPreconditions.checkState( - updateCount != null, "This result does not contain an update count"); - return updateCount; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionMode.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionMode.java deleted file mode 100644 index ae98118c139..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionMode.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -/** Enum used to define the transaction type of a {@link Connection} */ -enum TransactionMode { - READ_ONLY_TRANSACTION("READ ONLY"), - READ_WRITE_TRANSACTION("READ WRITE"); - - private final String statementString; - - private TransactionMode(String statement) { - this.statementString = statement; - } - - /** - * Use this method to get the correct format for use in a SQL statement. The SQL statement for - * setting the mode to read-only should for example be without the underscore: - * SET TRANSACTION READ ONLY - * - * @return a string representation of this {@link TransactionMode} that can be used in a SQL - * statement to set the transaction mode. - */ - public String getStatementString() { - return statementString; - } - - @Override - public String toString() { - return statementString; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionRetryListener.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionRetryListener.java deleted file mode 100644 index 546cd4f27d9..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/TransactionRetryListener.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedException; - -/** - * Cloud Spanner can abort any read/write transaction because of potential deadlocks or other - * internal reasons. When a transaction is aborted, the entire transaction should be retried. A - * {@link Connection} can automatically retry a transaction internally and check whether the results - * that are returned during a retry attempt are equal to the results during the original - * transaction. This is done by keeping track of a SHA-256 checksum of all the results that are - * returned by Spanner during both transactions. - * - *

This listener class for internal transaction retries allow client applications to do - * additional testing or logging of transaction retries. Transaction retry listeners of a {@link - * Connection} can be added using {@link - * Connection#addTransactionRetryListener(TransactionRetryListener)}. - */ -public interface TransactionRetryListener { - /** The result of a retry. */ - public enum RetryResult { - /** The retry executed successfully and the transaction will continue. */ - RETRY_SUCCESSFUL, - /** The retry was aborted by Spanner and another retry attempt will be started. */ - RETRY_ABORTED_AND_RESTARTING, - /** - * The retry was aborted by the {@link Connection} because of a concurrent modification. The - * transaction cannot continue and will throw an {@link - * AbortedDueToConcurrentModificationException}. - */ - RETRY_ABORTED_DUE_TO_CONCURRENT_MODIFICATION, - /** - * The retry was aborted by Spanner and the maximum number of retry attempts allowed has been - * exceeded. The transaction cannot continue and will throw an {@link AbortedException}. - */ - RETRY_ABORTED_AND_MAX_ATTEMPTS_EXCEEDED, - /** - * An unexpected error occurred during transaction retry, the transaction cannot continue and - * will throw an exception. - */ - RETRY_ERROR; - } - - /** - * This method is called when a retry is about to start. - * - * @param transactionStarted The start date/time of the transaction that is retrying. - * @param transactionId An internally assigned ID of the transaction (unique during the lifetime - * of the JVM) that can be used to identify the transaction for logging purposes. - * @param retryAttempt The number of retry attempts the current transaction has executed, - * including the current retry attempt. - */ - void retryStarting(Timestamp transactionStarted, long transactionId, int retryAttempt); - - /** - * This method is called when a retry has finished. - * - * @param transactionStarted The start date/time of the transaction that is retrying. - * @param transactionId An internally assigned ID of the transaction (unique during the lifetime - * of the JVM) that can be used to identify the transaction for logging purposes. - * @param retryAttempt The number of retry attempts the current transaction has executed, - * including the current retry attempt. - * @param result The result of the retry indicating whether the retry was successful or not. - */ - void retryFinished( - Timestamp transactionStarted, - long transactionId, - int retryAttempt, - TransactionRetryListener.RetryResult result); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/UnitOfWork.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/UnitOfWork.java deleted file mode 100644 index 4287981dfce..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/java/com/google/cloud/spanner/jdbc/UnitOfWork.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.core.InternalApi; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.ReadContext; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.spanner.v1.ResultSetStats; - -/** Internal interface for transactions and batches on {@link Connection}s. */ -@InternalApi -interface UnitOfWork { - - /** A unit of work can be either a transaction or a DDL/DML batch. */ - enum Type { - TRANSACTION, - BATCH; - } - - enum UnitOfWorkState { - STARTED, - COMMITTED, - COMMIT_FAILED, - ROLLED_BACK, - RAN, - RUN_FAILED, - ABORTED; - - public boolean isActive() { - return this == STARTED; - } - } - - /** Cancel the currently running statement (if any and the statement may be cancelled). */ - void cancel(); - - /** @return the type of unit of work. */ - Type getType(); - - /** @return the current state of this unit of work. */ - UnitOfWorkState getState(); - - /** @return true if this unit of work is still active. */ - boolean isActive(); - - /** - * Commits the changes in this unit of work to the database. For read-only transactions, this only - * closes the {@link ReadContext}. This method will throw a {@link SpannerException} if called for - * a {@link Type#BATCH}. - */ - void commit(); - - /** - * Rollbacks any changes in this unit of work. For read-only transactions, this only closes the - * {@link ReadContext}. This method will throw a {@link SpannerException} if called for a {@link - * Type#BATCH}. - */ - void rollback(); - - /** - * Sends the currently buffered statements in this unit of work to the database and ends the - * batch. This method will throw a {@link SpannerException} if called for a {@link - * Type#TRANSACTION}. - * - * @return the update counts in case of a DML batch. Returns an array containing 1 for each - * successful statement and 0 for each failed statement or statement that was not executed DDL - * in case of a DDL batch. - */ - long[] runBatch(); - - /** - * Clears the currently buffered statements in this unit of work and ends the batch. This method - * will throw a {@link SpannerException} if called for a {@link Type#TRANSACTION}. - */ - void abortBatch(); - - /** @return true if this unit of work is read-only. */ - boolean isReadOnly(); - - /** - * Executes a query with the given options. If {@link AnalyzeMode} is set to {@link - * AnalyzeMode#PLAN} or {@link AnalyzeMode#PROFILE}, the returned {@link ResultSet} will include - * {@link ResultSetStats}. - * - * @param statement The statement to execute. - * @param analyzeMode Indicates whether to include {@link ResultSetStats} in the returned {@link - * ResultSet} or not. Cannot be used in combination with {@link QueryOption}s. - * @param options the options to configure the query. May only be set if analyzeMode is set to - * {@link AnalyzeMode#NONE}. - * @return a {@link ResultSet} with the results of the query. - * @throws SpannerException if the query is not allowed on this {@link UnitOfWork}, or if a - * database error occurs. - */ - ResultSet executeQuery( - ParsedStatement statement, AnalyzeMode analyzeMode, QueryOption... options); - - /** - * @return the read timestamp of this transaction. Will throw a {@link SpannerException} if there - * is no read timestamp. - */ - Timestamp getReadTimestamp(); - - /** @return the read timestamp of this transaction or null if there is no read timestamp. */ - Timestamp getReadTimestampOrNull(); - - /** - * @return the commit timestamp of this transaction. Will throw a {@link SpannerException} if - * there is no commit timestamp. - */ - Timestamp getCommitTimestamp(); - - /** @return the commit timestamp of this transaction or null if there is no commit timestamp. */ - Timestamp getCommitTimestampOrNull(); - - /** - * Executes the specified DDL statements in this unit of work. For DDL batches, this will mean - * that the statements are buffered locally and will be sent to Spanner when {@link - * UnitOfWork#commit()} is called. For {@link SingleUseTransaction}s, this will execute the DDL - * statement directly on Spanner. - * - * @param ddl The DDL statement to execute. - */ - void executeDdl(ParsedStatement ddl); - - /** - * Execute a DML statement on Spanner. - * - * @param update The DML statement to execute. - * @return the number of records that were inserted/updated/deleted by this statement. - */ - long executeUpdate(ParsedStatement update); - - /** - * Execute a batch of DML statements on Spanner. - * - * @param updates The DML statements to execute. - * @return an array containing the number of records that were inserted/updated/deleted per - * statement. - * @see TransactionContext#batchUpdate(Iterable) - */ - long[] executeBatchUpdate(Iterable updates); - - /** - * Writes a {@link Mutation} to Spanner. For {@link ReadWriteTransaction}s, this means buffering - * the {@link Mutation} locally and writing the {@link Mutation} to Spanner upon {@link - * UnitOfWork#commit()}. For {@link SingleUseTransaction}s, the {@link Mutation} will be sent - * directly to Spanner. - * - * @param mutation The mutation to write. - */ - void write(Mutation mutation); - - /** - * Writes a batch of {@link Mutation}s to Spanner. For {@link ReadWriteTransaction}s, this means - * buffering the {@link Mutation}s locally and writing the {@link Mutation}s to Spanner upon - * {@link UnitOfWork#commit()}. For {@link SingleUseTransaction}s, the {@link Mutation}s will be - * sent directly to Spanner. - * - * @param mutations The mutations to write. - */ - void write(Iterable mutations); -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/META-INF/services/java.sql.Driver b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/META-INF/services/java.sql.Driver deleted file mode 100644 index 5a8873f221e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/META-INF/services/java.sql.Driver +++ /dev/null @@ -1 +0,0 @@ -com.google.cloud.spanner.jdbc.JdbcDriver diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/ClientSideStatements.json b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/ClientSideStatements.json deleted file mode 100644 index 28c20a5b419..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/ClientSideStatements.json +++ /dev/null @@ -1,246 +0,0 @@ -{ -"statements": - [ - { - "name": "SHOW VARIABLE AUTOCOMMIT", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+autocommit\\s*\\z", - "method": "statementShowAutocommit", - "exampleStatements": ["show variable autocommit"] - }, - { - "name": "SHOW VARIABLE READONLY", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+readonly\\s*\\z", - "method": "statementShowReadOnly", - "exampleStatements": ["show variable readonly"] - }, - { - "name": "SHOW VARIABLE RETRY_ABORTS_INTERNALLY", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+retry_aborts_internally\\s*\\z", - "method": "statementShowRetryAbortsInternally", - "exampleStatements": ["show variable retry_aborts_internally"], - "examplePrerequisiteStatements": ["set readonly=false", "set autocommit=false"] - }, - { - "name": "SHOW VARIABLE AUTOCOMMIT_DML_MODE", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+autocommit_dml_mode\\s*\\z", - "method": "statementShowAutocommitDmlMode", - "exampleStatements": ["show variable autocommit_dml_mode"] - }, - { - "name": "SHOW VARIABLE STATEMENT_TIMEOUT", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+statement_timeout\\s*\\z", - "method": "statementShowStatementTimeout", - "exampleStatements": ["show variable statement_timeout"] - }, - { - "name": "SHOW VARIABLE READ_TIMESTAMP", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+read_timestamp\\s*\\z", - "method": "statementShowReadTimestamp", - "exampleStatements": ["show variable read_timestamp"], - "examplePrerequisiteStatements": ["set readonly = true", "SELECT 1 AS TEST"] - }, - { - "name": "SHOW VARIABLE COMMIT_TIMESTAMP", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+commit_timestamp\\s*\\z", - "method": "statementShowCommitTimestamp", - "exampleStatements": ["show variable commit_timestamp"], - "examplePrerequisiteStatements": ["update foo set bar=1"] - }, - { - "name": "SHOW VARIABLE READ_ONLY_STALENESS", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "RESULT_SET", - "regex": "(?is)\\A\\s*show\\s+variable\\s+read_only_staleness\\s*\\z", - "method": "statementShowReadOnlyStaleness", - "exampleStatements": ["show variable read_only_staleness"] - }, - { - "name": "BEGIN TRANSACTION", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:begin|start)(?:\\s+transaction)?\\s*\\z", - "method": "statementBeginTransaction", - "exampleStatements": ["begin", "start", "begin transaction", "start transaction"] - }, - { - "name": "COMMIT TRANSACTION", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:commit)(?:\\s+transaction)?\\s*\\z", - "method": "statementCommit", - "exampleStatements": ["commit", "commit transaction"], - "examplePrerequisiteStatements": ["begin transaction"] - }, - { - "name": "ROLLBACK TRANSACTION", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:rollback)(?:\\s+transaction)?\\s*\\z", - "method": "statementRollback", - "exampleStatements": ["rollback", "rollback transaction"], - "examplePrerequisiteStatements": ["begin transaction"] - }, - { - "name": "START BATCH DDL", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:start)(?:\\s+batch)(?:\\s+ddl)\\s*\\z", - "method": "statementStartBatchDdl", - "exampleStatements": ["start batch ddl"] - }, - { - "name": "START BATCH DML", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:start)(?:\\s+batch)(?:\\s+dml)\\s*\\z", - "method": "statementStartBatchDml", - "exampleStatements": ["start batch dml"] - }, - { - "name": "RUN BATCH", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:run)(?:\\s+batch)\\s*\\z", - "method": "statementRunBatch", - "exampleStatements": ["run batch"], - "examplePrerequisiteStatements": ["start batch ddl"] - }, - { - "name": "ABORT BATCH", - "executorName": "ClientSideStatementNoParamExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*(?:abort)(?:\\s+batch)\\s*\\z", - "method": "statementAbortBatch", - "exampleStatements": ["abort batch"], - "examplePrerequisiteStatements": ["start batch ddl"] - }, - { - "name": "SET AUTOCOMMIT = TRUE|FALSE", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+autocommit\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetAutocommit", - "exampleStatements": ["set autocommit = true", "set autocommit = false"], - "setStatement": { - "propertyName": "AUTOCOMMIT", - "separator": "=", - "allowedValues": "(TRUE|FALSE)", - "converterName": "ClientSideStatementValueConverters$BooleanConverter" - } - }, - { - "name": "SET READONLY = TRUE|FALSE", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+readonly\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetReadOnly", - "exampleStatements": ["set readonly = true", "set readonly = false"], - "setStatement": { - "propertyName": "READONLY", - "separator": "=", - "allowedValues": "(TRUE|FALSE)", - "converterName": "ClientSideStatementValueConverters$BooleanConverter" - } - }, - { - "name": "SET RETRY_ABORTS_INTERNALLY = TRUE|FALSE", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+retry_aborts_internally\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetRetryAbortsInternally", - "exampleStatements": ["set retry_aborts_internally = true", "set retry_aborts_internally = false"], - "examplePrerequisiteStatements": ["set readonly = false", "set autocommit = false"], - "setStatement": { - "propertyName": "RETRY_ABORTS_INTERNALLY", - "separator": "=", - "allowedValues": "(TRUE|FALSE)", - "converterName": "ClientSideStatementValueConverters$BooleanConverter" - } - }, - { - "name": "SET AUTOCOMMIT_DML_MODE = 'PARTITIONED_NON_ATOMIC'|'TRANSACTIONAL'", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+autocommit_dml_mode\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetAutocommitDmlMode", - "exampleStatements": ["set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'", "set autocommit_dml_mode='TRANSACTIONAL'"], - "setStatement": { - "propertyName": "AUTOCOMMIT_DML_MODE", - "separator": "=", - "allowedValues": "'(PARTITIONED_NON_ATOMIC|TRANSACTIONAL)'", - "converterName": "ClientSideStatementValueConverters$AutocommitDmlModeConverter" - } - }, - { - "name": "SET STATEMENT_TIMEOUT = ''|NULL", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+statement_timeout\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetStatementTimeout", - "exampleStatements": ["set statement_timeout=null", "set statement_timeout='1s'", "set statement_timeout='100ms'", "set statement_timeout='10000us'", "set statement_timeout='9223372036854775807ns'"], - "setStatement": { - "propertyName": "STATEMENT_TIMEOUT", - "separator": "=", - "allowedValues": "('(\\d{1,19})(s|ms|us|ns)'|NULL)", - "converterName": "ClientSideStatementValueConverters$DurationConverter" - } - }, - { - "name": "SET TRANSACTION READ ONLY|READ WRITE", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+transaction\\s*(?:\\s+)\\s*(.*)\\z", - "method": "statementSetTransactionMode", - "exampleStatements": ["set transaction read only", "set transaction read write"], - "examplePrerequisiteStatements": ["set autocommit = false"], - "setStatement": { - "propertyName": "TRANSACTION", - "separator": "\\s+", - "allowedValues": "(READ\\s+ONLY|READ\\s+WRITE)", - "converterName": "ClientSideStatementValueConverters$TransactionModeConverter" - } - }, - { - "name": "SET READ_ONLY_STALENESS = 'STRONG' | 'MIN_READ_TIMESTAMP ' | 'READ_TIMESTAMP ' | 'MAX_STALENESS s|ms|us|ns' | 'EXACT_STALENESS (s|ms|us|ns)'", - "executorName": "ClientSideStatementSetExecutor", - "resultType": "NO_RESULT", - "regex": "(?is)\\A\\s*set\\s+read_only_staleness\\s*(?:=)\\s*(.*)\\z", - "method": "statementSetReadOnlyStaleness", - "exampleStatements": ["set read_only_staleness='STRONG'", - "set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'", - "set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'", - "set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'", - "set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'", - "set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'", - "set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'", - "set read_only_staleness='MAX_STALENESS 12s'", - "set read_only_staleness='MAX_STALENESS 100ms'", - "set read_only_staleness='MAX_STALENESS 99999us'", - "set read_only_staleness='MAX_STALENESS 10ns'", - "set read_only_staleness='EXACT_STALENESS 15s'", - "set read_only_staleness='EXACT_STALENESS 1500ms'", - "set read_only_staleness='EXACT_STALENESS 15000000us'", - "set read_only_staleness='EXACT_STALENESS 9999ns'"], - "setStatement": { - "propertyName": "READ_ONLY_STALENESS", - "separator": "=", - "allowedValues": "'((STRONG)|(MIN_READ_TIMESTAMP)[\\t ]+((\\d{4})-(\\d{2})-(\\d{2})([Tt](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(READ_TIMESTAMP)[\\t ]+((\\d{4})-(\\d{2})-(\\d{2})([Tt](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(MAX_STALENESS)[\\t ]+((\\d{1,19})(s|ms|us|ns))|(EXACT_STALENESS)[\\t ]+((\\d{1,19})(s|ms|us|ns)))'", - "converterName": "ClientSideStatementValueConverters$ReadOnlyStalenessConverter" - } - } - ] -} \ No newline at end of file diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/DatabaseMetaData_GetColumns.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/DatabaseMetaData_GetColumns.sql deleted file mode 100644 index 40601611e84..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/main/resources/com/google/cloud/spanner/jdbc/DatabaseMetaData_GetColumns.sql +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, - CASE - WHEN SPANNER_TYPE LIKE 'ARRAY%' THEN 2003 - WHEN SPANNER_TYPE = 'BOOL' THEN 16 - WHEN SPANNER_TYPE LIKE 'BYTES%' THEN -2 - WHEN SPANNER_TYPE = 'DATE' THEN 91 - WHEN SPANNER_TYPE = 'FLOAT64' THEN 8 - WHEN SPANNER_TYPE = 'INT64' THEN -5 - WHEN SPANNER_TYPE LIKE 'STRING%' THEN -9 - WHEN SPANNER_TYPE = 'TIMESTAMP' THEN 93 - END AS DATA_TYPE, - SPANNER_TYPE AS TYPE_NAME, - CASE - WHEN STRPOS(SPANNER_TYPE, '(')=0 THEN - CASE - WHEN SPANNER_TYPE = 'INT64' OR SPANNER_TYPE = 'ARRAY' THEN 19 - WHEN SPANNER_TYPE = 'FLOAT64' OR SPANNER_TYPE = 'ARRAY' THEN 15 - WHEN SPANNER_TYPE = 'BOOL' OR SPANNER_TYPE = 'ARRAY' THEN NULL - WHEN SPANNER_TYPE = 'DATE' OR SPANNER_TYPE = 'ARRAY' THEN 10 - WHEN SPANNER_TYPE = 'TIMESTAMP' OR SPANNER_TYPE = 'ARRAY' THEN 35 - ELSE 0 - END - ELSE CAST(REPLACE(SUBSTR(SPANNER_TYPE, STRPOS(SPANNER_TYPE, '(')+1, STRPOS(SPANNER_TYPE, ')')-STRPOS(SPANNER_TYPE, '(')-1), 'MAX', CASE WHEN UPPER(SPANNER_TYPE) LIKE '%STRING%' THEN '2621440' ELSE '10485760' END) AS INT64) - END AS COLUMN_SIZE, - 0 AS BUFFER_LENGTH, - CASE - WHEN SPANNER_TYPE LIKE '%FLOAT64%' THEN 16 - ELSE NULL - END AS DECIMAL_DIGITS, - CASE - WHEN SPANNER_TYPE LIKE '%INT64%' THEN 10 - WHEN SPANNER_TYPE LIKE '%FLOAT64%' THEN 2 - ELSE NULL - END AS NUM_PREC_RADIX, - CASE - WHEN IS_NULLABLE = 'YES' THEN 1 - WHEN IS_NULLABLE = 'NO' THEN 0 - ELSE 2 - END AS NULLABLE, - NULL AS REMARKS, - NULL AS COLUMN_DEF, - 0 AS SQL_DATA_TYPE, - 0 AS SQL_DATETIME_SUB, - CASE - WHEN (SPANNER_TYPE LIKE 'STRING%' OR SPANNER_TYPE LIKE 'ARRAYasList(interceptor), - Arrays.asList(transactionRetryListener)); - } - - public ITConnection createConnection( - List interceptors, - List transactionRetryListeners) { - StringBuilder url = - new StringBuilder( - String.format( - "cloudspanner://localhost:%d/projects/proj/instances/inst/databases/db?usePlainText=true;autocommit=false;retryAbortsInternally=true", - server.getPort())); - ConnectionOptions.Builder builder = - ConnectionOptions.newBuilder() - .setUri(url.toString()) - .setStatementExecutionInterceptors(interceptors); - ConnectionOptions options = builder.build(); - ITConnection connection = createITConnection(options); - for (TransactionRetryListener listener : transactionRetryListeners) { - connection.addTransactionRetryListener(listener); - } - return connection; - } - - private ITConnection createITConnection(ConnectionOptions options) { - return new ITConnectionImpl(options); - } - - @Test - public void testCommitAborted() { - // Do two iterations to ensure that each iteration gets its own transaction, and that each - // transaction is the most recent transaction of that session. - for (int i = 0; i < 2; i++) { - mockSpanner.putStatementResult( - StatementResult.query(SELECT_COUNT, SELECT_COUNT_RESULTSET_BEFORE_INSERT)); - mockSpanner.putStatementResult(StatementResult.update(INSERT_STATEMENT, UPDATE_COUNT)); - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // do an insert - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // do a commit that will first abort, and then on retry will succeed - connection.commit(); - mockSpanner.putStatementResult( - StatementResult.query(SELECT_COUNT, SELECT_COUNT_RESULTSET_AFTER_INSERT)); - // verify that the insert succeeded - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractConnectionImplTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractConnectionImplTest.java deleted file mode 100644 index 798a4d2b75c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractConnectionImplTest.java +++ /dev/null @@ -1,918 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.getTimeUnitAbbreviation; -import static com.google.cloud.spanner.jdbc.SpannerExceptionMatcher.matchCode; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * This test class and all its subclasses are used to generate the file - * ConnectionImplGeneratedSqlScriptTest.sql. - */ -@RunWith(JUnit4.class) -public abstract class AbstractConnectionImplTest { - public static final String UPDATE = "UPDATE foo SET bar=1"; - public static final String SELECT = "SELECT 1 AS TEST"; - public static final String DDL = - "CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id)"; - - static interface ConnectionConsumer { - void accept(Connection connection); - } - - @Rule public ExpectedException exception = ExpectedException.none(); - - /** - * This test class can generate a large sql file that represents all the statements and - * verifications that are executed by this test class. This file can be fed into other test cases - * (in other programming languages) to execute the same tests as the tests covered by all the - * subclasses of {@link AbstractConnectionImplTest}. - */ - private static final String LOG_FILE = - "src/test/resources/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.sql"; - - private static final String DO_LOG_PROPERTY = "do_log_statements"; - private static boolean doLog; - private static PrintWriter writer; - - abstract Connection getConnection(); - - static void expectSpannerException( - String reason, ConnectionConsumer consumer, Connection connection) { - expectSpannerException(reason, consumer, connection, ErrorCode.FAILED_PRECONDITION); - } - - static void expectSpannerException( - String reason, ConnectionConsumer consumer, Connection connection, ErrorCode errorCode) { - SpannerException exception = null; - try { - consumer.accept(connection); - } catch (SpannerException e) { - exception = e; - } - assertThat(reason, exception, is(notNullValue())); - assertThat(reason, exception.getErrorCode(), is(equalTo(errorCode))); - } - - AbstractConnectionImplTest() {} - - /** Makes an empty test script. Can be called before a new script is to be generated. */ - static void emptyScript() { - openLog(false); - closeLog(); - } - - void log(String statement) { - if (doLog) { - writer.println(statement); - } - } - - @BeforeClass - public static void openLog() { - doLog = Boolean.valueOf(System.getProperty(DO_LOG_PROPERTY, "false")); - if (doLog) { - openLog(true); - } else { - writer = null; - } - } - - private static void openLog(boolean append) { - try { - writer = - new PrintWriter( - new OutputStreamWriter(new FileOutputStream(LOG_FILE, append), "UTF8"), true); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @AfterClass - public static void closeLog() { - if (writer != null) { - writer.close(); - } - } - - @Test - public void testClose() { - getConnection().close(); - } - - @Test - public void testIsClosed() { - Connection connection = getConnection(); - assertThat(connection.isClosed(), is(false)); - connection.close(); - assertThat(connection.isClosed(), is(true)); - } - - abstract boolean isSetAutocommitAllowed(); - - @Test - public void testSetAutocommit() { - try (Connection connection = getConnection()) { - if (isSetAutocommitAllowed()) { - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - - log("@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE"); - log("SHOW VARIABLE AUTOCOMMIT;"); - assertThat(connection.isAutocommit(), is(false)); - - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - - log("@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE"); - log("SHOW VARIABLE AUTOCOMMIT;"); - assertThat(connection.isAutocommit(), is(true)); - } else { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("SET AUTOCOMMIT=" + (connection.isAutocommit() ? "FALSE;" : "TRUE;")); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.setAutocommit(!connection.isAutocommit()); - } - } - } - - abstract boolean isSetReadOnlyAllowed(); - - @Test - public void testSetReadOnly() { - try (Connection connection = getConnection()) { - if (isSetReadOnlyAllowed()) { - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - - log("@EXPECT RESULT_SET 'READONLY',FALSE"); - log("SHOW VARIABLE READONLY;"); - assertThat(connection.isReadOnly(), is(false)); - - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - - log("@EXPECT RESULT_SET 'READONLY',TRUE"); - log("SHOW VARIABLE READONLY;"); - assertThat(connection.isReadOnly(), is(true)); - } else { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("SET READONLY=" + (connection.isAutocommit() ? "FALSE;" : "TRUE;")); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.setReadOnly(!connection.isReadOnly()); - } - } - } - - @Test - public void testSetStatementTimeout() { - try (Connection connection = getConnection()) { - for (TimeUnit unit : ReadOnlyStalenessUtil.SUPPORTED_UNITS) { - log(String.format("SET STATEMENT_TIMEOUT='1%s';", getTimeUnitAbbreviation(unit))); - connection.setStatementTimeout(1L, unit); - - log( - String.format( - "@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1%s'", getTimeUnitAbbreviation(unit))); - log("SHOW VARIABLE STATEMENT_TIMEOUT;"); - assertThat(connection.getStatementTimeout(unit), is(equalTo(1L))); - - log("SET STATEMENT_TIMEOUT=null;"); - connection.clearStatementTimeout(); - - log("@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null"); - log("SHOW VARIABLE STATEMENT_TIMEOUT;"); - assertThat(connection.getStatementTimeout(unit), is(equalTo(0L))); - assertThat(connection.hasStatementTimeout(), is(false)); - boolean gotException = false; - try { - log("@EXPECT EXCEPTION INVALID_ARGUMENT"); - log(String.format("SET STATEMENT_TIMEOUT='0%s';", getTimeUnitAbbreviation(unit))); - connection.setStatementTimeout(0L, unit); - } catch (IllegalArgumentException e) { - gotException = true; - } - assertThat(gotException, is(true)); - log("@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null"); - log("SHOW VARIABLE STATEMENT_TIMEOUT;"); - assertThat(connection.getStatementTimeout(unit), is(equalTo(0L))); - assertThat(connection.hasStatementTimeout(), is(false)); - } - } - } - - abstract boolean isStartBatchDmlAllowed(); - - @Test - public void testStartBatchDml() { - try (Connection connection = getConnection()) { - if (isStartBatchDmlAllowed()) { - assertThat(connection.isReadOnly(), is(false)); - assertThat(connection.isDdlBatchActive() || connection.isDmlBatchActive(), is(false)); - - log("START BATCH DML;"); - connection.startBatchDml(); - assertThat(connection.isDmlBatchActive(), is(true)); - - expectSpannerException( - "Select should not be allowed after startBatchDml()", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(SELECT + ";"); - t.execute(Statement.of(SELECT)); - } - }, - connection); - expectSpannerException( - "DDL should not be allowed after startBatchDml()", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(DDL + ";"); - t.execute(Statement.of(DDL)); - } - }, - connection); - log(UPDATE + ";"); - connection.execute(Statement.of(UPDATE)); - assertThat(connection.isDmlBatchActive(), is(true)); - } - // startBatchDml is not allowed as a batch has already been started. - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("START BATCH DML;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.startBatchDml(); - } - } - - abstract boolean isStartBatchDdlAllowed(); - - @Test - public void testStartBatchDdl() { - try (Connection connection = getConnection()) { - if (isStartBatchDdlAllowed()) { - assertThat(connection.isTransactionStarted(), is(false)); - assertThat(connection.isInTransaction(), is(equalTo(!connection.isAutocommit()))); - assertThat(connection.isDdlBatchActive() || connection.isDmlBatchActive(), is(false)); - - log("START BATCH DDL;"); - connection.startBatchDdl(); - assertThat(connection.isTransactionStarted(), is(false)); - assertThat(connection.isInTransaction(), is(false)); - assertThat(connection.isDdlBatchActive(), is(true)); - - expectSpannerException( - "Select should not be allowed after startBatchDdl()", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(SELECT + ";"); - t.execute(Statement.of(SELECT)); - } - }, - connection); - expectSpannerException( - "Update should not be allowed after startBatchDdl()", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(UPDATE + ";"); - t.execute(Statement.of(UPDATE)); - } - }, - connection); - log(DDL + ";"); - connection.execute(Statement.of(DDL)); - assertThat(connection.isTransactionStarted(), is(false)); - assertThat(connection.isDdlBatchActive(), is(true)); - } - // startBatchDdl is no longer allowed as a batch has already been started - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("START BATCH DDL;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.startBatchDdl(); - } - } - - abstract boolean isRunBatchAllowed(); - - @Test - public void testRunBatch() { - try (Connection connection = getConnection()) { - if (!isRunBatchAllowed()) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - log("RUN BATCH;"); - connection.runBatch(); - } - } - - abstract boolean isAbortBatchAllowed(); - - @Test - public void testAbortBatch() { - try (Connection connection = getConnection()) { - if (!isAbortBatchAllowed()) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - log("ABORT BATCH;"); - connection.abortBatch(); - } - } - - abstract boolean isBeginTransactionAllowed(); - - abstract boolean isSelectAllowedAfterBeginTransaction(); - - abstract boolean isDmlAllowedAfterBeginTransaction(); - - abstract boolean isDdlAllowedAfterBeginTransaction(); - - @Test - public void testBeginTransaction() { - try (Connection connection = getConnection()) { - if (isBeginTransactionAllowed()) { - assertThat(connection.isTransactionStarted(), is(false)); - assertThat(connection.isInTransaction(), is(equalTo(!connection.isAutocommit()))); - - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - assertThat(connection.isTransactionStarted(), is(false)); - assertThat(connection.isInTransaction(), is(true)); - - if (isSelectAllowedAfterBeginTransaction()) { - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)); - } else { - expectSpannerException( - "Select should not be allowed after beginTransaction", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(SELECT + ";"); - t.execute(Statement.of(SELECT)); - } - }, - connection); - } - if (isDmlAllowedAfterBeginTransaction()) { - log(UPDATE + ";"); - connection.execute(Statement.of(UPDATE)); - } else { - expectSpannerException( - "Update should not be allowed after beginTransaction", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(UPDATE + ";"); - t.execute(Statement.of(UPDATE)); - } - }, - connection); - } - if (isDdlAllowedAfterBeginTransaction()) { - log(DDL + ";"); - connection.execute(Statement.of(DDL)); - } else { - expectSpannerException( - "DDL should not be allowed after beginTransaction", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(DDL + ";"); - t.execute(Statement.of(DDL)); - } - }, - connection); - } - assertThat(connection.isTransactionStarted(), is(true)); - } - // beginTransaction is no longer allowed as the transaction has already started - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("BEGIN TRANSACTION;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.beginTransaction(); - } - } - - abstract boolean isSetTransactionModeAllowed(TransactionMode mode); - - @Test - public void testSetTransactionMode() { - for (TransactionMode mode : TransactionMode.values()) { - testSetTransactionMode(mode); - } - } - - private void testSetTransactionMode(final TransactionMode mode) { - try (Connection connection = getConnection()) { - if (isSetTransactionModeAllowed(mode)) { - log("SET TRANSACTION " + mode.toString() + ";"); - connection.setTransactionMode(mode); - assertThat(connection.getTransactionMode(), is(equalTo(mode))); - } else { - expectSpannerException( - mode + " should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("SET TRANSACTION " + mode.getStatementString() + ";"); - t.setTransactionMode(mode); - } - }, - connection); - } - } - } - - abstract boolean isGetTransactionModeAllowed(); - - @Test - public void testGetTransactionMode() { - try (Connection connection = getConnection()) { - if (isGetTransactionModeAllowed()) { - assertThat(connection.getTransactionMode(), is(notNullValue())); - } else { - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.getTransactionMode(); - } - } - } - - abstract boolean isSetAutocommitDmlModeAllowed(); - - @Test - public void testSetAutocommitDmlMode() { - try (Connection connection = getConnection()) { - if (isSetAutocommitDmlModeAllowed()) { - for (AutocommitDmlMode mode : AutocommitDmlMode.values()) { - log("SET AUTOCOMMIT_DML_MODE='" + mode.toString() + "';"); - connection.setAutocommitDmlMode(mode); - - log("@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','" + mode.toString() + "'"); - log("SHOW VARIABLE AUTOCOMMIT_DML_MODE;"); - assertThat(connection.getAutocommitDmlMode(), is(equalTo(mode))); - } - } else { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log( - "SET AUTOCOMMIT_DML_MODE='" - + AutocommitDmlMode.PARTITIONED_NON_ATOMIC.toString() - + "';"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.setAutocommitDmlMode(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - } - } - } - - abstract boolean isGetAutocommitDmlModeAllowed(); - - @Test - public void testGetAutocommitDmlMode() { - try (Connection connection = getConnection()) { - if (isGetAutocommitDmlModeAllowed()) { - log("@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE'"); - log("SHOW VARIABLE AUTOCOMMIT_DML_MODE;"); - assertThat(connection.getAutocommitDmlMode(), is(notNullValue())); - } else { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("SHOW VARIABLE AUTOCOMMIT_DML_MODE;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.getAutocommitDmlMode(); - } - } - } - - abstract boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode); - - @Test - public void testSetReadOnlyStaleness() { - for (TimestampBound staleness : getTestTimestampBounds()) { - testSetReadOnlyStaleness(staleness); - } - } - - private List getTestTimestampBounds() { - return Arrays.asList( - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(Timestamp.now()), - TimestampBound.ofMinReadTimestamp(Timestamp.now()), - TimestampBound.ofExactStaleness(1L, TimeUnit.SECONDS), - TimestampBound.ofMaxStaleness(100L, TimeUnit.MILLISECONDS), - TimestampBound.ofExactStaleness(100L, TimeUnit.MICROSECONDS)); - } - - private void testSetReadOnlyStaleness(final TimestampBound staleness) { - try (Connection connection = getConnection()) { - if (isSetReadOnlyStalenessAllowed(staleness.getMode())) { - log( - "SET READ_ONLY_STALENESS='" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "';"); - connection.setReadOnlyStaleness(staleness); - - log( - "@EXPECT RESULT_SET 'READ_ONLY_STALENESS','" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "'"); - log("SHOW VARIABLE READ_ONLY_STALENESS;"); - assertThat(connection.getReadOnlyStaleness(), is(equalTo(staleness))); - } else { - expectSpannerException( - staleness.getMode() + " should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log( - "SET READ_ONLY_STALENESS='" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "';"); - t.setReadOnlyStaleness(staleness); - } - }, - connection); - } - } - } - - abstract boolean isGetReadOnlyStalenessAllowed(); - - @Test - public void testGetReadOnlyStaleness() { - try (Connection connection = getConnection()) { - if (isGetReadOnlyStalenessAllowed()) { - log("@EXPECT RESULT_SET 'READ_ONLY_STALENESS'"); - log("SHOW VARIABLE READ_ONLY_STALENESS;"); - assertThat(connection.getReadOnlyStaleness(), is(notNullValue())); - } else { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log("SHOW VARIABLE READ_ONLY_STALENESS;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.getReadOnlyStaleness(); - } - } - } - - abstract boolean isCommitAllowed(); - - @Test - public void testCommit() { - try (Connection connection = getConnection()) { - if (!isCommitAllowed()) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - log("COMMIT;"); - connection.commit(); - } - } - - abstract boolean isRollbackAllowed(); - - @Test - public void testRollback() { - try (Connection connection = getConnection()) { - if (!isRollbackAllowed()) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - log("ROLLBACK;"); - connection.rollback(); - } - } - - abstract boolean expectedIsInTransaction(); - - @Test - public void testIsInTransaction() { - try (Connection connection = getConnection()) { - assertThat(connection.isInTransaction(), is(expectedIsInTransaction())); - } - } - - abstract boolean expectedIsTransactionStarted(); - - @Test - public void testIsTransactionStarted() { - try (Connection connection = getConnection()) { - assertThat(connection.isTransactionStarted(), is(expectedIsTransactionStarted())); - } - } - - abstract boolean isGetReadTimestampAllowed(); - - @Test - public void testGetReadTimestamp() { - try (Connection connection = getConnection()) { - if (isGetReadTimestampAllowed()) { - log("@EXPECT RESULT_SET 'READ_TIMESTAMP'"); - log("SHOW VARIABLE READ_TIMESTAMP;"); - assertThat(connection.getReadTimestamp(), is(notNullValue())); - } else { - log("@EXPECT RESULT_SET 'READ_TIMESTAMP',null"); - log("SHOW VARIABLE READ_TIMESTAMP;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.getReadTimestamp(); - } - } - } - - abstract boolean isGetCommitTimestampAllowed(); - - @Test - public void testGetCommitTimestamp() { - try (Connection connection = getConnection()) { - if (isGetCommitTimestampAllowed()) { - log("@EXPECT RESULT_SET 'COMMIT_TIMESTAMP'"); - log("SHOW VARIABLE COMMIT_TIMESTAMP;"); - assertThat(connection.getCommitTimestamp(), is(notNullValue())); - } else { - log("@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null"); - log("SHOW VARIABLE COMMIT_TIMESTAMP;"); - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.getCommitTimestamp(); - } - } - } - - abstract boolean isExecuteAllowed(StatementType type); - - @Test - public void testExecute() { - for (StatementType type : - new StatementType[] {StatementType.QUERY, StatementType.UPDATE, StatementType.DDL}) { - testExecute(type); - } - } - - private void testExecute(final StatementType type) { - try (Connection connection = getConnection()) { - if (isExecuteAllowed(type)) { - log(getTestStatement(type).getSql() + ";"); - assertThat(connection.execute(getTestStatement(type)), is(notNullValue())); - } else { - expectSpannerException( - type + " should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(getTestStatement(type).getSql() + ";"); - t.execute(getTestStatement(type)); - } - }, - connection); - } - } - } - - private Statement getTestStatement(StatementType type) { - switch (type) { - case QUERY: - return Statement.of(SELECT); - case UPDATE: - return Statement.of(UPDATE); - case DDL: - return Statement.of(DDL); - case CLIENT_SIDE: - case UNKNOWN: - default: - throw new IllegalArgumentException("Unsupported type: " + type); - } - } - - @Test - public void testExecuteQuery() { - for (StatementType type : - new StatementType[] {StatementType.QUERY, StatementType.UPDATE, StatementType.DDL}) { - testExecuteQuery(type); - } - } - - private void testExecuteQuery(final StatementType type) { - try (Connection connection = getConnection()) { - if (type == StatementType.QUERY && isExecuteAllowed(StatementType.QUERY)) { - log("@EXPECT RESULT_SET 'TEST',1"); - log(getTestStatement(type).getSql() + ";"); - ResultSet rs = connection.executeQuery(getTestStatement(type)); - assertThat(rs, is(notNullValue())); - assertThat(rs.getStats(), is(nullValue())); - } else if (type == StatementType.QUERY) { - // it is a query, but queries are not allowed for this connection state - expectSpannerException( - type + " should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(getTestStatement(type).getSql() + ";"); - t.executeQuery(getTestStatement(type)); - } - }, - connection, - ErrorCode.FAILED_PRECONDITION); - } else { - expectSpannerException( - type + " should be an invalid argument", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.executeQuery(getTestStatement(type)); - } - }, - connection, - ErrorCode.INVALID_ARGUMENT); - } - } - } - - @Test - public void testAnalyzeQuery() { - for (StatementType type : - new StatementType[] {StatementType.QUERY, StatementType.UPDATE, StatementType.DDL}) { - testAnalyzeQuery(type); - } - } - - private void testAnalyzeQuery(final StatementType type) { - // TODO: add log statements when ANALYZE ... sql statements are supported - try (Connection connection = getConnection()) { - for (QueryAnalyzeMode mode : QueryAnalyzeMode.values()) { - final QueryAnalyzeMode currentMode = mode; - if (type == StatementType.QUERY && isExecuteAllowed(StatementType.QUERY)) { - ResultSet rs = connection.analyzeQuery(getTestStatement(type), currentMode); - assertThat(rs, is(notNullValue())); - while (rs.next()) {} - assertThat(rs.getStats(), is(notNullValue())); - } else if (type == StatementType.QUERY) { - // it is a query, but queries are not allowed for this connection state - expectSpannerException( - type + " should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.analyzeQuery(getTestStatement(type), currentMode); - } - }, - connection, - ErrorCode.FAILED_PRECONDITION); - } else { - expectSpannerException( - type + " should be an invalid argument", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.analyzeQuery(getTestStatement(type), currentMode); - } - }, - connection, - ErrorCode.INVALID_ARGUMENT); - } - } - } - } - - @Test - public void testExecuteUpdate() { - for (StatementType type : - new StatementType[] {StatementType.QUERY, StatementType.UPDATE, StatementType.DDL}) { - testExecuteUpdate(type); - } - } - - private void testExecuteUpdate(final StatementType type) { - try (Connection connection = getConnection()) { - if (type == StatementType.UPDATE && isExecuteAllowed(StatementType.UPDATE)) { - log("@EXPECT UPDATE_COUNT 1"); - log(getTestStatement(type).getSql() + ";"); - assertThat(connection.executeUpdate(getTestStatement(type)), is(notNullValue())); - } else if (type == StatementType.UPDATE) { - // it is an update statement, but updates are not allowed for this connection state - expectSpannerException( - type + "should not be allowed", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - log("@EXPECT EXCEPTION FAILED_PRECONDITION"); - log(getTestStatement(type).getSql() + ";"); - t.executeUpdate(getTestStatement(type)); - } - }, - connection, - ErrorCode.FAILED_PRECONDITION); - } else { - expectSpannerException( - type + " should be an invalid argument", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.executeUpdate(getTestStatement(type)); - } - }, - connection, - ErrorCode.INVALID_ARGUMENT); - } - } - } - - abstract boolean isWriteAllowed(); - - @Test - public void testWrite() { - try (Connection connection = getConnection()) { - if (!isWriteAllowed() || !connection.isAutocommit()) { - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - connection.write(createTestMutation()); - } - } - - @Test - public void testWriteIterable() { - try (Connection connection = getConnection()) { - if (!isWriteAllowed() || !connection.isAutocommit()) { - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - connection.write(Arrays.asList(createTestMutation())); - } - } - - @Test - public void testBufferedWrite() { - try (Connection connection = getConnection()) { - if (!isWriteAllowed() || connection.isAutocommit()) { - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - connection.bufferedWrite(createTestMutation()); - } - } - - @Test - public void testBufferedWriteIterable() { - try (Connection connection = getConnection()) { - if (!isWriteAllowed() || connection.isAutocommit()) { - exception.expect(matchCode(ErrorCode.FAILED_PRECONDITION)); - } - connection.bufferedWrite(Arrays.asList(createTestMutation())); - } - } - - private Mutation createTestMutation() { - return Mutation.newInsertBuilder("foo").set("id").to(1L).set("name").to("bar").build(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSetTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSetTest.java deleted file mode 100644 index a267d224fc1..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcResultSetTest.java +++ /dev/null @@ -1,855 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; - -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.common.collect.Sets; -import com.google.rpc.Code; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigDecimal; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLXML; -import java.sql.Statement; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Set; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class AbstractJdbcResultSetTest { - - private JdbcResultSet rs; - - @Before - public void setup() { - rs = JdbcResultSet.of(mock(Statement.class), JdbcResultSetTest.getMockResultSet()); - } - - @Test - public void testFetchSize() throws SQLException { - assertThat(rs.getFetchSize(), is(equalTo(0))); - for (int size : new int[] {0, 1, 10, 100}) { - rs.setFetchSize(size); - assertThat(rs.getFetchSize(), is(equalTo(size))); - } - } - - @Test - public void testGetType() throws SQLException { - assertThat(rs.getType(), is(equalTo(ResultSet.TYPE_FORWARD_ONLY))); - } - - @Test - public void testGetConcurrency() throws SQLException { - assertThat(rs.getConcurrency(), is(equalTo(ResultSet.CONCUR_READ_ONLY))); - } - - @Test - public void testRowInsertedUpdatedDeleted() throws SQLException { - assertThat(rs.rowInserted(), is(false)); - assertThat(rs.rowUpdated(), is(false)); - assertThat(rs.rowDeleted(), is(false)); - } - - @Test - public void testGetFetchDirection() throws SQLException { - assertThat(rs.getFetchDirection(), is(equalTo(ResultSet.FETCH_FORWARD))); - } - - @Test - public void testSetFetchDirection() throws SQLException { - Set supported = Sets.newHashSet(ResultSet.FETCH_FORWARD); - for (int direction : - new int[] {ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, ResultSet.FETCH_UNKNOWN}) { - try { - rs.setFetchDirection(direction); - assertThat(supported.contains(direction), is(true)); - } catch (JdbcSqlExceptionImpl e) { - assertThat(supported.contains(direction), is(false)); - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - } - } - - private static interface SqlRunnable { - void run() throws SQLException; - } - - @Test - public void testUnsupportedFeatures() throws SQLException { - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getCursorName(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.isLast(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.beforeFirst(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.afterLast(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.first(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.last(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.absolute(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.relative(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.previous(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNull(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNull("test"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBoolean(1, Boolean.TRUE); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBoolean("test", Boolean.TRUE); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateByte(1, (byte) 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateByte("test", (byte) 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateShort(1, (short) 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateShort("test", (short) 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateInt(1, 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateInt("test", 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateLong(1, 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateLong("test", 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateFloat(1, 1F); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateFloat("test", 1F); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateDouble(1, 1D); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateDouble("test", 1D); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBigDecimal(1, BigDecimal.ONE); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBigDecimal("test", BigDecimal.ONE); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateString(1, "value"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateString("test", "value"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBytes(1, "value".getBytes()); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBytes("test", "value".getBytes()); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateDate(1, new Date(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateDate("test", new Date(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateTimestamp(1, new Timestamp(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateTimestamp("test", new Timestamp(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateTime(1, new Time(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateTime("test", new Time(System.currentTimeMillis())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream(1, new ByteArrayInputStream("value".getBytes())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream("test", new ByteArrayInputStream("value".getBytes())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream(1, new ByteArrayInputStream("value".getBytes()), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream("test", new ByteArrayInputStream("value".getBytes()), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream(1, new ByteArrayInputStream("value".getBytes()), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateAsciiStream("test", new ByteArrayInputStream("value".getBytes()), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream(1, new ByteArrayInputStream("value".getBytes())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream("test", new ByteArrayInputStream("value".getBytes())); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream(1, new ByteArrayInputStream("value".getBytes()), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream("test", new ByteArrayInputStream("value".getBytes()), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream(1, new ByteArrayInputStream("value".getBytes()), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBinaryStream("test", new ByteArrayInputStream("value".getBytes()), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream(1, new StringReader("value")); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream("test", new StringReader("value")); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream(1, new StringReader("value"), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream("test", new StringReader("value"), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream(1, new StringReader("value"), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateCharacterStream("test", new StringReader("value"), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateObject(1, new Object()); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateObject("test", new Object()); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateObject(1, new Object(), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateObject("test", new Object(), 1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.insertRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.deleteRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.refreshRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.cancelRowUpdates(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.moveToInsertRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.moveToCurrentRow(); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getRef(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getRef("test"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateRef(1, mock(Ref.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateRef("test", mock(Ref.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob(1, mock(Blob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob("test", mock(Blob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob(1, mock(InputStream.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob("test", mock(InputStream.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob(1, mock(InputStream.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateBlob("test", mock(InputStream.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob(1, mock(Clob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob("test", mock(Clob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob(1, mock(Reader.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob("test", mock(Reader.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob(1, mock(Reader.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateClob("test", mock(Reader.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateArray(1, mock(Array.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateArray("test", mock(Array.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getRowId(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getRowId("test"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateRowId(1, mock(RowId.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateRowId("test", mock(RowId.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNString(1, "value"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNString("test", "value"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob(1, mock(NClob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob("test", mock(NClob.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob(1, mock(Reader.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob("test", mock(Reader.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob(1, mock(Reader.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNClob("test", mock(Reader.class), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getSQLXML(1); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.getSQLXML("test"); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateSQLXML(1, mock(SQLXML.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateSQLXML("test", mock(SQLXML.class)); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNCharacterStream(1, new StringReader("value")); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNCharacterStream("test", new StringReader("value")); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNCharacterStream(1, new StringReader("value"), 1L); - } - }); - assertUnsupported( - new SqlRunnable() { - @Override - public void run() throws SQLException { - rs.updateNCharacterStream("test", new StringReader("value"), 1L); - } - }); - } - - private void assertUnsupported(SqlRunnable runnable) throws SQLException { - try { - runnable.run(); - fail("missing expected SQLFeatureNotSupportedException"); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } catch (Exception e) { - throw JdbcSqlExceptionFactory.of("unexpected exception", Code.INTERNAL, e); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapperTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapperTest.java deleted file mode 100644 index 1a391dfb24f..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapperTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.common.truth.Truth.assertThat; - -import java.sql.SQLException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class AbstractJdbcWrapperTest { - /** Create a concrete sub class to use for testing. */ - private static class TestWrapper extends AbstractJdbcWrapper { - @Override - public boolean isClosed() throws SQLException { - return false; - } - } - - /** Add a sub class for the test class for testing wrapping. */ - private static class SubTestWrapper extends TestWrapper {} - - @Test - public void testIsWrapperFor() throws SQLException { - TestWrapper subject = new TestWrapper(); - assertThat(subject.isWrapperFor(TestWrapper.class)).isTrue(); - assertThat(subject.isWrapperFor(SubTestWrapper.class)).isFalse(); - assertThat(subject.isWrapperFor(Object.class)).isTrue(); - assertThat(subject.isWrapperFor(getClass())).isFalse(); - - subject = new SubTestWrapper(); - assertThat(subject.isWrapperFor(TestWrapper.class)).isTrue(); - assertThat(subject.isWrapperFor(SubTestWrapper.class)).isTrue(); - assertThat(subject.isWrapperFor(Object.class)).isTrue(); - assertThat(subject.isWrapperFor(getClass())).isFalse(); - } - - @Test - public void testUnwrap() throws SQLException { - TestWrapper subject = new TestWrapper(); - assertThat(unwrapSucceeds(subject, TestWrapper.class)).isTrue(); - assertThat(unwrapSucceeds(subject, SubTestWrapper.class)).isFalse(); - assertThat(unwrapSucceeds(subject, Object.class)).isTrue(); - assertThat(unwrapSucceeds(subject, getClass())).isFalse(); - } - - private static interface CheckedCastChecker { - boolean cast(V val); - } - - private static final class CheckedCastToByteChecker implements CheckedCastChecker { - @Override - public boolean cast(Long val) { - try { - AbstractJdbcWrapper.checkedCastToByte(val); - return true; - } catch (SQLException e) { - return false; - } - } - } - - @Test - public void testCheckedCastToByte() throws SQLException { - CheckedCastToByteChecker checker = new CheckedCastToByteChecker(); - assertThat(checker.cast(0L)).isTrue(); - assertThat(checker.cast(1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Byte.MAX_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Byte.MAX_VALUE) + 1L)).isFalse(); - assertThat(checker.cast(Long.MAX_VALUE)).isFalse(); - assertThat(checker.cast(-1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Byte.MIN_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Byte.MIN_VALUE) - 1L)).isFalse(); - assertThat(checker.cast(Long.MIN_VALUE)).isFalse(); - } - - private static final class CheckedCastToShortChecker implements CheckedCastChecker { - @Override - public boolean cast(Long val) { - try { - AbstractJdbcWrapper.checkedCastToShort(val); - return true; - } catch (SQLException e) { - return false; - } - } - } - - @Test - public void testCheckedCastToShort() throws SQLException { - CheckedCastToShortChecker checker = new CheckedCastToShortChecker(); - assertThat(checker.cast(0L)).isTrue(); - assertThat(checker.cast(1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Short.MAX_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Short.MAX_VALUE) + 1L)).isFalse(); - assertThat(checker.cast(Long.MAX_VALUE)).isFalse(); - assertThat(checker.cast(-1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Short.MIN_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Short.MIN_VALUE) - 1L)).isFalse(); - assertThat(checker.cast(Long.MIN_VALUE)).isFalse(); - } - - private static final class CheckedCastToIntChecker implements CheckedCastChecker { - @Override - public boolean cast(Long val) { - try { - AbstractJdbcWrapper.checkedCastToInt(val); - return true; - } catch (SQLException e) { - return false; - } - } - } - - @Test - public void testCheckedCastToInt() throws SQLException { - CheckedCastToIntChecker checker = new CheckedCastToIntChecker(); - assertThat(checker.cast(0L)).isTrue(); - assertThat(checker.cast(1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Integer.MAX_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Integer.MAX_VALUE) + 1L)).isFalse(); - assertThat(checker.cast(Long.MAX_VALUE)).isFalse(); - assertThat(checker.cast(-1L)).isTrue(); - assertThat(checker.cast(Long.valueOf(Integer.MIN_VALUE))).isTrue(); - assertThat(checker.cast(Long.valueOf(Integer.MIN_VALUE) - 1L)).isFalse(); - assertThat(checker.cast(Long.MIN_VALUE)).isFalse(); - } - - private static final class CheckedCastToFloatChecker implements CheckedCastChecker { - @Override - public boolean cast(Double val) { - try { - AbstractJdbcWrapper.checkedCastToFloat(val); - return true; - } catch (SQLException e) { - return false; - } - } - } - - @Test - public void testCheckedCastToFloat() throws SQLException { - CheckedCastToFloatChecker checker = new CheckedCastToFloatChecker(); - assertThat(checker.cast(0D)).isTrue(); - assertThat(checker.cast(1D)).isTrue(); - assertThat(checker.cast(Double.valueOf(Float.MAX_VALUE))).isTrue(); - assertThat(checker.cast(Double.valueOf(Float.MAX_VALUE) * 2.0D)).isFalse(); - assertThat(checker.cast(Double.MAX_VALUE)).isFalse(); - assertThat(checker.cast(-1D)).isTrue(); - assertThat(checker.cast(Double.valueOf(Float.MIN_VALUE))).isTrue(); - assertThat(checker.cast(Double.valueOf(-Float.MAX_VALUE * 2))).isFalse(); - assertThat(checker.cast(-Double.MAX_VALUE)).isFalse(); - } - - private boolean unwrapSucceeds(AbstractJdbcWrapper subject, Class iface) { - try { - subject.unwrap(iface); - return true; - } catch (SQLException e) { - return false; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractSqlScriptVerifier.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractSqlScriptVerifier.java deleted file mode 100644 index 71a1865b84e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AbstractSqlScriptVerifier.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Scanner; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Base class for SQL Script verifiers for both the generic Connection API and JDBC connections - * - *

Simple parser/verifier for sql statements. This verifier is able to parse additional @EXPECT - * statements that defines the expected behavior of a sql statement. Possible uses are: - * - *

    - *
  • @EXPECT NO_RESULT: The following statement should not return a result (no {@link ResultSet} - * and no update count) - *
  • @EXPECT UPDATE_COUNT count: The following statement should return the specified - * update count - *
  • @EXPECT RESULT_SET: The following statement should return a {@link ResultSet} with two - * columns with the names ACTUAL and EXPECTED and containing at least one row. For each row, - * the values of ACTUAL and EXPECTED must be equal - *
  • @EXPECT RESULT_SET 'columnName': The following statement should return a {@link ResultSet} - * with a column with the specified name and containing at least one row (additional columns - * in the {@link ResultSet} are allowed). For each row, the value of the column must be not - * null - *
  • @EXPECT RESULT_SET 'columnName',value: The following statement should return a {@link - * ResultSet} with a column with the specified name and containing at least one row - * (additional columns in the {@link ResultSet} are allowed). For each row, the value of the - * column must be equal to the specified value - *
  • @EXPECT EXCEPTION code ['messagePrefix']: The following statement should throw a {@link - * SpannerException} with the specified code and starting with the (optional) message prefix - *
  • @EXPECT EQUAL 'variable1','variable2': The values of the two given variables should be - * equal. The value of a variable can be set using a @PUT statement. - *
- * - * The parser can set a temporary variable value using a @PUT statement: - * @PUT 'variable_name'\nSQL statement The SQL statement must be a statement that returns a - * {@link ResultSet} containing exactly one row and one column. - * - *

In addition the verifier can create new connections if the script contains NEW_CONNECTION; - * statements and the verifier has been created with a {@link GenericConnectionProvider}. See {@link - * ConnectionImplGeneratedSqlScriptTest} for an example for this. - */ -public abstract class AbstractSqlScriptVerifier { - private static final Pattern VERIFY_PATTERN = - Pattern.compile( - "(?is)\\s*(?:@EXPECT)\\s+" - + "(?NO_RESULT" - + "|RESULT_SET\\s*(?'.*?'(?,.*?)?)?" - + "|UPDATE_COUNT\\s*(?-?\\d{1,19})" - + "|EXCEPTION\\s*(?(?CANCELLED|UNKNOWN|INVALID_ARGUMENT|DEADLINE_EXCEEDED|NOT_FOUND|ALREADY_EXISTS|PERMISSION_DENIED|UNAUTHENTICATED|RESOURCE_EXHAUSTED|FAILED_PRECONDITION|ABORTED|OUT_OF_RANGE|UNIMPLEMENTED|INTERNAL|UNAVAILABLE|DATA_LOSS)(?:\\s*)(?'.*?')?)" - + "|EQUAL\\s+(?'.+?')\\s*,\\s*(?'.+?')" - + ")" - + "(\\n(?.*))?"); - - private static final String PUT_CONDITION = - "@PUT can only be used in combination with a statement that returns a" - + " result set containing exactly one row and one column"; - private static final Pattern PUT_PATTERN = - Pattern.compile("(?is)\\s*(?:@PUT)\\s+(?'.*?')" + "\\n(?.*)"); - - protected enum ExpectedResultType { - RESULT_SET, - UPDATE_COUNT, - NO_RESULT, - EXCEPTION, - EQUAL; - - StatementResult.ResultType getStatementResultType() { - switch (this) { - case NO_RESULT: - return StatementResult.ResultType.NO_RESULT; - case RESULT_SET: - return StatementResult.ResultType.RESULT_SET; - case UPDATE_COUNT: - return StatementResult.ResultType.UPDATE_COUNT; - case EXCEPTION: - case EQUAL: - default: - throw new IllegalArgumentException("not supported"); - } - } - } - - /** Result of an executed statement */ - protected abstract static class GenericStatementResult { - protected abstract StatementResult.ResultType getResultType(); - - protected abstract GenericResultSet getResultSet(); - - protected abstract long getUpdateCount(); - } - - /** - * Generic wrapper around a connection to a database. The underlying connection could be a Spanner - * {@link com.google.cloud.spanner.jdbc.Connection} or a JDBC {@link java.sql.Connection} - */ - public abstract static class GenericConnection implements AutoCloseable { - protected abstract GenericStatementResult execute(String sql) throws Exception; - - @Override - public abstract void close() throws Exception; - } - - /** - * Generic wrapper around a result set. The underlying result set could be a Spanner {@link - * ResultSet} or a JDBC {@link java.sql.ResultSet} - */ - protected abstract static class GenericResultSet { - protected abstract boolean next() throws Exception; - - protected abstract Object getValue(String col) throws Exception; - - protected abstract int getColumnCount() throws Exception; - - protected abstract Object getFirstValue() throws Exception; - } - - public static interface GenericConnectionProvider { - public GenericConnection getConnection(); - } - - /** Reads SQL statements from a file. Any copyright header in the file will be stripped away. */ - public static List readStatementsFromFile(String filename, Class resourceClass) { - File file = new File(resourceClass.getResource(filename).getFile()); - StringBuilder builder = new StringBuilder(); - try (Scanner scanner = new Scanner(file)) { - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - builder.append(line).append("\n"); - } - scanner.close(); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - String script = builder.toString().replaceAll(StatementParserTest.COPYRIGHT_PATTERN, ""); - String[] array = script.split(";"); - List res = new ArrayList<>(array.length); - for (String statement : array) { - if (statement != null && statement.trim().length() > 0) { - res.add(statement); - } - } - return res; - } - - private final GenericConnectionProvider connectionProvider; - - private final Map variables = new HashMap<>(); - - private final boolean logStatements; - - /** - * Constructor for a verifier that will take a {@link GenericConnection} as a parameter to the - * {@link AbstractSqlScriptVerifier#verifyStatementsInFile(GenericConnection, String, Class, - * boolean)} - */ - public AbstractSqlScriptVerifier() { - this(null); - } - - /** Constructor for a verifier that will use a connection provider for connections */ - public AbstractSqlScriptVerifier(GenericConnectionProvider provider) { - this.connectionProvider = provider; - this.logStatements = Boolean.parseBoolean(System.getProperty("log_sql_statements", "false")); - } - - /** - * Reads sql statements from the specified file name and executes and verifies these. Statements - * that are preceeded by an @EXPECT statement are verified against the @EXPECT specification. - * Statements without an @EXPECT statement will be executed and its result will be ignored, unless - * the statement throws an exception, which will fail the test case. - * - *

The {@link com.google.cloud.spanner.jdbc.Connection}s that the statements are executed on - * must be created by a {@link GenericConnectionProvider} - * - * @param filename The file name containing the statements. Statements must be separated by a - * semicolon (;) - * @param resourceClass The class that should be used to locate the resource specified by the file - * name - * @throws Exception - */ - public void verifyStatementsInFile(String filename, Class resourceClass) throws Exception { - verifyStatementsInFile(connectionProvider.getConnection(), filename, resourceClass); - } - - /** - * Reads sql statements from the specified file name and executes and verifies these. Statements - * that are preceeded by an @EXPECT statement are verified against the @EXPECT specification. - * Statements without an @EXPECT statement will be executed and its result will be ignored, unless - * the statement throws an exception, which will fail the test case. - * - * @param connection The {@link com.google.cloud.spanner.jdbc.Connection} to execute the - * statements against - * @param filename The file name containing the statements. Statements must be separated by a - * semicolon (;) - * @param resourceClass The class that defines the package where to find the input file - */ - public void verifyStatementsInFile( - GenericConnection connection, String filename, Class resourceClass) throws Exception { - try { - List statements = readStatementsFromFile(filename, resourceClass); - for (String statement : statements) { - String sql = statement.trim(); - if (logStatements) { - System.out.println( - "\n------------------------------------------------------\n" - + new Date() - + " ---- verifying statement:"); - System.out.println(sql); - } - if (sql.equalsIgnoreCase("NEW_CONNECTION")) { - connection.close(); - connection = connectionProvider.getConnection(); - variables.clear(); - } else { - verifyStatement(connection, sql); - } - } - } finally { - if (connection != null) { - connection.close(); - } - } - } - - private void verifyStatement(GenericConnection connection, String statement) throws Exception { - statement = replaceVariables(statement); - String statementWithoutComments = StatementParser.removeCommentsAndTrim(statement); - Matcher verifyMatcher = VERIFY_PATTERN.matcher(statementWithoutComments); - Matcher putMatcher = PUT_PATTERN.matcher(statementWithoutComments); - if (verifyMatcher.matches()) { - String sql = verifyMatcher.group("statement"); - String typeName = verifyMatcher.group("type"); - int endIndex = getFirstSpaceChar(typeName); - ExpectedResultType type = ExpectedResultType.valueOf(typeName.substring(0, endIndex)); - if (type == ExpectedResultType.EXCEPTION) { - String code = verifyMatcher.group("code"); - String messagePrefix = verifyMatcher.group("messagePrefix"); - try { - connection.execute(sql); - fail("expected exception: " + sql); - } catch (Exception e) { - verifyExpectedException(statementWithoutComments, e, code, messagePrefix); - } - } else if (type == ExpectedResultType.EQUAL) { - String variable1 = verifyMatcher.group("variable1"); - String variable2 = verifyMatcher.group("variable2"); - // get rid of the single quotes - variable1 = variable1.substring(1, variable1.length() - 1); - variable2 = variable2.substring(1, variable2.length() - 1); - assertThat( - "No variable with name " + variable1, variables.containsKey(variable1), is(true)); - assertThat( - "No variable with name " + variable2, variables.containsKey(variable2), is(true)); - Object value1 = variables.get(variable1); - Object value2 = variables.get(variable2); - if ((value1 instanceof Timestamp) && (value2 instanceof Timestamp)) { - // read timestamps are rounded - Timestamp ts1 = (Timestamp) value1; - Timestamp ts2 = (Timestamp) value2; - value1 = - Timestamp.ofTimeSecondsAndNanos(ts1.getSeconds(), (ts1.getNanos() / 1000) * 1000); - value2 = - Timestamp.ofTimeSecondsAndNanos(ts2.getSeconds(), (ts2.getNanos() / 1000) * 1000); - } - assertThat(value1, is(equalTo(value2))); - } else { - GenericStatementResult result = connection.execute(sql); - assertThat(statement, result.getResultType(), is(equalTo(type.getStatementResultType()))); - switch (type.getStatementResultType()) { - case NO_RESULT: - break; - case RESULT_SET: - String column = verifyMatcher.group("column"); - if (column == null) { - verifyActualVsExpectedResultSet(statement, result.getResultSet()); - } else { - String value = verifyMatcher.group("value"); - if (value != null) { - String parts[] = column.split(",", 2); - column = parts[0].trim(); - value = parts[1].trim(); - column = column.substring(1, column.length() - 1); - verifyResultSetValue(statement, result.getResultSet(), column, parseValue(value)); - } else { - // get rid of the quotation marks - column = column.substring(1, column.length() - 1); - verifyResultSetColumnNotNull(statement, result.getResultSet(), column); - } - } - break; - case UPDATE_COUNT: - long expectedUpdateCount = Long.valueOf(verifyMatcher.group("count").trim()); - assertThat(statement, result.getUpdateCount(), is(equalTo(expectedUpdateCount))); - break; - } - } - } else if (putMatcher.matches()) { - String sql = putMatcher.group("statement"); - String variable = putMatcher.group("variable"); - // get rid of the single quotes - variable = variable.substring(1, variable.length() - 1); - GenericStatementResult result = connection.execute(sql); - assertThat( - PUT_CONDITION, - result.getResultType(), - is(equalTo(com.google.cloud.spanner.jdbc.StatementResult.ResultType.RESULT_SET))); - GenericResultSet rs = result.getResultSet(); - assertThat(PUT_CONDITION, rs.next(), is(true)); - assertThat(PUT_CONDITION, rs.getColumnCount(), is(equalTo(1))); - variables.put(variable, rs.getFirstValue()); - assertThat(PUT_CONDITION, rs.next(), is(false)); - } else { - // just execute the statement - connection.execute(statement); - } - } - - private String replaceVariables(String sql) { - for (String key : variables.keySet()) { - sql = sql.replaceAll("%%" + key + "%%", variables.get(key).toString()); - } - return sql; - } - - protected abstract void verifyExpectedException( - String statement, Exception e, String code, String messagePrefix); - - private static final Pattern INT64_PATTERN = Pattern.compile("\\d{1,19}"); - private static final Pattern ARRAY_INT64_PATTERN = - Pattern.compile("\\[\\s*\\d{1,19}(\\s*,\\s*\\d{1,19})*\\s*\\]"); - private static final Pattern FLOAT64_PATTERN = Pattern.compile("\\d{1,19}.\\d{1,19}"); - private static final String TS_PREFIX = "ts'"; - private static final String TS_SUFFIX = "'"; - private static final Pattern BOOLEAN_PATTERN = Pattern.compile("(?is)true|false"); - - private Object parseValue(String valueString) { - if (valueString == null || "".equals(valueString) || "null".equalsIgnoreCase(valueString)) { - return null; - } - if (valueString.startsWith("'") && valueString.endsWith("'")) { - return valueString.substring(1, valueString.length() - 1); - } - if (INT64_PATTERN.matcher(valueString).matches()) { - return Long.valueOf(valueString); - } - if (ARRAY_INT64_PATTERN.matcher(valueString).matches()) { - String[] stringArray = valueString.substring(1, valueString.length() - 1).split(","); - List res = new ArrayList<>(); - for (int i = 0; i < stringArray.length; i++) { - res.add(Long.valueOf(stringArray[i])); - } - return res; - } - if (FLOAT64_PATTERN.matcher(valueString).matches()) { - return Double.valueOf(valueString); - } - if (valueString.startsWith(TS_PREFIX) && valueString.endsWith(TS_SUFFIX)) { - try { - return ReadOnlyStalenessUtil.parseRfc3339( - valueString.substring(TS_PREFIX.length(), valueString.length() - TS_SUFFIX.length())); - } catch (IllegalArgumentException e) { - // ignore, apparently not a valid a timestamp after all. - } - } - if (BOOLEAN_PATTERN.matcher(valueString).matches()) { - return Boolean.valueOf(valueString); - } - return valueString; - } - - private int getFirstSpaceChar(String input) { - for (int index = 0; index < input.length(); index++) { - if (Character.isWhitespace(input.charAt(index))) { - return index; - } - } - return input.length(); - } - - private void verifyResultSetColumnNotNull(String statement, GenericResultSet rs, String column) - throws Exception { - int count = 0; - while (rs.next()) { - assertThat(statement, getValue(rs, column), is(notNullValue())); - count++; - } - assertThat(count, is(not(equalTo(0)))); - } - - private void verifyResultSetValue( - String statement, GenericResultSet rs, String column, Object value) throws Exception { - int count = 0; - while (rs.next()) { - if (value == null) { - assertThat(statement, getValue(rs, column), is(nullValue())); - } else { - assertEquals(statement, getValue(rs, column), value); - } - count++; - } - assertThat(count, is(not(equalTo(0)))); - } - - private void verifyActualVsExpectedResultSet(String statement, GenericResultSet rs) - throws Exception { - int count = 0; - while (rs.next()) { - assertThat(statement, getValue(rs, "ACTUAL"), is(equalTo(getValue(rs, "EXPECTED")))); - count++; - } - assertThat(count, is(not(equalTo(0)))); - } - - private Object getValue(GenericResultSet rs, String col) throws Exception { - return rs.getValue(col); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeConverterTest.java deleted file mode 100644 index 91b54a961a8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeConverterTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.ClientSideStatementValueConverters.AutocommitDmlModeConverter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class AutocommitDmlModeConverterTest { - - @Test - public void testConvert() throws CompileException { - String allowedValues = - ReadOnlyStalenessConverterTest.getAllowedValues(AutocommitDmlModeConverter.class); - assertThat(allowedValues, is(notNullValue())); - AutocommitDmlModeConverter converter = new AutocommitDmlModeConverter(allowedValues); - assertThat(converter.convert("transactional"), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - assertThat(converter.convert("TRANSACTIONAL"), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - assertThat(converter.convert("Transactional"), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - - assertThat( - converter.convert("partitioned_non_atomic"), - is(equalTo(AutocommitDmlMode.PARTITIONED_NON_ATOMIC))); - assertThat( - converter.convert("Partitioned_Non_Atomic"), - is(equalTo(AutocommitDmlMode.PARTITIONED_NON_ATOMIC))); - assertThat( - converter.convert("PARTITIONED_NON_ATOMIC"), - is(equalTo(AutocommitDmlMode.PARTITIONED_NON_ATOMIC))); - - assertThat(converter.convert(""), is(nullValue())); - assertThat(converter.convert(" "), is(nullValue())); - assertThat(converter.convert("random string"), is(nullValue())); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeTest.java deleted file mode 100644 index cf7ba02e33c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/AutocommitDmlModeTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionRunner; -import com.google.cloud.spanner.TransactionRunner.TransactionCallable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class AutocommitDmlModeTest { - private static final String UPDATE = "UPDATE foo SET bar=1"; - private static final String URI = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - - private DatabaseClient dbClient; - private TransactionContext txContext; - - @SuppressWarnings("unchecked") - private ConnectionImpl createConnection(ConnectionOptions options) { - dbClient = mock(DatabaseClient.class); - txContext = mock(TransactionContext.class); - Spanner spanner = mock(Spanner.class); - SpannerPool spannerPool = mock(SpannerPool.class); - when(spannerPool.getSpanner(any(ConnectionOptions.class), any(ConnectionImpl.class))) - .thenReturn(spanner); - DdlClient ddlClient = mock(DdlClient.class); - TransactionRunner txRunner = mock(TransactionRunner.class); - when(dbClient.readWriteTransaction()).thenReturn(txRunner); - when(txRunner.run(any(TransactionCallable.class))) - .thenAnswer( - new Answer() { - @Override - public Long answer(InvocationOnMock invocation) throws Throwable { - TransactionCallable callable = - (TransactionCallable) invocation.getArguments()[0]; - return callable.run(txContext); - } - }); - - TransactionManager txManager = mock(TransactionManager.class); - when(txManager.begin()).thenReturn(txContext); - when(dbClient.transactionManager()).thenReturn(txManager); - - return new ConnectionImpl(options, spannerPool, ddlClient, dbClient); - } - - @Test - public void testAutocommitDmlModeTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(connection.isAutocommit(), is(true)); - assertThat(connection.isReadOnly(), is(false)); - assertThat(connection.getAutocommitDmlMode(), is(AutocommitDmlMode.TRANSACTIONAL)); - - connection.execute(Statement.of(UPDATE)); - verify(txContext).executeUpdate(Statement.of(UPDATE)); - verify(dbClient, never()).executePartitionedUpdate(Statement.of(UPDATE)); - } - } - - @Test - public void testAutocommitDmlModePartitioned() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(connection.isAutocommit(), is(true)); - assertThat(connection.isReadOnly(), is(false)); - connection.setAutocommitDmlMode(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - assertThat(connection.getAutocommitDmlMode(), is(AutocommitDmlMode.PARTITIONED_NON_ATOMIC)); - - connection.execute(Statement.of(UPDATE)); - verify(txContext, never()).executeUpdate(Statement.of(UPDATE)); - verify(dbClient).executePartitionedUpdate(Statement.of(UPDATE)); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/BooleanConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/BooleanConverterTest.java deleted file mode 100644 index 4c9447fb198..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/BooleanConverterTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.ClientSideStatementValueConverters.BooleanConverter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class BooleanConverterTest { - - @Test - public void testConvert() throws CompileException { - String allowedValues = ReadOnlyStalenessConverterTest.getAllowedValues(BooleanConverter.class); - assertThat(allowedValues, is(notNullValue())); - BooleanConverter converter = new BooleanConverter(allowedValues); - assertThat(converter.convert("true"), is(equalTo(Boolean.TRUE))); - assertThat(converter.convert("TRUE"), is(equalTo(Boolean.TRUE))); - assertThat(converter.convert("True"), is(equalTo(Boolean.TRUE))); - - assertThat(converter.convert("false"), is(equalTo(Boolean.FALSE))); - assertThat(converter.convert("FALSE"), is(equalTo(Boolean.FALSE))); - assertThat(converter.convert("False"), is(equalTo(Boolean.FALSE))); - - assertThat(converter.convert(""), is(nullValue())); - assertThat(converter.convert(" "), is(nullValue())); - assertThat(converter.convert("random string"), is(nullValue())); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.java deleted file mode 100644 index 4ba2cb7a0fb..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.junit.AfterClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Test that runs a pre-generated sql script for {@link ClientSideStatement}s. The sql script can be - * generated by running mvn -P generate-test-sql-scripts compile It is only necessary - * to generate a new test script if a new {@link ClientSideStatement} has been added, or the - * behavior of an existing {@link ClientSideStatement} has changed. - * - *

This class does not need to be implemented for the client libraries of other programming - * languages. All test cases are covered by the sql file ClientSideStatementsTest.sql. - */ -@RunWith(JUnit4.class) -public class ClientSideStatementsTest { - - @Test - public void testExecuteClientSideStatementsScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile("ClientSideStatementsTest.sql", getClass()); - } - - private static final String SCRIPT_FILE = - "src/test/resources/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.sql"; - private static PrintWriter writer; - - /** Generates the test script file */ - static void generateTestScript() throws Exception { - try { - openLog(); - ClientSideStatements statements = ClientSideStatements.INSTANCE; - for (ClientSideStatementImpl statement : statements.getCompiledStatements()) { - generateTestStatements(statement); - } - } finally { - closeLog(); - } - } - - /** Writes the prerequisite statements + the given sql statement to a script file */ - private static void log(List pre, String sql) { - writeLog("NEW_CONNECTION"); - for (String prerequisite : pre) { - writeLog(prerequisite); - } - writeLog(sql); - } - - /** - * Writes the prerequisite statements + the given sql statement to a script file preceded by - * an @EXPECT EXCEPTION error statement - */ - private static void log(List pre, String statement, ErrorCode error) { - log(pre, "@EXPECT EXCEPTION " + error.name() + "\n" + statement); - } - - /** Writes the actual statement to the script file */ - private static void writeLog(String statement) { - writer.println(statement + ";"); - } - - private static void openLog() { - try { - writer = - new PrintWriter( - new OutputStreamWriter(new FileOutputStream(SCRIPT_FILE, false), "UTF8"), true); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @AfterClass - public static void closeLog() { - if (writer != null) { - writer.close(); - } - } - - static class TestConnectionProvider implements GenericConnectionProvider { - @Override - public GenericConnection getConnection() { - return SpannerGenericConnection.of( - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build())); - } - } - - /** Generates test statements for all {@link ClientSideStatement}s */ - private static void generateTestStatements(ClientSideStatementImpl statement) { - for (String sql : statement.getExampleStatements()) { - log(statement.getExamplePrerequisiteStatements(), sql); - log(statement.getExamplePrerequisiteStatements(), upper(sql)); - log(statement.getExamplePrerequisiteStatements(), lower(sql)); - log(statement.getExamplePrerequisiteStatements(), withLeadingSpaces(sql)); - log(statement.getExamplePrerequisiteStatements(), withLeadingTabs(sql)); - log(statement.getExamplePrerequisiteStatements(), withLeadingLinefeeds(sql)); - log(statement.getExamplePrerequisiteStatements(), withTrailingSpaces(sql)); - log(statement.getExamplePrerequisiteStatements(), withTrailingTabs(sql)); - log(statement.getExamplePrerequisiteStatements(), withTrailingLinefeeds(sql)); - log(statement.getExamplePrerequisiteStatements(), withSpaces(sql)); - log(statement.getExamplePrerequisiteStatements(), withTabs(sql)); - log(statement.getExamplePrerequisiteStatements(), withLinefeeds(sql)); - - log( - statement.getExamplePrerequisiteStatements(), - withInvalidPrefix(sql), - ErrorCode.INVALID_ARGUMENT); - log( - statement.getExamplePrerequisiteStatements(), - withInvalidSuffix(sql), - ErrorCode.INVALID_ARGUMENT); - - final String[] replacements = { - "%", "_", "&", "$", "@", "!", "*", "(", ")", "-", "+", "-#", "/", "\\", "?", "-/", "/#", - "/-" - }; - for (String replacement : replacements) { - log( - statement.getExamplePrerequisiteStatements(), - withPrefix(replacement, sql), - ErrorCode.INVALID_ARGUMENT); - log( - statement.getExamplePrerequisiteStatements(), - withSuffix(replacement, sql), - ErrorCode.INVALID_ARGUMENT); - log( - statement.getExamplePrerequisiteStatements(), - replaceLastSpaceWith(replacement, sql), - ErrorCode.INVALID_ARGUMENT); - } - } - } - - private static String upper(String statement) { - return statement.toUpperCase(); - } - - private static String lower(String statement) { - return statement.toLowerCase(); - } - - private static String withLeadingSpaces(String statement) { - return " " + statement; - } - - private static String withLeadingTabs(String statement) { - return "\t\t\t" + statement; - } - - private static String withLeadingLinefeeds(String statement) { - return "\n\n\n" + statement; - } - - private static String withTrailingSpaces(String statement) { - return statement + " "; - } - - private static String withTrailingTabs(String statement) { - return statement + "\t\t"; - } - - private static String withTrailingLinefeeds(String statement) { - return statement + "\n\n"; - } - - private static String withSpaces(String statement) { - return statement.replaceAll(" ", " "); - } - - private static String withTabs(String statement) { - return statement.replaceAll(" ", "\t"); - } - - private static String withLinefeeds(String statement) { - // Do not replace spaces inside quotes - Matcher matcher = Pattern.compile("(.*)('.*')").matcher(statement); - if (matcher.matches()) { - return matcher.group(1).replaceAll(" ", "\n") + matcher.group(2); - } - return statement.replaceAll(" ", "\n"); - } - - private static String withInvalidPrefix(String statement) { - return "foo " + statement; - } - - private static String withInvalidSuffix(String statement) { - return statement + " bar"; - } - - private static String withPrefix(String prefix, String statement) { - return prefix + statement; - } - - private static String withSuffix(String suffix, String statement) { - return statement + suffix; - } - - private static String replaceLastSpaceWith(String replacement, String statement) { - if (statement.lastIndexOf(' ') > -1) { - return statement.substring(0, statement.lastIndexOf(' ')) - + replacement - + statement.substring(statement.lastIndexOf(' ') + 1); - } - return statement + replacement; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadOnlyTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadOnlyTest.java deleted file mode 100644 index 3cfd42d7e10..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadOnlyTest.java +++ /dev/null @@ -1,914 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import java.util.concurrent.TimeUnit; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -/** - * The tests in this class do not need to be implemented for client libraries in other programming - * languages, as all test cases are covered by the file ConnectionImplGeneratedSqlScriptTest.sql - */ -@RunWith(Enclosed.class) -public class ConnectionImplAutocommitReadOnlyTest { - - public static class ConnectionImplAutocommitReadOnlyNoActionsTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query has been executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadOnlyAfterSelectTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - // no call to next() on ResultSet - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last statement was a query, next() has not yet been called, but as the connection api - // returns a directly executed resultset, the read timestamp is already available - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadOnlyAfterSelectAndResultSetNextTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)).next(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last statement was a query - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadOnlyAfterBeginTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // connection is in read-only mode - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // in a transaction, only exact allowed - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadOnlyAfterTemporaryTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - // readonly - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last action was a transaction that ended with a select query - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadOnlyAfterSetReadOnlyMaxStalenessTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - TimestampBound staleness = TimestampBound.ofMaxStaleness(10L, TimeUnit.SECONDS); - log( - "SET READ_ONLY_STALENESS='" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "';"); - connection.setReadOnlyStaleness(staleness); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - // readonly - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadWriteTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadWriteTest.java deleted file mode 100644 index 304bf8f539d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplAutocommitReadWriteTest.java +++ /dev/null @@ -1,1325 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -/** - * The tests in this class do not need to be implemented for client libraries in other programming - * languages, as all test cases are covered by the file ConnectionImplGeneratedSqlScriptTest.sql - */ -@RunWith(Enclosed.class) -public class ConnectionImplAutocommitReadWriteTest { - - public static class ConnectionImplAutocommitReadWriteNoActionsTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query has been executed - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterSelectTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - // no next() called - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last statement was a query, next() has not yet been called, but as the connection api - // returns a directly executed resultset, the read timestamp is already available - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterSelectAndResultSetNextTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - // the @expect ensures next() is called - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // the last action was a query that has retrieved data - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterUpdateTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log(UPDATE + ";"); - connection.execute(Statement.of(UPDATE)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return true; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterDdlTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log(DDL + ";"); - connection.execute(Statement.of(DDL)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // there is no transaction - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterBeginTransactionTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // in temporary transaction - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - // default is a read-write transaction - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterTemporaryTransactionTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log(UPDATE + ";"); - connection.execute(Statement.of(UPDATE)); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return true; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return true; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return true; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterBeginReadOnlyTransactionTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log("SET TRANSACTION READ ONLY;"); - connection.setTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // in temporary transaction - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - // it's a read-only transaction - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplAutocommitReadWriteAfterStartDdlBatchTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=TRUE;"); - connection.setAutocommit(true); - log("START BATCH DDL;"); - connection.startBatchDdl(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return false; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - // it's a DDL batch - return type == StatementType.CLIENT_SIDE || type == StatementType.DDL; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return true; - } - - @Override - boolean isAbortBatchAllowed() { - return true; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.java deleted file mode 100644 index fff50fa8982..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.ClassPath; -import com.google.common.reflect.ClassPath.ClassInfo; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * This test executes a SQL script that has been generated from the log of all the subclasses of - * {@link AbstractConnectionImplTest} and covers the same test cases. Its aim is to verify that the - * connection reacts correctly in all possible states (i.e. DML statements should not be allowed - * when the connection is in read-only mode, or when a read-only transaction has started etc.) - * - *

A new test script can be generated by running: mvn -P generate-test-sql-scripts compile - * It is only necessary to generate a new test script if the behavior of {@link - * com.google.cloud.spanner.jdbc.Connection} has changed (for example calling COMMIT is currently - * not allowed in AUTOCOMMIT mode, but this has changed to be a no-op). A new test script must also - * be generated if additional test cases have been added to {@link AbstractConnectionImplTest}. - */ -@RunWith(JUnit4.class) -public class ConnectionImplGeneratedSqlScriptTest { - - static class TestConnectionProvider implements GenericConnectionProvider { - @Override - public GenericConnection getConnection() { - return SpannerGenericConnection.of( - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build())); - } - } - - @Test - public void testGeneratedScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile("ConnectionImplGeneratedSqlScriptTest.sql", getClass()); - } - - /** - * Generates the test SQL script. It should be noted that running this method multiple times - * without having changed anything in the underlying code, could still yield different script - * files, as the script is generated by running a number of JUnit test cases. The order in which - * these test cases are run is non-deterministic. That means that the generated sql script will - * still contain exactly the same test cases after each generation, but the order of the test - * cases in the script file is equal to the order in which the test cases were run the last time - * the script was generated. It is therefore also not recommended to include this generation in an - * automatic build, but to generate the script only when there has been some fundamental change in - * the code. - * - *

The sql test scripts can be generated by running - * mvn -P generate-test-sql-scripts compile - */ - static void generateTestScript() throws ClassNotFoundException, IOException { - // first make the current script file empty - AbstractConnectionImplTest.emptyScript(); - JUnitCore junit = new JUnitCore(); - Class[] testClasses = getAbstractConnectionImplTestSubclasses(); - Result result = junit.run(testClasses); - if (!result.wasSuccessful()) { - throw new RuntimeException("Generating test script failed!"); - } - } - - private static Class[] getAbstractConnectionImplTestSubclasses() - throws IOException, ClassNotFoundException { - List> list = new ArrayList<>(); - ClassPath cp = ClassPath.from(ConnectionImplGeneratedSqlScriptTest.class.getClassLoader()); - ImmutableSet classes = - cp.getTopLevelClassesRecursive( - ConnectionImplGeneratedSqlScriptTest.class.getPackage().getName()); - for (ClassInfo c : classes) { - Class clazz = - ConnectionImplGeneratedSqlScriptTest.class.getClassLoader().loadClass(c.getName()); - addAbstractConnectionImplTestSubclassesToList(list, clazz); - } - Class[] res = new Class[list.size()]; - for (int i = 0; i < list.size(); i++) { - res[i] = list.get(i); - } - return res; - } - - private static void addAbstractConnectionImplTestSubclassesToList( - List> list, Class clazz) { - for (Class innerClass : clazz.getDeclaredClasses()) { - addAbstractConnectionImplTestSubclassesToList(list, innerClass); - } - if (!clazz.isInterface() - && !Modifier.isAbstract(clazz.getModifiers()) - && AbstractConnectionImplTest.class.isAssignableFrom(clazz)) { - list.add(clazz); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTest.java deleted file mode 100644 index 87190f715d0..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTest.java +++ /dev/null @@ -1,1117 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.DDL; -import static com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.SELECT; -import static com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.UPDATE; -import static com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.expectSpannerException; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.NoCredentials; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ForwardingResultSet; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ReadOnlyTransaction; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionRunner; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.ConnectionConsumer; -import com.google.cloud.spanner.jdbc.ConnectionImpl.UnitOfWorkType; -import com.google.cloud.spanner.jdbc.ConnectionStatementExecutorImpl.StatementTimeoutGetter; -import com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.GetExactStaleness; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import com.google.spanner.v1.ResultSetStats; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.Matchers; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class ConnectionImplTest { - public static final String URI = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - - static class SimpleTransactionManager implements TransactionManager { - private TransactionState state; - private Timestamp commitTimestamp; - private TransactionContext txContext; - - private SimpleTransactionManager(TransactionContext txContext) { - this.txContext = txContext; - } - - @Override - public TransactionContext begin() { - state = TransactionState.STARTED; - return txContext; - } - - @Override - public void commit() { - commitTimestamp = Timestamp.now(); - state = TransactionState.COMMITTED; - } - - @Override - public void rollback() { - state = TransactionState.ROLLED_BACK; - } - - @Override - public TransactionContext resetForRetry() { - return txContext; - } - - @Override - public Timestamp getCommitTimestamp() { - return commitTimestamp; - } - - @Override - public TransactionState getState() { - return state; - } - - @Override - public void close() { - if (state != TransactionState.COMMITTED) { - state = TransactionState.ROLLED_BACK; - } - } - } - - private static class SimpleResultSet extends ForwardingResultSet { - private boolean nextCalled = false; - private boolean onValidRow = false; - private boolean hasNextReturnedFalse = false; - - SimpleResultSet(ResultSet delegate) { - super(delegate); - } - - @Override - public boolean next() { - nextCalled = true; - onValidRow = super.next(); - hasNextReturnedFalse = !onValidRow; - return onValidRow; - } - - boolean isNextCalled() { - return nextCalled; - } - - @Override - public ResultSetStats getStats() { - if (hasNextReturnedFalse) { - return super.getStats(); - } - return null; - } - - @Override - public long getLong(int columnIndex) { - if (onValidRow) { - return super.getLong(columnIndex); - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "ResultSet is not positioned on a valid row"); - } - } - - private static ResultSet createSelect1MockResultSet() { - ResultSet mockResultSet = mock(ResultSet.class); - when(mockResultSet.next()).thenReturn(true, false); - when(mockResultSet.getLong(0)).thenReturn(1L); - when(mockResultSet.getLong("TEST")).thenReturn(1L); - when(mockResultSet.getColumnType(0)).thenReturn(Type.int64()); - when(mockResultSet.getColumnType("TEST")).thenReturn(Type.int64()); - return mockResultSet; - } - - private static DdlClient createDefaultMockDdlClient() { - try { - DdlClient ddlClient = mock(DdlClient.class); - @SuppressWarnings("unchecked") - final OperationFuture operation = - mock(OperationFuture.class); - when(operation.get()).thenReturn(null); - UpdateDatabaseDdlMetadata metadata = UpdateDatabaseDdlMetadata.getDefaultInstance(); - ApiFuture futureMetadata = ApiFutures.immediateFuture(metadata); - when(operation.getMetadata()).thenReturn(futureMetadata); - when(ddlClient.executeDdl(anyString())).thenCallRealMethod(); - when(ddlClient.executeDdl(anyListOf(String.class))).thenReturn(operation); - return ddlClient; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static ConnectionImpl createConnection(ConnectionOptions options) { - Spanner spanner = mock(Spanner.class); - SpannerPool spannerPool = mock(SpannerPool.class); - when(spannerPool.getSpanner(any(ConnectionOptions.class), any(ConnectionImpl.class))) - .thenReturn(spanner); - DdlClient ddlClient = createDefaultMockDdlClient(); - DatabaseClient dbClient = mock(DatabaseClient.class); - ReadOnlyTransaction singleUseReadOnlyTx = mock(ReadOnlyTransaction.class); - - ResultSet mockResultSetWithStats = createSelect1MockResultSet(); - when(mockResultSetWithStats.getStats()).thenReturn(ResultSetStats.getDefaultInstance()); - - final SimpleResultSet select1ResultSet = new SimpleResultSet(createSelect1MockResultSet()); - final SimpleResultSet select1ResultSetWithStats = new SimpleResultSet(mockResultSetWithStats); - when(singleUseReadOnlyTx.executeQuery(Statement.of(SELECT))) - .thenAnswer( - new Answer() { - @Override - public ResultSet answer(InvocationOnMock invocation) throws Throwable { - if (select1ResultSet.nextCalled) { - // create a new mock - return new SimpleResultSet(createSelect1MockResultSet()); - } - return select1ResultSet; - } - }); - when(singleUseReadOnlyTx.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PLAN)) - .thenReturn(select1ResultSetWithStats); - when(singleUseReadOnlyTx.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PROFILE)) - .thenReturn(select1ResultSetWithStats); - when(singleUseReadOnlyTx.getReadTimestamp()) - .then( - new Answer() { - @Override - public Timestamp answer(InvocationOnMock invocation) throws Throwable { - if (select1ResultSet.isNextCalled() || select1ResultSetWithStats.isNextCalled()) { - return Timestamp.now(); - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, "No query has returned with any data yet"); - } - }); - when(dbClient.singleUseReadOnlyTransaction(Matchers.any(TimestampBound.class))) - .thenReturn(singleUseReadOnlyTx); - - when(dbClient.transactionManager()) - .thenAnswer( - new Answer() { - @Override - public TransactionManager answer(InvocationOnMock invocation) throws Throwable { - TransactionContext txContext = mock(TransactionContext.class); - when(txContext.executeQuery(Statement.of(SELECT))) - .thenAnswer( - new Answer() { - @Override - public ResultSet answer(InvocationOnMock invocation) throws Throwable { - if (select1ResultSet.nextCalled) { - // create a new mock - return new SimpleResultSet(createSelect1MockResultSet()); - } - return select1ResultSet; - } - }); - when(txContext.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PLAN)) - .thenReturn(select1ResultSetWithStats); - when(txContext.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PROFILE)) - .thenReturn(select1ResultSetWithStats); - when(txContext.executeUpdate(Statement.of(UPDATE))).thenReturn(1L); - return new SimpleTransactionManager(txContext); - } - }); - - when(dbClient.readOnlyTransaction(Matchers.any(TimestampBound.class))) - .thenAnswer( - new Answer() { - @Override - public ReadOnlyTransaction answer(InvocationOnMock invocation) throws Throwable { - ReadOnlyTransaction tx = mock(ReadOnlyTransaction.class); - when(tx.executeQuery(Statement.of(SELECT))) - .thenAnswer( - new Answer() { - @Override - public ResultSet answer(InvocationOnMock invocation) throws Throwable { - if (select1ResultSet.nextCalled) { - // create a new mock - return new SimpleResultSet(createSelect1MockResultSet()); - } - return select1ResultSet; - } - }); - when(tx.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PLAN)) - .thenReturn(select1ResultSetWithStats); - when(tx.analyzeQuery(Statement.of(SELECT), QueryAnalyzeMode.PROFILE)) - .thenReturn(select1ResultSetWithStats); - when(tx.getReadTimestamp()) - .then( - new Answer() { - @Override - public Timestamp answer(InvocationOnMock invocation) throws Throwable { - if (select1ResultSet.isNextCalled() - || select1ResultSetWithStats.isNextCalled()) { - return Timestamp.now(); - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.FAILED_PRECONDITION, - "No query has returned with any data yet"); - } - }); - return tx; - } - }); - - when(dbClient.readWriteTransaction()) - .thenAnswer( - new Answer() { - @Override - public TransactionRunner answer(InvocationOnMock invocation) throws Throwable { - TransactionRunner runner = - new TransactionRunner() { - private Timestamp commitTimestamp; - - @SuppressWarnings("unchecked") - @Override - public T run(TransactionCallable callable) { - this.commitTimestamp = Timestamp.now(); - return (T) Long.valueOf(1L); - } - - @Override - public Timestamp getCommitTimestamp() { - return commitTimestamp; - } - - @Override - public TransactionRunner allowNestedTransaction() { - return this; - } - }; - return runner; - } - }); - return new ConnectionImpl(options, spannerPool, ddlClient, dbClient); - } - - @Test - public void testExecuteSetAutocommitOn() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI + ";autocommit=false") - .build())) { - assertThat(subject.isAutocommit(), is(false)); - - StatementResult res = subject.execute(Statement.of("set autocommit = true")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isAutocommit(), is(true)); - } - } - - @Test - public void testExecuteSetAutocommitOff() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - - StatementResult res = subject.execute(Statement.of("set autocommit = false")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isAutocommit(), is(false)); - } - } - - @Test - public void testExecuteGetAutocommit() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - - // assert that autocommit is true (default) - assertThat(subject.isAutocommit(), is(true)); - StatementResult res = subject.execute(Statement.of("show variable autocommit")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getBoolean("AUTOCOMMIT"), is(true)); - - // set autocommit to false and assert that autocommit is false - res = subject.execute(Statement.of("set autocommit = false")); - assertThat(subject.isAutocommit(), is(false)); - res = subject.execute(Statement.of("show variable autocommit")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getBoolean("AUTOCOMMIT"), is(false)); - } - } - - @Test - public void testExecuteSetReadOnlyOn() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isReadOnly(), is(false)); - - StatementResult res = subject.execute(Statement.of("set readonly = true")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isReadOnly(), is(true)); - } - } - - @Test - public void testExecuteSetReadOnlyOff() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI + ";readonly=true") - .build())) { - assertThat(subject.isReadOnly(), is(true)); - - StatementResult res = subject.execute(Statement.of("set readonly = false")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isReadOnly(), is(false)); - } - } - - @Test - public void testExecuteGetReadOnly() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - - // assert that read only is false (default) - assertThat(subject.isReadOnly(), is(false)); - StatementResult res = subject.execute(Statement.of("show variable readonly")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getBoolean("READONLY"), is(false)); - - // set read only to true and assert that read only is true - res = subject.execute(Statement.of("set readonly = true")); - assertThat(subject.isReadOnly(), is(true)); - res = subject.execute(Statement.of("show variable readonly")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getBoolean("READONLY"), is(true)); - } - } - - @Test - public void testExecuteSetAutocommitDmlMode() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - assertThat(subject.getAutocommitDmlMode(), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - - StatementResult res = - subject.execute(Statement.of("set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat( - subject.getAutocommitDmlMode(), is(equalTo(AutocommitDmlMode.PARTITIONED_NON_ATOMIC))); - - res = subject.execute(Statement.of("set autocommit_dml_mode='TRANSACTIONAL'")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getAutocommitDmlMode(), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - } - } - - @Test - public void testExecuteSetAutocommitDmlModeInvalidValue() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - assertThat(subject.getAutocommitDmlMode(), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - - ErrorCode expected = null; - try { - subject.execute(Statement.of("set autocommit_dml_mode='NON_EXISTENT_VALUE'")); - } catch (SpannerException e) { - expected = e.getErrorCode(); - } - assertThat(expected, is(equalTo(ErrorCode.INVALID_ARGUMENT))); - } - } - - @Test - public void testExecuteGetAutocommitDmlMode() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - assertThat(subject.getAutocommitDmlMode(), is(equalTo(AutocommitDmlMode.TRANSACTIONAL))); - - StatementResult res = subject.execute(Statement.of("show variable autocommit_dml_mode")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat( - res.getResultSet().getString("AUTOCOMMIT_DML_MODE"), - is(equalTo(AutocommitDmlMode.TRANSACTIONAL.toString()))); - - subject.execute(Statement.of("set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'")); - res = subject.execute(Statement.of("show variable autocommit_dml_mode")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat( - res.getResultSet().getString("AUTOCOMMIT_DML_MODE"), - is(equalTo(AutocommitDmlMode.PARTITIONED_NON_ATOMIC.toString()))); - } - } - - @Test - public void testExecuteSetStatementTimeout() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.getStatementTimeout(TimeUnit.MILLISECONDS), is(equalTo(0L))); - - for (TimeUnit unit : ReadOnlyStalenessUtil.SUPPORTED_UNITS) { - for (Long timeout : new Long[] {1L, 100L, 10000L, 315576000000L}) { - StatementResult res = - subject.execute( - Statement.of( - String.format( - "set statement_timeout='%d%s'", - timeout, ReadOnlyStalenessUtil.getTimeUnitAbbreviation(unit)))); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getStatementTimeout(unit), is(equalTo(timeout))); - assertThat(subject.hasStatementTimeout(), is(true)); - - StatementResult resNoTimeout = - subject.execute(Statement.of("set statement_timeout=null")); - assertThat(resNoTimeout.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getStatementTimeout(unit), is(equalTo(0L))); - assertThat(subject.hasStatementTimeout(), is(false)); - } - } - } - } - - @Test - public void testExecuteSetStatementTimeoutInvalidValue() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.getStatementTimeout(TimeUnit.MILLISECONDS), is(equalTo(0L))); - - ErrorCode expected = null; - try { - subject.execute(Statement.of("set statement_timeout=-1")); - } catch (SpannerException e) { - expected = e.getErrorCode(); - } - assertThat(expected, is(equalTo(ErrorCode.INVALID_ARGUMENT))); - } - } - - @Test - public void testExecuteGetStatementTimeout() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.getStatementTimeout(TimeUnit.MILLISECONDS), is(equalTo(0L))); - - for (TimeUnit unit : ReadOnlyStalenessUtil.SUPPORTED_UNITS) { - for (Long timeout : new Long[] {1L, 100L, 10000L, 315576000000L}) { - subject.execute( - Statement.of( - String.format( - "set statement_timeout='%d%s'", - timeout, ReadOnlyStalenessUtil.getTimeUnitAbbreviation(unit)))); - StatementResult res = subject.execute(Statement.of("show variable statement_timeout")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - TimeUnit appropriateUnit = - ReadOnlyStalenessUtil.getAppropriateTimeUnit(new StatementTimeoutGetter(subject)); - assertThat( - res.getResultSet().getString("STATEMENT_TIMEOUT"), - is( - equalTo( - subject.getStatementTimeout(appropriateUnit) - + ReadOnlyStalenessUtil.getTimeUnitAbbreviation(appropriateUnit)))); - - subject.execute(Statement.of("set statement_timeout=null")); - StatementResult resNoTimeout = - subject.execute(Statement.of("show variable statement_timeout")); - assertThat(resNoTimeout.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(resNoTimeout.getResultSet().next(), is(true)); - assertThat(resNoTimeout.getResultSet().isNull("STATEMENT_TIMEOUT"), is(true)); - } - } - } - } - - @Test - public void testExecuteGetReadTimestamp() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.beginTransaction(); - subject.setTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - subject.executeQuery(Statement.of(AbstractConnectionImplTest.SELECT)); - StatementResult res = subject.execute(Statement.of("show variable read_timestamp")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getTimestamp("READ_TIMESTAMP"), is(notNullValue())); - subject.commit(); - } - } - - @Test - public void testExecuteGetCommitTimestamp() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.beginTransaction(); - subject.executeQuery(Statement.of(AbstractConnectionImplTest.SELECT)).next(); - subject.commit(); - StatementResult res = subject.execute(Statement.of("show variable commit_timestamp")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat(res.getResultSet().getTimestamp("COMMIT_TIMESTAMP"), is(notNullValue())); - } - } - - private static final class StalenessDuration { - private final long duration; - private final TimeUnit unit; - - private StalenessDuration(long duration, TimeUnit unit) { - this.duration = duration; - this.unit = unit; - } - - @Override - public String toString() { - GetExactStaleness getExactStalenessFunction = - new GetExactStaleness(TimestampBound.ofExactStaleness(duration, unit)); - return ReadOnlyStalenessUtil.durationToString(getExactStalenessFunction); - } - } - - @Test - public void testExecuteGetReadOnlyStaleness() { - Map timestamps = new HashMap<>(); - timestamps.put(Mode.READ_TIMESTAMP, ReadOnlyStalenessUtil.parseRfc3339("2018-10-08T14:05:10Z")); - timestamps.put( - Mode.MIN_READ_TIMESTAMP, ReadOnlyStalenessUtil.parseRfc3339("2018-10-08T14:05:10.12345Z")); - Map durations = new HashMap<>(); - durations.put(Mode.EXACT_STALENESS, new StalenessDuration(1000L, TimeUnit.MILLISECONDS)); - durations.put(Mode.MAX_STALENESS, new StalenessDuration(1234567L, TimeUnit.MICROSECONDS)); - List stalenesses = - Arrays.asList( - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(timestamps.get(Mode.READ_TIMESTAMP)), - TimestampBound.ofMinReadTimestamp(timestamps.get(Mode.MIN_READ_TIMESTAMP)), - TimestampBound.ofExactStaleness( - durations.get(Mode.EXACT_STALENESS).duration, - durations.get(Mode.EXACT_STALENESS).unit), - TimestampBound.ofMaxStaleness( - durations.get(Mode.MAX_STALENESS).duration, - durations.get(Mode.MAX_STALENESS).unit)); - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - for (TimestampBound staleness : stalenesses) { - subject.setReadOnlyStaleness(staleness); - StatementResult res = subject.execute(Statement.of("show variable read_only_staleness")); - assertThat(res.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(res.getResultSet().next(), is(true)); - assertThat( - res.getResultSet().getString("READ_ONLY_STALENESS"), - is(equalTo(ReadOnlyStalenessUtil.timestampBoundToString(staleness)))); - } - } - } - - @Test - public void testExecuteSetReadOnlyStaleness() { - Map timestamps = new HashMap<>(); - timestamps.put(Mode.READ_TIMESTAMP, ReadOnlyStalenessUtil.parseRfc3339("2018-10-08T12:13:14Z")); - timestamps.put( - Mode.MIN_READ_TIMESTAMP, - ReadOnlyStalenessUtil.parseRfc3339("2018-10-08T14:13:14.1234+02:00")); - Map durations = new HashMap<>(); - durations.put(Mode.EXACT_STALENESS, new StalenessDuration(1000L, TimeUnit.MILLISECONDS)); - durations.put(Mode.MAX_STALENESS, new StalenessDuration(1234567L, TimeUnit.MICROSECONDS)); - List stalenesses = - Arrays.asList( - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(timestamps.get(Mode.READ_TIMESTAMP)), - TimestampBound.ofMinReadTimestamp(timestamps.get(Mode.MIN_READ_TIMESTAMP)), - TimestampBound.ofExactStaleness( - durations.get(Mode.EXACT_STALENESS).duration, - durations.get(Mode.EXACT_STALENESS).unit), - TimestampBound.ofMaxStaleness( - durations.get(Mode.MAX_STALENESS).duration, - durations.get(Mode.MAX_STALENESS).unit)); - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - for (TimestampBound staleness : stalenesses) { - StatementResult res = - subject.execute( - Statement.of( - String.format( - "set read_only_staleness='%s'", - ReadOnlyStalenessUtil.timestampBoundToString(staleness)))); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getReadOnlyStaleness(), is(equalTo(staleness))); - } - } - } - - @Test - public void testExecuteBeginTransaction() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isInTransaction(), is(false)); - - StatementResult res = subject.execute(Statement.of("begin transaction")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isInTransaction(), is(true)); - } - } - - @Test - public void testExecuteCommitTransaction() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.execute(Statement.of("begin transaction")); - assertThat(subject.isInTransaction(), is(true)); - - StatementResult res = subject.execute(Statement.of("commit")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isInTransaction(), is(false)); - } - } - - @Test - public void testExecuteRollbackTransaction() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.execute(Statement.of("begin")); - assertThat(subject.isInTransaction(), is(true)); - - StatementResult res = subject.execute(Statement.of("rollback")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.isInTransaction(), is(false)); - } - } - - @Test - public void testExecuteSetTransactionReadOnly() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.execute(Statement.of("begin")); - assertThat(subject.getTransactionMode(), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat(subject.isInTransaction(), is(true)); - - StatementResult res = subject.execute(Statement.of("set transaction read only")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getTransactionMode(), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - } - } - - @Test - public void testExecuteSetTransactionReadWrite() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI + ";readonly=true") - .build())) { - subject.execute(Statement.of("begin")); - assertThat(subject.getTransactionMode(), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat(subject.isInTransaction(), is(true)); - - // end the current temporary transaction and turn off read-only mode - subject.execute(Statement.of("commit")); - subject.execute(Statement.of("set readonly = false")); - - subject.execute(Statement.of("begin")); - StatementResult res = subject.execute(Statement.of("set transaction read only")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getTransactionMode(), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - res = subject.execute(Statement.of("set transaction read write")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getTransactionMode(), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - } - } - - @Test - public void testExecuteStartDdlBatch() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - StatementResult res = subject.execute(Statement.of("start batch ddl")); - assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT))); - assertThat(subject.getUnitOfWorkType(), is(equalTo(UnitOfWorkType.DDL_BATCH))); - assertThat(subject.isInTransaction(), is(false)); - } - } - - @Test - public void testDefaultIsAutocommit() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - assertThat(subject.isInTransaction(), is(false)); - } - } - - @Test - public void testDefaultIsReadWrite() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isReadOnly(), is(false)); - } - } - - @Test - public void testDefaultTransactionIsReadWrite() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - for (boolean autocommit : new Boolean[] {true, false}) { - subject.setAutocommit(autocommit); - subject.execute(Statement.of("begin")); - assertThat( - subject.getTransactionMode(), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - subject.commit(); - - subject.execute(Statement.of("begin")); - subject.execute(Statement.of("set transaction read only")); - assertThat( - subject.getTransactionMode(), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - subject.commit(); - - subject.execute(Statement.of("begin")); - assertThat( - subject.getTransactionMode(), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - subject.commit(); - - subject.execute(Statement.of("start batch ddl")); - assertThat(subject.getUnitOfWorkType(), is(equalTo(UnitOfWorkType.DDL_BATCH))); - subject.runBatch(); - - subject.execute(Statement.of("begin")); - assertThat( - subject.getTransactionMode(), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - subject.commit(); - } - } - } - - @Test - public void testDefaultTransactionIsReadOnly() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI + ";readOnly=true") - .build())) { - for (boolean autocommit : new Boolean[] {true, false}) { - subject.setAutocommit(autocommit); - subject.execute(Statement.of("begin")); - assertThat( - subject.getTransactionMode(), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - subject.commit(); - } - } - } - - /** - * ReadOnlyStaleness is a session setting for a connection. However, certain settings are only - * allowed when the connection is in autocommit mode. The setting therefore must be reset to its - * default {@link TimestampBound#strong()} when the current setting is not compatible with - * transactional mode. - */ - @Test - public void testResetReadOnlyStaleness() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.isAutocommit(), is(true)); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - - // the following values are always allowed - subject.setReadOnlyStaleness(TimestampBound.strong()); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - subject.setAutocommit(false); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - subject.setAutocommit(true); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - - subject.setReadOnlyStaleness(TimestampBound.ofReadTimestamp(Timestamp.MAX_VALUE)); - subject.setAutocommit(false); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofReadTimestamp(Timestamp.MAX_VALUE)))); - subject.setAutocommit(true); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofReadTimestamp(Timestamp.MAX_VALUE)))); - - subject.setReadOnlyStaleness(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - subject.setAutocommit(false); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)))); - subject.setAutocommit(true); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)))); - - // the following values are only allowed in autocommit mode. Turning off autocommit will - // return the setting to its default - subject.setReadOnlyStaleness(TimestampBound.ofMinReadTimestamp(Timestamp.MAX_VALUE)); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofMinReadTimestamp(Timestamp.MAX_VALUE)))); - subject.setAutocommit(false); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - subject.setAutocommit(true); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - - subject.setReadOnlyStaleness(TimestampBound.ofMaxStaleness(10L, TimeUnit.SECONDS)); - assertThat( - subject.getReadOnlyStaleness(), - is(equalTo(TimestampBound.ofMaxStaleness(10L, TimeUnit.SECONDS)))); - subject.setAutocommit(false); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - subject.setAutocommit(true); - assertThat(subject.getReadOnlyStaleness().getMode(), is(equalTo(TimestampBound.Mode.STRONG))); - } - } - - @Test - public void testChangeReadOnlyModeInAutocommit() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.execute(Statement.of(UPDATE)); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - - // change to read-only - subject.setReadOnly(true); - expectSpannerException( - "Updates should not be allowed in read-only mode", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.execute(Statement.of(UPDATE)); - } - }, - subject); - assertThat(subject.executeQuery(Statement.of(SELECT)), is(notNullValue())); - - // change back to read-write - subject.setReadOnly(false); - subject.execute(Statement.of(UPDATE)); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - - // and back to read-only - subject.setReadOnly(true); - expectSpannerException( - "DDL should not be allowed in read-only mode", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.execute(Statement.of(DDL)); - } - }, - subject); - assertThat(subject.executeQuery(Statement.of(SELECT)), is(notNullValue())); - } - } - - @Test - public void testChangeReadOnlyModeInTransactionalMode() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - subject.setAutocommit(false); - - subject.execute(Statement.of(UPDATE)); - subject.commit(); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - - // change to read-only - subject.setReadOnly(true); - expectSpannerException( - "Updates should not be allowed in read-only mode", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.execute(Statement.of(UPDATE)); - } - }, - subject); - assertThat(subject.executeQuery(Statement.of(SELECT)), is(notNullValue())); - subject.commit(); - - // change back to read-write - subject.setReadOnly(false); - subject.execute(Statement.of(UPDATE)); - subject.commit(); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - - // and back to read-only - subject.setReadOnly(true); - expectSpannerException( - "DDL should not be allowed in read-only mode", - new ConnectionConsumer() { - @Override - public void accept(Connection t) { - t.execute(Statement.of(DDL)); - } - }, - subject); - assertThat(subject.executeQuery(Statement.of(SELECT)), is(notNullValue())); - } - } - - @Test - public void testAddRemoveTransactionRetryListener() { - try (ConnectionImpl subject = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(subject.getTransactionRetryListeners().hasNext(), is(false)); - TransactionRetryListener listener = mock(TransactionRetryListener.class); - subject.addTransactionRetryListener(listener); - assertThat(subject.getTransactionRetryListeners().hasNext(), is(true)); - assertThat(subject.removeTransactionRetryListener(listener), is(true)); - assertThat(subject.getTransactionRetryListeners().hasNext(), is(false)); - assertThat(subject.removeTransactionRetryListener(listener), is(false)); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadOnlyTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadOnlyTest.java deleted file mode 100644 index 99c959083cd..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadOnlyTest.java +++ /dev/null @@ -1,1204 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import java.util.concurrent.TimeUnit; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -/** - * The tests in this class do not need to be implemented for client libraries in other programming - * languages, as all test cases are covered by the file ConnectionImplGeneratedSqlScriptTest.sql - */ -@RunWith(Enclosed.class) -public class ConnectionImplTransactionalReadOnlyTest { - - public static class ConnectionImplTransactionalReadOnlyNoActionsTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query has been executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterSelectTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - // no call to next() on ResultSet - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // transaction has started - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return true; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last statement was a query, next() has not yet been called, but as the connection api - // returns a directly executed resultset, the read timestamp is already available - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterSelectAndResultSetNextTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)).next(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // transaction is running - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // transaction has started - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return true; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last statement was a query - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterBeginTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // connection is in read-only mode - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // in a transaction, only exact allowed - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last action was a transaction that ended with a select query - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterRollbackTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("ROLLBACK;"); - connection.rollback(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // transaction was rolled back - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterSetReadOnlyMaxStalenessTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - TimestampBound staleness = TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS); - log( - "SET READ_ONLY_STALENESS='" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "';"); - connection.setReadOnlyStaleness(staleness); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadOnlyAfterEmptyCommitTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=TRUE;"); - connection.setReadOnly(true); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return mode == TransactionMode.READ_ONLY_TRANSACTION; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last commit was empty - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // read-only - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadWriteTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadWriteTest.java deleted file mode 100644 index ff58828eae3..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionImplTransactionalReadWriteTest.java +++ /dev/null @@ -1,1945 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TimestampBound.Mode; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import java.util.concurrent.TimeUnit; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; - -/** - * The tests in this class do not need to be implemented for client libraries in other programming - * languages, as all test cases are covered by the file ConnectionImplGeneratedSqlScriptTest.sql - */ -@RunWith(Enclosed.class) -public class ConnectionImplTransactionalReadWriteTest { - - public static class ConnectionImplTransactionalReadWriteNoActionsTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query has been executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterSelectTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - // no call to next() on ResultSet - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // transaction has started - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return true; - } - - @Override - boolean isGetReadTimestampAllowed() { - // read-write transactions never have a read-timestamp - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterSelectAndResultSetNextTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.executeQuery(Statement.of(SELECT)).next(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - // transaction is running - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // transaction has started - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return true; - } - - @Override - boolean isGetReadTimestampAllowed() { - // read-write transactions never have a read-timestamp - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterBeginTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalArgumentException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - // in a transaction, only exact allowed - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // read-write transaction never have a read-timestamp - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // last action was a read-write transaction - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return true; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterRollbackTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("BEGIN TRANSACTION;"); - connection.beginTransaction(); - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("ROLLBACK;"); - connection.rollback(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // transaction was rolled back - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterSetReadOnlyMaxStalenessTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - TimestampBound staleness = TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS); - log( - "SET READ_ONLY_STALENESS='" - + ReadOnlyStalenessUtil.timestampBoundToString(staleness) - + "';"); - connection.setReadOnlyStaleness(staleness); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterSetTransactionReadOnlyTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("SET TRANSACTION READ ONLY;"); - connection.setTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.QUERY; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterCommittedReadOnlyTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("SET TRANSACTION READ ONLY;"); - connection.setTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - // ensure there will be a read-timestamp available by calling next() - log("@EXPECT RESULT_SET 'TEST',1"); - log(SELECT + ";"); - connection.execute(Statement.of(SELECT)).getResultSet().next(); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return true; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // last transaction was a read-only transaction - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterStartDdlBatchTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("START BATCH DDL;"); - connection.startBatchDdl(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return false; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // no commit yet - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.DDL; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return true; - } - - @Override - boolean isAbortBatchAllowed() { - return true; - } - } - - public static class ConnectionImplTransactionalReadWriteInDdlBatchTransactionTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("START BATCH DDL;"); - connection.startBatchDdl(); - log(DDL + ";"); - connection.execute(Statement.of(DDL)); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - throw new IllegalStateException(); - } - - @Override - boolean isSetAutocommitAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyAllowed() { - return false; - } - - @Override - boolean isBeginTransactionAllowed() { - return false; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return false; - } - - @Override - boolean isGetTransactionModeAllowed() { - return false; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return false; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return false; - } - - @Override - boolean isCommitAllowed() { - return false; - } - - @Override - boolean isRollbackAllowed() { - return false; - } - - @Override - boolean expectedIsInTransaction() { - return false; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE || type == StatementType.DDL; - } - - @Override - boolean isWriteAllowed() { - return false; - } - - @Override - boolean isStartBatchDmlAllowed() { - return false; - } - - @Override - boolean isStartBatchDdlAllowed() { - return false; - } - - @Override - boolean isRunBatchAllowed() { - return true; - } - - @Override - boolean isAbortBatchAllowed() { - return true; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterRanDdlBatchTest - extends AbstractConnectionImplTest { - - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("START BATCH DDL;"); - connection.startBatchDdl(); - log(DDL + ";"); - connection.execute(Statement.of(DDL)); - log("RUN BATCH;"); - connection.runBatch(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // ddl-batch has no commit timestamp - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } - - public static class ConnectionImplTransactionalReadWriteAfterEmptyCommitTest - extends AbstractConnectionImplTest { - @Override - Connection getConnection() { - log("NEW_CONNECTION;"); - Connection connection = - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build()); - log("SET READONLY=FALSE;"); - connection.setReadOnly(false); - log("SET AUTOCOMMIT=FALSE;"); - connection.setAutocommit(false); - log("COMMIT;"); - connection.commit(); - return connection; - } - - @Override - boolean isSelectAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDmlAllowedAfterBeginTransaction() { - return true; - } - - @Override - boolean isDdlAllowedAfterBeginTransaction() { - return false; - } - - @Override - boolean isSetAutocommitAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyAllowed() { - return true; - } - - @Override - boolean isBeginTransactionAllowed() { - return true; - } - - @Override - boolean isSetTransactionModeAllowed(TransactionMode mode) { - return true; - } - - @Override - boolean isGetTransactionModeAllowed() { - return true; - } - - @Override - boolean isSetAutocommitDmlModeAllowed() { - return false; - } - - @Override - boolean isGetAutocommitDmlModeAllowed() { - return true; - } - - @Override - boolean isSetReadOnlyStalenessAllowed(TimestampBound.Mode mode) { - return mode == Mode.STRONG || mode == Mode.EXACT_STALENESS || mode == Mode.READ_TIMESTAMP; - } - - @Override - boolean isGetReadOnlyStalenessAllowed() { - return true; - } - - @Override - boolean isCommitAllowed() { - return true; - } - - @Override - boolean isRollbackAllowed() { - return true; - } - - @Override - boolean expectedIsInTransaction() { - return true; - } - - @Override - boolean expectedIsTransactionStarted() { - return false; - } - - @Override - boolean isGetReadTimestampAllowed() { - // no query has been executed yet - return false; - } - - @Override - boolean isGetCommitTimestampAllowed() { - // empty commit - return false; - } - - @Override - boolean isExecuteAllowed(StatementType type) { - return type == StatementType.CLIENT_SIDE - || type == StatementType.QUERY - || type == StatementType.UPDATE; - } - - @Override - boolean isWriteAllowed() { - return true; - } - - @Override - boolean isStartBatchDmlAllowed() { - return true; - } - - @Override - boolean isStartBatchDdlAllowed() { - return true; - } - - @Override - boolean isRunBatchAllowed() { - return false; - } - - @Override - boolean isAbortBatchAllowed() { - return false; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionOptionsTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionOptionsTest.java deleted file mode 100644 index 1435cd1d9ca..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionOptionsTest.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.auth.oauth2.ServiceAccountCredentials; -import com.google.cloud.spanner.SpannerOptions; -import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ConnectionOptionsTest { - private static final String FILE_TEST_PATH = - ConnectionOptionsTest.class.getResource("test-key.json").getFile(); - private static final String DEFAULT_HOST = "https://spanner.googleapis.com"; - - @Test - public void testBuildWithValidURIAndCredentialsFileURL() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance-123/databases/test-database-123"); - builder.setCredentialsUrl(FILE_TEST_PATH); - ConnectionOptions options = builder.build(); - assertThat(options.getHost(), is(equalTo(DEFAULT_HOST))); - assertThat(options.getProjectId(), is(equalTo("test-project-123"))); - assertThat(options.getInstanceId(), is(equalTo("test-instance-123"))); - assertThat(options.getDatabaseName(), is(equalTo("test-database-123"))); - assertThat( - (GoogleCredentials) options.getCredentials(), - is(equalTo(new CredentialsService().createCredentials(FILE_TEST_PATH)))); - assertThat(options.isAutocommit(), is(equalTo(ConnectionOptions.DEFAULT_AUTOCOMMIT))); - assertThat(options.isReadOnly(), is(equalTo(ConnectionOptions.DEFAULT_READONLY))); - } - - @Test - public void testBuildWithValidURIAndProperties() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance-123/databases/test-database-123?autocommit=false;readonly=true"); - builder.setCredentialsUrl(FILE_TEST_PATH); - ConnectionOptions options = builder.build(); - assertThat(options.getHost(), is(equalTo(DEFAULT_HOST))); - assertThat(options.getProjectId(), is(equalTo("test-project-123"))); - assertThat(options.getInstanceId(), is(equalTo("test-instance-123"))); - assertThat(options.getDatabaseName(), is(equalTo("test-database-123"))); - assertThat( - (GoogleCredentials) options.getCredentials(), - is(equalTo(new CredentialsService().createCredentials(FILE_TEST_PATH)))); - assertThat(options.isAutocommit(), is(equalTo(false))); - assertThat(options.isReadOnly(), is(equalTo(true))); - } - - @Test - public void testBuildWithHostAndValidURI() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - builder.setUri( - "cloudspanner://test-spanner.googleapis.com/projects/test-project-123/instances/test-instance-123/databases/test-database-123"); - builder.setCredentialsUrl(FILE_TEST_PATH); - ConnectionOptions options = builder.build(); - assertThat(options.getHost(), is(equalTo("https://test-spanner.googleapis.com"))); - assertThat(options.getProjectId(), is(equalTo("test-project-123"))); - assertThat(options.getInstanceId(), is(equalTo("test-instance-123"))); - assertThat(options.getDatabaseName(), is(equalTo("test-database-123"))); - assertThat( - (GoogleCredentials) options.getCredentials(), - is(equalTo(new CredentialsService().createCredentials(FILE_TEST_PATH)))); - assertThat(options.isAutocommit(), is(equalTo(ConnectionOptions.DEFAULT_AUTOCOMMIT))); - assertThat(options.isReadOnly(), is(equalTo(ConnectionOptions.DEFAULT_READONLY))); - } - - @Test - public void testBuildWithLocalhostPortAndValidURI() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - builder.setUri( - "cloudspanner://localhost:8443/projects/test-project-123/instances/test-instance-123/databases/test-database-123"); - builder.setCredentialsUrl(FILE_TEST_PATH); - ConnectionOptions options = builder.build(); - assertThat(options.getHost(), is(equalTo("https://localhost:8443"))); - assertThat(options.getProjectId(), is(equalTo("test-project-123"))); - assertThat(options.getInstanceId(), is(equalTo("test-instance-123"))); - assertThat(options.getDatabaseName(), is(equalTo("test-database-123"))); - assertThat( - (GoogleCredentials) options.getCredentials(), - is(equalTo(new CredentialsService().createCredentials(FILE_TEST_PATH)))); - assertThat(options.isAutocommit(), is(equalTo(ConnectionOptions.DEFAULT_AUTOCOMMIT))); - assertThat(options.isReadOnly(), is(equalTo(ConnectionOptions.DEFAULT_READONLY))); - } - - @Test - public void testBuildWithDefaultProjectPlaceholder() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - builder.setUri( - "cloudspanner:/projects/default_project_id/instances/test-instance-123/databases/test-database-123"); - builder.setCredentialsUrl(FILE_TEST_PATH); - ConnectionOptions options = builder.build(); - assertThat(options.getHost(), is(equalTo(DEFAULT_HOST))); - String projectId = SpannerOptions.getDefaultProjectId(); - if (projectId == null) { - projectId = - ((ServiceAccountCredentials) new CredentialsService().createCredentials(FILE_TEST_PATH)) - .getProjectId(); - } - assertThat(options.getProjectId(), is(equalTo(projectId))); - assertThat(options.getInstanceId(), is(equalTo("test-instance-123"))); - assertThat(options.getDatabaseName(), is(equalTo("test-database-123"))); - assertThat( - (GoogleCredentials) options.getCredentials(), - is(equalTo(new CredentialsService().createCredentials(FILE_TEST_PATH)))); - assertThat(options.isAutocommit(), is(equalTo(ConnectionOptions.DEFAULT_AUTOCOMMIT))); - assertThat(options.isReadOnly(), is(equalTo(ConnectionOptions.DEFAULT_READONLY))); - } - - @Test - public void testBuilderSetUri() { - ConnectionOptions.Builder builder = ConnectionOptions.newBuilder(); - - // set valid uri's - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"); - builder.setUri("cloudspanner:/projects/test-project-123/instances/test-instance"); - builder.setUri("cloudspanner:/projects/test-project-123"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance/databases/test-database"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance"); - builder.setUri("cloudspanner://spanner.googleapis.com/projects/test-project-123"); - - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?autocommit=true"); - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance?autocommit=true"); - builder.setUri("cloudspanner:/projects/test-project-123?autocommit=true"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance/databases/test-database?autocommit=true"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance?autocommit=true"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123?autocommit=true"); - - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?autocommit=true;readonly=false"); - builder.setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance?autocommit=true;readonly=false"); - builder.setUri("cloudspanner:/projects/test-project-123?autocommit=true;readonly=false"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance/databases/test-database?autocommit=true;readonly=false"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123/instances/test-instance?autocommit=true;readonly=false"); - builder.setUri( - "cloudspanner://spanner.googleapis.com/projects/test-project-123?autocommit=true;readonly=false"); - - // set invalid uri's - setInvalidUri( - builder, "/projects/test-project-123/instances/test-instance/databases/test-database"); - setInvalidUri(builder, "cloudspanner:/test-project-123/test-instance/test-database"); - setInvalidUri( - builder, - "cloudspanner:spanner.googleapis.com/projects/test-project-123/instances/test-instance/databases/test-database"); - setInvalidUri( - builder, - "cloudspanner://spanner.googleapis.com/projects/test-project-$$$/instances/test-instance/databases/test-database"); - setInvalidUri( - builder, - "cloudspanner://spanner.googleapis.com/projects/test-project-123/databases/test-database"); - setInvalidUri( - builder, - "cloudspanner:/projects/test_project_123/instances/test-instance/databases/test-database"); - - // Set URI's that are valid, but that contain unknown properties. - setInvalidProperty( - builder, - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?read=false", - "read"); - setInvalidProperty( - builder, - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?read=false;autocommit=true", - "read"); - setInvalidProperty( - builder, - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?read=false;auto=true", - "read, auto"); - } - - private void setInvalidUri(ConnectionOptions.Builder builder, String uri) { - boolean invalid = false; - try { - builder.setUri(uri); - } catch (IllegalArgumentException e) { - invalid = true; - } - assertThat(uri + " should be considered an invalid uri", invalid, is(true)); - } - - private void setInvalidProperty( - ConnectionOptions.Builder builder, String uri, String expectedInvalidProperties) { - boolean invalid = false; - try { - builder.setUri(uri); - } catch (IllegalArgumentException e) { - invalid = e.getMessage().contains(expectedInvalidProperties); - } - assertThat(uri + " should contain invalid properties", invalid, is(true)); - } - - @Test - public void testParseUriProperty() { - final String baseUri = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - - assertThat(ConnectionOptions.parseUriProperty(baseUri, "autocommit"), is(nullValue())); - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?autocommit=true", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?autocommit=false", "autocommit"), - is(equalTo("false"))); - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?autocommit=true;", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?autocommit=false;", "autocommit"), - is(equalTo("false"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?autocommit=true;readOnly=false", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?autocommit=false;readOnly=false", "autocommit"), - is(equalTo("false"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?readOnly=false;autocommit=true", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?readOnly=false;autocommit=false", "autocommit"), - is(equalTo("false"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?readOnly=false;autocommit=true;foo=bar", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?readOnly=false;autocommit=false;foo=bar", "autocommit"), - is(equalTo("false"))); - - // case insensitive - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?AutoCommit=true", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?AutoCommit=false", "autocommit"), - is(equalTo("false"))); - - // ; instead of ? before the properties is ok - assertThat( - ConnectionOptions.parseUriProperty(baseUri + ";autocommit=true", "autocommit"), - is(equalTo("true"))); - - // forgot the ? or ; before the properties - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "autocommit=true", "autocommit"), - is(nullValue())); - // substring is not ok - assertThat( - ConnectionOptions.parseUriProperty(baseUri + "?isautocommit=true", "autocommit"), - is(nullValue())); - } - - @Test - public void testParseProperties() { - final String baseUri = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - assertThat( - ConnectionOptions.parseProperties(baseUri + "?autocommit=true"), - is(equalTo(Arrays.asList("autocommit")))); - assertThat( - ConnectionOptions.parseProperties(baseUri + "?autocommit=true;readonly=false"), - is(equalTo(Arrays.asList("autocommit", "readonly")))); - assertThat( - ConnectionOptions.parseProperties(baseUri + "?autocommit=true;READONLY=false"), - is(equalTo(Arrays.asList("autocommit", "READONLY")))); - assertThat( - ConnectionOptions.parseProperties(baseUri + ";autocommit=true;readonly=false"), - is(equalTo(Arrays.asList("autocommit", "readonly")))); - assertThat( - ConnectionOptions.parseProperties(baseUri + ";autocommit=true;readonly=false;"), - is(equalTo(Arrays.asList("autocommit", "readonly")))); - } - - @Test - public void testParsePropertiesSpecifiedMultipleTimes() { - final String baseUri = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?autocommit=true;autocommit=false", "autocommit"), - is(equalTo("true"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + "?autocommit=false;autocommit=true", "autocommit"), - is(equalTo("false"))); - assertThat( - ConnectionOptions.parseUriProperty( - baseUri + ";autocommit=false;readonly=false;autocommit=true", "autocommit"), - is(equalTo("false"))); - ConnectionOptions.newBuilder() - .setUri( - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database" - + ";autocommit=false;readonly=false;autocommit=true"); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorTest.java deleted file mode 100644 index 1709ca4080a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementExecutorTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.TimestampBound; -import com.google.protobuf.Duration; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ConnectionStatementExecutorTest { - - private ConnectionImpl connection; - private ConnectionStatementExecutorImpl subject; - - @Before - public void createSubject() { - connection = mock(ConnectionImpl.class); - when(connection.getAutocommitDmlMode()).thenReturn(AutocommitDmlMode.TRANSACTIONAL); - when(connection.getReadOnlyStaleness()).thenReturn(TimestampBound.strong()); - subject = new ConnectionStatementExecutorImpl(connection); - } - - @Test - public void testGetConnection() { - assertThat(subject.getConnection(), is(equalTo(connection))); - } - - @Test - public void testStatementBeginTransaction() { - subject.statementBeginTransaction(); - verify(connection).beginTransaction(); - } - - @Test - public void testStatementCommit() { - subject.statementCommit(); - verify(connection).commit(); - } - - @Test - public void testStatementGetAutocommit() { - subject.statementShowAutocommit(); - verify(connection).isAutocommit(); - } - - @Test - public void testStatementGetAutocommitDmlMode() { - subject.statementShowAutocommitDmlMode(); - verify(connection).getAutocommitDmlMode(); - } - - @Test - public void testStatementGetCommitTimestamp() { - subject.statementShowCommitTimestamp(); - verify(connection).getCommitTimestampOrNull(); - } - - @Test - public void testStatementGetReadOnly() { - subject.statementShowReadOnly(); - verify(connection).isReadOnly(); - } - - @Test - public void testStatementGetReadOnlyStaleness() { - subject.statementShowReadOnlyStaleness(); - verify(connection).getReadOnlyStaleness(); - } - - @Test - public void testStatementGetReadTimestamp() { - subject.statementShowReadTimestamp(); - verify(connection).getReadTimestampOrNull(); - } - - @Test - public void testStatementGetStatementTimeout() { - subject.statementSetStatementTimeout(Duration.newBuilder().setSeconds(1L).build()); - when(connection.hasStatementTimeout()).thenReturn(true); - subject.statementShowStatementTimeout(); - verify(connection, atLeastOnce()).getStatementTimeout(any(TimeUnit.class)); - subject.statementSetStatementTimeout(Duration.getDefaultInstance()); - when(connection.hasStatementTimeout()).thenReturn(false); - } - - @Test - public void testStatementRollback() { - subject.statementRollback(); - verify(connection).rollback(); - } - - @Test - public void testStatementSetAutocommit() { - subject.statementSetAutocommit(Boolean.TRUE); - verify(connection).setAutocommit(true); - subject.statementSetAutocommit(Boolean.FALSE); - verify(connection).setAutocommit(false); - } - - @Test - public void testStatementSetAutocommitDmlMode() { - subject.statementSetAutocommitDmlMode(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - verify(connection).setAutocommitDmlMode(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - subject.statementSetAutocommitDmlMode(AutocommitDmlMode.TRANSACTIONAL); - verify(connection).setAutocommitDmlMode(AutocommitDmlMode.TRANSACTIONAL); - } - - @Test - public void testStatementSetReadOnly() { - subject.statementSetReadOnly(Boolean.TRUE); - verify(connection).setReadOnly(true); - subject.statementSetReadOnly(Boolean.FALSE); - verify(connection).setReadOnly(false); - } - - @Test - public void testStatementSetReadOnlyStaleness() { - subject.statementSetReadOnlyStaleness(TimestampBound.strong()); - verify(connection).setReadOnlyStaleness(TimestampBound.strong()); - - subject.statementSetReadOnlyStaleness( - TimestampBound.ofReadTimestamp(Timestamp.parseTimestamp("2018-10-31T10:11:12.123Z"))); - verify(connection) - .setReadOnlyStaleness( - TimestampBound.ofReadTimestamp(Timestamp.parseTimestamp("2018-10-31T10:11:12.123Z"))); - - subject.statementSetReadOnlyStaleness( - TimestampBound.ofMinReadTimestamp(Timestamp.parseTimestamp("2018-10-31T10:11:12.123Z"))); - verify(connection) - .setReadOnlyStaleness( - TimestampBound.ofReadTimestamp(Timestamp.parseTimestamp("2018-10-31T10:11:12.123Z"))); - - subject.statementSetReadOnlyStaleness(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - verify(connection).setReadOnlyStaleness(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - - subject.statementSetReadOnlyStaleness( - TimestampBound.ofMaxStaleness(20L, TimeUnit.MILLISECONDS)); - verify(connection) - .setReadOnlyStaleness(TimestampBound.ofMaxStaleness(20L, TimeUnit.MILLISECONDS)); - } - - @Test - public void testStatementSetStatementTimeout() { - subject.statementSetStatementTimeout(Duration.newBuilder().setNanos(100).build()); - verify(connection).setStatementTimeout(100L, TimeUnit.NANOSECONDS); - } - - @Test - public void testStatementSetTransactionMode() { - subject.statementSetTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - verify(connection).setTransactionMode(TransactionMode.READ_ONLY_TRANSACTION); - subject.statementSetTransactionMode(TransactionMode.READ_WRITE_TRANSACTION); - verify(connection).setTransactionMode(TransactionMode.READ_WRITE_TRANSACTION); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithNoParametersTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithNoParametersTest.java deleted file mode 100644 index e106bcd6946..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithNoParametersTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import java.util.concurrent.TimeUnit; -import org.junit.Test; - -public class ConnectionStatementWithNoParametersTest { - private final StatementParser parser = StatementParser.INSTANCE; - - @Test - public void testExecuteGetAutocommit() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable autocommit")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowAutocommit()).thenCallRealMethod(); - statement.getClientSideStatement().execute(executor, "show variable autocommit"); - verify(connection, times(1)).isAutocommit(); - } - - @Test - public void testExecuteGetReadOnly() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable readonly")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowReadOnly()).thenCallRealMethod(); - statement.getClientSideStatement().execute(executor, "show variable readonly"); - verify(connection, times(1)).isReadOnly(); - } - - @Test - public void testExecuteGetAutocommitDmlMode() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable autocommit_dml_mode")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowAutocommitDmlMode()).thenCallRealMethod(); - when(connection.getAutocommitDmlMode()).thenReturn(AutocommitDmlMode.TRANSACTIONAL); - statement.getClientSideStatement().execute(executor, "show variable autocommit_dml_mode"); - verify(connection, times(1)).getAutocommitDmlMode(); - } - - @Test - public void testExecuteGetStatementTimeout() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable statement_timeout")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowStatementTimeout()).thenCallRealMethod(); - when(connection.hasStatementTimeout()).thenReturn(true); - when(connection.getStatementTimeout(TimeUnit.NANOSECONDS)).thenReturn(1L); - statement.getClientSideStatement().execute(executor, "show variable statement_timeout"); - verify(connection, times(2)).getStatementTimeout(TimeUnit.NANOSECONDS); - } - - @Test - public void testExecuteGetReadTimestamp() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable read_timestamp")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowReadTimestamp()).thenCallRealMethod(); - when(connection.getReadTimestampOrNull()).thenReturn(Timestamp.now()); - statement.getClientSideStatement().execute(executor, "show variable read_timestamp"); - verify(connection, times(1)).getReadTimestampOrNull(); - } - - @Test - public void testExecuteGetCommitTimestamp() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable commit_timestamp")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowCommitTimestamp()).thenCallRealMethod(); - when(connection.getCommitTimestampOrNull()).thenReturn(Timestamp.now()); - statement.getClientSideStatement().execute(executor, "show variable commit_timestamp"); - verify(connection, times(1)).getCommitTimestampOrNull(); - } - - @Test - public void testExecuteGetReadOnlyStaleness() throws Exception { - ParsedStatement statement = parser.parse(Statement.of("show variable read_only_staleness")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementShowReadOnlyStaleness()).thenCallRealMethod(); - when(connection.getReadOnlyStaleness()).thenReturn(TimestampBound.strong()); - statement.getClientSideStatement().execute(executor, "show variable read_only_staleness"); - verify(connection, times(1)).getReadOnlyStaleness(); - } - - @Test - public void testExecuteBegin() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("begin")); - for (String statement : subject.getClientSideStatement().getExampleStatements()) { - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementBeginTransaction()).thenCallRealMethod(); - subject.getClientSideStatement().execute(executor, statement); - verify(connection, times(1)).beginTransaction(); - } - } - - @Test - public void testExecuteCommit() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("commit")); - for (String statement : subject.getClientSideStatement().getExampleStatements()) { - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementCommit()).thenCallRealMethod(); - subject.getClientSideStatement().execute(executor, statement); - verify(connection, times(1)).commit(); - } - } - - @Test - public void testExecuteRollback() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("rollback")); - for (String statement : subject.getClientSideStatement().getExampleStatements()) { - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementRollback()).thenCallRealMethod(); - subject.getClientSideStatement().execute(executor, statement); - verify(connection, times(1)).rollback(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithOneParameterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithOneParameterTest.java deleted file mode 100644 index de5354fc66b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ConnectionStatementWithOneParameterTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.protobuf.Duration; -import java.util.concurrent.TimeUnit; -import org.junit.Test; - -public class ConnectionStatementWithOneParameterTest { - private final StatementParser parser = StatementParser.INSTANCE; - - @Test - public void testExecuteSetAutcommit() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("set autocommit = true")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementSetAutocommit(any(Boolean.class))).thenCallRealMethod(); - for (Boolean mode : new Boolean[] {Boolean.FALSE, Boolean.TRUE}) { - subject - .getClientSideStatement() - .execute(executor, String.format("set autocommit = %s", mode)); - verify(connection, times(1)).setAutocommit(mode); - } - } - - @Test - public void testExecuteSetReadOnly() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("set readonly = true")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementSetReadOnly(any(Boolean.class))).thenCallRealMethod(); - for (Boolean mode : new Boolean[] {Boolean.FALSE, Boolean.TRUE}) { - subject - .getClientSideStatement() - .execute(executor, String.format("set readonly = %s", Boolean.toString(mode))); - verify(connection, times(1)).setReadOnly(mode); - } - } - - @Test - public void testExecuteSetAutcommitDmlMode() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("set autocommit_dml_mode='foo'")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementSetAutocommitDmlMode(any(AutocommitDmlMode.class))).thenCallRealMethod(); - for (AutocommitDmlMode mode : AutocommitDmlMode.values()) { - subject - .getClientSideStatement() - .execute(executor, String.format("set autocommit_dml_mode='%s'", mode.name())); - verify(connection, times(1)).setAutocommitDmlMode(mode); - } - } - - @Test - public void testExecuteSetStatementTimeout() throws Exception { - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.statementSetStatementTimeout(any(Duration.class))).thenCallRealMethod(); - ConnectionImpl connection = mock(ConnectionImpl.class); - when(executor.getConnection()).thenReturn(connection); - for (TimeUnit unit : ReadOnlyStalenessUtil.SUPPORTED_UNITS) { - for (Long val : new Long[] {1L, 100L, 999L}) { - ParsedStatement subject = - parser.parse( - Statement.of( - String.format( - "set statement_timeout='%d%s'", - val, ReadOnlyStalenessUtil.getTimeUnitAbbreviation(unit)))); - subject - .getClientSideStatement() - .execute( - executor, - String.format( - "set statement_timeout='%d%s'", - val, ReadOnlyStalenessUtil.getTimeUnitAbbreviation(unit))); - verify(connection, times(1)).setStatementTimeout(val, unit); - } - } - ParsedStatement subject = - parser.parse(Statement.of(String.format("set statement_timeout=null"))); - subject.getClientSideStatement().execute(executor, String.format("set statement_timeout=null")); - verify(connection, times(1)).clearStatementTimeout(); - } - - @Test - public void testExecuteSetReadOnlyStaleness() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("set read_only_staleness='foo'")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementSetReadOnlyStaleness(any(TimestampBound.class))).thenCallRealMethod(); - for (TimestampBound val : - new TimestampBound[] { - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(Timestamp.now()), - TimestampBound.ofMinReadTimestamp(Timestamp.now()), - TimestampBound.ofExactStaleness(1000L, TimeUnit.SECONDS), - TimestampBound.ofMaxStaleness(2000L, TimeUnit.MICROSECONDS) - }) { - subject - .getClientSideStatement() - .execute( - executor, String.format("set read_only_staleness='%s'", timestampBoundToString(val))); - verify(connection, times(1)).setReadOnlyStaleness(val); - } - } - - private String timestampBoundToString(TimestampBound staleness) { - switch (staleness.getMode()) { - case STRONG: - return "strong"; - case READ_TIMESTAMP: - return "read_timestamp " + staleness.getReadTimestamp().toString(); - case MIN_READ_TIMESTAMP: - return "min_read_timestamp " + staleness.getMinReadTimestamp().toString(); - case EXACT_STALENESS: - return "exact_staleness " + staleness.getExactStaleness(TimeUnit.SECONDS) + "s"; - case MAX_STALENESS: - return "max_staleness " + staleness.getMaxStaleness(TimeUnit.MICROSECONDS) + "us"; - default: - throw new IllegalStateException("Unknown mode: " + staleness.getMode()); - } - } - - @Test - public void testExecuteSetTransaction() throws Exception { - ParsedStatement subject = parser.parse(Statement.of("set transaction read_only")); - ConnectionImpl connection = mock(ConnectionImpl.class); - ConnectionStatementExecutorImpl executor = mock(ConnectionStatementExecutorImpl.class); - when(executor.getConnection()).thenReturn(connection); - when(executor.statementSetTransactionMode(any(TransactionMode.class))).thenCallRealMethod(); - for (TransactionMode mode : TransactionMode.values()) { - subject - .getClientSideStatement() - .execute(executor, String.format("set transaction %s", mode.getStatementString())); - verify(connection, times(1)).setTransactionMode(mode); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/CredentialsServiceTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/CredentialsServiceTest.java deleted file mode 100644 index fbc35f7286e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/CredentialsServiceTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.auth.oauth2.ServiceAccountCredentials; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import java.io.FileInputStream; -import java.io.IOException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for reading and parsing test key files and getting service accounts. */ -@RunWith(JUnit4.class) -public class CredentialsServiceTest { - private static final String FILE_TEST_PATH = - CredentialsServiceTest.class.getResource("test-key.json").getFile(); - private static final String APP_DEFAULT_FILE_TEST_PATH = - CredentialsServiceTest.class.getResource("test-key-app-default.json").getFile(); - - private static final String TEST_PROJECT_ID = "test-project"; - private static final String APP_DEFAULT_PROJECT_ID = "app-default-test-project"; - - private final CredentialsService service = - new CredentialsService() { - - @Override - GoogleCredentials internalGetApplicationDefault() throws IOException { - // Read application default credentials directly from a specific file instead of actually - // fetching the default from the environment. - return GoogleCredentials.fromStream(new FileInputStream(APP_DEFAULT_FILE_TEST_PATH)); - } - }; - - @Test - public void testCreateCredentialsDefault() throws Exception { - ServiceAccountCredentials credentials = - (ServiceAccountCredentials) service.createCredentials(null); - assertThat(credentials.getProjectId(), is(equalTo(APP_DEFAULT_PROJECT_ID))); - } - - @Test - public void testCreateCredentialsFile() throws IOException { - ServiceAccountCredentials credentials = - (ServiceAccountCredentials) service.createCredentials(FILE_TEST_PATH); - assertThat(credentials.getProjectId(), is(equalTo(TEST_PROJECT_ID))); - } - - @Test(expected = SpannerException.class) - public void testCreateCredentialsInvalidFile() { - service.createCredentials("invalid_file_path.json"); - } - - @Test - public void testCreateCredentialsInvalidCloudStorage() { - try { - service.createCredentials("gs://test-bucket/test-blob"); - fail("missing expected exception"); - } catch (SpannerException e) { - assertThat(e.getErrorCode(), is(equalTo(ErrorCode.INVALID_ARGUMENT))); - assertThat(e.getCause().getMessage(), is(equalTo(CredentialsService.GCS_NOT_SUPPORTED_MSG))); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlBatchTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlBatchTest.java deleted file mode 100644 index 3700f4c71a1..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlBatchTest.java +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ReadContext; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ConnectionImpl.InternalMetadataQuery; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState; -import com.google.protobuf.Timestamp; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import io.grpc.Status; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.ArgumentMatcher; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class DdlBatchTest { - - @Rule public ExpectedException exception = ExpectedException.none(); - - private DdlClient createDefaultMockDdlClient() { - return createDefaultMockDdlClient(false, 0L); - } - - private DdlClient createDefaultMockDdlClient(boolean exceptionOnGetResult) { - return createDefaultMockDdlClient(exceptionOnGetResult, 0L); - } - - private DdlClient createDefaultMockDdlClient(long waitForMillis) { - return createDefaultMockDdlClient(false, waitForMillis); - } - - private DdlClient createDefaultMockDdlClient( - boolean exceptionOnGetResult, final long waitForMillis) { - try { - DdlClient ddlClient = mock(DdlClient.class); - @SuppressWarnings("unchecked") - final OperationFuture operation = - mock(OperationFuture.class); - if (waitForMillis > 0L) { - when(operation.get()) - .thenAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(waitForMillis); - return null; - } - }); - } else if (exceptionOnGetResult) { - when(operation.get()) - .thenThrow( - SpannerExceptionFactory.newSpannerException( - ErrorCode.UNKNOWN, "ddl statement failed")); - } else { - when(operation.get()).thenReturn(null); - } - UpdateDatabaseDdlMetadata.Builder metadataBuilder = UpdateDatabaseDdlMetadata.newBuilder(); - if (!exceptionOnGetResult) { - metadataBuilder.addCommitTimestamps( - Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000L)); - } - ApiFuture metadataFuture = - ApiFutures.immediateFuture(metadataBuilder.build()); - when(operation.getMetadata()).thenReturn(metadataFuture); - when(ddlClient.executeDdl(anyString())).thenReturn(operation); - when(ddlClient.executeDdl(anyListOf(String.class))).thenReturn(operation); - return ddlClient; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private DdlBatch createSubject() { - return createSubject(createDefaultMockDdlClient()); - } - - private DdlBatch createSubject(DdlClient ddlClient) { - return createSubject(ddlClient, mock(DatabaseClient.class)); - } - - private DdlBatch createSubject(DdlClient ddlClient, DatabaseClient dbClient) { - return DdlBatch.newBuilder() - .setDdlClient(ddlClient) - .setDatabaseClient(dbClient) - .withStatementExecutor(new StatementExecutor()) - .build(); - } - - @Test - public void testExecuteQuery() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.executeQuery(mock(ParsedStatement.class), AnalyzeMode.NONE); - } - - @Test - public void testExecuteMetadataQuery() { - Statement statement = Statement.of("SELECT * FROM INFORMATION_SCHEMA.TABLES"); - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.isQuery()).thenReturn(true); - when(parsedStatement.getStatement()).thenReturn(statement); - DatabaseClient dbClient = mock(DatabaseClient.class); - ReadContext singleUse = mock(ReadContext.class); - ResultSet resultSet = mock(ResultSet.class); - when(singleUse.executeQuery(statement)).thenReturn(resultSet); - when(dbClient.singleUse()).thenReturn(singleUse); - DdlBatch batch = createSubject(createDefaultMockDdlClient(), dbClient); - assertThat( - batch - .executeQuery(parsedStatement, AnalyzeMode.NONE, InternalMetadataQuery.INSTANCE) - .hashCode(), - is(equalTo(resultSet.hashCode()))); - } - - @Test - public void testExecuteUpdate() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.executeUpdate(mock(ParsedStatement.class)); - } - - @Test - public void testGetCommitTimestamp() { - DdlBatch batch = createSubject(); - batch.runBatch(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.getCommitTimestamp(); - } - - @Test - public void testGetReadTimestamp() { - DdlBatch batch = createSubject(); - batch.runBatch(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.getReadTimestamp(); - } - - @Test - public void testWrite() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.write(Mutation.newInsertBuilder("foo").build()); - } - - @Test - public void testWriteIterable() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.write(Arrays.asList(Mutation.newInsertBuilder("foo").build())); - } - - @Test - public void testIsReadOnly() { - DdlBatch batch = createSubject(); - assertThat(batch.isReadOnly(), is(false)); - } - - @Test - public void testGetStateAndIsActive() { - DdlBatch batch = createSubject(); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - batch.runBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.RAN)); - assertThat(batch.isActive(), is(false)); - - batch = createSubject(); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - batch.abortBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.ABORTED)); - assertThat(batch.isActive(), is(false)); - - DdlClient client = mock(DdlClient.class); - doThrow(SpannerException.class).when(client).executeDdl(anyListOf(String.class)); - batch = createSubject(client); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getStatement()).thenReturn(Statement.of("CREATE TABLE FOO")); - when(statement.getSqlWithoutComments()).thenReturn("CREATE TABLE FOO"); - when(statement.getType()).thenReturn(StatementType.DDL); - batch.executeDdl(statement); - boolean exception = false; - try { - batch.runBatch(); - } catch (SpannerException e) { - exception = true; - } - assertThat(exception, is(true)); - assertThat(batch.getState(), is(UnitOfWorkState.RUN_FAILED)); - assertThat(batch.isActive(), is(false)); - } - - private static IsListOfStringsWithSize isEmptyListOfStrings() { - return new IsListOfStringsWithSize(0); - } - - private static IsListOfStringsWithSize isListOfStringsWithSize(int size) { - return new IsListOfStringsWithSize(size); - } - - private static class IsListOfStringsWithSize extends ArgumentMatcher> { - private final int size; - - private IsListOfStringsWithSize(int size) { - this.size = size; - } - - @SuppressWarnings("unchecked") - @Override - public boolean matches(Object list) { - return ((List) list).size() == size; - } - } - - @Test - public void testRunBatch() { - DdlClient client = createDefaultMockDdlClient(); - DdlBatch batch = createSubject(client); - batch.runBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.RAN)); - verify(client, never()).executeDdl(anyString()); - verify(client, never()).executeDdl(argThat(isEmptyListOfStrings())); - - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.DDL); - when(statement.getStatement()).thenReturn(Statement.of("CREATE TABLE FOO")); - when(statement.getSqlWithoutComments()).thenReturn("CREATE TABLE FOO"); - - client = createDefaultMockDdlClient(); - batch = createSubject(client); - batch.executeDdl(statement); - batch.runBatch(); - verify(client).executeDdl(argThat(isListOfStringsWithSize(1))); - - client = createDefaultMockDdlClient(); - batch = createSubject(client); - batch.executeDdl(statement); - batch.executeDdl(statement); - batch.runBatch(); - verify(client).executeDdl(argThat(isListOfStringsWithSize(2))); - assertThat(batch.getState(), is(UnitOfWorkState.RAN)); - boolean exception = false; - try { - batch.runBatch(); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.FAILED_PRECONDITION) { - throw e; - } - exception = true; - } - assertThat(exception, is(true)); - assertThat(batch.getState(), is(UnitOfWorkState.RAN)); - exception = false; - try { - batch.executeDdl(statement); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.FAILED_PRECONDITION) { - throw e; - } - exception = true; - } - assertThat(exception, is(true)); - exception = false; - try { - batch.executeDdl(statement); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.FAILED_PRECONDITION) { - throw e; - } - exception = true; - } - assertThat(exception, is(true)); - - client = createDefaultMockDdlClient(true); - batch = createSubject(client); - batch.executeDdl(statement); - batch.executeDdl(statement); - exception = false; - try { - batch.runBatch(); - } catch (SpannerException e) { - exception = true; - } - assertThat(exception, is(true)); - assertThat(batch.getState(), is(UnitOfWorkState.RUN_FAILED)); - verify(client).executeDdl(argThat(isListOfStringsWithSize(2))); - } - - @Test - public void testUpdateCount() throws InterruptedException, ExecutionException { - DdlClient client = mock(DdlClient.class); - UpdateDatabaseDdlMetadata metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps( - Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000L - 1L)) - .addCommitTimestamps( - Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000L)) - .addAllStatements(Arrays.asList("CREATE TABLE FOO", "CREATE TABLE BAR")) - .build(); - ApiFuture metadataFuture = ApiFutures.immediateFuture(metadata); - @SuppressWarnings("unchecked") - OperationFuture operationFuture = mock(OperationFuture.class); - when(operationFuture.get()).thenReturn(null); - when(operationFuture.getMetadata()).thenReturn(metadataFuture); - when(client.executeDdl(argThat(isListOfStringsWithSize(2)))).thenReturn(operationFuture); - DdlBatch batch = - DdlBatch.newBuilder() - .withStatementExecutor(new StatementExecutor()) - .setDdlClient(client) - .setDatabaseClient(mock(DatabaseClient.class)) - .build(); - batch.executeDdl(StatementParser.INSTANCE.parse(Statement.of("CREATE TABLE FOO"))); - batch.executeDdl(StatementParser.INSTANCE.parse(Statement.of("CREATE TABLE BAR"))); - long[] updateCounts = batch.runBatch(); - assertThat(updateCounts.length, is(equalTo(2))); - assertThat(updateCounts[0], is(equalTo(1L))); - assertThat(updateCounts[1], is(equalTo(1L))); - } - - @Test - public void testFailedUpdateCount() throws InterruptedException, ExecutionException { - DdlClient client = mock(DdlClient.class); - UpdateDatabaseDdlMetadata metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps( - Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000L - 1L)) - .addAllStatements(Arrays.asList("CREATE TABLE FOO", "CREATE TABLE INVALID_TABLE")) - .build(); - ApiFuture metadataFuture = ApiFutures.immediateFuture(metadata); - @SuppressWarnings("unchecked") - OperationFuture operationFuture = mock(OperationFuture.class); - when(operationFuture.get()) - .thenThrow( - new ExecutionException( - "ddl statement failed", Status.INVALID_ARGUMENT.asRuntimeException())); - when(operationFuture.getMetadata()).thenReturn(metadataFuture); - when(client.executeDdl(argThat(isListOfStringsWithSize(2)))).thenReturn(operationFuture); - DdlBatch batch = - DdlBatch.newBuilder() - .withStatementExecutor(new StatementExecutor()) - .setDdlClient(client) - .setDatabaseClient(mock(DatabaseClient.class)) - .build(); - batch.executeDdl(StatementParser.INSTANCE.parse(Statement.of("CREATE TABLE FOO"))); - batch.executeDdl(StatementParser.INSTANCE.parse(Statement.of("CREATE TABLE INVALID_TABLE"))); - try { - batch.runBatch(); - fail("missing expected exception"); - } catch (SpannerBatchUpdateException e) { - assertThat(e.getUpdateCounts().length, is(equalTo(2))); - assertThat(e.getUpdateCounts()[0], is(equalTo(1L))); - assertThat(e.getUpdateCounts()[1], is(equalTo(0L))); - } - } - - @Test - public void testAbort() { - DdlClient client = createDefaultMockDdlClient(); - DdlBatch batch = createSubject(client); - batch.abortBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.ABORTED)); - verify(client, never()).executeDdl(anyString()); - verify(client, never()).executeDdl(anyListOf(String.class)); - - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.DDL); - when(statement.getStatement()).thenReturn(Statement.of("CREATE TABLE FOO")); - when(statement.getSqlWithoutComments()).thenReturn("CREATE TABLE FOO"); - - client = createDefaultMockDdlClient(); - batch = createSubject(client); - batch.executeDdl(statement); - batch.abortBatch(); - verify(client, never()).executeDdl(anyListOf(String.class)); - - client = createDefaultMockDdlClient(); - batch = createSubject(client); - batch.executeDdl(statement); - batch.executeDdl(statement); - batch.abortBatch(); - verify(client, never()).executeDdl(anyListOf(String.class)); - - client = createDefaultMockDdlClient(); - batch = createSubject(client); - batch.executeDdl(statement); - batch.executeDdl(statement); - batch.abortBatch(); - verify(client, never()).executeDdl(anyListOf(String.class)); - boolean exception = false; - try { - batch.runBatch(); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.FAILED_PRECONDITION) { - throw e; - } - exception = true; - } - assertThat(exception, is(true)); - verify(client, never()).executeDdl(anyListOf(String.class)); - } - - @Test - public void testCancel() { - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.DDL); - when(statement.getStatement()).thenReturn(Statement.of("CREATE TABLE FOO")); - when(statement.getSqlWithoutComments()).thenReturn("CREATE TABLE FOO"); - - DdlClient client = createDefaultMockDdlClient(10000L); - final DdlBatch batch = createSubject(client); - batch.executeDdl(statement); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - batch.cancel(); - } - }, - 100, - TimeUnit.MILLISECONDS); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - batch.runBatch(); - } - - @Test - public void testCommit() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.commit(); - } - - @Test - public void testRollback() { - DdlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.rollback(); - } - - @Test - public void testExtractUpdateCounts() { - DdlBatch batch = createSubject(); - UpdateDatabaseDdlMetadata metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(1000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(2000L).build()) - .addStatements("CREATE TABLE FOO") - .addStatements("CREATE TABLE BAR") - .addStatements("CREATE TABLE BAZ") - .build(); - long[] updateCounts = batch.extractUpdateCounts(metadata); - assertThat(updateCounts, is(equalTo(new long[] {1L, 1L, 0L}))); - - metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(1000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(2000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(3000L).build()) - .addStatements("CREATE TABLE FOO") - .addStatements("CREATE TABLE BAR") - .addStatements("CREATE TABLE BAZ") - .build(); - updateCounts = batch.extractUpdateCounts(metadata); - assertThat(updateCounts, is(equalTo(new long[] {1L, 1L, 1L}))); - - metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(1000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(2000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(3000L).build()) - .addStatements("CREATE TABLE FOO") - .addStatements("CREATE TABLE BAR") - .addStatements("CREATE TABLE BAZ") - .build(); - updateCounts = batch.extractUpdateCounts(metadata); - assertThat(updateCounts, is(equalTo(new long[] {1L, 1L, 1L}))); - - // This is not something Cloud Spanner should return, but the method can handle it. - metadata = - UpdateDatabaseDdlMetadata.newBuilder() - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(1000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(2000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(3000L).build()) - .addCommitTimestamps(Timestamp.newBuilder().setSeconds(4000L).build()) - .addStatements("CREATE TABLE FOO") - .addStatements("CREATE TABLE BAR") - .addStatements("CREATE TABLE BAZ") - .build(); - updateCounts = batch.extractUpdateCounts(metadata); - assertThat(updateCounts, is(equalTo(new long[] {1L, 1L, 1L}))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlClientTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlClientTest.java deleted file mode 100644 index 8ec9f600d31..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DdlClientTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.spanner.DatabaseAdminClient; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.ExecutionException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DdlClientTest { - - private final String instanceId = "test-instance"; - private final String databaseId = "test-database"; - - private DdlClient createSubject(DatabaseAdminClient client) { - return DdlClient.newBuilder() - .setInstanceId(instanceId) - .setDatabaseName(databaseId) - .setDatabaseAdminClient(client) - .build(); - } - - @Test - public void testExecuteDdl() throws InterruptedException, ExecutionException { - DatabaseAdminClient client = mock(DatabaseAdminClient.class); - @SuppressWarnings("unchecked") - OperationFuture operation = mock(OperationFuture.class); - when(operation.get()).thenReturn(null); - when(client.updateDatabaseDdl( - eq(instanceId), eq(databaseId), anyListOf(String.class), isNull(String.class))) - .thenReturn(operation); - DdlClient subject = createSubject(client); - String ddl = "CREATE TABLE FOO"; - subject.executeDdl(ddl); - verify(client).updateDatabaseDdl(instanceId, databaseId, Arrays.asList(ddl), null); - - subject = createSubject(client); - List ddlList = Arrays.asList("CREATE TABLE FOO", "DROP TABLE FOO"); - subject.executeDdl(ddlList); - verify(client).updateDatabaseDdl(instanceId, databaseId, ddlList, null); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSetTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSetTest.java deleted file mode 100644 index b138b1e6251..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DirectExecuteResultSetTest.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DirectExecuteResultSetTest { - - private DirectExecuteResultSet createSubject() { - ResultSet delegate = - ResultSets.forRows( - Type.struct(StructField.of("test", Type.int64())), - Arrays.asList(Struct.newBuilder().set("test").to(1L).build())); - return DirectExecuteResultSet.ofResultSet(delegate); - } - - @Test - public void testMethodCallBeforeNext() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = - Arrays.asList("getStats", "next", "close", "ofResultSet", "equals", "hashCode"); - DirectExecuteResultSet subject = createSubject(); - callMethods(subject, excludedMethods, IllegalStateException.class); - } - - @Test - public void testMethodCallAfterClose() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = - Arrays.asList( - "getStats", - "next", - "close", - "getType", - "getColumnCount", - "getColumnIndex", - "getColumnType", - "ofResultSet", - "equals", - "hashCode"); - DirectExecuteResultSet subject = createSubject(); - subject.next(); - subject.close(); - callMethods(subject, excludedMethods, IllegalStateException.class); - } - - @Test - public void testMethodCallAfterNextHasReturnedFalse() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = - Arrays.asList( - "getStats", - "next", - "close", - "getType", - "getColumnCount", - "getColumnIndex", - "getColumnType", - "ofResultSet", - "equals", - "hashCode"); - DirectExecuteResultSet subject = createSubject(); - subject.next(); - subject.next(); - callMethods(subject, excludedMethods, IndexOutOfBoundsException.class); - } - - private void callMethods( - DirectExecuteResultSet subject, - List excludedMethods, - Class expectedException) - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - for (Method method : DirectExecuteResultSet.class.getDeclaredMethods()) { - if (Modifier.isPublic(method.getModifiers()) && !excludedMethods.contains(method.getName())) { - boolean exception = false; - int numberOfParameters = method.getParameterTypes().length; - Class firstParameterType = null; - if (numberOfParameters == 1) { - firstParameterType = method.getParameterTypes()[0]; - } - try { - switch (numberOfParameters) { - case 0: - method.invoke(subject); - break; - case 1: - if (firstParameterType == String.class) { - method.invoke(subject, "test"); - } else if (firstParameterType == int.class) { - method.invoke(subject, 0); - } else { - fail("unknown parameter type"); - } - break; - default: - fail("method with more than 1 parameter is unknown"); - } - } catch (InvocationTargetException e) { - if (e.getCause().getClass().equals(expectedException)) { - // expected - exception = true; - } else { - throw e; - } - } - assertThat( - method.getName() + " did not throw an IllegalStateException", exception, is(true)); - } - } - } - - @Test - public void testValidMethodCall() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - ResultSet delegate = mock(ResultSet.class); - when(delegate.next()).thenReturn(true, true, false); - DirectExecuteResultSet subject = DirectExecuteResultSet.ofResultSet(delegate); - subject.next(); - - subject.getBoolean(0); - verify(delegate).getBoolean(0); - subject.getBoolean("test0"); - verify(delegate).getBoolean("test0"); - subject.getBooleanArray(1); - verify(delegate).getBooleanArray(1); - subject.getBooleanArray("test1"); - verify(delegate).getBooleanArray("test1"); - subject.getBooleanList(2); - verify(delegate).getBooleanList(2); - subject.getBooleanList("test2"); - verify(delegate).getBooleanList("test2"); - - subject.getBytes(0); - verify(delegate).getBytes(0); - subject.getBytes("test0"); - verify(delegate).getBytes("test0"); - subject.getBytesList(2); - verify(delegate).getBytesList(2); - subject.getBytesList("test2"); - verify(delegate).getBytesList("test2"); - - subject.getDate(0); - verify(delegate).getDate(0); - subject.getDate("test0"); - verify(delegate).getDate("test0"); - subject.getDateList(2); - verify(delegate).getDateList(2); - subject.getDateList("test2"); - verify(delegate).getDateList("test2"); - - subject.getDouble(0); - verify(delegate).getDouble(0); - subject.getDouble("test0"); - verify(delegate).getDouble("test0"); - subject.getDoubleArray(1); - verify(delegate).getDoubleArray(1); - subject.getDoubleArray("test1"); - verify(delegate).getDoubleArray("test1"); - subject.getDoubleList(2); - verify(delegate).getDoubleList(2); - subject.getDoubleList("test2"); - verify(delegate).getDoubleList("test2"); - - subject.getLong(0); - verify(delegate).getLong(0); - subject.getLong("test0"); - verify(delegate).getLong("test0"); - subject.getLongArray(1); - verify(delegate).getLongArray(1); - subject.getLongArray("test1"); - verify(delegate).getLongArray("test1"); - subject.getLongList(2); - verify(delegate).getLongList(2); - subject.getLongList("test2"); - verify(delegate).getLongList("test2"); - - subject.getString(0); - verify(delegate).getString(0); - subject.getString("test0"); - verify(delegate).getString("test0"); - subject.getStringList(2); - verify(delegate).getStringList(2); - subject.getStringList("test2"); - verify(delegate).getStringList("test2"); - - subject.getStructList(0); - subject.getStructList("test0"); - - subject.getTimestamp(0); - verify(delegate).getTimestamp(0); - subject.getTimestamp("test0"); - verify(delegate).getTimestamp("test0"); - subject.getTimestampList(2); - verify(delegate).getTimestampList(2); - subject.getTimestampList("test2"); - verify(delegate).getTimestampList("test2"); - - subject.getColumnCount(); - verify(delegate).getColumnCount(); - subject.getColumnIndex("test"); - verify(delegate).getColumnIndex("test"); - subject.getColumnType(100); - verify(delegate).getColumnType(100); - subject.getColumnType("test"); - verify(delegate).getColumnType("test"); - subject.getCurrentRowAsStruct(); - verify(delegate).getCurrentRowAsStruct(); - subject.getType(); - verify(delegate).getType(); - subject.isNull(50); - verify(delegate).isNull(50); - subject.isNull("test"); - verify(delegate).isNull("test"); - - while (subject.next()) { - // ignore - } - subject.getStats(); - verify(delegate).getStats(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DmlBatchTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DmlBatchTest.java deleted file mode 100644 index e6c54d115b1..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DmlBatchTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState; -import java.util.Arrays; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DmlBatchTest { - private final ParsedStatement statement1 = - StatementParser.INSTANCE.parse(Statement.of("UPDATE FOO SET BAR=1 WHERE BAZ=2")); - private final ParsedStatement statement2 = - StatementParser.INSTANCE.parse(Statement.of("UPDATE FOO SET BAR=2 WHERE BAZ=3")); - - @Rule public ExpectedException exception = ExpectedException.none(); - - private DmlBatch createSubject() { - UnitOfWork transaction = mock(UnitOfWork.class); - when(transaction.executeBatchUpdate(Arrays.asList(statement1, statement2))) - .thenReturn(new long[] {3L, 5L}); - return createSubject(transaction); - } - - private DmlBatch createSubject(UnitOfWork transaction) { - return DmlBatch.newBuilder() - .setTransaction(transaction) - .withStatementExecutor(new StatementExecutor()) - .build(); - } - - @Test - public void testExecuteQuery() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.executeQuery(mock(ParsedStatement.class), AnalyzeMode.NONE); - } - - @Test - public void testExecuteDdl() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.executeDdl(mock(ParsedStatement.class)); - } - - @Test - public void testGetReadTimestamp() { - DmlBatch batch = createSubject(); - batch.runBatch(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.getReadTimestamp(); - } - - @Test - public void testIsReadOnly() { - DmlBatch batch = createSubject(); - assertThat(batch.isReadOnly(), is(false)); - } - - @Test - public void testGetCommitTimestamp() { - DmlBatch batch = createSubject(); - batch.runBatch(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.getCommitTimestamp(); - } - - @Test - public void testWrite() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.write(Mutation.newInsertBuilder("foo").build()); - } - - @Test - public void testWriteIterable() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.write(Arrays.asList(Mutation.newInsertBuilder("foo").build())); - } - - @Test - public void testGetStateAndIsActive() { - DmlBatch batch = createSubject(); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - batch.runBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.RAN)); - assertThat(batch.isActive(), is(false)); - - batch = createSubject(); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - batch.abortBatch(); - assertThat(batch.getState(), is(UnitOfWorkState.ABORTED)); - assertThat(batch.isActive(), is(false)); - - UnitOfWork tx = mock(UnitOfWork.class); - doThrow(SpannerException.class).when(tx).executeBatchUpdate(anyListOf(ParsedStatement.class)); - batch = createSubject(tx); - assertThat(batch.getState(), is(UnitOfWorkState.STARTED)); - assertThat(batch.isActive(), is(true)); - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getStatement()).thenReturn(Statement.of("UPDATE TEST SET COL1=2")); - when(statement.getSqlWithoutComments()).thenReturn("UPDATE TEST SET COL1=2"); - when(statement.getType()).thenReturn(StatementType.UPDATE); - batch.executeUpdate(statement); - boolean exception = false; - try { - batch.runBatch(); - } catch (SpannerException e) { - exception = true; - } - assertThat(exception, is(true)); - assertThat(batch.getState(), is(UnitOfWorkState.RUN_FAILED)); - assertThat(batch.isActive(), is(false)); - } - - @Test - public void testCommit() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.commit(); - } - - @Test - public void testRollback() { - DmlBatch batch = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - batch.rollback(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DurationConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DurationConverterTest.java deleted file mode 100644 index 073f33f31d6..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/DurationConverterTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.ClientSideStatementValueConverters.DurationConverter; -import com.google.protobuf.Duration; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DurationConverterTest { - - @Test - public void testConvert() throws CompileException { - String allowedValues = ReadOnlyStalenessConverterTest.getAllowedValues(DurationConverter.class); - assertThat(allowedValues, is(notNullValue())); - DurationConverter converter = new DurationConverter(allowedValues); - assertThat( - converter.convert("'100ms'"), - is( - equalTo( - Duration.newBuilder() - .setNanos((int) TimeUnit.MILLISECONDS.toNanos(100L)) - .build()))); - assertThat(converter.convert("'0ms'"), is(nullValue())); - assertThat(converter.convert("'-100ms'"), is(nullValue())); - assertThat( - converter.convert("'315576000000000ms'"), - is(equalTo(Duration.newBuilder().setSeconds(315576000000L).build()))); - assertThat( - converter.convert("'1000ms'"), is(equalTo(Duration.newBuilder().setSeconds(1L).build()))); - assertThat( - converter.convert("'1001ms'"), - is( - equalTo( - Duration.newBuilder() - .setSeconds(1L) - .setNanos((int) TimeUnit.MILLISECONDS.toNanos(1L)) - .build()))); - - assertThat(converter.convert("'1ns'"), is(equalTo(Duration.newBuilder().setNanos(1).build()))); - assertThat( - converter.convert("'1us'"), is(equalTo(Duration.newBuilder().setNanos(1000).build()))); - assertThat( - converter.convert("'1ms'"), is(equalTo(Duration.newBuilder().setNanos(1000000).build()))); - assertThat( - converter.convert("'999999999ns'"), - is(equalTo(Duration.newBuilder().setNanos(999999999).build()))); - assertThat( - converter.convert("'1s'"), is(equalTo(Duration.newBuilder().setSeconds(1L).build()))); - - assertThat(converter.convert("''"), is(nullValue())); - assertThat(converter.convert("' '"), is(nullValue())); - assertThat(converter.convert("'random string'"), is(nullValue())); - - assertThat(converter.convert("null"), is(equalTo(Duration.getDefaultInstance()))); - assertThat(converter.convert("NULL"), is(equalTo(Duration.getDefaultInstance()))); - assertThat(converter.convert("Null"), is(equalTo(Duration.getDefaultInstance()))); - assertThat(converter.convert("'null'"), is(nullValue())); - assertThat(converter.convert("'NULL'"), is(nullValue())); - assertThat(converter.convert("'Null'"), is(nullValue())); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractJdbcTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractJdbcTest.java deleted file mode 100644 index eab1fcc521a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractJdbcTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Database; -import com.google.cloud.spanner.GceTestEnvConfig; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.IntegrationTestEnv; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier.JdbcGenericConnection; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; - -/** Base class for all JDBC integration tests. */ -@Category(IntegrationTest.class) -public class ITAbstractJdbcTest { - protected class ITJdbcConnectionProvider implements GenericConnectionProvider { - public ITJdbcConnectionProvider() {} - - @Override - public JdbcGenericConnection getConnection() { - try { - return JdbcGenericConnection.of(createConnection()); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - } - - @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv(); - private static final String DEFAULT_KEY_FILE = null; - private static Database database; - - protected static String getKeyFile() { - return System.getProperty(GceTestEnvConfig.GCE_CREDENTIALS_FILE, DEFAULT_KEY_FILE); - } - - protected static boolean hasValidKeyFile() { - return getKeyFile() != null && Files.exists(Paths.get(getKeyFile())); - } - - protected static IntegrationTestEnv getTestEnv() { - return env; - } - - protected static Database getDatabase() { - return database; - } - - @BeforeClass - public static void setup() throws IOException, InterruptedException, ExecutionException { - database = env.getTestHelper().createTestDatabase(); - } - - /** - * Creates a new default JDBC connection to a test database. Use the method {@link - * ITAbstractJdbcTest#appendConnectionUri(StringBuilder)} to append additional connection options - * to the connection URI. - * - * @return The newly opened JDBC connection. - */ - public CloudSpannerJdbcConnection createConnection() throws SQLException { - // Create a connection URL for the generic connection API. - StringBuilder url = - ITAbstractSpannerTest.extractConnectionUrl(env.getTestHelper().getOptions(), getDatabase()); - // Prepend it with 'jdbc:' to make it a valid JDBC connection URL. - url.insert(0, "jdbc:"); - if (hasValidKeyFile()) { - url.append(";credentials=").append(getKeyFile()); - } - appendConnectionUri(url); - - return DriverManager.getConnection(url.toString()).unwrap(CloudSpannerJdbcConnection.class); - } - - protected void appendConnectionUri(StringBuilder uri) {} - - /** - * Override this method to instruct the test to create a default test table in the form: - * - *

-   * CREATE TABLE TEST (ID INT64 NOT NULL, NAME STRING(100) NOT NULL) PRIMARY KEY (ID)
-   * 
- * - * Note that the table is not re-created for each test case, but is preserved between test cases. - * It is the responsibility of the test class to either empty the table at the end of each test - * case, or keep track of the state of the test table and execute the test cases in a specific - * order. - * - * @return true if the default test table should be created. - */ - protected boolean doCreateDefaultTestTable() { - return false; - } - - protected boolean doCreateMusicTables() { - return false; - } - - @Before - public void createTestTable() throws SQLException { - if (doCreateDefaultTestTable()) { - try (Connection connection = createConnection()) { - connection.setAutoCommit(true); - if (!tableExists(connection, "TEST")) { - connection.setAutoCommit(false); - connection.createStatement().execute("START BATCH DDL"); - connection - .createStatement() - .execute( - "CREATE TABLE TEST (ID INT64 NOT NULL, NAME STRING(100) NOT NULL) PRIMARY KEY (ID)"); - connection.createStatement().execute("RUN BATCH"); - } - } - } - } - - @Before - public void createMusicTables() throws SQLException { - if (doCreateMusicTables()) { - try (Connection connection = createConnection()) { - connection.setAutoCommit(true); - if (!tableExists(connection, "Singers")) { - for (String statement : - AbstractSqlScriptVerifier.readStatementsFromFile( - "CreateMusicTables.sql", getClass())) { - connection.createStatement().execute(statement); - } - } - } - } - } - - protected boolean tableExists(Connection connection, String table) throws SQLException { - try (ResultSet rs = connection.getMetaData().getTables("", "", table, null)) { - if (rs.next()) { - if (rs.getString("TABLE_NAME").equalsIgnoreCase(table)) { - return true; - } - } - } - return false; - } - - protected boolean indexExists(Connection connection, String table, String index) - throws SQLException { - Preconditions.checkArgument(!Strings.isNullOrEmpty(index)); - try (PreparedStatement ps = - connection.prepareStatement( - "SELECT INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE UPPER(TABLE_NAME)=? AND UPPER(INDEX_NAME)=?")) { - ps.setString(1, table); - ps.setString(2, index); - try (ResultSet rs = ps.executeQuery()) { - return rs.next(); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractSpannerTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractSpannerTest.java deleted file mode 100644 index 7cd39c7a3dd..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITAbstractSpannerTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.Database; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.GceTestEnvConfig; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.IntegrationTestEnv; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.SpannerOptions; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionManager.TransactionState; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; -import java.io.IOException; -import java.lang.reflect.Field; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Random; -import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.experimental.categories.Category; - -/** - * Base class for integration tests. This class is located in this package to be able to access - * package-private methods of the Connection API - */ -@Category(IntegrationTest.class) -public abstract class ITAbstractSpannerTest { - protected class ITConnectionProvider implements GenericConnectionProvider { - public ITConnectionProvider() {} - - @Override - public GenericConnection getConnection() { - return SpannerGenericConnection.of(createConnection()); - } - } - - protected interface ITConnection extends Connection {} - - private ITConnection createITConnection(ConnectionOptions options) { - return new ITConnectionImpl(options); - } - - protected void closeSpanner() { - ConnectionOptions.closeSpanner(); - } - - public static class AbortInterceptor implements StatementExecutionInterceptor { - /** We need to replicate the enum here as it is not visibible outside the connection package */ - public enum ExecutionStep { - /** The initial execution of a statement (DML/Query) */ - EXECUTE_STATEMENT, - /** A call to {@link ResultSet#next()} */ - CALL_NEXT_ON_RESULT_SET, - /** Execution of the statement during a transaction retry */ - RETRY_STATEMENT, - /** A call to {@link ResultSet#next()} during transaction retry */ - RETRY_NEXT_ON_RESULT_SET; - - static ExecutionStep of(StatementExecutionStep step) { - return ExecutionStep.valueOf(step.name()); - } - } - - private double probability; - private boolean onlyInjectOnce = false; - private final Random random = new Random(); - - public AbortInterceptor(double probability) { - Preconditions.checkArgument(probability >= 0.0D && probability <= 1.0D); - this.probability = probability; - } - - public void setProbability(double probability) { - Preconditions.checkArgument(probability >= 0.0D && probability <= 1.0D); - this.probability = probability; - } - - /** Set this value to true to automatically set the probability to zero after an abort */ - public void setOnlyInjectOnce(boolean value) { - this.onlyInjectOnce = value; - } - - protected boolean shouldAbort(String statement, ExecutionStep step) { - return probability > random.nextDouble(); - } - - @Override - public void intercept( - ParsedStatement statement, StatementExecutionStep step, UnitOfWork transaction) { - if (shouldAbort(statement.getSqlWithoutComments(), ExecutionStep.of(step))) { - // ugly hack warning: inject the aborted state into the transaction manager to simulate an - // abort - if (transaction instanceof ReadWriteTransaction) { - try { - Field field = ReadWriteTransaction.class.getDeclaredField("txManager"); - field.setAccessible(true); - TransactionManager tx = (TransactionManager) field.get(transaction); - Class cls = Class.forName("com.google.cloud.spanner.TransactionManagerImpl"); - Class cls2 = - Class.forName("com.google.cloud.spanner.SessionPool$AutoClosingTransactionManager"); - Field delegateField = cls2.getDeclaredField("delegate"); - delegateField.setAccessible(true); - TransactionManager delegate = (TransactionManager) delegateField.get(tx); - Field stateField = cls.getDeclaredField("txnState"); - stateField.setAccessible(true); - - // First rollback the delegate, and then pretend it aborted. - // We should call rollback on the delegate and not the wrapping - // AutoClosingTransactionManager, as the latter would cause the session to be returned - // to the session pool. - delegate.rollback(); - stateField.set(delegate, TransactionState.ABORTED); - } catch (Exception e) { - throw new RuntimeException(e); - } - if (onlyInjectOnce) { - probability = 0; - } - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.ABORTED, "Transaction was aborted by interceptor"); - } - } - } - } - - @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv(); - private static final String DEFAULT_KEY_FILE = null; - private static Database database; - - protected static String getKeyFile() { - return System.getProperty(GceTestEnvConfig.GCE_CREDENTIALS_FILE, DEFAULT_KEY_FILE); - } - - protected static boolean hasValidKeyFile() { - return getKeyFile() != null && Files.exists(Paths.get(getKeyFile())); - } - - protected static IntegrationTestEnv getTestEnv() { - return env; - } - - protected static Database getDatabase() { - return database; - } - - /** - * Returns a connection URL that is extracted from the given {@link SpannerOptions} and database - * in the form - * cloudspanner:[//host]/projects/PROJECT_ID/instances/INSTANCE_ID/databases/DATABASE_ID - */ - static StringBuilder extractConnectionUrl(SpannerOptions options, Database database) { - StringBuilder url = new StringBuilder("cloudspanner:"); - if (options.getHost() != null) { - url.append(options.getHost().substring(options.getHost().indexOf(':') + 1)); - } - url.append("/").append(database.getId().getName()); - return url; - } - - @BeforeClass - public static void setup() throws IOException, InterruptedException, ExecutionException { - database = env.getTestHelper().createTestDatabase(); - } - - /** - * Creates a new default connection to a test database. Use the method {@link - * ITAbstractSpannerTest#appendConnectionUri(StringBuilder)} to append additional connection - * options to the connection URI. - * - * @return the newly opened connection. - */ - public ITConnection createConnection() { - return createConnection( - Collections.emptyList(), - Collections.emptyList()); - } - - public ITConnection createConnection(AbortInterceptor interceptor) { - return createConnection( - Arrays.asList(interceptor), - Collections.emptyList()); - } - - public ITConnection createConnection( - AbortInterceptor interceptor, TransactionRetryListener transactionRetryListener) { - return createConnection( - Arrays.asList(interceptor), - Arrays.asList(transactionRetryListener)); - } - - /** - * Creates a new default connection to a test database. Use the method {@link - * ITAbstractSpannerTest#appendConnectionUri(StringBuilder)} to append additional connection - * options to the connection URI. - * - * @param interceptors Interceptors that should be executed after each statement - * @param transactionRetryListeners Transaction retry listeners that should be added to the {@link - * Connection} - * @return the newly opened connection. - */ - public ITConnection createConnection( - List interceptors, - List transactionRetryListeners) { - StringBuilder url = - extractConnectionUrl(getTestEnv().getTestHelper().getOptions(), getDatabase()); - appendConnectionUri(url); - ConnectionOptions.Builder builder = - ConnectionOptions.newBuilder() - .setUri(url.toString()) - .setStatementExecutionInterceptors(interceptors); - if (hasValidKeyFile()) { - builder.setCredentialsUrl(getKeyFile()); - } - ConnectionOptions options = builder.build(); - ITConnection connection = createITConnection(options); - for (TransactionRetryListener listener : transactionRetryListeners) { - connection.addTransactionRetryListener(listener); - } - return connection; - } - - protected void appendConnectionUri(StringBuilder uri) {} - - /** - * Override this method to instruct the test to create a default test table in the form: - * - *
-   * CREATE TABLE TEST (ID INT64 NOT NULL, NAME STRING(100) NOT NULL) PRIMARY KEY (ID)
-   * 
- * - * Note that the table is not re-created for each test case, but is preserved between test cases. - * It is the responsibility of the test class to either empty the table at the end of each test - * case, or keep track of the state of the test table and execute the test cases in a specific - * order. - * - * @return true if the default test table should be created. - */ - protected boolean doCreateDefaultTestTable() { - return false; - } - - @Before - public void createTestTable() throws Exception { - if (doCreateDefaultTestTable()) { - try (Connection connection = createConnection()) { - connection.setAutocommit(true); - if (!tableExists(connection, "TEST")) { - connection.setAutocommit(false); - connection.startBatchDdl(); - connection.execute( - Statement.of( - "CREATE TABLE TEST (ID INT64 NOT NULL, NAME STRING(100) NOT NULL) PRIMARY KEY (ID)")); - connection.runBatch(); - } - } - } - } - - protected boolean tableExists(Connection connection, String table) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(table)); - try (ResultSet rs = - connection.executeQuery( - Statement.newBuilder( - "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE UPPER(TABLE_NAME)=@table_name") - .bind("table_name") - .to(table.toUpperCase()) - .build())) { - while (rs.next()) { - return true; - } - } - return false; - } - - protected boolean indexExists(Connection connection, String table, String index) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(index)); - try (ResultSet rs = - connection.executeQuery( - Statement.newBuilder( - "SELECT INDEX_NAME FROM INFORMATION_SCHEMA.INDEXES WHERE UPPER(TABLE_NAME)=@table_name AND UPPER(INDEX_NAME)=@index_name") - .bind("table_name") - .to(table) - .bind("index_name") - .to(index.toUpperCase()) - .build())) { - while (rs.next()) { - return true; - } - } - return false; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITConnectionImpl.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITConnectionImpl.java deleted file mode 100644 index c6361d0fd04..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ITConnectionImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest.ITConnection; - -/** Implementation of {@link ITConnection} for Spanner generic (not JDBC) connections. */ -class ITConnectionImpl extends ConnectionImpl implements ITConnection { - ITConnectionImpl(ConnectionOptions options) { - super(options); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcAbortedTransactionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcAbortedTransactionTest.java deleted file mode 100644 index f55e383be8f..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcAbortedTransactionTest.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.endsWith; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.MockSpannerServiceImpl; -import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl; -import com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcAbortedDueToConcurrentModificationException; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcAbortedException; -import com.google.protobuf.ListValue; -import com.google.protobuf.Value; -import com.google.spanner.v1.ResultSetMetadata; -import com.google.spanner.v1.StructType; -import com.google.spanner.v1.StructType.Field; -import com.google.spanner.v1.Type; -import com.google.spanner.v1.TypeCode; -import io.grpc.Server; -import io.grpc.Status; -import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class JdbcAbortedTransactionTest { - private static final class TransactionRetryCounter implements TransactionRetryListener { - private int retriesFinished; - - @Override - public void retryStarting(Timestamp transactionStarted, long transactionId, int retryAttempt) {} - - @Override - public void retryFinished( - Timestamp transactionStarted, long transactionId, int retryAttempt, RetryResult result) { - retriesFinished++; - } - } - - private static final Statement SELECT1 = Statement.of("SELECT 1 AS COL1"); - private static final ResultSetMetadata SELECT1_METADATA = - ResultSetMetadata.newBuilder() - .setRowType( - StructType.newBuilder() - .addFields( - Field.newBuilder() - .setName("COL1") - .setType(Type.newBuilder().setCode(TypeCode.INT64).build()) - .build()) - .build()) - .build(); - private static final com.google.spanner.v1.ResultSet SELECT1_RESULTSET = - com.google.spanner.v1.ResultSet.newBuilder() - .addRows( - ListValue.newBuilder() - .addValues(Value.newBuilder().setStringValue("1").build()) - .build()) - .setMetadata(SELECT1_METADATA) - .build(); - private static final Statement SELECT_RANDOM = Statement.of("SELECT * FROM RANDOM"); - private static final Statement UPDATE_STATEMENT = - Statement.of("UPDATE FOO SET BAR=1 WHERE BAZ=2"); - private static final int UPDATE_COUNT = 1; - - private static MockSpannerServiceImpl mockSpanner; - private static MockInstanceAdminImpl mockInstanceAdmin; - private static MockDatabaseAdminImpl mockDatabaseAdmin; - private static Server server; - private static InetSocketAddress address; - - @Parameter(0) - public boolean retryAbortsInternally; - - @Rule public ExpectedException expected = ExpectedException.none(); - - @Parameters(name = "retryAbortsInternally = {0}") - public static Collection data() { - List params = new ArrayList<>(); - params.add(new Object[] {Boolean.TRUE}); - params.add(new Object[] {Boolean.FALSE}); - return params; - } - - @BeforeClass - public static void startStaticServer() throws IOException { - mockSpanner = new MockSpannerServiceImpl(); - mockSpanner.setAbortProbability(0.0D); // We don't want any unpredictable aborted transactions. - mockSpanner.putStatementResult(StatementResult.query(SELECT1, SELECT1_RESULTSET)); - mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT)); - mockInstanceAdmin = new MockInstanceAdminImpl(); - mockDatabaseAdmin = new MockDatabaseAdminImpl(); - address = new InetSocketAddress("localhost", 0); - server = - NettyServerBuilder.forAddress(address) - .addService(mockSpanner) - .addService(mockInstanceAdmin) - .addService(mockDatabaseAdmin) - .build() - .start(); - } - - @AfterClass - public static void stopServer() throws Exception { - SpannerPool.closeSpannerPool(); - server.shutdown(); - server.awaitTermination(); - } - - private String createUrl() { - return String.format( - "jdbc:cloudspanner://localhost:%d/projects/%s/instances/%s/databases/%s?usePlainText=true;retryAbortsInternally=%s", - server.getPort(), "proj", "inst", "db", Boolean.toString(retryAbortsInternally)); - } - - private Connection createConnection() throws SQLException { - Connection connection = DriverManager.getConnection(createUrl()); - CloudSpannerJdbcConnection cs = connection.unwrap(CloudSpannerJdbcConnection.class); - cs.addTransactionRetryListener(new TransactionRetryCounter()); - return connection; - } - - private int getRetryCount(Connection connection) throws SQLException { - return ((TransactionRetryCounter) - connection - .unwrap(CloudSpannerJdbcConnection.class) - .getTransactionRetryListeners() - .next()) - .retriesFinished; - } - - @Test - public void testAutocommitUpdateAborted() throws SQLException { - // Updates in autocommit are always automatically retried. - // These retries are not picked up by the transaction retry listener, as that is only done for - // actual JDBC transactions that are retried. - try (java.sql.Connection connection = createConnection()) { - mockSpanner.abortNextStatement(); - int updateCount = connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - assertThat(updateCount, is(equalTo(UPDATE_COUNT))); - } - } - - @Test - public void testTransactionalUpdateAborted() throws SQLException { - // Updates in transactional mode are automatically retried by default, but this can be switched - // off. - if (!retryAbortsInternally) { - expected.expect(JdbcAbortedException.class); - } - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - mockSpanner.abortNextStatement(); - int updateCount = connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - assertThat(updateCount, is(equalTo(UPDATE_COUNT))); - assertThat(getRetryCount(connection), is(equalTo(1))); - } - } - - @Test - public void testAutocommitBatchUpdateAborted() throws SQLException { - try (java.sql.Connection connection = createConnection()) { - mockSpanner.abortNextStatement(); - try (java.sql.Statement statement = connection.createStatement()) { - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.addBatch(UPDATE_STATEMENT.getSql()); - int[] updateCounts = statement.executeBatch(); - assertThat(updateCounts, is(equalTo(new int[] {UPDATE_COUNT, UPDATE_COUNT}))); - } - } - } - - @Test - public void testTransactionalBatchUpdateAborted() throws SQLException { - if (!retryAbortsInternally) { - expected.expect(JdbcAbortedException.class); - } - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - mockSpanner.abortNextStatement(); - try (java.sql.Statement statement = connection.createStatement()) { - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.addBatch(UPDATE_STATEMENT.getSql()); - int[] updateCounts = statement.executeBatch(); - assertThat(updateCounts, is(equalTo(new int[] {UPDATE_COUNT, UPDATE_COUNT}))); - assertThat(getRetryCount(connection), is(equalTo(1))); - } - } - } - - @Test - public void testAutocommitSelectAborted() throws SQLException { - // Selects in autocommit are executed using a singleUse read-only transaction and cannot abort. - try (java.sql.Connection connection = createConnection()) { - mockSpanner.abortNextStatement(); - try (ResultSet rs = connection.createStatement().executeQuery(SELECT1.getSql())) { - while (rs.next()) { - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - } - } - - @Test - public void testTransactionalSelectAborted() throws SQLException { - if (!retryAbortsInternally) { - expected.expect(JdbcAbortedException.class); - } - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - mockSpanner.abortNextStatement(); - try (ResultSet rs = connection.createStatement().executeQuery(SELECT1.getSql())) { - while (rs.next()) { - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - assertThat(getRetryCount(connection), is(equalTo(1))); - } - } - - @Test - public void testTransactionalUpdateWithConcurrentModificationsAborted() throws SQLException { - if (retryAbortsInternally) { - // As the transaction does a random select, the retry will always see different data than the - // original attempt. - expected.expect(JdbcAbortedDueToConcurrentModificationException.class); - } else { - expected.expect(JdbcAbortedException.class); - } - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - // Set a random answer. - mockSpanner.putStatementResult( - StatementResult.query(SELECT_RANDOM, new RandomResultSetGenerator(25).generate())); - try (ResultSet rs = connection.createStatement().executeQuery(SELECT_RANDOM.getSql())) { - while (rs.next()) {} - } - // Set a new random answer that will be returned during the retry. - mockSpanner.putStatementResult( - StatementResult.query(SELECT_RANDOM, new RandomResultSetGenerator(25).generate())); - // Abort all transactions (including the current one). - mockSpanner.abortNextStatement(); - // This will abort and start an internal retry. - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - fail("missing expected aborted exception"); - } - } - - @Test - public void testTransactionalUpdateWithErrorOnOriginalAndRetry() throws SQLException { - if (!retryAbortsInternally) { - expected.expect(JdbcAbortedException.class); - } - final String sql = "UPDATE SOMETHING SET OTHER=1"; - mockSpanner.putStatementResult( - StatementResult.exception( - Statement.of(sql), - Status.INVALID_ARGUMENT.withDescription("test").asRuntimeException())); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - try (ResultSet rs = connection.createStatement().executeQuery(SELECT1.getSql())) { - while (rs.next()) { - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - try { - connection.createStatement().executeUpdate(sql); - fail("missing 'test' exception"); - } catch (SQLException e) { - // ignore - } - mockSpanner.abortNextStatement(); - connection.commit(); - } - } - - @Test - public void testTransactionalUpdateWithErrorOnRetryAndNotOnOriginal() throws SQLException { - if (retryAbortsInternally) { - expected.expect(JdbcAbortedDueToConcurrentModificationException.class); - } else { - expected.expect(JdbcAbortedException.class); - } - final String sql = "UPDATE SOMETHING SET OTHER=1"; - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - // Set a normal response to the update statement. - mockSpanner.putStatementResult(StatementResult.update(Statement.of(sql), 1L)); - connection.createStatement().executeUpdate(sql); - // Set an error as response for the same update statement that will be used during the retry. - // This will cause the retry to fail. - mockSpanner.putStatementResult( - StatementResult.exception( - Statement.of(sql), - Status.INVALID_ARGUMENT.withDescription("test").asRuntimeException())); - mockSpanner.abortNextStatement(); - connection.commit(); - fail("missing expected aborted exception"); - } catch (JdbcAbortedDueToConcurrentModificationException e) { - assertThat( - e.getDatabaseErrorDuringRetry().getErrorCode(), is(equalTo(ErrorCode.INVALID_ARGUMENT))); - assertThat(e.getDatabaseErrorDuringRetry().getMessage(), endsWith("test")); - throw e; - } - } - - @Test - public void testTransactionalUpdateWithErrorOnOriginalAndNotOnRetry() throws SQLException { - if (retryAbortsInternally) { - expected.expect(JdbcAbortedDueToConcurrentModificationException.class); - } else { - expected.expect(JdbcAbortedException.class); - } - final String sql = "UPDATE SOMETHING SET OTHER=1"; - mockSpanner.putStatementResult( - StatementResult.exception( - Statement.of(sql), - Status.INVALID_ARGUMENT.withDescription("test").asRuntimeException())); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - try (ResultSet rs = connection.createStatement().executeQuery(SELECT1.getSql())) { - while (rs.next()) { - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - try { - connection.createStatement().executeUpdate(sql); - fail("missing 'test' exception"); - } catch (SQLException e) { - // ignore - } - // Set the update statement to return a result next time (i.e. during retry). - mockSpanner.putStatementResult(StatementResult.update(Statement.of(sql), 1L)); - mockSpanner.abortNextStatement(); - connection.commit(); - fail("missing expected aborted exception"); - } catch (JdbcAbortedDueToConcurrentModificationException e) { - assertThat(e.getDatabaseErrorDuringRetry(), is(nullValue())); - throw e; - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcArrayTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcArrayTest.java deleted file mode 100644 index 50a696fa512..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcArrayTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.junit.Assert.assertEquals; - -import java.sql.Date; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.sql.Types; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcArrayTest { - - @Test - public void testCreateArrayTypeName() throws SQLException { - // Note that JDBC array indices start at 1. - JdbcArray array; - array = JdbcArray.createArray("BOOL", new Boolean[] {true, false, true}); - assertEquals(array.getBaseType(), Types.BOOLEAN); - assertEquals(((Boolean[]) array.getArray(1, 1))[0], Boolean.TRUE); - - array = JdbcArray.createArray("BYTES", new byte[][] {new byte[] {1, 2}, new byte[] {3, 4}}); - assertEquals(array.getBaseType(), Types.BINARY); - assertEquals(((byte[][]) array.getArray(1, 1))[0][1], (byte) 2); - - array = - JdbcArray.createArray("DATE", new Date[] {new Date(1L), new Date(100L), new Date(1000L)}); - assertEquals(array.getBaseType(), Types.DATE); - assertEquals(((Date[]) array.getArray(1, 1))[0], new Date(1L)); - - array = JdbcArray.createArray("FLOAT64", new Double[] {1.1D, 2.2D, Math.PI}); - assertEquals(array.getBaseType(), Types.DOUBLE); - assertEquals(((Double[]) array.getArray(1, 3))[2], Double.valueOf(Math.PI)); - - array = JdbcArray.createArray("INT64", new Long[] {1L, 2L, 3L}); - assertEquals(array.getBaseType(), Types.BIGINT); - assertEquals(((Long[]) array.getArray(1, 1))[0], Long.valueOf(1L)); - - array = JdbcArray.createArray("STRING", new String[] {"foo", "bar", "baz"}); - assertEquals(array.getBaseType(), Types.NVARCHAR); - assertEquals(((String[]) array.getArray(1, 1))[0], "foo"); - - array = - JdbcArray.createArray( - "TIMESTAMP", - new Timestamp[] {new Timestamp(1L), new Timestamp(100L), new Timestamp(1000L)}); - assertEquals(array.getBaseType(), Types.TIMESTAMP); - assertEquals(((Timestamp[]) array.getArray(1, 1))[0], new Timestamp(1L)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcBlobTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcBlobTest.java deleted file mode 100644 index c629eac207c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcBlobTest.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.rpc.Code; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.SQLException; -import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcBlobTest { - - private static final class PosLength { - private final long pos; - private final int len; - - private static PosLength of(long pos, int len) { - return new PosLength(pos, len); - } - - private PosLength(long pos, int len) { - this.pos = pos; - this.len = len; - } - - @Override - public String toString() { - return "pos: " + pos + ", len: " + len; - } - } - - private static final class PosBytes { - private final long pos; - private final byte[] bytes; - - private static PosBytes of(long pos, byte[] bytes) { - return new PosBytes(pos, bytes); - } - - private PosBytes(long pos, byte[] bytes) { - this.pos = pos; - this.bytes = bytes; - } - - @Override - public String toString() { - return "pos: " + pos + ", bytes: " + Arrays.toString(bytes); - } - } - - @Test - public void testLength() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - assertThat(blob.length(), is(equalTo(0L))); - blob.setBytes(1L, new byte[] {1, 2, 3}); - assertThat(blob.length(), is(equalTo(3L))); - blob.free(); - assertThat(blob.length(), is(equalTo(0L))); - } - - @Test - public void testGetBytes() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - assertThat(blob.getBytes(1L, 5), is(equalTo(new byte[] {1, 2, 3, 4, 5}))); - assertThat(blob.getBytes(2L, 5), is(equalTo(new byte[] {2, 3, 4, 5}))); - assertThat(blob.getBytes(2L, 3), is(equalTo(new byte[] {2, 3, 4}))); - assertThat(blob.getBytes(1L, 0), is(equalTo(new byte[] {}))); - - // test invalid parameters - PosLength[] params = - new PosLength[] {PosLength.of(0L, 4), PosLength.of(-1L, 4), PosLength.of(1L, -1)}; - for (PosLength param : params) { - boolean exception = false; - try { - blob.getBytes(param.pos, param.len); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testGetBinaryStream() throws SQLException, IOException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - byte[] buf = new byte[5]; - try (InputStream is = blob.getBinaryStream()) { - int b; - int index = 0; - while ((b = is.read()) > -1) { - buf[index] = (byte) b; - index++; - } - } - assertThat(buf, is(equalTo(new byte[] {1, 2, 3, 4, 5}))); - - buf = new byte[10]; - try (InputStream is = blob.getBinaryStream()) { - assertThat(is.read(buf), is(equalTo(5))); - assertThat(is.read(), is(equalTo(-1))); - } - assertThat(buf, is(equalTo(new byte[] {1, 2, 3, 4, 5, 0, 0, 0, 0, 0}))); - } - - @Test - public void testPosition() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - assertThat(blob.position(new byte[] {1}, 1L), is(equalTo(1L))); - assertThat(blob.position(new byte[] {1, 2}, 1L), is(equalTo(1L))); - assertThat(blob.position(new byte[] {2}, 1L), is(equalTo(2L))); - // note that the spec says that the method should return the position within the BLOB where the - // pattern can be found, so it's not relative to the starting position. - assertThat(blob.position(new byte[] {2}, 2L), is(equalTo(2L))); - assertThat(blob.position(new byte[] {1, 2, 3, 4, 5}, 1L), is(equalTo(1L))); - assertThat(blob.position(new byte[] {1, 2, 3, 4, 5, 6}, 1L), is(equalTo(-1L))); - assertThat(blob.position(new byte[] {1, 2, 3, 4, 5}, 2L), is(equalTo(-1L))); - assertThat(blob.position(new byte[] {2}, 3L), is(equalTo(-1L))); - assertThat(blob.position(new byte[] {1}, 6L), is(equalTo(-1L))); - - // test invalid parameters - PosBytes[] params = - new PosBytes[] { - PosBytes.of(0L, new byte[] {}), PosBytes.of(-1L, new byte[] {}), PosBytes.of(1L, null) - }; - for (PosBytes param : params) { - boolean exception = false; - try { - blob.position(param.bytes, param.pos); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testPositionBlob() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - - assertThat(blob.position(createBlob((byte) 1), 1L), is(equalTo(1L))); - assertThat(blob.position(createBlob((byte) 1, (byte) 2), 1L), is(equalTo(1L))); - assertThat(blob.position(createBlob((byte) 2), 1L), is(equalTo(2L))); - // note that the spec says that the method should return the position within the BLOB where the - // pattern can be found, so it's not relative to the starting position. - assertThat(blob.position(createBlob((byte) 2), 2L), is(equalTo(2L))); - assertThat(blob.position(createBlob(new byte[] {1, 2, 3, 4, 5}), 1L), is(equalTo(1L))); - assertThat(blob.position(createBlob(new byte[] {1, 2, 3, 4, 5, 6}), 1L), is(equalTo(-1L))); - assertThat(blob.position(createBlob(new byte[] {1, 2, 3, 4, 5}), 2L), is(equalTo(-1L))); - assertThat(blob.position(createBlob(new byte[] {2}), 3L), is(equalTo(-1L))); - assertThat(blob.position(createBlob(new byte[] {1}), 6L), is(equalTo(-1L))); - - // test invalid parameters - PosBytes[] params = - new PosBytes[] { - PosBytes.of(0L, new byte[] {}), PosBytes.of(-1L, new byte[] {}), PosBytes.of(1L, null) - }; - for (PosBytes param : params) { - boolean exception = false; - try { - blob.position(createBlob(param.bytes), param.pos); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - private JdbcBlob createBlob(byte... bytes) throws SQLException { - if (bytes == null) { - return null; - } - JdbcBlob res = new JdbcBlob(); - res.setBytes(1L, bytes); - return res; - } - - @Test - public void testSetBytes() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3}); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {1, 2, 3}))); - blob.setBytes(2L, new byte[] {1}); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {1, 1, 3}))); - blob.setBytes(4L, new byte[] {4}); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {1, 1, 3, 4}))); - blob.setBytes(8L, new byte[] {8}); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {1, 1, 3, 4, 0, 0, 0, 8}))); - } - - @Test - public void testSetBytesOffsetLength() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(4L, new byte[] {1, 2, 3}, 0, 3); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 0, 0, 1, 2, 3}))); - blob.free(); - blob.setBytes(4L, new byte[] {1, 2, 3}, 1, 3); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 0, 0, 2, 3}))); - blob.free(); - blob.setBytes(4L, new byte[] {1, 2, 3}, 3, 3); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 0, 0}))); - blob.free(); - blob.setBytes(4L, new byte[] {1, 2, 3}, 4, 3); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 0, 0}))); - blob.setBytes(2L, new byte[] {1, 2, 3}, 0, 10); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 1, 2, 3}))); - blob.setBytes(3L, new byte[] {1, 2, 3}, 2, 10); - assertThat(blob.getBytes(1L, 10), is(equalTo(new byte[] {0, 1, 3, 3}))); - blob.setBytes(10L, new byte[] {1, 2, 3}, 2, 10); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {0, 1, 3, 3, 0, 0, 0, 0, 0, 3}))); - } - - @Test - public void testSetBinaryStream() throws SQLException, IOException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - try (OutputStream os = blob.setBinaryStream(1L)) { - os.write(6); - // no flush yet, so it should be unchanged - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5}))); - os.flush(); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {6, 2, 3, 4, 5}))); - os.write(7); - } - // closing the stream should also flush the changes - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {6, 7, 3, 4, 5}))); - - // test writing beyond the end of the stream - try (OutputStream os = blob.setBinaryStream(1L)) { - os.write(new byte[] {1, 2, 3, 4, 5, 6, 7}); - // no flush yet, so it should be unchanged - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {6, 7, 3, 4, 5}))); - os.flush(); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5, 6, 7}))); - } - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5, 6, 7}))); - - // test writing from a position that is larger than 1 - try (OutputStream os = blob.setBinaryStream(5L)) { - os.write(new byte[] {1, 2, 3}); - // no flush yet, so it should be unchanged - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5, 6, 7}))); - os.flush(); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 1, 2, 3}))); - } - - // test writing from a position that is larger than the current length - try (OutputStream os = blob.setBinaryStream(10L)) { - os.write(new byte[] {1, 2, 3}); - // no flush yet, so it should be unchanged - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 1, 2, 3}))); - os.flush(); - assertThat( - blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 1, 2, 3, 0, 0, 1, 2, 3}))); - } - - // test writing a large number of bytes - try (OutputStream os = blob.setBinaryStream(1L)) { - os.write(new byte[2000]); - // no flush yet, so it should be unchanged - assertThat( - blob.getBytes(1L, 3000), is(equalTo(new byte[] {1, 2, 3, 4, 1, 2, 3, 0, 0, 1, 2, 3}))); - os.flush(); - assertThat(blob.getBytes(1L, 3000), is(equalTo(new byte[2000]))); - } - } - - @Test - public void testTruncate() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5}))); - blob.truncate(3); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3}))); - blob.truncate(0); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {}))); - } - - @Test - public void testFree() throws SQLException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {1, 2, 3, 4, 5}))); - blob.free(); - assertThat(blob.getBytes(1L, 20), is(equalTo(new byte[] {}))); - } - - @Test - public void testGetBinaryStreamPosLength() throws SQLException, IOException { - JdbcBlob blob = new JdbcBlob(); - blob.setBytes(1L, new byte[] {1, 2, 3, 4, 5}); - - byte[] buf = new byte[5]; - try (InputStream is = blob.getBinaryStream(1L, 3)) { - int b; - int index = 0; - while ((b = is.read()) > -1) { - buf[index] = (byte) b; - index++; - } - } - assertThat(buf, is(equalTo(new byte[] {1, 2, 3, 0, 0}))); - - buf = new byte[10]; - try (InputStream is = blob.getBinaryStream(4L, 10)) { - assertThat(is.read(buf), is(equalTo(2))); - assertThat(is.read(), is(equalTo(-1))); - } - assertThat(buf, is(equalTo(new byte[] {4, 5, 0, 0, 0, 0, 0, 0, 0, 0}))); - - buf = new byte[10]; - try (InputStream is = blob.getBinaryStream(6L, 10)) { - assertThat(is.read(buf), is(equalTo(-1))); - } - assertThat(buf, is(equalTo(new byte[10]))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcClobTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcClobTest.java deleted file mode 100644 index 3bb04fc6309..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcClobTest.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.rpc.Code; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.sql.SQLException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcClobTest { - - private static final class PosLength { - private final long pos; - private final int len; - - private static PosLength of(long pos, int len) { - return new PosLength(pos, len); - } - - private PosLength(long pos, int len) { - this.pos = pos; - this.len = len; - } - - @Override - public String toString() { - return "pos: " + pos + ", len: " + len; - } - } - - private static final class PosString { - private final long pos; - private final String str; - - private static PosString of(long pos, String str) { - return new PosString(pos, str); - } - - private PosString(long pos, String str) { - this.pos = pos; - this.str = str; - } - - @Override - public String toString() { - return "pos: " + pos + ", str: " + str; - } - } - - @Test - public void testLength() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - assertThat(clob.length(), is(equalTo(4L))); - clob.setString(1L, "test-test"); - assertThat(clob.length(), is(equalTo(9L))); - } - - @Test - public void testGetSubstring() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - assertThat(clob.getSubString(1, 4), is(equalTo("test"))); - assertThat(clob.getSubString(1, 2), is(equalTo("te"))); - assertThat(clob.getSubString(3, 2), is(equalTo("st"))); - assertThat(clob.getSubString(1, 5), is(equalTo("test"))); - assertThat(clob.getSubString(4, 5), is(equalTo("t"))); - assertThat(clob.getSubString(5, 5), is(equalTo(""))); - assertThat(clob.getSubString(6, 5), is(equalTo(""))); - - // test invalid parameters - PosLength[] params = - new PosLength[] {PosLength.of(0L, 4), PosLength.of(-1L, 4), PosLength.of(1L, -1)}; - for (PosLength param : params) { - boolean exception = false; - try { - clob.getSubString(param.pos, param.len); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testGetCharacterStream() throws SQLException, IOException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - char[] cbuf = new char[4]; - try (Reader reader = clob.getCharacterStream()) { - reader.read(cbuf, 0, 4); - } - assertThat(cbuf, is(equalTo(new char[] {'t', 'e', 's', 't'}))); - try (Reader reader = clob.getCharacterStream()) { - reader.read(cbuf, 0, 2); - reader.read(cbuf, 2, 2); - } - assertThat(cbuf, is(equalTo(new char[] {'t', 'e', 's', 't'}))); - try (Reader reader = clob.getCharacterStream()) { - reader.read(cbuf, 0, 2); - // changing the value of the clob will not change a character stream that has already been - // opened - clob.setString(1L, "foobar"); - reader.read(cbuf, 2, 2); - } - assertThat(cbuf, is(equalTo(new char[] {'t', 'e', 's', 't'}))); - } - - @Test - public void testPositionString() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - assertThat(clob.position("st", 1L), is(equalTo(3L))); - clob.setString(1L, "foobarfoobar"); - assertThat(clob.position("bar", 1L), is(equalTo(4L))); - assertThat(clob.position("bar", 2L), is(equalTo(4L))); - assertThat(clob.position("bar", 5L), is(equalTo(10L))); - assertThat(clob.position("bar", 8L), is(equalTo(10L))); - assertThat(clob.position("bar", 10L), is(equalTo(10L))); - assertThat(clob.position("bar", 11L), is(equalTo(-1L))); - assertThat(clob.position("bar", 100L), is(equalTo(-1L))); - assertThat(clob.position("not_there", 1L), is(equalTo(-1L))); - // test invalid parameters - PosString[] params = - new PosString[] {PosString.of(0L, "bar"), PosString.of(-1L, "bar"), PosString.of(1L, null)}; - for (PosString param : params) { - boolean exception = false; - try { - clob.position(param.str, param.pos); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testPositionClob() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - JdbcClob search = new JdbcClob(); - search.setString(1L, "st"); - assertThat(clob.position(search, 1L), is(equalTo(3L))); - clob.setString(1L, "foobarfoobar"); - search.setString(1L, "bar"); - assertThat(clob.position(search, 1L), is(equalTo(4L))); - assertThat(clob.position(search, 2L), is(equalTo(4L))); - assertThat(clob.position(search, 5L), is(equalTo(10L))); - assertThat(clob.position(search, 8L), is(equalTo(10L))); - assertThat(clob.position(search, 10L), is(equalTo(10L))); - assertThat(clob.position(search, 11L), is(equalTo(-1L))); - assertThat(clob.position(search, 100L), is(equalTo(-1L))); - search.setString(1L, "not_there"); - assertThat(clob.position(search, 1L), is(equalTo(-1L))); - // test invalid parameters - PosString[] params = - new PosString[] {PosString.of(0L, "bar"), PosString.of(-1L, "bar"), PosString.of(1L, null)}; - for (PosString param : params) { - boolean exception = false; - try { - search.setString(1L, param.str); - clob.position(search, param.pos); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testSetString() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test"); - assertThat(clob.getSubString(1L, 4), is(equalTo("test"))); - clob.setString(1L, "bar"); - assertThat(clob.getSubString(1L, 4), is(equalTo("bart"))); - clob.setString(1L, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - clob.setString(2L, "foobar"); - assertThat(clob.getSubString(1L, 7), is(equalTo("ffoobar"))); - clob.setString(8L, "test"); - assertThat(clob.getSubString(1L, 11), is(equalTo("ffoobartest"))); - clob.setString(15, "end"); - assertThat(clob.getSubString(1L, 17), is(equalTo("ffoobartest end"))); - // test invalid parameters - PosString[] params = - new PosString[] {PosString.of(0L, "bar"), PosString.of(-1L, "bar"), PosString.of(1L, null)}; - for (PosString param : params) { - boolean exception = false; - try { - clob.setString(param.pos, param.str); - } catch (SQLException e) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } - assertThat(param.toString(), exception, is(true)); - } - } - - @Test - public void testSetStringOffsetLen() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "test", 2, 3); - assertThat(clob.getSubString(1L, 4), is(equalTo("est"))); - clob.setString(1L, "bar", 1, 1); - assertThat(clob.getSubString(1L, 4), is(equalTo("bst"))); - clob.setString(1L, "foobar", 1, 6); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - clob.setString(2L, "foobar", 2, 5); - assertThat(clob.getSubString(1L, 7), is(equalTo("foobar"))); - clob.setString(8L, "test", 4, 1); - assertThat(clob.getSubString(1L, 8), is(equalTo("foobar t"))); - clob.setString(15, "end", 1, 3); - assertThat(clob.getSubString(1L, 17), is(equalTo("foobar t end"))); - } - - @Test - public void testSetCharacterStream() throws SQLException, IOException { - JdbcClob clob = new JdbcClob(); - clob.setString(1, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - try (Writer writer = clob.setCharacterStream(1L)) { - writer.write("t"); - // not yet flushed, there should be no change - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - writer.flush(); - // after a flush the change should be visible - assertThat(clob.getSubString(1L, 6), is(equalTo("toobar"))); - writer.write("est"); - } - // close should also autoflush - assertThat(clob.getSubString(1L, 6), is(equalTo("testar"))); - - // start all over - clob.free(); - clob.setString(1, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - try (Writer writer = clob.setCharacterStream(5L)) { - writer.write("t"); - // not yet flushed, there should be no change - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - writer.flush(); - // after a flush the change should be visible - assertThat(clob.getSubString(1L, 6), is(equalTo("foobtr"))); - writer.write("est"); - } - // close should also autoflush - assertThat(clob.getSubString(1L, 8), is(equalTo("foobtest"))); - - // do a test with multiple flushes - clob.free(); - clob.setString(1, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - try (Writer writer = clob.setCharacterStream(1L)) { - writer.write("t"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - writer.flush(); - assertThat(clob.getSubString(1L, 6), is(equalTo("toobar"))); - writer.write("est"); - assertThat(clob.getSubString(1L, 6), is(equalTo("toobar"))); - writer.flush(); - assertThat(clob.getSubString(1L, 6), is(equalTo("testar"))); - } - assertThat(clob.getSubString(1L, 8), is(equalTo("testar"))); - - // writer after end - clob.free(); - clob.setString(1, "foobar"); - assertThat(clob.getSubString(1L, 10), is(equalTo("foobar"))); - try (Writer writer = clob.setCharacterStream(10L)) { - writer.write("t"); - assertThat(clob.getSubString(1L, 20), is(equalTo("foobar"))); - writer.flush(); - assertThat(clob.getSubString(1L, 20), is(equalTo("foobar t"))); - writer.write("est"); - } - assertThat(clob.getSubString(1L, 20), is(equalTo("foobar test"))); - } - - @Test - public void testTruncate() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - clob.truncate(3L); - assertThat(clob.getSubString(1L, 6), is(equalTo("foo"))); - clob.truncate(0L); - assertThat(clob.getSubString(1L, 6), is(equalTo(""))); - } - - @Test - public void testFree() throws SQLException { - JdbcClob clob = new JdbcClob(); - clob.setString(1L, "foobar"); - assertThat(clob.getSubString(1L, 6), is(equalTo("foobar"))); - clob.free(); - assertThat(clob.getSubString(1L, 6), is(equalTo(""))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionGeneratedSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionGeneratedSqlScriptTest.java deleted file mode 100644 index fb4fccbc643..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionGeneratedSqlScriptTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier.JdbcGenericConnection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * This test executes a SQL script that has been generated from the log of all the subclasses of - * {@link AbstractConnectionImplTest} and covers the same test cases. Its aim is to verify that the - * connection reacts correctly in all possible states (i.e. DML statements should not be allowed - * when the connection is in read-only mode, or when a read-only transaction has started etc.) - */ -@RunWith(JUnit4.class) -public class JdbcConnectionGeneratedSqlScriptTest { - - static class TestConnectionProvider implements GenericConnectionProvider { - @Override - public GenericConnection getConnection() { - ConnectionOptions options = mock(ConnectionOptions.class); - when(options.getUri()).thenReturn(ConnectionImplTest.URI); - com.google.cloud.spanner.jdbc.Connection spannerConnection = - ConnectionImplTest.createConnection(options); - when(options.getConnection()).thenReturn(spannerConnection); - JdbcConnection connection = - new JdbcConnection( - "jdbc:cloudspanner://localhost/projects/project/instances/instance/databases/database;credentialsUrl=url", - options); - JdbcGenericConnection res = JdbcGenericConnection.of(connection); - res.setStripCommentsBeforeExecute(true); - return res; - } - } - - @Test - public void testGeneratedScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile( - "ConnectionImplGeneratedSqlScriptTest.sql", SqlScriptVerifier.class); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java deleted file mode 100644 index 6740782a4aa..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcConnectionTest.java +++ /dev/null @@ -1,669 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.rpc.Code; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.SQLWarning; -import java.sql.Savepoint; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcConnectionTest { - @Rule public final ExpectedException exception = ExpectedException.none(); - private static final com.google.cloud.spanner.ResultSet SELECT1_RESULTSET = - ResultSets.forRows( - Type.struct(StructField.of("", Type.int64())), - Arrays.asList(Struct.newBuilder().set("").to(1L).build())); - - private JdbcConnection createConnection(ConnectionOptions options) { - com.google.cloud.spanner.jdbc.Connection spannerConnection = - ConnectionImplTest.createConnection(options); - when(options.getConnection()).thenReturn(spannerConnection); - return new JdbcConnection( - "jdbc:cloudspanner://localhost/projects/project/instances/instance/databases/database;credentialsUrl=url", - options); - } - - @Test - public void testAutoCommit() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - when(options.isAutocommit()).thenReturn(true); - try (Connection connection = createConnection(options)) { - assertThat(connection.getAutoCommit(), is(true)); - connection.setAutoCommit(false); - assertThat(connection.getAutoCommit(), is(false)); - // execute a query that will start a transaction - connection.createStatement().executeQuery(AbstractConnectionImplTest.SELECT); - // setting autocommit will automatically commit the transaction - connection.setAutoCommit(true); - assertThat(connection.getAutoCommit(), is(true)); - } - } - - @Test - public void testReadOnly() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - when(options.isAutocommit()).thenReturn(true); - when(options.isReadOnly()).thenReturn(true); - try (Connection connection = createConnection(options)) { - assertThat(connection.isReadOnly(), is(true)); - connection.setReadOnly(false); - assertThat(connection.isReadOnly(), is(false)); - // start a transaction - connection.createStatement().execute("begin transaction"); - // setting readonly should no longer be allowed - exception.expect(JdbcExceptionMatcher.matchCode(Code.FAILED_PRECONDITION)); - connection.setReadOnly(true); - } - } - - @Test - public void testCommit() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - // verify that there is no transaction started - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(false)); - // start a transaction - connection.createStatement().execute(AbstractConnectionImplTest.SELECT); - // verify that we did start a transaction - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(true)); - // do a commit - connection.commit(); - // verify that there is no transaction started anymore - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(false)); - // verify that there is a commit timestamp - assertThat(connection.getSpannerConnection().getCommitTimestamp(), is(notNullValue())); - } - } - - @Test - public void testRollback() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - // verify that there is no transaction started - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(false)); - // start a transaction - connection.createStatement().execute(AbstractConnectionImplTest.SELECT); - // verify that we did start a transaction - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(true)); - // do a rollback - connection.rollback(); - // verify that there is no transaction started anymore - assertThat(connection.getSpannerConnection().isTransactionStarted(), is(false)); - // verify that there is no commit timestamp - try (ResultSet rs = - connection.createStatement().executeQuery("show variable commit_timestamp")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getTimestamp("COMMIT_TIMESTAMP"), is(nullValue())); - } - } - } - - @Test - public void testClosedAbstractJdbcConnection() - throws SQLException, NoSuchMethodException, SecurityException, IllegalAccessException, - IllegalArgumentException {} - - @Test - public void testClosedJdbcConnection() - throws SQLException, NoSuchMethodException, SecurityException, IllegalAccessException, - IllegalArgumentException { - testClosed(Connection.class, "getCatalog"); - testClosed(Connection.class, "getWarnings"); - testClosed(Connection.class, "clearWarnings"); - testClosed(Connection.class, "getHoldability"); - testClosed(Connection.class, "createClob"); - testClosed(Connection.class, "createBlob"); - testClosed(Connection.class, "createNClob"); - testClosed(Connection.class, "createSQLXML"); - testClosed(Connection.class, "getCatalog"); - testClosed(Connection.class, "getClientInfo"); - testClosed(Connection.class, "getSchema"); - testClosed(Connection.class, "getNetworkTimeout"); - - testClosed( - Connection.class, "setCatalog", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, - "prepareCall", - new Class[] {String.class, int.class, int.class}, - new Object[] {"TEST", 0, 0}); - testClosed( - Connection.class, - "prepareCall", - new Class[] {String.class, int.class, int.class, int.class}, - new Object[] {"TEST", 0, 0, 0}); - testClosed( - Connection.class, - "setClientInfo", - new Class[] {String.class, String.class}, - new Object[] {"TEST", "TEST"}); - testClosed( - Connection.class, "setClientInfo", new Class[] {Properties.class}, new Object[] {null}); - testClosed( - Connection.class, "getClientInfo", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, - "createStruct", - new Class[] {String.class, Object[].class}, - new Object[] {"TEST", new Object[] {}}); - testClosed(Connection.class, "setSchema", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, - "setNetworkTimeout", - new Class[] {Executor.class, int.class}, - new Object[] {null, 0}); - - testClosed(Connection.class, "getTypeMap"); - testClosed(Connection.class, "createStatement"); - testClosed(Connection.class, "getAutoCommit"); - testClosed(Connection.class, "commit"); - testClosed(Connection.class, "rollback"); - testClosed(Connection.class, "getMetaData"); - testClosed(Connection.class, "isReadOnly"); - testClosed(Connection.class, "getTransactionIsolation"); - testClosed(Connection.class, "setSavepoint"); - - testClosed( - Connection.class, - "setTypeMap", - new Class[] {Map.class}, - new Object[] {Collections.EMPTY_MAP}); - testClosed( - Connection.class, "prepareStatement", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, "prepareCall", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed(Connection.class, "nativeSQL", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, "prepareStatement", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed( - Connection.class, "setAutoCommit", new Class[] {boolean.class}, new Object[] {true}); - testClosed( - Connection.class, "setReadOnly", new Class[] {boolean.class}, new Object[] {true}); - testClosed( - Connection.class, "setTransactionIsolation", new Class[] {int.class}, new Object[] {0}); - testClosed( - Connection.class, - "createStatement", - new Class[] {int.class, int.class}, - new Object[] {0, 0}); - testClosed( - Connection.class, - "prepareStatement", - new Class[] {String.class, int.class, int.class}, - new Object[] {"TEST", 0, 0}); - testClosed( - Connection.class, - "createStatement", - new Class[] {int.class, int.class, int.class}, - new Object[] {0, 0, 0}); - testClosed( - Connection.class, - "prepareStatement", - new Class[] {String.class, int.class, int.class, int.class}, - new Object[] {"TEST", 0, 0, 0}); - testClosed( - Connection.class, - "prepareStatement", - new Class[] {String.class, int.class}, - new Object[] {"TEST", 0}); - testClosed( - Connection.class, - "prepareStatement", - new Class[] {String.class, int[].class}, - new Object[] {"TEST", new int[] {0}}); - testClosed( - Connection.class, - "prepareStatement", - new Class[] {String.class, String[].class}, - new Object[] {"TEST", new String[] {"COL1"}}); - testClosed( - Connection.class, - "createArrayOf", - new Class[] {String.class, Object[].class}, - new Object[] {"TEST", new Object[] {"COL1"}}); - - testClosed( - Connection.class, "setSavepoint", new Class[] {String.class}, new Object[] {"TEST"}); - testClosed(Connection.class, "rollback", new Class[] {Savepoint.class}, new Object[] {null}); - testClosed( - Connection.class, - "releaseSavepoint", - new Class[] {Savepoint.class}, - new Object[] {null}); - } - - private void testClosed(Class clazz, String name) - throws NoSuchMethodException, SecurityException, SQLException, IllegalAccessException, - IllegalArgumentException { - testClosed(clazz, name, null, null); - } - - private void testClosed( - Class clazz, String name, Class[] paramTypes, Object[] args) - throws NoSuchMethodException, SecurityException, SQLException, IllegalAccessException, - IllegalArgumentException { - Method method = clazz.getDeclaredMethod(name, paramTypes); - testInvokeMethodOnClosedConnection(method, args); - } - - private void testInvokeMethodOnClosedConnection(Method method, Object... args) - throws SQLException, IllegalAccessException, IllegalArgumentException { - ConnectionOptions options = mock(ConnectionOptions.class); - JdbcConnection connection = createConnection(options); - connection.close(); - boolean valid = false; - try { - method.invoke(connection, args); - } catch (InvocationTargetException e) { - if (e.getTargetException() instanceof JdbcSqlException - && ((JdbcSqlException) e.getTargetException()).getCode() == Code.FAILED_PRECONDITION - && ((JdbcSqlException) e.getTargetException()).getMessage().endsWith("has been closed")) { - // this is the expected exception - valid = true; - } - } - assertThat( - "Method did not throw exception on closed connection: " + method.getName(), - valid, - is(true)); - } - - @Test - public void testTransactionIsolation() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - assertThat( - connection.getTransactionIsolation(), is(equalTo(Connection.TRANSACTION_SERIALIZABLE))); - // assert that setting it to this value is ok. - connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); - // assert that setting it to something else is not ok. - int[] settings = - new int[] { - Connection.TRANSACTION_READ_COMMITTED, - Connection.TRANSACTION_READ_UNCOMMITTED, - Connection.TRANSACTION_REPEATABLE_READ, - -100 - }; - for (int setting : settings) { - boolean exception = false; - try { - connection.setTransactionIsolation(setting); - } catch (SQLException e) { - if (setting == -100) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } else { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.UNIMPLEMENTED); - } - } - assertThat(exception, is(true)); - } - } - } - - @Test - public void testHoldability() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - assertThat(connection.getHoldability(), is(equalTo(ResultSet.CLOSE_CURSORS_AT_COMMIT))); - // assert that setting it to this value is ok. - connection.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); - // assert that setting it to something else is not ok. - int[] settings = new int[] {ResultSet.HOLD_CURSORS_OVER_COMMIT, -100}; - for (int setting : settings) { - boolean exception = false; - try { - connection.setHoldability(setting); - } catch (SQLException e) { - if (setting == -100) { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT); - } else { - exception = - (e instanceof JdbcSqlException - && ((JdbcSqlException) e).getCode() == Code.UNIMPLEMENTED); - } - } - assertThat(exception, is(true)); - } - } - } - - @Test - public void testWarnings() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - assertThat(connection.getWarnings(), is(nullValue())); - - // Push one warning and get it twice. - connection.pushWarning(new SQLWarning("test")); - assertThat(connection.getWarnings().getMessage(), is(equalTo("test"))); - assertThat(connection.getWarnings().getMessage(), is(equalTo("test"))); - - // Clear warnings and push two warnings and get them both. - connection.clearWarnings(); - connection.pushWarning(new SQLWarning("test 1")); - connection.pushWarning(new SQLWarning("test 2")); - assertThat(connection.getWarnings().getMessage(), is(equalTo("test 1"))); - assertThat(connection.getWarnings().getMessage(), is(equalTo("test 1"))); - assertThat(connection.getWarnings().getNextWarning().getMessage(), is(equalTo("test 2"))); - - // Clear warnings. - connection.clearWarnings(); - assertThat(connection.getWarnings(), is(nullValue())); - } - } - - @Test - public void testSetClientInfo() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - try (JdbcConnection connection = createConnection(options)) { - assertThat(connection.getWarnings(), is(nullValue())); - connection.setClientInfo("test", "foo"); - assertThat(connection.getWarnings(), is(notNullValue())); - assertThat( - connection.getWarnings().getMessage(), - is(equalTo(AbstractJdbcConnection.CLIENT_INFO_NOT_SUPPORTED))); - - connection.clearWarnings(); - assertThat(connection.getWarnings(), is(nullValue())); - - Properties props = new Properties(); - props.setProperty("test", "foo"); - connection.setClientInfo(props); - assertThat(connection.getWarnings(), is(notNullValue())); - assertThat( - connection.getWarnings().getMessage(), - is(equalTo(AbstractJdbcConnection.CLIENT_INFO_NOT_SUPPORTED))); - } - } - - @Test - public void testIsValid() throws SQLException { - // Setup. - ConnectionOptions options = mock(ConnectionOptions.class); - com.google.cloud.spanner.jdbc.Connection spannerConnection = - mock(com.google.cloud.spanner.jdbc.Connection.class); - when(options.getConnection()).thenReturn(spannerConnection); - Statement statement = Statement.of(JdbcConnection.IS_VALID_QUERY); - - // Verify that an opened connection that returns a result set is valid. - try (JdbcConnection connection = new JdbcConnection("url", options)) { - when(spannerConnection.executeQuery(statement)).thenReturn(SELECT1_RESULTSET); - assertThat(connection.isValid(1), is(true)); - try { - // Invalid timeout value. - connection.isValid(-1); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - - // Now let the query return an error. isValid should now return false. - when(spannerConnection.executeQuery(statement)) - .thenThrow( - SpannerExceptionFactory.newSpannerException( - ErrorCode.ABORTED, "the current transaction has been aborted")); - assertThat(connection.isValid(1), is(false)); - } - } - - @Test - public void testIsValidOnClosedConnection() throws SQLException { - Connection connection = createConnection(mock(ConnectionOptions.class)); - connection.close(); - assertThat(connection.isValid(1), is(false)); - } - - @Test - public void testCreateStatement() throws SQLException { - try (JdbcConnection connection = createConnection(mock(ConnectionOptions.class))) { - for (int resultSetType : - new int[] { - ResultSet.TYPE_FORWARD_ONLY, - ResultSet.TYPE_SCROLL_INSENSITIVE, - ResultSet.TYPE_SCROLL_SENSITIVE - }) { - for (int resultSetConcurrency : - new int[] {ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE}) { - if (resultSetType == ResultSet.TYPE_FORWARD_ONLY // Only FORWARD_ONLY is supported - && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY) // Only READ_ONLY is supported - { - java.sql.Statement statement = - connection.createStatement(resultSetType, resultSetConcurrency); - assertThat(statement.getResultSetType(), is(equalTo(resultSetType))); - assertThat(statement.getResultSetConcurrency(), is(equalTo(resultSetConcurrency))); - } else { - assertCreateStatementFails(connection, resultSetType, resultSetConcurrency); - } - for (int resultSetHoldability : - new int[] {ResultSet.CLOSE_CURSORS_AT_COMMIT, ResultSet.HOLD_CURSORS_OVER_COMMIT}) { - if (resultSetType == ResultSet.TYPE_FORWARD_ONLY // Only FORWARD_ONLY is supported - && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY // Only READ_ONLY is supported - && resultSetHoldability - == ResultSet - .CLOSE_CURSORS_AT_COMMIT) // Only CLOSE_CURSORS_AT_COMMIT is supported - { - java.sql.Statement statement = - connection.createStatement( - resultSetType, resultSetConcurrency, resultSetHoldability); - assertThat(statement.getResultSetType(), is(equalTo(resultSetType))); - assertThat(statement.getResultSetConcurrency(), is(equalTo(resultSetConcurrency))); - assertThat(statement.getResultSetHoldability(), is(equalTo(resultSetHoldability))); - } else { - assertCreateStatementFails( - connection, resultSetType, resultSetConcurrency, resultSetHoldability); - } - } - } - } - } - } - - private void assertCreateStatementFails( - JdbcConnection connection, - int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) - throws SQLException { - try { - connection.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - fail( - String.format( - "missing expected exception for %d %d %d", - resultSetType, resultSetConcurrency, resultSetHoldability)); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } - } - - private void assertCreateStatementFails( - JdbcConnection connection, int resultSetType, int resultSetConcurrency) throws SQLException { - try { - connection.createStatement(resultSetType, resultSetConcurrency); - fail( - String.format( - "missing expected exception for %d %d", resultSetType, resultSetConcurrency)); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } - } - - @Test - public void testPrepareStatement() throws SQLException { - try (JdbcConnection connection = createConnection(mock(ConnectionOptions.class))) { - for (int resultSetType : - new int[] { - ResultSet.TYPE_FORWARD_ONLY, - ResultSet.TYPE_SCROLL_INSENSITIVE, - ResultSet.TYPE_SCROLL_SENSITIVE - }) { - for (int resultSetConcurrency : - new int[] {ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE}) { - if (resultSetType == ResultSet.TYPE_FORWARD_ONLY // Only FORWARD_ONLY is supported - && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY) // Only READ_ONLY is supported - { - PreparedStatement ps = - connection.prepareStatement("SELECT 1", resultSetType, resultSetConcurrency); - assertThat(ps.getResultSetType(), is(equalTo(resultSetType))); - assertThat(ps.getResultSetConcurrency(), is(equalTo(resultSetConcurrency))); - } else { - assertPrepareStatementFails(connection, resultSetType, resultSetConcurrency); - } - for (int resultSetHoldability : - new int[] {ResultSet.CLOSE_CURSORS_AT_COMMIT, ResultSet.HOLD_CURSORS_OVER_COMMIT}) { - if (resultSetType == ResultSet.TYPE_FORWARD_ONLY // Only FORWARD_ONLY is supported - && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY // Only READ_ONLY is supported - && resultSetHoldability - == ResultSet - .CLOSE_CURSORS_AT_COMMIT) // Only CLOSE_CURSORS_AT_COMMIT is supported - { - PreparedStatement ps = - connection.prepareStatement( - "SELECT 1", resultSetType, resultSetConcurrency, resultSetHoldability); - assertThat(ps.getResultSetType(), is(equalTo(resultSetType))); - assertThat(ps.getResultSetConcurrency(), is(equalTo(resultSetConcurrency))); - assertThat(ps.getResultSetHoldability(), is(equalTo(resultSetHoldability))); - } else { - assertPrepareStatementFails( - connection, resultSetType, resultSetConcurrency, resultSetHoldability); - } - } - } - } - } - } - - private void assertPrepareStatementFails( - JdbcConnection connection, - int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) - throws SQLException { - try { - connection.prepareStatement( - "SELECT 1", resultSetType, resultSetConcurrency, resultSetHoldability); - fail( - String.format( - "missing expected exception for %d %d %d", - resultSetType, resultSetConcurrency, resultSetHoldability)); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } - } - - private void assertPrepareStatementFails( - JdbcConnection connection, int resultSetType, int resultSetConcurrency) throws SQLException { - try { - connection.prepareStatement("SELECT 1", resultSetType, resultSetConcurrency); - fail( - String.format( - "missing expected exception for %d %d", resultSetType, resultSetConcurrency)); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } - } - - @Test - public void testPrepareStatementWithAutoGeneratedKeys() throws SQLException { - String sql = "INSERT INTO FOO (COL1) VALUES (?)"; - try (JdbcConnection connection = createConnection(mock(ConnectionOptions.class))) { - PreparedStatement statement = - connection.prepareStatement(sql, java.sql.Statement.NO_GENERATED_KEYS); - ResultSet rs = statement.getGeneratedKeys(); - assertThat(rs.next(), is(false)); - try { - statement = connection.prepareStatement(sql, java.sql.Statement.RETURN_GENERATED_KEYS); - fail("missing expected SQLFeatureNotSupportedException"); - } catch (SQLFeatureNotSupportedException e) { - // ignore, this is the expected exception. - } - } - } - - @Test - public void testCatalog() throws SQLException { - ConnectionOptions options = mock(ConnectionOptions.class); - when(options.getDatabaseName()).thenReturn("test"); - try (JdbcConnection connection = createConnection(options)) { - assertThat(connection.getCatalog(), is(equalTo("test"))); - // This should be allowed. - connection.setCatalog(""); - try { - // This should cause an exception. - connection.setCatalog("other"); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - } - } - - @Test - public void testSchema() throws SQLException { - try (JdbcConnection connection = createConnection(mock(ConnectionOptions.class))) { - assertThat(connection.getSchema(), is(equalTo(""))); - // This should be allowed. - connection.setSchema(""); - try { - // This should cause an exception. - connection.setSchema("other"); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java deleted file mode 100644 index 6c3363be383..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.auth.oauth2.GoogleCredentials; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowIdLifetime; -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcDatabaseMetaDataTest { - private static final String DEFAULT_CATALOG = ""; - private static final String DEFAULT_SCHEMA = ""; - private static final String TEST_TABLE = "FOO"; - private static final int DATABASE_MAJOR_VERSION = 1; - private static final int DATABASE_MINOR_VERSION = 0; - private static final String DATABASE_PRODUCT_NAME = "Google Cloud Spanner"; - - @Test - public void testTrivialMethods() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - assertThat(meta.allProceduresAreCallable(), is(true)); - assertThat(meta.allTablesAreSelectable(), is(true)); - assertThat(meta.autoCommitFailureClosesAllResultSets(), is(false)); - assertThat(meta.dataDefinitionCausesTransactionCommit(), is(false)); - assertThat(meta.dataDefinitionIgnoredInTransactions(), is(false)); - for (int type : - new int[] { - ResultSet.TYPE_FORWARD_ONLY, - ResultSet.TYPE_SCROLL_INSENSITIVE, - ResultSet.TYPE_SCROLL_SENSITIVE - }) { - assertThat(meta.deletesAreDetected(type), is(false)); - assertThat(meta.insertsAreDetected(type), is(false)); - assertThat(meta.updatesAreDetected(type), is(false)); - assertThat(meta.ownDeletesAreVisible(type), is(false)); - assertThat(meta.ownInsertsAreVisible(type), is(false)); - assertThat(meta.ownUpdatesAreVisible(type), is(false)); - assertThat(meta.othersDeletesAreVisible(type), is(false)); - assertThat(meta.othersInsertsAreVisible(type), is(false)); - assertThat(meta.othersUpdatesAreVisible(type), is(false)); - } - assertThat(meta.doesMaxRowSizeIncludeBlobs(), is(true)); - assertThat(meta.generatedKeyAlwaysReturned(), is(false)); - assertThat(meta.getCatalogSeparator(), is(equalTo("."))); - assertThat(meta.getCatalogTerm(), is(equalTo("CATALOG"))); - assertThat(meta.getDatabaseMajorVersion(), is(equalTo(DATABASE_MAJOR_VERSION))); - assertThat(meta.getDatabaseMinorVersion(), is(equalTo(DATABASE_MINOR_VERSION))); - assertThat(meta.getDatabaseProductName(), is(equalTo(DATABASE_PRODUCT_NAME))); - assertThat( - meta.getDatabaseProductVersion(), - is(equalTo(DATABASE_MAJOR_VERSION + "." + DATABASE_MINOR_VERSION))); - assertThat( - meta.getDefaultTransactionIsolation(), is(equalTo(Connection.TRANSACTION_SERIALIZABLE))); - assertThat(meta.getDriverName(), is(equalTo("com.google.cloud.spanner.jdbc.JdbcDriver"))); - assertThat(meta.getExtraNameCharacters(), is(equalTo(""))); - assertThat(meta.getIdentifierQuoteString(), is(equalTo("`"))); - assertThat(meta.getJDBCMajorVersion(), is(equalTo(4))); - assertThat(meta.getJDBCMinorVersion(), is(equalTo(1))); // Java 7 is JDBC 4.1 - assertThat(meta.getMaxBinaryLiteralLength(), is(equalTo(0))); - assertThat(meta.getMaxCatalogNameLength(), is(equalTo(0))); - assertThat(meta.getMaxCharLiteralLength(), is(equalTo(0))); - assertThat(meta.getMaxColumnNameLength(), is(equalTo(128))); - assertThat(meta.getMaxColumnsInGroupBy(), is(equalTo(1000))); - assertThat(meta.getMaxColumnsInIndex(), is(equalTo(16))); - assertThat(meta.getMaxColumnsInOrderBy(), is(equalTo(0))); - assertThat(meta.getMaxColumnsInSelect(), is(equalTo(0))); - assertThat(meta.getMaxColumnsInTable(), is(equalTo(1024))); - assertThat(meta.getMaxConnections(), is(equalTo(0))); // there is a max number of sessions, but - // that is not the same as connections - assertThat(meta.getMaxCursorNameLength(), is(equalTo(0))); - assertThat(meta.getMaxIndexLength(), is(equalTo(8000))); - assertThat(meta.getMaxProcedureNameLength(), is(equalTo(0))); - assertThat(meta.getMaxRowSize(), is(equalTo(1024 * 10000000))); - assertThat(meta.getMaxSchemaNameLength(), is(equalTo(0))); - assertThat(meta.getMaxStatementLength(), is(equalTo(1000000))); - assertThat(meta.getMaxStatements(), is(equalTo(0))); - assertThat(meta.getMaxTableNameLength(), is(equalTo(128))); - assertThat(meta.getMaxTablesInSelect(), is(equalTo(0))); - assertThat(meta.getMaxUserNameLength(), is(equalTo(0))); - assertThat(meta.getProcedureTerm(), is(equalTo("PROCEDURE"))); - assertThat(meta.getResultSetHoldability(), is(equalTo(ResultSet.CLOSE_CURSORS_AT_COMMIT))); - assertThat(meta.getRowIdLifetime(), is(equalTo(RowIdLifetime.ROWID_UNSUPPORTED))); - assertThat(meta.getSchemaTerm(), is(equalTo("SCHEMA"))); - assertThat(meta.getSearchStringEscape(), is(equalTo("\\"))); - assertThat(meta.getSQLStateType(), is(equalTo(DatabaseMetaData.sqlStateSQL))); - assertThat(meta.locatorsUpdateCopy(), is(true)); - assertThat(meta.nullsAreSortedHigh(), is(false)); - assertThat(meta.nullsAreSortedLow(), is(true)); - assertThat(meta.nullsAreSortedAtStart(), is(false)); - assertThat(meta.nullsAreSortedAtEnd(), is(false)); - assertThat(meta.nullPlusNonNullIsNull(), is(true)); - assertThat(meta.isCatalogAtStart(), is(false)); - assertThat(meta.isReadOnly(), is(equalTo(connection.isReadOnly()))); - assertThat(meta.storesLowerCaseIdentifiers(), is(false)); - assertThat(meta.storesLowerCaseQuotedIdentifiers(), is(false)); - assertThat(meta.storesMixedCaseIdentifiers(), is(true)); - assertThat(meta.storesMixedCaseQuotedIdentifiers(), is(true)); - assertThat(meta.storesUpperCaseIdentifiers(), is(false)); - assertThat(meta.storesUpperCaseQuotedIdentifiers(), is(false)); - assertThat(meta.supportsAlterTableWithAddColumn(), is(true)); - assertThat(meta.supportsAlterTableWithDropColumn(), is(true)); - assertThat(meta.supportsANSI92EntryLevelSQL(), is(false)); - assertThat(meta.supportsANSI92FullSQL(), is(false)); - assertThat(meta.supportsANSI92IntermediateSQL(), is(false)); - assertThat(meta.supportsBatchUpdates(), is(true)); - assertThat(meta.supportsCatalogsInDataManipulation(), is(false)); - assertThat(meta.supportsCatalogsInIndexDefinitions(), is(false)); - assertThat(meta.supportsCatalogsInPrivilegeDefinitions(), is(false)); - assertThat(meta.supportsCatalogsInProcedureCalls(), is(false)); - assertThat(meta.supportsCatalogsInTableDefinitions(), is(false)); - assertThat(meta.supportsColumnAliasing(), is(true)); - // Note that the supportsConvert() method indicates whether the server side function CONVERT is - // supported, not what the JDBC driver might be able to convert on the client side. - assertThat(meta.supportsConvert(), is(false)); - int[] types = - new int[] { - Types.ARRAY, - Types.BIGINT, - Types.BINARY, - Types.BIT, - Types.BLOB, - Types.BOOLEAN, - Types.CHAR, - Types.CLOB, - Types.DATALINK, - Types.DATE, - Types.DECIMAL, - Types.DISTINCT, - Types.DOUBLE, - Types.FLOAT, - Types.INTEGER, - Types.JAVA_OBJECT, - Types.LONGNVARCHAR, - Types.LONGVARCHAR, - Types.LONGVARBINARY, - Types.LONGVARCHAR, - Types.NCHAR, - Types.NCLOB, - Types.NULL, - Types.NUMERIC, - Types.NVARCHAR, - Types.OTHER, - Types.REAL, - Types.REF, - Types.ROWID, - Types.SMALLINT, - Types.SQLXML, - Types.STRUCT, - Types.TIME, - Types.TIMESTAMP, - Types.TINYINT, - Types.VARBINARY, - Types.VARCHAR - }; - for (int from : types) { - for (int to : types) { - assertThat(meta.supportsConvert(from, to), is(false)); - } - } - assertThat(meta.supportsCoreSQLGrammar(), is(false)); - assertThat(meta.supportsCorrelatedSubqueries(), is(true)); - assertThat(meta.supportsDataDefinitionAndDataManipulationTransactions(), is(false)); - assertThat(meta.supportsDataManipulationTransactionsOnly(), is(true)); - assertThat(meta.supportsDifferentTableCorrelationNames(), is(false)); - assertThat(meta.supportsExpressionsInOrderBy(), is(true)); - assertThat(meta.supportsExtendedSQLGrammar(), is(false)); - assertThat(meta.supportsFullOuterJoins(), is(true)); - assertThat(meta.supportsGetGeneratedKeys(), is(false)); - assertThat(meta.supportsGroupBy(), is(true)); - assertThat(meta.supportsGroupByBeyondSelect(), is(true)); - assertThat(meta.supportsGroupByUnrelated(), is(true)); - assertThat(meta.supportsIntegrityEnhancementFacility(), is(false)); - assertThat(meta.supportsLikeEscapeClause(), is(true)); - assertThat(meta.supportsLimitedOuterJoins(), is(true)); - assertThat(meta.supportsMinimumSQLGrammar(), is(false)); - assertThat(meta.supportsMixedCaseIdentifiers(), is(false)); - assertThat(meta.supportsMixedCaseQuotedIdentifiers(), is(false)); - assertThat(meta.supportsMultipleOpenResults(), is(true)); - assertThat(meta.supportsMultipleResultSets(), is(true)); - assertThat(meta.supportsMultipleTransactions(), is(true)); - assertThat(meta.supportsNamedParameters(), is(false)); - assertThat(meta.supportsNonNullableColumns(), is(true)); - assertThat(meta.supportsOpenCursorsAcrossCommit(), is(false)); - assertThat(meta.supportsOpenCursorsAcrossRollback(), is(false)); - assertThat(meta.supportsOpenStatementsAcrossCommit(), is(true)); - assertThat(meta.supportsOpenStatementsAcrossRollback(), is(true)); - assertThat(meta.supportsOrderByUnrelated(), is(true)); - assertThat(meta.supportsOuterJoins(), is(true)); - assertThat(meta.supportsPositionedDelete(), is(false)); - assertThat(meta.supportsPositionedUpdate(), is(false)); - for (int type : - new int[] { - ResultSet.TYPE_FORWARD_ONLY, - ResultSet.TYPE_SCROLL_INSENSITIVE, - ResultSet.TYPE_SCROLL_SENSITIVE - }) { - assertThat(meta.supportsResultSetType(type), is(type == ResultSet.TYPE_FORWARD_ONLY)); - for (int concur : new int[] {ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE}) { - assertThat( - meta.supportsResultSetConcurrency(type, concur), - is(type == ResultSet.TYPE_FORWARD_ONLY && concur == ResultSet.CONCUR_READ_ONLY)); - } - } - assertThat(meta.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT), is(true)); - assertThat(meta.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT), is(false)); - assertThat(meta.supportsSavepoints(), is(false)); - assertThat(meta.supportsSchemasInDataManipulation(), is(false)); - assertThat(meta.supportsSchemasInIndexDefinitions(), is(false)); - assertThat(meta.supportsSchemasInPrivilegeDefinitions(), is(false)); - assertThat(meta.supportsSchemasInProcedureCalls(), is(false)); - assertThat(meta.supportsSchemasInTableDefinitions(), is(false)); - assertThat(meta.supportsSelectForUpdate(), is(false)); - assertThat(meta.supportsStatementPooling(), is(false)); - assertThat(meta.supportsStoredFunctionsUsingCallSyntax(), is(false)); - assertThat(meta.supportsStoredProcedures(), is(false)); - assertThat(meta.supportsSubqueriesInComparisons(), is(true)); - assertThat(meta.supportsSubqueriesInExists(), is(true)); - assertThat(meta.supportsSubqueriesInIns(), is(true)); - assertThat(meta.supportsSubqueriesInQuantifieds(), is(true)); - assertThat(meta.supportsTableCorrelationNames(), is(true)); - assertThat(meta.supportsTransactions(), is(true)); - assertThat(meta.supportsUnion(), is(true)); - assertThat(meta.supportsUnionAll(), is(true)); - assertThat(meta.usesLocalFiles(), is(false)); - assertThat(meta.usesLocalFilePerTable(), is(false)); - assertThat( - meta.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE), is(true)); - for (int level : - new int[] { - Connection.TRANSACTION_NONE, - Connection.TRANSACTION_READ_COMMITTED, - Connection.TRANSACTION_READ_UNCOMMITTED, - Connection.TRANSACTION_REPEATABLE_READ - }) { - assertThat(meta.supportsTransactionIsolationLevel(level), is(false)); - } - - // trivial tests that guarantee that the function works, but the return value doesn't matter - assertThat(meta.getNumericFunctions(), is(notNullValue())); - assertThat(meta.getSQLKeywords(), is(notNullValue())); - assertThat(meta.getStringFunctions(), is(notNullValue())); - assertThat(meta.getSystemFunctions(), is(notNullValue())); - assertThat(meta.getTimeDateFunctions(), is(notNullValue())); - } - - @Test - public void testGetAttributes() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getAttributes(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(21))); - } - } - - @Test - public void testGetBestRowIdentifier() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = - meta.getBestRowIdentifier( - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - TEST_TABLE, - DatabaseMetaData.bestRowTransaction, - false)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(8))); - } - } - - @Test - public void testGetCatalogs() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getCatalogs()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(""))); - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(1))); - } - } - - @Test - public void testGetClientInfoProperties() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getClientInfoProperties()) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(4))); - } - } - - public void testGetColumnPrivileges() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = - meta.getColumnPrivileges(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(8))); - } - } - - @Test - public void testGetFunctionColumns() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getFunctionColumns(DEFAULT_CATALOG, DEFAULT_SCHEMA, null, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(17))); - } - } - - @Test - public void testGetFunctions() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getFunctions(DEFAULT_CATALOG, DEFAULT_SCHEMA, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(6))); - } - } - - @Test - public void testGetProcedureColumns() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getProcedureColumns(DEFAULT_CATALOG, DEFAULT_SCHEMA, null, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(20))); - } - } - - @Test - public void testGetProcedures() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getProcedures(DEFAULT_CATALOG, DEFAULT_SCHEMA, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(9))); - } - } - - @Test - public void testGetPseudoColumns() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getPseudoColumns(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(12))); - } - } - - @Test - public void testGetSuperTables() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getSuperTables(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(4))); - } - } - - @Test - public void testGetSuperTypes() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getSuperTypes(DEFAULT_CATALOG, DEFAULT_SCHEMA, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(6))); - } - } - - @Test - public void testGetTablePrivileges() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getTablePrivileges(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(7))); - } - } - - @Test - public void testGetTableTypes() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getTableTypes()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_TYPE"), is(equalTo("TABLE"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_TYPE"), is(equalTo("VIEW"))); - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(1))); - } - } - - @Test - public void testGetTypeInfo() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getTypeInfo()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("STRING"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("INT64"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("BYTES"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("FLOAT64"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("BOOL"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("DATE"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TYPE_NAME"), is(equalTo("TIMESTAMP"))); - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(18))); - } - } - - @Test - public void testGetUDTs() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getUDTs(DEFAULT_CATALOG, DEFAULT_SCHEMA, null, null)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(7))); - } - } - - @Test - public void testGetVersionColumns() throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - try (ResultSet rs = meta.getVersionColumns(DEFAULT_CATALOG, DEFAULT_SCHEMA, TEST_TABLE)) { - assertThat(rs.next(), is(false)); - ResultSetMetaData rsmd = rs.getMetaData(); - assertThat(rsmd.getColumnCount(), is(equalTo(8))); - } - } - - @Test - public void testGetUserName() throws SQLException, IOException { - GoogleCredentials credentials = - GoogleCredentials.fromStream( - ConnectionOptionsTest.class.getResource("test-key.json").openStream()); - JdbcConnection connection = mock(JdbcConnection.class); - ConnectionOptions options = mock(ConnectionOptions.class); - when(options.getCredentials()).thenReturn(credentials); - when(connection.getConnectionOptions()).thenReturn(options); - DatabaseMetaData meta = new JdbcDatabaseMetaData(connection); - assertThat(meta.getUserName(), is(equalTo("test@test-project.iam.gserviceaccount.com"))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataWithMockedServerTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataWithMockedServerTest.java deleted file mode 100644 index 95e0acae24e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataWithMockedServerTest.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.MockSpannerServiceImpl; -import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.JdbcParameterStore.ParametersInfo; -import com.google.protobuf.ListValue; -import com.google.protobuf.Value; -import com.google.spanner.v1.ResultSetMetadata; -import com.google.spanner.v1.StructType; -import com.google.spanner.v1.StructType.Field; -import com.google.spanner.v1.Type; -import com.google.spanner.v1.TypeCode; -import io.grpc.Server; -import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcDatabaseMetaDataWithMockedServerTest { - private static final ResultSetMetadata RESULTSET_METADATA = - ResultSetMetadata.newBuilder() - .setRowType( - StructType.newBuilder() - .addFields( - Field.newBuilder() - .setName("TAB1") - .setType(Type.newBuilder().setCode(TypeCode.STRING).build()) - .build()) - .build()) - .build(); - private static final com.google.spanner.v1.ResultSet RESULTSET = - com.google.spanner.v1.ResultSet.newBuilder() - .addRows( - ListValue.newBuilder() - .addValues(Value.newBuilder().setStringValue("TAB").build()) - .build()) - .setMetadata(RESULTSET_METADATA) - .build(); - - private static MockSpannerServiceImpl mockSpanner; - private static Server server; - private static InetSocketAddress address; - - @BeforeClass - public static void startStaticServer() throws IOException { - mockSpanner = new MockSpannerServiceImpl(); - mockSpanner.setAbortProbability(0.0D); // We don't want any unpredictable aborted transactions. - address = new InetSocketAddress("localhost", 0); - server = NettyServerBuilder.forAddress(address).addService(mockSpanner).build().start(); - } - - @AfterClass - public static void stopServer() throws Exception { - SpannerPool.closeSpannerPool(); - server.shutdown(); - server.awaitTermination(); - } - - @After - public void reset() { - // Close Spanner pool to prevent reusage of the same Spanner instance (and thereby the same - // session pool). - SpannerPool.closeSpannerPool(); - mockSpanner.removeAllExecutionTimes(); - mockSpanner.reset(); - } - - private String createUrl() { - return String.format( - "jdbc:cloudspanner://localhost:%d/projects/%s/instances/%s/databases/%s?usePlainText=true", - server.getPort(), "proj", "inst", "db"); - } - - private Connection createConnection() throws SQLException { - return DriverManager.getConnection(createUrl()); - } - - @Test - public void getTablesInDdlBatch() throws SQLException { - String sql = - StatementParser.removeCommentsAndTrim( - JdbcDatabaseMetaData.readSqlFromFile("DatabaseMetaData_GetTables.sql")); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("CAT") - .bind("p2") - .to("SCH") - .bind("p3") - .to("TAB") - .bind("p4") - .to("TABLE") - .bind("p5") - .to("VIEW") - .build(), - RESULTSET)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - // Executing an internal metadata query should be allowed during a DDL batch. - // This query will be executed on a single use read-only transaction. - try (ResultSet tables = connection.getMetaData().getTables("CAT", "SCH", "TAB", null)) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } - - @Test - public void getColumnsInDdlBatch() throws SQLException { - String sql = - StatementParser.removeCommentsAndTrim( - JdbcDatabaseMetaData.readSqlFromFile("DatabaseMetaData_GetColumns.sql")); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("CAT") - .bind("p2") - .to("SCH") - .bind("p3") - .to("TAB") - .bind("p4") - .to("%") - .build(), - RESULTSET)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - try (ResultSet tables = connection.getMetaData().getColumns("CAT", "SCH", "TAB", null)) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } - - @Test - public void getKeysInDdlBatch() throws SQLException { - for (String fileName : - new String[] { - "DatabaseMetaData_GetPrimaryKeys.sql", - "DatabaseMetaData_GetImportedKeys.sql", - "DatabaseMetaData_GetExportedKeys.sql" - }) { - String sql = - StatementParser.removeCommentsAndTrim(JdbcDatabaseMetaData.readSqlFromFile(fileName)); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("CAT") - .bind("p2") - .to("SCH") - .bind("p3") - .to("TAB") - .build(), - RESULTSET)); - } - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - try (ResultSet tables = connection.getMetaData().getPrimaryKeys("CAT", "SCH", "TAB")) { - while (tables.next()) {} - } - try (ResultSet tables = connection.getMetaData().getImportedKeys("CAT", "SCH", "TAB")) { - while (tables.next()) {} - } - try (ResultSet tables = connection.getMetaData().getExportedKeys("CAT", "SCH", "TAB")) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } - - @Test - public void getCrossReferencesInDdlBatch() throws SQLException { - String sql = - StatementParser.removeCommentsAndTrim( - JdbcDatabaseMetaData.readSqlFromFile("DatabaseMetaData_GetCrossReferences.sql")); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("CAT") - .bind("p2") - .to("SCH") - .bind("p3") - .to("TAB") - .bind("p4") - .to("CAT2") - .bind("p5") - .to("SCH2") - .bind("p6") - .to("TAB2") - .build(), - RESULTSET)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - try (ResultSet tables = - connection.getMetaData().getCrossReference("CAT", "SCH", "TAB", "CAT2", "SCH2", "TAB2")) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } - - @Test - public void getIndexInfoInDdlBatch() throws SQLException { - String sql = - StatementParser.removeCommentsAndTrim( - JdbcDatabaseMetaData.readSqlFromFile("DatabaseMetaData_GetIndexInfo.sql")); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("CAT") - .bind("p2") - .to("SCH") - .bind("p3") - .to("TAB") - .bind("p4") - .to("%") - .bind("p5") - .to("YES") - .build(), - RESULTSET)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - try (ResultSet tables = - connection.getMetaData().getIndexInfo("CAT", "SCH", "TAB", true, false)) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } - - @Test - public void getSchemasInDdlBatch() throws SQLException { - String sql = - StatementParser.removeCommentsAndTrim( - JdbcDatabaseMetaData.readSqlFromFile("DatabaseMetaData_GetSchemas.sql")); - ParametersInfo params = JdbcParameterStore.convertPositionalParametersToNamedParameters(sql); - mockSpanner.putStatementResult( - StatementResult.query( - Statement.newBuilder(params.sqlWithNamedParameters) - .bind("p1") - .to("%") - .bind("p2") - .to("%") - .build(), - RESULTSET)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DDL"); - try (ResultSet tables = connection.getMetaData().getSchemas()) { - while (tables.next()) {} - } - try (ResultSet tables = connection.getMetaData().getSchemas(null, null)) { - while (tables.next()) {} - } - connection.createStatement().execute("CREATE TABLE FOO"); - connection.createStatement().execute("ABORT BATCH"); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDriverTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDriverTest.java deleted file mode 100644 index 68c252ebe34..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcDriverTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.MockSpannerServiceImpl; -import io.grpc.Server; -import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcDriverTest { - /** - * Make sure the JDBC driver class is loaded. This is needed when running the test using Maven. - */ - static { - try { - Class.forName("com.google.cloud.spanner.jdbc.JdbcDriver"); - } catch (ClassNotFoundException e) { - throw new IllegalStateException( - "JdbcDataSource failed to load com.google.cloud.spanner.jdbc.JdbcDriver", e); - } - } - - private static MockSpannerServiceImpl mockSpanner; - private static Server server; - private static InetSocketAddress address; - private static final String TEST_KEY_PATH = - ConnectionOptionsTest.class.getResource("test-key.json").getFile(); - - @BeforeClass - public static void startStaticServer() throws IOException { - mockSpanner = new MockSpannerServiceImpl(); - address = new InetSocketAddress("localhost", 0); - server = NettyServerBuilder.forAddress(address).addService(mockSpanner).build().start(); - } - - @AfterClass - public static void stopServer() throws Exception { - SpannerPool.closeSpannerPool(); - server.shutdown(); - server.awaitTermination(); - } - - @Test - public void testConnect() throws SQLException { - try (Connection connection = - DriverManager.getConnection( - String.format( - "jdbc:cloudspanner://localhost:%d/projects/test-project/instances/static-test-instance/databases/test-database;usePlainText=true;credentials=%s", - server.getPort(), TEST_KEY_PATH))) { - assertThat(connection.isClosed(), is(false)); - } - } - - @Test(expected = SQLException.class) - public void testInvalidConnect() throws SQLException { - try (Connection connection = - DriverManager.getConnection( - String.format( - "jdbc:cloudspanner://localhost:%d/projects/test-project/instances/static-test-instance/databases/test-database;usePlainText=true;credentialsUrl=%s", - server.getPort(), TEST_KEY_PATH))) { - assertThat(connection.isClosed(), is(false)); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcExceptionMatcher.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcExceptionMatcher.java deleted file mode 100644 index afe9657f047..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcExceptionMatcher.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.common.base.Preconditions; -import com.google.rpc.Code; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - -public final class JdbcExceptionMatcher extends BaseMatcher { - private final Code errorCode; - private final String message; - - public static JdbcExceptionMatcher matchCode(Code errorCode) { - Preconditions.checkNotNull(errorCode); - return new JdbcExceptionMatcher(errorCode, null); - } - - public static JdbcExceptionMatcher matchCodeAndMessage(Code errorCode, String message) { - Preconditions.checkNotNull(errorCode); - Preconditions.checkNotNull(message); - return new JdbcExceptionMatcher(errorCode, message); - } - - private JdbcExceptionMatcher(Code errorCode, String message) { - this.errorCode = errorCode; - this.message = message; - } - - @Override - public boolean matches(Object item) { - if (item instanceof JdbcSqlException) { - JdbcSqlException exception = (JdbcSqlException) item; - if (message == null) { - return exception.getCode().equals(errorCode); - } - return exception.getCode().equals(errorCode) - && exception.getMessage().equals(errorCode.name() + ": " + message); - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText(JdbcSqlException.class.getName() + " with code " + errorCode.name()); - if (message != null) { - description.appendText(" - " + JdbcSqlException.class.getName() + " with message " + message); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcGrpcErrorTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcGrpcErrorTest.java deleted file mode 100644 index 06ea2a343af..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcGrpcErrorTest.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.MockSpannerServiceImpl; -import com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime; -import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl; -import com.google.cloud.spanner.admin.instance.v1.MockInstanceAdminImpl; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.protobuf.ListValue; -import com.google.protobuf.Value; -import com.google.spanner.v1.ResultSetMetadata; -import com.google.spanner.v1.StructType; -import com.google.spanner.v1.StructType.Field; -import com.google.spanner.v1.Type; -import com.google.spanner.v1.TypeCode; -import io.grpc.Server; -import io.grpc.Status; -import io.grpc.Status.Code; -import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test that the JDBC driver propagates {@link SQLException}s when a gRPC error occurs. */ -@RunWith(JUnit4.class) -public class JdbcGrpcErrorTest { - private static final Statement SELECT1 = Statement.of("SELECT 1 AS COL1"); - private static final ResultSetMetadata SELECT1_METADATA = - ResultSetMetadata.newBuilder() - .setRowType( - StructType.newBuilder() - .addFields( - Field.newBuilder() - .setName("COL1") - .setType(Type.newBuilder().setCode(TypeCode.INT64).build()) - .build()) - .build()) - .build(); - private static final com.google.spanner.v1.ResultSet SELECT1_RESULTSET = - com.google.spanner.v1.ResultSet.newBuilder() - .addRows( - ListValue.newBuilder() - .addValues(Value.newBuilder().setStringValue("1").build()) - .build()) - .setMetadata(SELECT1_METADATA) - .build(); - private static final Statement UPDATE_STATEMENT = - Statement.of("UPDATE FOO SET BAR=1 WHERE BAZ=2"); - private static final int UPDATE_COUNT = 1; - private static final Statement INVALID_UPDATE_STATEMENT = - Statement.of("UPDATE NON_EXISING_TABLE SET FOO=1 WHERE BAR=2"); - - private static MockSpannerServiceImpl mockSpanner; - private static MockInstanceAdminImpl mockInstanceAdmin; - private static MockDatabaseAdminImpl mockDatabaseAdmin; - private static Server server; - private static InetSocketAddress address; - - @Rule public ExpectedException expected = ExpectedException.none(); - // FAILED_PRECONDITION is chosen as the test error code as it should never be retryable. - private final Exception serverException = - Status.FAILED_PRECONDITION.withDescription("test exception").asRuntimeException(); - private final SpannerJdbcExceptionMatcher testExceptionMatcher = - SpannerJdbcExceptionMatcher.matchCodeAndMessage( - JdbcSqlExceptionImpl.class, Code.FAILED_PRECONDITION, "test exception"); - - @BeforeClass - public static void startStaticServer() throws IOException { - mockSpanner = new MockSpannerServiceImpl(); - mockSpanner.setAbortProbability(0.0D); // We don't want any unpredictable aborted transactions. - mockSpanner.putStatementResult(StatementResult.query(SELECT1, SELECT1_RESULTSET)); - mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT)); - mockSpanner.putStatementResult( - StatementResult.exception( - INVALID_UPDATE_STATEMENT, - Status.NOT_FOUND.withDescription("Unknown table name").asRuntimeException())); - mockInstanceAdmin = new MockInstanceAdminImpl(); - mockDatabaseAdmin = new MockDatabaseAdminImpl(); - address = new InetSocketAddress("localhost", 0); - server = - NettyServerBuilder.forAddress(address) - .addService(mockSpanner) - .addService(mockInstanceAdmin) - .addService(mockDatabaseAdmin) - .build() - .start(); - } - - @AfterClass - public static void stopServer() throws Exception { - SpannerPool.closeSpannerPool(); - server.shutdown(); - server.awaitTermination(); - } - - @After - public void reset() { - // Close Spanner pool to prevent reusage of the same Spanner instance (and thereby the same - // session pool). - SpannerPool.closeSpannerPool(); - mockSpanner.removeAllExecutionTimes(); - mockSpanner.reset(); - } - - private String createUrl() { - return String.format( - "jdbc:cloudspanner://localhost:%d/projects/%s/instances/%s/databases/%s?usePlainText=true", - server.getPort(), "proj", "inst", "db"); - } - - private Connection createConnection() throws SQLException { - return DriverManager.getConnection(createUrl()); - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void autocommitBeginTransaction() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBeginTransactionExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void autocommitBeginPDMLTransaction() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBeginTransactionExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'"); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void transactionalBeginTransaction() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBeginTransactionExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void readOnlyBeginTransaction() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBeginTransactionExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.setReadOnly(true); - connection.createStatement().executeQuery(SELECT1.getSql()); - } - } - - @Test - public void autocommitExecuteSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteSqlExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Test - public void autocommitPDMLExecuteSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteSqlExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().execute("SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'"); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Test - public void transactionalExecuteSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteSqlExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Test - public void autocommitExecuteBatchDml() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteBatchDmlExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - try (java.sql.Statement statement = connection.createStatement()) { - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.executeBatch(); - } - } - } - - @Test - public void transactionalExecuteBatchDml() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteBatchDmlExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - try (java.sql.Statement statement = connection.createStatement()) { - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.addBatch(UPDATE_STATEMENT.getSql()); - statement.executeBatch(); - } - } - } - - @Test - public void autocommitCommit() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setCommitExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Test - public void transactionalCommit() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setCommitExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - connection.commit(); - } - } - - @Test - public void autocommitRollback() throws SQLException { - // The JDBC driver should throw the exception of the SQL statement and ignore any errors from - // the rollback() method. - expected.expect( - SpannerJdbcExceptionMatcher.matchCodeAndMessage( - JdbcSqlExceptionImpl.class, Code.NOT_FOUND, "Unknown table name")); - mockSpanner.setRollbackExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeUpdate(INVALID_UPDATE_STATEMENT.getSql()); - } - } - - @Test - public void transactionalRollback() throws SQLException { - // Rollback exceptions are ignored by the client library and not propagated to the JDBC driver. - // This method will therefore not throw any errors. - mockSpanner.setRollbackExecutionTime(SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - connection.rollback(); - } - } - - @Test - public void autocommitExecuteStreamingSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteStreamingSqlExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeQuery(SELECT1.getSql()); - } - } - - @Test - public void transactionalExecuteStreamingSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteStreamingSqlExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeQuery(SELECT1.getSql()); - } - } - - @Test - public void readOnlyExecuteStreamingSql() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setExecuteStreamingSqlExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.setReadOnly(true); - connection.createStatement().executeQuery(SELECT1.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void autocommitCreateSession() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBatchCreateSessionsExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void transactionalCreateSession() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBatchCreateSessionsExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.createStatement().executeUpdate(UPDATE_STATEMENT.getSql()); - } - } - - @Ignore( - "This can only be guaranteed with MinSessions=0. Re-enable when MinSessions is configurable for JDBC.") - @Test - public void readOnlyCreateSession() throws SQLException { - expected.expect(testExceptionMatcher); - mockSpanner.setBatchCreateSessionsExecutionTime( - SimulatedExecutionTime.ofException(serverException)); - try (java.sql.Connection connection = createConnection()) { - connection.setAutoCommit(false); - connection.setReadOnly(true); - connection.createStatement().executeQuery(SELECT1.getSql()); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcParameterStoreTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcParameterStoreTest.java deleted file mode 100644 index 336bfc1a5ed..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcParameterStoreTest.java +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.JdbcParameterStore.convertPositionalParametersToNamedParameters; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.cloud.ByteArray; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Value; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.common.io.CharStreams; -import com.google.rpc.Code; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigDecimal; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.Date; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.Arrays; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcParameterStoreTest { - - /** Tests setting a parameter value together with a sql type */ - @SuppressWarnings("deprecation") - @Test - public void testSetParameterWithType() throws SQLException, IOException { - JdbcParameterStore params = new JdbcParameterStore(); - // test the valid default combinations - params.setParameter(1, true, Types.BOOLEAN); - assertThat((Boolean) params.getParameter(1), is(equalTo(true))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, (byte) 1, Types.TINYINT); - assertThat((Byte) params.getParameter(1), is(equalTo((byte) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (short) 1, Types.SMALLINT); - assertThat((Short) params.getParameter(1), is(equalTo((short) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1, Types.INTEGER); - assertThat((Integer) params.getParameter(1), is(equalTo(1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1L, Types.BIGINT); - assertThat((Long) params.getParameter(1), is(equalTo(1L))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (float) 1, Types.FLOAT); - assertThat((Float) params.getParameter(1), is(equalTo((float) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, (double) 1, Types.DOUBLE); - assertThat((Double) params.getParameter(1), is(equalTo((double) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, new Date(1970 - 1900, 0, 1), Types.DATE); - assertThat((Date) params.getParameter(1), is(equalTo(new Date(1970 - 1900, 0, 1)))); - verifyParameter(params, Value.date(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1))); - params.setParameter(1, new Time(0L), Types.TIME); - assertThat((Time) params.getParameter(1), is(equalTo(new Time(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new Timestamp(0L), Types.TIMESTAMP); - assertThat((Timestamp) params.getParameter(1), is(equalTo(new Timestamp(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new byte[] {1, 2, 3}, Types.BINARY); - assertThat((byte[]) params.getParameter(1), is(equalTo(new byte[] {1, 2, 3}))); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - params.setParameter(1, "test", Types.NVARCHAR); - assertThat((String) params.getParameter(1), is(equalTo("test"))); - verifyParameter(params, Value.string("test")); - - params.setParameter(1, new JdbcBlob(new byte[] {1, 2, 3}), Types.BLOB); - assertThat((JdbcBlob) params.getParameter(1), is(equalTo(new JdbcBlob(new byte[] {1, 2, 3})))); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - params.setParameter(1, new ByteArrayInputStream(new byte[] {1, 2, 3}), Types.BLOB); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - - params.setParameter(1, new JdbcClob("test"), Types.CLOB); - assertThat((JdbcClob) params.getParameter(1), is(equalTo(new JdbcClob("test")))); - verifyParameter(params, Value.string("test")); - params.setParameter(1, new StringReader("test"), Types.CLOB); - assertThat( - stringReadersEqual((StringReader) params.getParameter(1), new StringReader("test")), - is(true)); - verifyParameter(params, Value.string("test")); - - params.setParameter(1, new JdbcClob("test"), Types.NCLOB); - assertThat((JdbcClob) params.getParameter(1), is(equalTo(new JdbcClob("test")))); - verifyParameter(params, Value.string("test")); - params.setParameter(1, new StringReader("test"), Types.NCLOB); - assertThat( - stringReadersEqual((StringReader) params.getParameter(1), new StringReader("test")), - is(true)); - verifyParameter(params, Value.string("test")); - - // test unsupported types - boolean expectedException = false; - try { - params.setParameter(1, BigDecimal.ONE, Types.DECIMAL); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - expectedException = ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT; - } - } - assertThat(expectedException, is(true)); - - // types that should lead to int64 - for (int type : new int[] {Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT}) { - params.setParameter(1, (byte) 1, type); - assertThat((Byte) params.getParameter(1), is(equalTo((byte) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (short) 1, type); - assertThat((Short) params.getParameter(1), is(equalTo((short) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1, type); - assertThat((Integer) params.getParameter(1), is(equalTo(1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1L, type); - assertThat((Long) params.getParameter(1), is(equalTo(1L))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (float) 1, type); - assertThat((Float) params.getParameter(1), is(equalTo((float) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (double) 1, type); - assertThat((Double) params.getParameter(1), is(equalTo((double) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, BigDecimal.ONE, type); - assertThat((BigDecimal) params.getParameter(1), is(equalTo(BigDecimal.ONE))); - verifyParameter(params, Value.int64(1)); - } - - // types that should lead to float64 - for (int type : new int[] {Types.FLOAT, Types.REAL, Types.DOUBLE}) { - params.setParameter(1, (byte) 1, type); - assertThat((Byte) params.getParameter(1), is(equalTo((byte) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, (short) 1, type); - assertThat((Short) params.getParameter(1), is(equalTo((short) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, 1, type); - assertThat((Integer) params.getParameter(1), is(equalTo(1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, 1L, type); - assertThat((Long) params.getParameter(1), is(equalTo(1L))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, (float) 1, type); - assertThat((Float) params.getParameter(1), is(equalTo((float) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, (double) 1, type); - assertThat((Double) params.getParameter(1), is(equalTo((double) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, BigDecimal.ONE, type); - assertThat((BigDecimal) params.getParameter(1), is(equalTo(BigDecimal.ONE))); - verifyParameter(params, Value.float64(1)); - } - - // types that should lead to date - for (int type : new int[] {Types.DATE}) { - params.setParameter(1, new Date(1970 - 1900, 0, 1), type); - assertThat((Date) params.getParameter(1), is(equalTo(new Date(1970 - 1900, 0, 1)))); - verifyParameter(params, Value.date(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1))); - params.setParameter(1, new Time(0L), type); - assertThat((Time) params.getParameter(1), is(equalTo(new Time(0L)))); - verifyParameter(params, Value.date(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1))); - params.setParameter(1, new Timestamp(1970 - 1900, 0, 1, 0, 0, 0, 0), type); - assertThat( - (Timestamp) params.getParameter(1), - is(equalTo(new Timestamp(1970 - 1900, 0, 1, 0, 0, 0, 0)))); - verifyParameter(params, Value.date(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1))); - } - - // types that should lead to timestamp - for (int type : new int[] {Types.TIME, Types.TIMESTAMP}) { - params.setParameter(1, new Date(0L), type); - assertThat((Date) params.getParameter(1), is(equalTo(new Date(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new Time(0L), type); - assertThat((Time) params.getParameter(1), is(equalTo(new Time(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new Timestamp(0L), type); - assertThat((Timestamp) params.getParameter(1), is(equalTo(new Timestamp(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - } - - // types that should lead to bytes (except BLOB which is handled separately) - for (int type : new int[] {Types.BINARY, Types.VARBINARY, Types.LONGVARBINARY}) { - params.setParameter(1, new byte[] {1, 2, 3}, type); - assertThat((byte[]) params.getParameter(1), is(equalTo(new byte[] {1, 2, 3}))); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - } - - // types that should lead to string - for (int type : - new int[] { - Types.CHAR, - Types.VARCHAR, - Types.LONGVARCHAR, - Types.NCHAR, - Types.NVARCHAR, - Types.LONGNVARCHAR - }) { - params.setParameter(1, "test", type); - assertThat((String) params.getParameter(1), is(equalTo("test"))); - verifyParameter(params, Value.string("test")); - - params.setParameter(1, new StringReader("test"), type); - assertThat( - stringReadersEqual((StringReader) params.getParameter(1), new StringReader("test")), - is(true)); - verifyParameter(params, Value.string("test")); - - params.setParameter( - 1, new ByteArrayInputStream(StandardCharsets.US_ASCII.encode("test").array()), type); - assertThat( - asciiStreamsEqual( - (ByteArrayInputStream) params.getParameter(1), - new ByteArrayInputStream(StandardCharsets.US_ASCII.encode("test").array())), - is(true)); - verifyParameter(params, Value.string("test")); - - params.setParameter(1, new URL("https://cloud.google.com/spanner"), type); - assertThat( - (URL) params.getParameter(1), is(equalTo(new URL("https://cloud.google.com/spanner")))); - verifyParameter(params, Value.string("https://cloud.google.com/spanner")); - } - - // types that should lead to bool - for (int type : new int[] {Types.BOOLEAN, Types.BIT}) { - params.setParameter(1, true, type); - assertThat((Boolean) params.getParameter(1), is(equalTo(true))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, (byte) 1, type); - assertThat((Byte) params.getParameter(1), is(equalTo((byte) 1))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, (short) 0, type); - assertThat((Short) params.getParameter(1), is(equalTo((short) 0))); - verifyParameter(params, Value.bool(false)); - params.setParameter(1, 1, type); - assertThat((Integer) params.getParameter(1), is(equalTo(1))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, 1L, type); - assertThat((Long) params.getParameter(1), is(equalTo(1L))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, (float) 1, type); - assertThat((Float) params.getParameter(1), is(equalTo((float) 1))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, (double) 1, type); - assertThat((Double) params.getParameter(1), is(equalTo((double) 1))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, BigDecimal.ZERO, type); - assertThat((BigDecimal) params.getParameter(1), is(equalTo(BigDecimal.ZERO))); - verifyParameter(params, Value.bool(false)); - } - } - - @Test - public void testSetInvalidParameterWithType() throws SQLException, IOException { - JdbcParameterStore params = new JdbcParameterStore(); - - // types that should lead to int64, but with invalid values. - for (int type : new int[] {Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - } - - // types that should lead to float64 - for (int type : new int[] {Types.FLOAT, Types.REAL, Types.DOUBLE}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - } - - // types that should lead to date - for (int type : new int[] {Types.DATE}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - assertInvalidParameter(params, 1, type); - assertInvalidParameter(params, 1L, type); - } - - // types that should lead to timestamp - for (int type : new int[] {Types.TIME, Types.TIMESTAMP}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - assertInvalidParameter(params, 1, type); - assertInvalidParameter(params, 1L, type); - } - - // types that should lead to bytes (except BLOB which is handled separately) - for (int type : new int[] {Types.BINARY, Types.VARBINARY, Types.LONGVARBINARY}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - assertInvalidParameter(params, 1, type); - assertInvalidParameter(params, 1L, type); - assertInvalidParameter(params, new JdbcBlob(), type); - } - - for (int type : - new int[] { - Types.CHAR, - Types.VARCHAR, - Types.LONGVARCHAR, - Types.NCHAR, - Types.NVARCHAR, - Types.LONGNVARCHAR - }) { - assertInvalidParameter(params, new Object(), type); - assertInvalidParameter(params, Boolean.TRUE, type); - assertInvalidParameter(params, 1, type); - assertInvalidParameter(params, 1L, type); - assertInvalidParameter(params, new JdbcBlob(), type); - assertInvalidParameter(params, new JdbcClob(), type); - } - - // types that should lead to bool - for (int type : new int[] {Types.BOOLEAN, Types.BIT}) { - assertInvalidParameter(params, "1", type); - assertInvalidParameter(params, "true", type); - assertInvalidParameter(params, new Object(), type); - } - - assertInvalidParameter(params, BigDecimal.ONE, Types.DECIMAL); - assertInvalidParameter(params, BigDecimal.ZERO, Types.NUMERIC); - - // test setting closed readers and streams. - for (int type : - new int[] { - Types.CHAR, - Types.VARCHAR, - Types.LONGVARCHAR, - Types.NCHAR, - Types.NVARCHAR, - Types.LONGNVARCHAR - }) { - Reader reader = new StringReader("test"); - reader.close(); - params.setParameter(1, reader, type); - verifyParameterBindFails(params); - - InputStream stream = - new InputStream() { - @Override - public int read() throws IOException { - throw new IOException(); - } - }; - params.setParameter(1, stream, type); - verifyParameterBindFails(params); - } - } - - private void assertInvalidParameter(JdbcParameterStore params, Object value, int type) - throws SQLException { - try { - params.setParameter(1, value, type); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - } - - /** - * Tests setting a parameter value without knowing the sql type. The type must be deferred from - * the type of the parameter value - */ - @SuppressWarnings("deprecation") - @Test - public void testSetParameterWithoutType() throws SQLException { - JdbcParameterStore params = new JdbcParameterStore(); - params.setParameter(1, (byte) 1, null); - assertThat((Byte) params.getParameter(1), is(equalTo((byte) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (short) 1, null); - assertThat((Short) params.getParameter(1), is(equalTo((short) 1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1, null); - assertThat((Integer) params.getParameter(1), is(equalTo(1))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, 1L, null); - assertThat((Long) params.getParameter(1), is(equalTo(1L))); - verifyParameter(params, Value.int64(1)); - params.setParameter(1, (float) 1, null); - assertThat((Float) params.getParameter(1), is(equalTo((float) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, (double) 1, null); - assertThat((Double) params.getParameter(1), is(equalTo((double) 1))); - verifyParameter(params, Value.float64(1)); - params.setParameter(1, new Date(1970 - 1900, 0, 1), null); - assertThat((Date) params.getParameter(1), is(equalTo(new Date(1970 - 1900, 0, 1)))); - verifyParameter(params, Value.date(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1))); - params.setParameter(1, new Time(0L), null); - assertThat((Time) params.getParameter(1), is(equalTo(new Time(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new Timestamp(0L), null); - assertThat((Timestamp) params.getParameter(1), is(equalTo(new Timestamp(0L)))); - verifyParameter( - params, Value.timestamp(com.google.cloud.Timestamp.ofTimeSecondsAndNanos(0L, 0))); - params.setParameter(1, new byte[] {1, 2, 3}, null); - assertThat((byte[]) params.getParameter(1), is(equalTo(new byte[] {1, 2, 3}))); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - - params.setParameter(1, new JdbcBlob(new byte[] {1, 2, 3}), null); - assertThat((JdbcBlob) params.getParameter(1), is(equalTo(new JdbcBlob(new byte[] {1, 2, 3})))); - verifyParameter(params, Value.bytes(ByteArray.copyFrom(new byte[] {1, 2, 3}))); - params.setParameter(1, new JdbcClob("test"), null); - assertThat((JdbcClob) params.getParameter(1), is(equalTo(new JdbcClob("test")))); - verifyParameter(params, Value.string("test")); - params.setParameter(1, true, null); - assertThat((Boolean) params.getParameter(1), is(equalTo(true))); - verifyParameter(params, Value.bool(true)); - params.setParameter(1, "test", null); - assertThat((String) params.getParameter(1), is(equalTo("test"))); - verifyParameter(params, Value.string("test")); - params.setParameter(1, new JdbcClob("test"), null); - assertThat((JdbcClob) params.getParameter(1), is(equalTo(new JdbcClob("test")))); - verifyParameter(params, Value.string("test")); - } - - private boolean stringReadersEqual(StringReader r1, StringReader r2) throws IOException { - boolean res = CharStreams.toString(r1).equals(CharStreams.toString(r2)); - r1.reset(); - r2.reset(); - return res; - } - - private boolean asciiStreamsEqual(InputStream is1, InputStream is2) throws IOException { - InputStreamReader r1 = new InputStreamReader(is1, StandardCharsets.US_ASCII); - String s1 = CharStreams.toString(r1); - InputStreamReader r2 = new InputStreamReader(is2, StandardCharsets.US_ASCII); - String s2 = CharStreams.toString(r2); - is1.reset(); - is2.reset(); - return s1.equals(s2); - } - - /** Tests setting array types of parameters */ - @Test - public void testSetArrayParameter() throws SQLException { - JdbcParameterStore params = new JdbcParameterStore(); - params.setParameter( - 1, JdbcArray.createArray("BOOL", new Boolean[] {true, false, true}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("BOOL", new Boolean[] {true, false, true})))); - verifyParameter(params, Value.boolArray(new boolean[] {true, false, true})); - - params.setParameter( - 1, JdbcArray.createArray("BOOL", new Boolean[] {true, false, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("BOOL", new Boolean[] {true, false, null})))); - verifyParameter(params, Value.boolArray(Arrays.asList(true, false, null))); - - params.setParameter(1, JdbcArray.createArray("BOOL", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("BOOL", null)))); - verifyParameter(params, Value.boolArray((boolean[]) null)); - - params.setParameter(1, JdbcArray.createArray("INT64", new Long[] {1L, 2L, 3L}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("INT64", new Long[] {1L, 2L, 3L})))); - verifyParameter(params, Value.int64Array(new long[] {1, 2, 3})); - - params.setParameter(1, JdbcArray.createArray("INT64", new Long[] {1L, 2L, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("INT64", new Long[] {1L, 2L, null})))); - verifyParameter(params, Value.int64Array(Arrays.asList(1L, 2L, null))); - - params.setParameter(1, JdbcArray.createArray("INT64", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("INT64", null)))); - verifyParameter(params, Value.int64Array((long[]) null)); - - params.setParameter( - 1, JdbcArray.createArray("FLOAT64", new Double[] {1D, 2D, 3D}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("FLOAT64", new Double[] {1D, 2D, 3D})))); - verifyParameter(params, Value.float64Array(new double[] {1, 2, 3})); - - params.setParameter( - 1, JdbcArray.createArray("FLOAT64", new Double[] {1D, 2D, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("FLOAT64", new Double[] {1D, 2D, null})))); - verifyParameter(params, Value.float64Array(Arrays.asList(1D, 2D, null))); - - params.setParameter(1, JdbcArray.createArray("FLOAT64", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("FLOAT64", null)))); - verifyParameter(params, Value.float64Array((double[]) null)); - - @SuppressWarnings("deprecation") - Date sqlDate = new Date(2018 - 1900, 12 - 1, 14); - params.setParameter(1, JdbcArray.createArray("DATE", new Date[] {sqlDate}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("DATE", new Date[] {sqlDate})))); - verifyParameter( - params, - Value.dateArray(Arrays.asList(com.google.cloud.Date.fromYearMonthDay(2018, 12, 14)))); - - params.setParameter(1, JdbcArray.createArray("DATE", new Date[] {sqlDate, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("DATE", new Date[] {sqlDate, null})))); - verifyParameter( - params, - Value.dateArray(Arrays.asList(com.google.cloud.Date.fromYearMonthDay(2018, 12, 14), null))); - - params.setParameter(1, JdbcArray.createArray("DATE", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("DATE", null)))); - verifyParameter(params, Value.dateArray(null)); - - Timestamp sqlTimestamp = new Timestamp(System.currentTimeMillis()); - params.setParameter( - 1, JdbcArray.createArray("TIMESTAMP", new Timestamp[] {sqlTimestamp}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("TIMESTAMP", new Timestamp[] {sqlTimestamp})))); - verifyParameter( - params, Value.timestampArray(Arrays.asList(com.google.cloud.Timestamp.of(sqlTimestamp)))); - - params.setParameter( - 1, JdbcArray.createArray("TIMESTAMP", new Timestamp[] {sqlTimestamp, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("TIMESTAMP", new Timestamp[] {sqlTimestamp, null})))); - verifyParameter( - params, - Value.timestampArray(Arrays.asList(com.google.cloud.Timestamp.of(sqlTimestamp), null))); - - params.setParameter(1, JdbcArray.createArray("TIMESTAMP", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("TIMESTAMP", null)))); - verifyParameter(params, Value.timestampArray(null)); - - params.setParameter( - 1, JdbcArray.createArray("BYTES", new byte[][] {{1, 2, 3}, {4, 5, 6}}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("BYTES", new byte[][] {{1, 2, 3}, {4, 5, 6}})))); - verifyParameter( - params, - Value.bytesArray( - Arrays.asList( - ByteArray.copyFrom(new byte[] {1, 2, 3}), - ByteArray.copyFrom(new byte[] {4, 5, 6})))); - - params.setParameter( - 1, JdbcArray.createArray("BYTES", new byte[][] {{1, 2, 3}, {4, 5, 6}, null}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("BYTES", new byte[][] {{1, 2, 3}, {4, 5, 6}, null})))); - verifyParameter( - params, - Value.bytesArray( - Arrays.asList( - ByteArray.copyFrom(new byte[] {1, 2, 3}), - ByteArray.copyFrom(new byte[] {4, 5, 6}), - null))); - - params.setParameter(1, JdbcArray.createArray("BYTES", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("BYTES", null)))); - verifyParameter(params, Value.bytesArray(null)); - - params.setParameter( - 1, JdbcArray.createArray("STRING", new String[] {"test1", "test2", "test3"}), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is(equalTo(JdbcArray.createArray("STRING", new String[] {"test1", "test2", "test3"})))); - verifyParameter(params, Value.stringArray(Arrays.asList("test1", "test2", "test3"))); - - params.setParameter( - 1, - JdbcArray.createArray("STRING", new String[] {"test1", null, "test2", "test3"}), - Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), - is( - equalTo( - JdbcArray.createArray("STRING", new String[] {"test1", null, "test2", "test3"})))); - verifyParameter(params, Value.stringArray(Arrays.asList("test1", null, "test2", "test3"))); - - params.setParameter(1, JdbcArray.createArray("STRING", null), Types.ARRAY); - assertThat( - (JdbcArray) params.getParameter(1), is(equalTo(JdbcArray.createArray("STRING", null)))); - verifyParameter(params, Value.stringArray(null)); - } - - private void verifyParameter(JdbcParameterStore params, Value value) throws SQLException { - Statement.Builder builder = Statement.newBuilder("SELECT * FROM FOO WHERE BAR=:p1"); - params.bindParameterValue(builder.bind("p1"), 1); - assertThat(builder.build().getParameters().get("p1"), is(equalTo(value))); - } - - private void verifyParameterBindFails(JdbcParameterStore params) throws SQLException { - Statement.Builder builder = Statement.newBuilder("SELECT * FROM FOO WHERE BAR=:p1"); - try { - params.bindParameterValue(builder.bind("p1"), 1); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.INVALID_ARGUMENT))); - } - } - - @Test - public void testConvertPositionalParametersToNamedParameters() throws SQLException { - assertThat( - convertPositionalParametersToNamedParameters("select * from foo where name=?") - .sqlWithNamedParameters, - is(equalTo("select * from foo where name=@p1"))); - assertThat( - convertPositionalParametersToNamedParameters("?'?test?\"?test?\"?'?") - .sqlWithNamedParameters, - is(equalTo("@p1'?test?\"?test?\"?'@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?'?it\\'?s'?").sqlWithNamedParameters, - is(equalTo("@p1'?it\\'?s'@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?'?it\\\"?s'?").sqlWithNamedParameters, - is(equalTo("@p1'?it\\\"?s'@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?\"?it\\\"?s\"?").sqlWithNamedParameters, - is(equalTo("@p1\"?it\\\"?s\"@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?`?it\\`?s`?").sqlWithNamedParameters, - is(equalTo("@p1`?it\\`?s`@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?'''?it\\'?s'''?").sqlWithNamedParameters, - is(equalTo("@p1'''?it\\'?s'''@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?\"\"\"?it\\\"?s\"\"\"?") - .sqlWithNamedParameters, - is(equalTo("@p1\"\"\"?it\\\"?s\"\"\"@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?```?it\\`?s```?").sqlWithNamedParameters, - is(equalTo("@p1```?it\\`?s```@p2"))); - assertThat( - convertPositionalParametersToNamedParameters("?'''?it\\'?s \n ?it\\'?s'''?") - .sqlWithNamedParameters, - is(equalTo("@p1'''?it\\'?s \n ?it\\'?s'''@p2"))); - - assertUnclosedLiteral("?'?it\\'?s \n ?it\\'?s'?"); - assertUnclosedLiteral("?'?it\\'?s \n ?it\\'?s?"); - assertUnclosedLiteral("?'''?it\\'?s \n ?it\\'?s'?"); - - assertThat( - convertPositionalParametersToNamedParameters( - "select 1, ?, 'test?test', \"test?test\", foo.* from `foo` where col1=? and col2='test' and col3=? and col4='?' and col5=\"?\" and col6='?''?''?'") - .sqlWithNamedParameters, - is( - equalTo( - "select 1, @p1, 'test?test', \"test?test\", foo.* from `foo` where col1=@p2 and col2='test' and col3=@p3 and col4='?' and col5=\"?\" and col6='?''?''?'"))); - - assertThat( - convertPositionalParametersToNamedParameters( - "select * " + "from foo " + "where name=? " + "and col2 like ? " + "and col3 > ?") - .sqlWithNamedParameters, - is( - equalTo( - "select * " - + "from foo " - + "where name=@p1 " - + "and col2 like @p2 " - + "and col3 > @p3"))); - assertThat( - convertPositionalParametersToNamedParameters( - "select * " + "from foo " + "where id between ? and ?") - .sqlWithNamedParameters, - is(equalTo("select * " + "from foo " + "where id between @p1 and @p2"))); - assertThat( - convertPositionalParametersToNamedParameters("select * " + "from foo " + "limit ? offset ?") - .sqlWithNamedParameters, - is(equalTo("select * " + "from foo " + "limit @p1 offset @p2"))); - assertThat( - convertPositionalParametersToNamedParameters( - "select * " - + "from foo " - + "where col1=? " - + "and col2 like ? " - + "and col3 > ? " - + "and col4 < ? " - + "and col5 != ? " - + "and col6 not in (?, ?, ?) " - + "and col7 in (?, ?, ?) " - + "and col8 between ? and ?") - .sqlWithNamedParameters, - is( - equalTo( - "select * " - + "from foo " - + "where col1=@p1 " - + "and col2 like @p2 " - + "and col3 > @p3 " - + "and col4 < @p4 " - + "and col5 != @p5 " - + "and col6 not in (@p6, @p7, @p8) " - + "and col7 in (@p9, @p10, @p11) " - + "and col8 between @p12 and @p13"))); - } - - private void assertUnclosedLiteral(String sql) { - boolean exception = false; - try { - convertPositionalParametersToNamedParameters(sql); - } catch (SQLException t) { - assertThat(t instanceof JdbcSqlException, is(true)); - JdbcSqlException e = (JdbcSqlException) t; - assertThat(e.getCode(), is(Code.INVALID_ARGUMENT)); - assertThat( - e.getMessage(), - startsWith( - Code.INVALID_ARGUMENT.name() - + ": SQL statement contains an unclosed literal: " - + sql)); - exception = true; - } - assertThat(exception, is(true)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatementTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatementTest.java deleted file mode 100644 index bbfded162f6..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcPreparedStatementTest.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.rpc.Code; -import java.io.ByteArrayInputStream; -import java.io.StringReader; -import java.math.BigDecimal; -import java.net.MalformedURLException; -import java.net.URL; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.Ref; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLXML; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.Arrays; -import java.util.Calendar; -import java.util.TimeZone; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcPreparedStatementTest { - @Rule public final ExpectedException thrown = ExpectedException.none(); - - private String generateSqlWithParameters(int numberOfParams) { - StringBuilder sql = new StringBuilder("INSERT INTO FOO ("); - boolean first = true; - for (int i = 0; i < numberOfParams; i++) { - if (first) { - first = false; - } else { - sql.append(", "); - } - sql.append("COL").append(i); - } - sql.append(") VALUES ("); - first = true; - for (int i = 0; i < numberOfParams; i++) { - if (first) { - first = false; - } else { - sql.append(", "); - } - sql.append("?"); - } - sql.append(")"); - return sql.toString(); - } - - private JdbcConnection createMockConnection() throws SQLException { - return createMockConnection(mock(Connection.class)); - } - - private JdbcConnection createMockConnection(Connection spanner) throws SQLException { - JdbcConnection connection = mock(JdbcConnection.class); - when(connection.getSpannerConnection()).thenReturn(spanner); - when(connection.createBlob()).thenCallRealMethod(); - when(connection.createClob()).thenCallRealMethod(); - when(connection.createNClob()).thenCallRealMethod(); - when(connection.createArrayOf(anyString(), any(Object[].class))).thenCallRealMethod(); - - return connection; - } - - @Test - public void testParameters() throws SQLException, MalformedURLException { - final int numberOfParams = 48; - String sql = generateSqlWithParameters(numberOfParams); - - JdbcConnection connection = createMockConnection(); - try (JdbcPreparedStatement ps = new JdbcPreparedStatement(connection, sql)) { - ps.setArray(1, connection.createArrayOf("INT64", new Long[] {1L, 2L, 3L})); - ps.setAsciiStream(2, new ByteArrayInputStream("TEST".getBytes())); - ps.setAsciiStream(3, new ByteArrayInputStream("TEST".getBytes()), 4); - ps.setAsciiStream(4, new ByteArrayInputStream("TEST".getBytes()), 4l); - ps.setBinaryStream(6, new ByteArrayInputStream("TEST".getBytes())); - ps.setBinaryStream(7, new ByteArrayInputStream("TEST".getBytes()), 4); - ps.setBinaryStream(8, new ByteArrayInputStream("TEST".getBytes()), 4l); - ps.setBlob(9, connection.createBlob()); - ps.setBlob(10, new ByteArrayInputStream("TEST".getBytes())); - ps.setBlob(11, new ByteArrayInputStream("TEST".getBytes()), 4l); - ps.setBoolean(12, Boolean.TRUE); - ps.setByte(13, (byte) 1); - ps.setBytes(14, "TEST".getBytes()); - ps.setCharacterStream(15, new StringReader("TEST")); - ps.setCharacterStream(16, new StringReader("TEST"), 4); - ps.setCharacterStream(17, new StringReader("TEST"), 4l); - ps.setClob(18, connection.createClob()); - ps.setClob(19, new StringReader("TEST")); - ps.setClob(20, new StringReader("TEST"), 4l); - ps.setDate(21, new Date(1000l)); - ps.setDate(22, new Date(1000l), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); - ps.setDouble(23, 1d); - ps.setFloat(24, 1f); - ps.setInt(25, 1); - ps.setLong(26, 1l); - ps.setNCharacterStream(27, new StringReader("TEST")); - ps.setNCharacterStream(28, new StringReader("TEST"), 4l); - ps.setNClob(29, connection.createNClob()); - ps.setNClob(30, new StringReader("TEST")); - ps.setNClob(31, new StringReader("TEST"), 4l); - ps.setNString(32, "TEST"); - ps.setNull(33, Types.BIGINT); - ps.setNull(34, Types.BIGINT, "INT64"); - ps.setObject(35, "TEST"); - ps.setObject(36, "TEST", Types.NVARCHAR); - ps.setObject(37, "TEST", Types.NVARCHAR, 20); - ps.setShort(40, (short) 1); - ps.setString(42, "TEST"); - ps.setTime(43, new Time(1000l)); - ps.setTime(44, new Time(1000l), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); - ps.setTimestamp(45, new Timestamp(1000l)); - ps.setTimestamp(46, new Timestamp(1000l), Calendar.getInstance(TimeZone.getTimeZone("GMT"))); - ps.setUnicodeStream(47, new ByteArrayInputStream("TEST".getBytes()), 4); - ps.setURL(48, new URL("https://spanner.google.com")); - - testSetUnsupportedTypes(ps); - - JdbcParameterMetaData pmd = ps.getParameterMetaData(); - Assert.assertEquals(numberOfParams, pmd.getParameterCount()); - Assert.assertEquals(JdbcArray.class.getName(), pmd.getParameterClassName(1)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(2)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(3)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(4)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(6)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(7)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(8)); - Assert.assertEquals(JdbcBlob.class.getName(), pmd.getParameterClassName(9)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(10)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(11)); - Assert.assertEquals(Boolean.class.getName(), pmd.getParameterClassName(12)); - Assert.assertEquals(Byte.class.getName(), pmd.getParameterClassName(13)); - Assert.assertEquals(byte[].class.getName(), pmd.getParameterClassName(14)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(15)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(16)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(17)); - Assert.assertEquals(JdbcClob.class.getName(), pmd.getParameterClassName(18)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(19)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(20)); - Assert.assertEquals(Date.class.getName(), pmd.getParameterClassName(21)); - Assert.assertEquals(Date.class.getName(), pmd.getParameterClassName(22)); - Assert.assertEquals(Double.class.getName(), pmd.getParameterClassName(23)); - Assert.assertEquals(Float.class.getName(), pmd.getParameterClassName(24)); - Assert.assertEquals(Integer.class.getName(), pmd.getParameterClassName(25)); - Assert.assertEquals(Long.class.getName(), pmd.getParameterClassName(26)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(27)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(28)); - Assert.assertEquals(JdbcClob.class.getName(), pmd.getParameterClassName(29)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(30)); - Assert.assertEquals(StringReader.class.getName(), pmd.getParameterClassName(31)); - Assert.assertEquals(String.class.getName(), pmd.getParameterClassName(32)); - Assert.assertEquals(Long.class.getName(), pmd.getParameterClassName(33)); - Assert.assertEquals(Long.class.getName(), pmd.getParameterClassName(34)); - Assert.assertEquals(String.class.getName(), pmd.getParameterClassName(35)); - Assert.assertEquals(String.class.getName(), pmd.getParameterClassName(36)); - Assert.assertEquals(String.class.getName(), pmd.getParameterClassName(37)); - Assert.assertNull(pmd.getParameterClassName(38)); - Assert.assertNull(pmd.getParameterClassName(39)); - Assert.assertEquals(Short.class.getName(), pmd.getParameterClassName(40)); - Assert.assertNull(pmd.getParameterClassName(41)); - Assert.assertEquals(String.class.getName(), pmd.getParameterClassName(42)); - Assert.assertEquals(Time.class.getName(), pmd.getParameterClassName(43)); - Assert.assertEquals(Time.class.getName(), pmd.getParameterClassName(44)); - Assert.assertEquals(Timestamp.class.getName(), pmd.getParameterClassName(45)); - Assert.assertEquals(Timestamp.class.getName(), pmd.getParameterClassName(46)); - Assert.assertEquals(ByteArrayInputStream.class.getName(), pmd.getParameterClassName(47)); - Assert.assertEquals(URL.class.getName(), pmd.getParameterClassName(48)); - - ps.clearParameters(); - pmd = ps.getParameterMetaData(); - Assert.assertEquals(numberOfParams, pmd.getParameterCount()); - } - } - - private void testSetUnsupportedTypes(PreparedStatement ps) { - // TODO: Rewrite these tests using functional interfaces when Java8 is available. - boolean expectedException = false; - try { - ps.setBigDecimal(5, BigDecimal.valueOf(1l)); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - expectedException = ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT; - } - } - assertThat(expectedException, is(true)); - expectedException = false; - try { - ps.setRef(38, (Ref) null); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - expectedException = ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT; - } - } - assertThat(expectedException, is(true)); - expectedException = false; - try { - ps.setRowId(39, (RowId) null); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - expectedException = ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT; - } - } - assertThat(expectedException, is(true)); - expectedException = false; - try { - ps.setSQLXML(41, (SQLXML) null); - } catch (SQLException e) { - if (e instanceof JdbcSqlException) { - expectedException = ((JdbcSqlException) e).getCode() == Code.INVALID_ARGUMENT; - } - } - assertThat(expectedException, is(true)); - } - - @Test - public void testSetNullValues() throws SQLException { - String sql = generateSqlWithParameters(27); - try (JdbcPreparedStatement ps = new JdbcPreparedStatement(createMockConnection(), sql)) { - ps.setNull(1, Types.BLOB); - ps.setNull(2, Types.NVARCHAR); - ps.setNull(4, Types.BINARY); - ps.setNull(5, Types.BOOLEAN); - ps.setNull(6, Types.TINYINT); - ps.setNull(7, Types.DATE); - ps.setNull(8, Types.DOUBLE); - ps.setNull(9, Types.FLOAT); - ps.setNull(10, Types.INTEGER); - ps.setNull(11, Types.BIGINT); - ps.setNull(12, Types.SMALLINT); - ps.setNull(13, Types.TIME); - ps.setNull(14, Types.TIMESTAMP); - ps.setNull(15, Types.CHAR); - ps.setNull(16, Types.CLOB); - ps.setNull(17, Types.LONGNVARCHAR); - ps.setNull(18, Types.LONGVARBINARY); - ps.setNull(19, Types.LONGVARCHAR); - ps.setNull(20, Types.NCHAR); - ps.setNull(21, Types.NCLOB); - ps.setNull(23, Types.NVARCHAR); - ps.setNull(24, Types.REAL); - ps.setNull(25, Types.BIT); - ps.setNull(26, Types.VARBINARY); - ps.setNull(27, Types.VARCHAR); - - JdbcParameterMetaData pmd = ps.getParameterMetaData(); - Assert.assertEquals(27, pmd.getParameterCount()); - Assert.assertEquals(Timestamp.class.getName(), pmd.getParameterClassName(14)); - - ps.clearParameters(); - pmd = ps.getParameterMetaData(); - Assert.assertEquals(27, pmd.getParameterCount()); - } - } - - @Test - public void testGetResultSetMetadata() throws SQLException { - final String sql = "SELECT * FROM FOO"; - Connection connection = mock(Connection.class); - ResultSet rs = - ResultSets.forRows( - Type.struct( - StructField.of("ID", Type.int64()), - StructField.of("NAME", Type.string()), - StructField.of("AMOUNT", Type.float64())), - Arrays.asList( - Struct.newBuilder() - .set("ID") - .to(1L) - .set("NAME") - .to("foo") - .set("AMOUNT") - .to(Math.PI) - .build())); - when(connection.executeQuery(Statement.of(sql))).thenReturn(rs); - try (JdbcPreparedStatement ps = - new JdbcPreparedStatement(createMockConnection(connection), sql)) { - ResultSetMetaData metadata = ps.getMetaData(); - assertThat(metadata.getColumnCount(), is(equalTo(3))); - assertThat(metadata.getColumnLabel(1), is(equalTo("ID"))); - assertThat(metadata.getColumnLabel(2), is(equalTo("NAME"))); - assertThat(metadata.getColumnLabel(3), is(equalTo("AMOUNT"))); - assertThat(metadata.getColumnType(1), is(equalTo(Types.BIGINT))); - assertThat(metadata.getColumnType(2), is(equalTo(Types.NVARCHAR))); - assertThat(metadata.getColumnType(3), is(equalTo(Types.DOUBLE))); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaDataTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaDataTest.java deleted file mode 100644 index e97382d0a0b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetMetaDataTest.java +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.ByteArray; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.Code; -import com.google.cloud.spanner.Type.StructField; -import com.google.cloud.spanner.Value; -import com.google.common.base.Preconditions; -import java.sql.Date; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.internal.stubbing.answers.Returns; - -@RunWith(JUnit4.class) -public class JdbcResultSetMetaDataTest { - private JdbcResultSetMetaData subject; - private java.sql.Connection connection; - - private static class TestColumn { - private final Type type; - private final String name; - private final int defaultSize; - private final boolean calculated; - - private TestColumn(Type type, String name, Integer nulls, int size, boolean calculated) { - Preconditions.checkNotNull(type); - Preconditions.checkNotNull(name); - Preconditions.checkNotNull(nulls); - this.type = type; - this.name = name; - this.defaultSize = getDefaultSize(type); - this.calculated = calculated; - } - - private static int getDefaultSize(Type type) { - if (type == Type.bool()) return 1; - if (type == Type.date()) return 10; - if (type == Type.float64()) return 14; - if (type == Type.int64()) return 10; - if (type == Type.timestamp()) return 24; - if (type == Type.string()) return 50; - if (type == Type.bytes()) return 50; - return 50; - } - - private boolean isTableColumn() { - return !calculated; - } - - private static class Builder { - private Type type; - private String name; - private Integer nulls; - private int size = 0; - private boolean calculated = false; - - public static Builder getBuilder() { - return new Builder(); - } - - private TestColumn build() { - return new TestColumn(type, name, nulls, size, calculated); - } - - private Builder withType(Type type) { - this.type = type; - return this; - } - - private Builder withName(String name) { - this.name = name; - return this; - } - - private Builder withNotNull() { - this.nulls = ResultSetMetaData.columnNoNulls; - return this; - } - - private Builder withNullable() { - this.nulls = ResultSetMetaData.columnNullable; - return this; - } - - private Builder withNullableUnknown() { - this.nulls = ResultSetMetaData.columnNullableUnknown; - return this; - } - - private Builder withSize(int size) { - this.size = size; - return this; - } - - private Builder withCalculated(boolean calculated) { - this.calculated = calculated; - return this; - } - } - } - - private static final List TEST_COLUMNS = createTestColumns(); - - @Before - public void setup() throws SQLException { - connection = mock(java.sql.Connection.class); - Statement statement = mock(Statement.class); - JdbcResultSet resultSet = getFooTestResultSet(statement); - when(connection.getSchema()).thenReturn(""); - when(connection.getCatalog()).thenReturn("test-database"); - when(statement.getConnection()).then(new Returns(connection)); - - subject = resultSet.getMetaData(); - } - - private static List createTestColumns() { - List res = new ArrayList<>(); - int index = 1; - for (Type type : getAllTypes()) { - TestColumn.Builder builder = TestColumn.Builder.getBuilder(); - builder.withName("COL" + index).withType(type).withSize(getDefaultSize(type)); - if (index % 2 == 1) builder.withNotNull(); - else builder.withNullable(); - res.add(builder.build()); - index++; - } - TestColumn.Builder builder = TestColumn.Builder.getBuilder(); - builder - .withName("CALCULATED") - .withType(Type.int64()) - .withNullableUnknown() - .withCalculated(true); - res.add(builder.build()); - return res; - } - - private static int getDefaultSize(Type type) { - if (type == Type.string()) return 100; - return 0; - } - - private static List getAllTypes() { - List types = new ArrayList<>(); - types.add(Type.bool()); - types.add(Type.bytes()); - types.add(Type.date()); - types.add(Type.float64()); - types.add(Type.int64()); - types.add(Type.string()); - types.add(Type.timestamp()); - List arrayTypes = new ArrayList<>(); - for (Type type : types) { - arrayTypes.add(Type.array(type)); - } - types.addAll(arrayTypes); - - return types; - } - - private JdbcResultSet getFooTestResultSet(Statement statement) throws SQLException { - List rows = new ArrayList<>(4); - for (int row = 1; row <= 4; row++) { - Struct.Builder builder = Struct.newBuilder(); - for (TestColumn col : TEST_COLUMNS) { - builder.set(col.name).to(getDefaultValue(col.type, row)); - } - rows.add(builder.build()); - } - StructField[] fields = new StructField[TEST_COLUMNS.size()]; - int index = 0; - for (TestColumn col : TEST_COLUMNS) { - fields[index] = StructField.of(col.name, col.type); - index++; - } - - ResultSet rs = ResultSets.forRows(Type.struct(fields), rows); - return JdbcResultSet.of(statement, rs); - } - - private Value getDefaultValue(Type type, int row) { - if (type == Type.bool()) return Value.bool(Boolean.TRUE); - if (type == Type.bytes()) return Value.bytes(ByteArray.copyFrom("test byte array " + row)); - if (type == Type.date()) return Value.date(com.google.cloud.Date.fromYearMonthDay(2018, 4, 1)); - if (type == Type.float64()) return Value.float64(123.45D); - if (type == Type.int64()) return Value.int64(12345L); - if (type == Type.string()) return Value.string("test value " + row); - if (type == Type.timestamp()) return Value.timestamp(com.google.cloud.Timestamp.now()); - - if (type.getCode() == Code.ARRAY) { - if (type.getArrayElementType() == Type.bool()) - return Value.boolArray(Arrays.asList(Boolean.TRUE, Boolean.FALSE)); - if (type.getArrayElementType() == Type.bytes()) - return Value.bytesArray( - Arrays.asList( - ByteArray.copyFrom("test byte array " + row), - ByteArray.copyFrom("test byte array " + row))); - if (type.getArrayElementType() == Type.date()) - return Value.dateArray( - Arrays.asList( - com.google.cloud.Date.fromYearMonthDay(2018, 4, 1), - com.google.cloud.Date.fromYearMonthDay(2018, 4, 2))); - if (type.getArrayElementType() == Type.float64()) - return Value.float64Array(Arrays.asList(123.45D, 543.21D)); - if (type.getArrayElementType() == Type.int64()) - return Value.int64Array(Arrays.asList(12345L, 54321L)); - if (type.getArrayElementType() == Type.string()) - return Value.stringArray(Arrays.asList("test value " + row, "test value " + row)); - if (type.getArrayElementType() == Type.timestamp()) - return Value.timestampArray( - Arrays.asList(com.google.cloud.Timestamp.now(), com.google.cloud.Timestamp.now())); - } - return null; - } - - @Test - public void testGetColumnCount() throws SQLException { - assertEquals(TEST_COLUMNS.size(), subject.getColumnCount()); - } - - @Test - public void testIsAutoIncrement() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(false, subject.isAutoIncrement(i)); - } - } - - @Test - public void testIsCaseSensitive() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - Type type = TEST_COLUMNS.get(i - 1).type; - assertEquals(type == Type.string() || type == Type.bytes(), subject.isCaseSensitive(i)); - } - } - - @Test - public void testIsSearchable() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(true, subject.isSearchable(i)); - } - } - - @Test - public void testIsCurrency() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(false, subject.isCurrency(i)); - } - } - - @Test - public void testIsNullable() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(ResultSetMetaData.columnNullableUnknown, subject.isNullable(i)); - } - } - - @Test - public void testIsSigned() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - Type type = TEST_COLUMNS.get(i - 1).type; - if (type == Type.int64() || type == Type.float64()) { - assertTrue(subject.isSigned(i)); - } else { - assertFalse(subject.isSigned(i)); - } - } - } - - @Test - public void testGetColumnDisplaySize() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals( - getDefaultDisplaySize(TEST_COLUMNS.get(i - 1).type, i), subject.getColumnDisplaySize(i)); - } - } - - private int getDefaultDisplaySize(Type type, int column) throws SQLException { - if (type.getCode() == Code.ARRAY) return 50; - if (type == Type.bool()) return 5; - if (type == Type.bytes()) return 50; - if (type == Type.date()) return 10; - if (type == Type.float64()) return 14; - if (type == Type.int64()) return 10; - if (type == Type.string()) { - int length = subject.getPrecision(column); - return length == 0 ? 50 : length; - } - if (type == Type.timestamp()) return 16; - return 10; - } - - @Test - public void testGetColumnLabel() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(TEST_COLUMNS.get(i - 1).name, subject.getColumnLabel(i)); - } - } - - @Test - public void testGetColumnName() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(TEST_COLUMNS.get(i - 1).name, subject.getColumnName(i)); - } - } - - @Test - public void testGetSchemaName() throws SQLException { - assertEquals("", subject.getSchemaName(1)); - } - - @Test - public void testGetPrecision() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(getPrecision(TEST_COLUMNS.get(i - 1)), subject.getPrecision(i)); - } - } - - private int getPrecision(TestColumn col) { - if (col.type == Type.bool()) return 1; - if (col.type == Type.date()) return 10; - if (col.type == Type.float64()) return 14; - if (col.type == Type.int64()) return 10; - if (col.type == Type.timestamp()) return 24; - if (col.isTableColumn()) return col.defaultSize; - return 50; - } - - @Test - public void testGetScale() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(getScale(TEST_COLUMNS.get(i - 1)), subject.getScale(i)); - } - } - - private int getScale(TestColumn col) { - if (col.type == Type.float64()) return 15; - return 0; - } - - @Test - public void testGetTableName() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals("", subject.getTableName(i)); - } - } - - @Test - public void testGetCatalogName() throws SQLException { - assertEquals("test-database", subject.getCatalogName(1)); - } - - @Test - public void testGetColumnType() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(getSqlType(TEST_COLUMNS.get(i - 1).type), subject.getColumnType(i)); - } - } - - private int getSqlType(Type type) { - if (type == Type.bool()) return Types.BOOLEAN; - if (type == Type.bytes()) return Types.BINARY; - if (type == Type.date()) return Types.DATE; - if (type == Type.float64()) return Types.DOUBLE; - if (type == Type.int64()) return Types.BIGINT; - if (type == Type.string()) return Types.NVARCHAR; - if (type == Type.timestamp()) return Types.TIMESTAMP; - if (type.getCode() == Code.ARRAY) return Types.ARRAY; - return Types.OTHER; - } - - @Test - public void getColumnTypeName() throws SQLException { - int index = 1; - for (TestColumn col : TEST_COLUMNS) { - assertEquals(col.type.getCode().name(), subject.getColumnTypeName(index)); - index++; - } - } - - @Test - public void testIsReadOnly() throws SQLException { - for (int i = 0; i < TEST_COLUMNS.size(); i++) { - assertFalse(subject.isReadOnly(i)); - } - } - - @Test - public void testIsWritable() throws SQLException { - for (int i = 0; i < TEST_COLUMNS.size(); i++) { - assertTrue(subject.isWritable(i)); - } - } - - @Test - public void testIsDefinitelyWritable() throws SQLException { - for (int i = 0; i < TEST_COLUMNS.size(); i++) { - assertFalse(subject.isDefinitelyWritable(i)); - } - } - - @Test - public void testGetColumnClassName() throws SQLException { - for (int i = 1; i <= TEST_COLUMNS.size(); i++) { - assertEquals(getTypeClassName(TEST_COLUMNS.get(i - 1).type), subject.getColumnClassName(i)); - } - } - - private String getTypeClassName(Type type) { - if (type == Type.bool()) return Boolean.class.getName(); - if (type == Type.bytes()) return byte[].class.getName(); - if (type == Type.date()) return Date.class.getName(); - if (type == Type.float64()) return Double.class.getName(); - if (type == Type.int64()) return Long.class.getName(); - if (type == Type.string()) return String.class.getName(); - if (type == Type.timestamp()) return Timestamp.class.getName(); - if (type.getCode() == Code.ARRAY) { - if (type.getArrayElementType() == Type.bool()) return Boolean[].class.getName(); - if (type.getArrayElementType() == Type.bytes()) return byte[][].class.getName(); - if (type.getArrayElementType() == Type.date()) return Date[].class.getName(); - if (type.getArrayElementType() == Type.float64()) return Double[].class.getName(); - if (type.getArrayElementType() == Type.int64()) return Long[].class.getName(); - if (type.getArrayElementType() == Type.string()) return String[].class.getName(); - if (type.getArrayElementType() == Type.timestamp()) return Timestamp[].class.getName(); - } - return null; - } - - private static final String EXPECTED_TO_STRING = - "Col 1: COL1 BOOL\n" - + "Col 2: COL2 BYTES\n" - + "Col 3: COL3 DATE\n" - + "Col 4: COL4 FLOAT64\n" - + "Col 5: COL5 INT64\n" - + "Col 6: COL6 STRING\n" - + "Col 7: COL7 TIMESTAMP\n" - + "Col 8: COL8 ARRAY\n" - + "Col 9: COL9 ARRAY\n" - + "Col 10: COL10 ARRAY\n" - + "Col 11: COL11 ARRAY\n" - + "Col 12: COL12 ARRAY\n" - + "Col 13: COL13 ARRAY\n" - + "Col 14: COL14 ARRAY\n" - + "Col 15: CALCULATED INT64\n"; - - @Test - public void testToString() { - assertEquals(subject.toString(), EXPECTED_TO_STRING); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetTest.java deleted file mode 100644 index d564ad0f2a1..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcResultSetTest.java +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -import com.google.cloud.ByteArray; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Time; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcResultSetTest { - private static final String UNKNOWN_COLUMN = "UNKNOWN_COLUMN"; - private static final String STRING_COL_NULL = "STRING_COL_NULL"; - private static final String STRING_COL_NOT_NULL = "STRING_COL_NOT_NULL"; - private static final String STRING_VALUE = "FOO"; - private static final int STRING_COLINDEX_NULL = 1; - private static final int STRING_COLINDEX_NOTNULL = 2; - private static final String BOOLEAN_COL_NULL = "BOOLEAN_COL_NULL"; - private static final String BOOLEAN_COL_NOT_NULL = "BOOLEAN_COL_NOT_NULL"; - private static final boolean BOOLEAN_VALUE = true; - private static final int BOOLEAN_COLINDEX_NULL = 3; - private static final int BOOLEAN_COLINDEX_NOTNULL = 4; - private static final String DOUBLE_COL_NULL = "DOUBLE_COL_NULL"; - private static final String DOUBLE_COL_NOT_NULL = "DOUBLE_COL_NOT_NULL"; - private static final double DOUBLE_VALUE = 3.14159265359D; - private static final int DOUBLE_COLINDEX_NULL = 5; - private static final int DOUBLE_COLINDEX_NOTNULL = 6; - private static final String BYTES_COL_NULL = "BYTES_COL_NULL"; - private static final String BYTES_COL_NOT_NULL = "BYTES_COL_NOT_NULL"; - private static final ByteArray BYTES_VALUE = ByteArray.copyFrom("FOO"); - private static final int BYTES_COLINDEX_NULL = 7; - private static final int BYTES_COLINDEX_NOTNULL = 8; - private static final String LONG_COL_NULL = "LONG_COL_NULL"; - private static final String LONG_COL_NOT_NULL = "LONG_COL_NOT_NULL"; - private static final long LONG_VALUE = 1L; - private static final int LONG_COLINDEX_NULL = 9; - private static final int LONG_COLINDEX_NOTNULL = 10; - private static final String DATE_COL_NULL = "DATE_COL_NULL"; - private static final String DATE_COL_NOT_NULL = "DATE_COL_NOT_NULL"; - private static final Date DATE_VALUE = Date.fromYearMonthDay(2019, 1, 18); - private static final int DATE_COLINDEX_NULL = 11; - private static final int DATE_COLINDEX_NOTNULL = 12; - private static final String TIMESTAMP_COL_NULL = "TIMESTAMP_COL_NULL"; - private static final String TIMESTAMP_COL_NOT_NULL = "TIMESTAMP_COL_NOT_NULL"; - private static final Timestamp TIMESTAMP_VALUE = - Timestamp.parseTimestamp("2019-01-18T10:00:01.1213Z"); - private static final int TIMESTAMP_COLINDEX_NULL = 13; - private static final int TIMESTAMP_COLINDEX_NOTNULL = 14; - private static final String TIME_COL_NULL = "TIME_COL_NULL"; - private static final String TIME_COL_NOT_NULL = "TIME_COL_NOT_NULL"; - private static final Timestamp TIME_VALUE = Timestamp.parseTimestamp("1970-01-01T10:01:02.995Z"); - private static final int TIME_COLINDEX_NULL = 15; - private static final int TIME_COLINDEX_NOTNULL = 16; - private static final String ARRAY_COL_NULL = "ARRAY_COL_NULL"; - private static final String ARRAY_COL_NOT_NULL = "ARRAY_COL_NOT_NULL"; - private static final long[] ARRAY_VALUE = new long[] {1L, 2L, 3L}; - private static final int ARRAY_COLINDEX_NULL = 17; - private static final int ARRAY_COLINDEX_NOTNULL = 18; - private static final String URL_COL_NULL = "URL_COL_NULL"; - private static final String URL_COL_NOT_NULL = "URL_COL_NOT_NULL"; - private static final String URL_VALUE = "https://cloud.google.com/spanner/docs/apis"; - private static final int URL_COLINDEX_NULL = 19; - private static final int URL_COLINDEX_NOTNULL = 20; - - @Rule public ExpectedException thrown = ExpectedException.none(); - - private JdbcResultSet subject; - - static ResultSet getMockResultSet() { - return ResultSets.forRows( - Type.struct( - StructField.of(STRING_COL_NULL, Type.string()), - StructField.of(STRING_COL_NOT_NULL, Type.string()), - StructField.of(BOOLEAN_COL_NULL, Type.bool()), - StructField.of(BOOLEAN_COL_NOT_NULL, Type.bool()), - StructField.of(DOUBLE_COL_NULL, Type.float64()), - StructField.of(DOUBLE_COL_NOT_NULL, Type.float64()), - StructField.of(BYTES_COL_NULL, Type.bytes()), - StructField.of(BYTES_COL_NOT_NULL, Type.bytes()), - StructField.of(LONG_COL_NULL, Type.int64()), - StructField.of(LONG_COL_NOT_NULL, Type.int64()), - StructField.of(DATE_COL_NULL, Type.date()), - StructField.of(DATE_COL_NOT_NULL, Type.date()), - StructField.of(TIMESTAMP_COL_NULL, Type.timestamp()), - StructField.of(TIMESTAMP_COL_NOT_NULL, Type.timestamp()), - StructField.of(TIME_COL_NULL, Type.timestamp()), - StructField.of(TIME_COL_NOT_NULL, Type.timestamp()), - StructField.of(ARRAY_COL_NULL, Type.array(Type.int64())), - StructField.of(ARRAY_COL_NOT_NULL, Type.array(Type.int64())), - StructField.of(URL_COL_NULL, Type.string()), - StructField.of(URL_COL_NOT_NULL, Type.string())), - Arrays.asList( - Struct.newBuilder() - .set(STRING_COL_NULL) - .to((String) null) - .set(STRING_COL_NOT_NULL) - .to(STRING_VALUE) - .set(BOOLEAN_COL_NULL) - .to((Boolean) null) - .set(BOOLEAN_COL_NOT_NULL) - .to(BOOLEAN_VALUE) - .set(DOUBLE_COL_NULL) - .to((Double) null) - .set(DOUBLE_COL_NOT_NULL) - .to(DOUBLE_VALUE) - .set(BYTES_COL_NULL) - .to((ByteArray) null) - .set(BYTES_COL_NOT_NULL) - .to(BYTES_VALUE) - .set(LONG_COL_NULL) - .to((Long) null) - .set(LONG_COL_NOT_NULL) - .to(LONG_VALUE) - .set(DATE_COL_NULL) - .to((Date) null) - .set(DATE_COL_NOT_NULL) - .to(DATE_VALUE) - .set(TIMESTAMP_COL_NULL) - .to((Timestamp) null) - .set(TIMESTAMP_COL_NOT_NULL) - .to(TIMESTAMP_VALUE) - .set(TIME_COL_NULL) - .to((Timestamp) null) - .set(TIME_COL_NOT_NULL) - .to(TIME_VALUE) - .set(ARRAY_COL_NULL) - .toInt64Array((long[]) null) - .set(ARRAY_COL_NOT_NULL) - .toInt64Array(ARRAY_VALUE) - .set(URL_COL_NULL) - .to((String) null) - .set(URL_COL_NOT_NULL) - .to(URL_VALUE) - .build())); - } - - public JdbcResultSetTest() throws SQLException { - subject = JdbcResultSet.of(mock(Statement.class), getMockResultSet()); - subject.next(); - } - - @Test - public void testWasNull() throws SQLException { - String value = subject.getString(STRING_COL_NULL); - boolean wasNull = subject.wasNull(); - assertTrue(wasNull); - assertNull(value); - String valueNotNull = subject.getString(STRING_COL_NOT_NULL); - boolean wasNotNull = subject.wasNull(); - assertFalse(wasNotNull); - assertNotNull(valueNotNull); - } - - @Test - public void testNext() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - assertTrue(rs.isBeforeFirst()); - assertFalse(rs.isAfterLast()); - int num = 0; - while (rs.next()) { - num++; - } - assertTrue(num > 0); - assertFalse(rs.isBeforeFirst()); - assertTrue(rs.isAfterLast()); - } - } - - @Test - public void testClose() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - assertFalse(rs.isClosed()); - rs.next(); - assertNotNull(rs.getString(STRING_COL_NOT_NULL)); - rs.close(); - assertTrue(rs.isClosed()); - boolean failed = false; - try { - // Should fail - rs.getString(STRING_COL_NOT_NULL); - } catch (SQLException e) { - failed = true; - } - assertTrue(failed); - } - } - - @Test - public void testGetStringIndex() throws SQLException { - assertNotNull(subject.getString(STRING_COLINDEX_NOTNULL)); - assertEquals(STRING_VALUE, subject.getString(STRING_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getString(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetNStringIndex() throws SQLException { - assertNotNull(subject.getNString(STRING_COLINDEX_NOTNULL)); - assertEquals(STRING_VALUE, subject.getNString(STRING_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getNString(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetURLIndex() throws SQLException, MalformedURLException { - assertNotNull(subject.getURL(URL_COLINDEX_NOTNULL)); - assertEquals(new URL(URL_VALUE), subject.getURL(URL_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getURL(URL_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetURLIndexInvalid() throws SQLException, MalformedURLException { - thrown.expect(JdbcSqlExceptionImpl.class); - thrown.expectMessage("Invalid URL"); - assertNotNull(subject.getURL(STRING_COLINDEX_NOTNULL)); - } - - @Test - public void testGetBooleanIndex() throws SQLException { - assertNotNull(subject.getBoolean(BOOLEAN_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertFalse(subject.getBoolean(BOOLEAN_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetLongIndex() throws SQLException { - assertNotNull(subject.getLong(LONG_COLINDEX_NOTNULL)); - assertEquals(LONG_VALUE, subject.getLong(LONG_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertEquals(0l, subject.getLong(LONG_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetDoubleIndex() throws SQLException { - assertNotNull(subject.getDouble(DOUBLE_COLINDEX_NOTNULL)); - assertEquals(DOUBLE_VALUE, subject.getDouble(DOUBLE_COLINDEX_NOTNULL), 0d); - assertFalse(subject.wasNull()); - assertEquals(0d, subject.getDouble(DOUBLE_COLINDEX_NULL), 0d); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBigDecimalIndexAndScale() throws SQLException { - assertNotNull(subject.getBigDecimal(DOUBLE_COLINDEX_NOTNULL, 2)); - assertEquals( - BigDecimal.valueOf(DOUBLE_VALUE).setScale(2, RoundingMode.HALF_UP), - subject.getBigDecimal(DOUBLE_COLINDEX_NOTNULL, 2)); - assertFalse(subject.wasNull()); - assertNull(subject.getBigDecimal(DOUBLE_COLINDEX_NULL, 2)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBytesIndex() throws SQLException { - assertNotNull(subject.getBytes(BYTES_COLINDEX_NOTNULL)); - assertArrayEquals(BYTES_VALUE.toByteArray(), subject.getBytes(BYTES_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getBytes(BYTES_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetDateIndex() throws SQLException { - assertNotNull(subject.getDate(DATE_COLINDEX_NOTNULL)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getDate(DATE_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getDate(DATE_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimeIndex() throws SQLException { - assertNotNull(subject.getTime(TIME_COLINDEX_NOTNULL)); - assertEquals( - new Time(TIME_VALUE.toSqlTimestamp().getTime()), subject.getTime(TIME_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getTime(TIME_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimestampIndex() throws SQLException { - assertNotNull(subject.getTimestamp(TIMESTAMP_COLINDEX_NOTNULL)); - assertEquals( - TIMESTAMP_VALUE.toSqlTimestamp(), subject.getTimestamp(TIMESTAMP_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getTimestamp(TIMESTAMP_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetStringLabel() throws SQLException { - assertNotNull(subject.getString(STRING_COL_NOT_NULL)); - assertEquals("FOO", subject.getString(STRING_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getString(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetNStringLabel() throws SQLException { - assertNotNull(subject.getNString(STRING_COL_NOT_NULL)); - assertEquals("FOO", subject.getNString(STRING_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getNString(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetURLLabel() throws SQLException { - assertNotNull(subject.getString(URL_COL_NOT_NULL)); - assertEquals(URL_VALUE, subject.getString(URL_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getString(URL_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetURLLabelInvalid() throws SQLException { - thrown.expect(JdbcSqlExceptionImpl.class); - thrown.expectMessage("Invalid URL"); - assertNotNull(subject.getURL(STRING_COL_NOT_NULL)); - } - - @Test - public void testGetBooleanLabel() throws SQLException { - assertNotNull(subject.getBoolean(BOOLEAN_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertFalse(subject.getBoolean(BOOLEAN_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetLongLabel() throws SQLException { - assertNotNull(subject.getLong(LONG_COL_NOT_NULL)); - assertEquals(1l, subject.getLong(LONG_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertEquals(0l, subject.getLong(LONG_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetDoubleLabel() throws SQLException { - assertNotNull(subject.getDouble(DOUBLE_COL_NOT_NULL)); - assertEquals(DOUBLE_VALUE, subject.getDouble(DOUBLE_COL_NOT_NULL), 0d); - assertFalse(subject.wasNull()); - assertEquals(0d, subject.getDouble(DOUBLE_COL_NULL), 0d); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBigDecimalLabelAndScale() throws SQLException { - assertNotNull(subject.getBigDecimal(DOUBLE_COL_NOT_NULL, 2)); - assertEquals(BigDecimal.valueOf(3.14d), subject.getBigDecimal(DOUBLE_COL_NOT_NULL, 2)); - assertFalse(subject.wasNull()); - assertNull(subject.getBigDecimal(DOUBLE_COL_NULL, 2)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBytesLabel() throws SQLException { - assertNotNull(subject.getBytes(BYTES_COL_NOT_NULL)); - assertArrayEquals( - ByteArray.copyFrom("FOO").toByteArray(), subject.getBytes(BYTES_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getBytes(BYTES_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetDateLabel() throws SQLException { - assertNotNull(subject.getDate(DATE_COL_NOT_NULL)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getDate(DATE_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getDate(DATE_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimeLabel() throws SQLException { - assertNotNull(subject.getTime(TIME_COL_NOT_NULL)); - assertEquals( - new Time(TIME_VALUE.toSqlTimestamp().getTime()), subject.getTime(TIME_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getTime(TIME_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimestampLabel() throws SQLException { - assertNotNull(subject.getTime(TIMESTAMP_COL_NOT_NULL)); - assertEquals(TIMESTAMP_VALUE.toSqlTimestamp(), subject.getTimestamp(TIMESTAMP_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getTimestamp(TIMESTAMP_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetMetaData() throws SQLException { - JdbcResultSetMetaData metadata = subject.getMetaData(); - assertNotNull(metadata); - } - - @Test - public void testFindColumn() throws SQLException { - assertEquals(2, subject.findColumn(STRING_COL_NOT_NULL)); - } - - @Test - public void testGetBigDecimalIndex() throws SQLException { - assertNotNull(subject.getBigDecimal(DOUBLE_COLINDEX_NOTNULL)); - assertEquals(BigDecimal.valueOf(DOUBLE_VALUE), subject.getBigDecimal(DOUBLE_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getBigDecimal(DOUBLE_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBigDecimalLabel() throws SQLException { - assertNotNull(subject.getBigDecimal(DOUBLE_COL_NOT_NULL)); - assertEquals(BigDecimal.valueOf(DOUBLE_VALUE), subject.getBigDecimal(DOUBLE_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getBigDecimal(DOUBLE_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetStatement() throws SQLException { - assertNotNull(subject.getStatement()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetDateIndexCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(); - assertNotNull(subject.getDate(DATE_COLINDEX_NOTNULL, cal)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getDate(DATE_COLINDEX_NOTNULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getDate(DATE_COLINDEX_NULL, cal)); - assertTrue(subject.wasNull()); - - Calendar calGMT = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - Calendar expectedCal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - expectedCal.clear(); - expectedCal.set(DATE_VALUE.getYear(), DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()); - java.sql.Date expected = new java.sql.Date(expectedCal.getTimeInMillis()); - assertEquals(expected, subject.getDate(DATE_COLINDEX_NOTNULL, calGMT)); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetDateLabelCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(); - assertNotNull(subject.getDate(DATE_COL_NOT_NULL, cal)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getDate(DATE_COL_NOT_NULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getDate(DATE_COL_NULL, cal)); - assertTrue(subject.wasNull()); - - Calendar calGMT = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - expected.set( - DATE_VALUE.getYear(), DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth(), 0, 0, 0); - expected.clear(Calendar.MILLISECOND); - assertEquals( - new java.sql.Date(expected.getTimeInMillis()), subject.getDate(DATE_COL_NOT_NULL, calGMT)); - } - - @Test - public void testGetTimeIndexCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - assertNotNull(subject.getTime(TIME_COLINDEX_NOTNULL, cal)); - assertEquals( - new Time(TIME_VALUE.toSqlTimestamp().getTime()), - subject.getTime(TIME_COLINDEX_NOTNULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getTime(TIME_COLINDEX_NULL, cal)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimeLabelCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - assertNotNull(subject.getTime(TIME_COL_NOT_NULL, cal)); - assertEquals( - new Time(TIME_VALUE.toSqlTimestamp().getTime()), subject.getTime(TIME_COL_NOT_NULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getTime(TIME_COL_NULL, cal)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimestampIndexCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - assertNotNull(subject.getTimestamp(TIMESTAMP_COLINDEX_NOTNULL, cal)); - assertEquals( - TIMESTAMP_VALUE.toSqlTimestamp(), subject.getTimestamp(TIMESTAMP_COLINDEX_NOTNULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getTimestamp(TIMESTAMP_COLINDEX_NULL, cal)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetTimestampLabelCalendar() throws SQLException { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - assertNotNull(subject.getTimestamp(TIMESTAMP_COL_NOT_NULL, cal)); - assertEquals( - TIMESTAMP_VALUE.toSqlTimestamp(), subject.getTimestamp(TIMESTAMP_COL_NOT_NULL, cal)); - assertFalse(subject.wasNull()); - assertNull(subject.getTimestamp(TIMESTAMP_COL_NULL, cal)); - assertTrue(subject.wasNull()); - } - - @Test - public void testIsClosed() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - assertFalse(rs.isClosed()); - rs.close(); - assertTrue(rs.isClosed()); - } - } - - @Test - public void testGetByteIndex() throws SQLException { - assertNotNull(subject.getByte(LONG_COLINDEX_NOTNULL)); - assertEquals(LONG_VALUE, subject.getByte(LONG_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getByte(LONG_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetShortIndex() throws SQLException { - assertNotNull(subject.getShort(LONG_COLINDEX_NOTNULL)); - assertEquals(LONG_VALUE, subject.getShort(LONG_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getShort(LONG_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetIntIndex() throws SQLException { - assertNotNull(subject.getInt(LONG_COLINDEX_NOTNULL)); - int expected = (int) LONG_VALUE; - assertEquals(expected, subject.getInt(LONG_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getInt(LONG_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetFloatIndex() throws SQLException { - assertNotNull(subject.getFloat(DOUBLE_COLINDEX_NOTNULL)); - float expected = (float) DOUBLE_VALUE; - assertEquals(expected, subject.getFloat(DOUBLE_COLINDEX_NOTNULL), 0f); - assertFalse(subject.wasNull()); - assertEquals(0d, subject.getFloat(DOUBLE_COLINDEX_NULL), 0f); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetByteLabel() throws SQLException { - assertNotNull(subject.getByte(LONG_COL_NOT_NULL)); - assertEquals(1, subject.getByte(LONG_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getByte(LONG_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetShortLabel() throws SQLException { - assertNotNull(subject.getShort(LONG_COL_NOT_NULL)); - assertEquals(1, subject.getShort(LONG_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getShort(LONG_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetIntLabel() throws SQLException { - assertNotNull(subject.getInt(LONG_COL_NOT_NULL)); - assertEquals(1, subject.getInt(LONG_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertEquals(0, subject.getInt(LONG_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetFloatLabel() throws SQLException { - assertNotNull(subject.getFloat(DOUBLE_COL_NOT_NULL)); - float expected = (float) DOUBLE_VALUE; - assertEquals(expected, subject.getFloat(DOUBLE_COL_NOT_NULL), 0f); - assertFalse(subject.wasNull()); - assertEquals(0f, subject.getFloat(DOUBLE_COL_NULL), 0f); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetObjectLabel() throws SQLException { - assertNotNull(subject.getObject(DATE_COL_NOT_NULL)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getObject(DATE_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getObject(DATE_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetObjectIndex() throws SQLException { - assertNotNull(subject.getObject(DATE_COLINDEX_NOTNULL)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getObject(DATE_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getObject(DATE_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetObjectLabelMap() throws SQLException { - Map> map = new HashMap<>(); - assertNotNull(subject.getObject(DATE_COL_NOT_NULL, map)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getObject(DATE_COL_NOT_NULL, map)); - assertFalse(subject.wasNull()); - assertNull(subject.getObject(DATE_COL_NULL, map)); - assertTrue(subject.wasNull()); - } - - @SuppressWarnings("deprecation") - @Test - public void testGetObjectIndexMap() throws SQLException { - Map> map = Collections.emptyMap(); - assertNotNull(subject.getObject(DATE_COLINDEX_NOTNULL, map)); - assertEquals( - new java.sql.Date( - DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()), - subject.getObject(DATE_COLINDEX_NOTNULL, map)); - assertFalse(subject.wasNull()); - assertNull(subject.getObject(DATE_COLINDEX_NULL, map)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetArrayLabel() throws SQLException { - assertNotNull(subject.getArray(ARRAY_COL_NOT_NULL)); - assertEquals( - JdbcArray.createArray(JdbcDataType.INT64, Arrays.asList(1L, 2L, 3L)), - subject.getArray(ARRAY_COL_NOT_NULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getArray(ARRAY_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetArrayIndex() throws SQLException { - assertNotNull(subject.getArray(ARRAY_COLINDEX_NOTNULL)); - assertEquals( - JdbcArray.createArray(JdbcDataType.INT64, Arrays.asList(1L, 2L, 3L)), - subject.getArray(ARRAY_COLINDEX_NOTNULL)); - assertFalse(subject.wasNull()); - assertNull(subject.getArray(ARRAY_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetWarnings() throws SQLException { - assertNull(subject.getWarnings()); - } - - @Test - public void testClearWarnings() throws SQLException { - subject.clearWarnings(); - } - - @Test - public void testIsBeforeFirst() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - assertTrue(rs.isBeforeFirst()); - rs.next(); - assertFalse(rs.isBeforeFirst()); - } - } - - @Test - public void testIsAfterLast() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - assertFalse(rs.isAfterLast()); - while (rs.next()) { - // do nothing - } - assertTrue(rs.isAfterLast()); - } - } - - @Test - public void testGetCharacterStreamIndex() throws SQLException, IOException { - assertNotNull(subject.getCharacterStream(STRING_COLINDEX_NOTNULL)); - Reader actual = subject.getCharacterStream(STRING_COLINDEX_NOTNULL); - char[] cbuf = new char[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals(STRING_VALUE, new String(cbuf, 0, len)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getCharacterStream(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetCharacterStreamLabel() throws SQLException, IOException { - assertNotNull(subject.getCharacterStream(STRING_COL_NOT_NULL)); - Reader actual = subject.getCharacterStream(STRING_COL_NOT_NULL); - char[] cbuf = new char[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals("FOO", new String(cbuf, 0, len)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getCharacterStream(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetNCharacterStreamIndex() throws SQLException, IOException { - assertNotNull(subject.getNCharacterStream(STRING_COLINDEX_NOTNULL)); - Reader actual = subject.getNCharacterStream(STRING_COLINDEX_NOTNULL); - char[] cbuf = new char[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals(STRING_VALUE, new String(cbuf, 0, len)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getNCharacterStream(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetNCharacterStreamLabel() throws SQLException, IOException { - assertNotNull(subject.getNCharacterStream(STRING_COL_NOT_NULL)); - Reader actual = subject.getNCharacterStream(STRING_COL_NOT_NULL); - char[] cbuf = new char[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals("FOO", new String(cbuf, 0, len)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getNCharacterStream(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetAsciiStreamIndex() throws SQLException, IOException { - assertNotNull(subject.getAsciiStream(STRING_COLINDEX_NOTNULL)); - InputStream actual = subject.getAsciiStream(STRING_COLINDEX_NOTNULL); - byte[] cbuf = new byte[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals(STRING_VALUE, new String(cbuf, 0, len, StandardCharsets.US_ASCII)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getAsciiStream(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetUnicodeStreamIndex() throws SQLException, IOException { - assertNotNull(subject.getUnicodeStream(STRING_COLINDEX_NOTNULL)); - InputStream actual = subject.getUnicodeStream(STRING_COLINDEX_NOTNULL); - byte[] cbuf = new byte[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals(STRING_VALUE, new String(cbuf, 0, len, StandardCharsets.UTF_16LE)); - assertEquals(6, len); - assertFalse(subject.wasNull()); - assertNull(subject.getUnicodeStream(STRING_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBinaryStreamIndex() throws SQLException, IOException { - assertNotNull(subject.getBinaryStream(BYTES_COLINDEX_NOTNULL)); - InputStream actual = subject.getBinaryStream(BYTES_COLINDEX_NOTNULL); - byte[] cbuf = new byte[3]; - int len = actual.read(cbuf, 0, cbuf.length); - assertArrayEquals(BYTES_VALUE.toByteArray(), cbuf); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getUnicodeStream(BYTES_COLINDEX_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetAsciiStreamLabel() throws SQLException, IOException { - assertNotNull(subject.getAsciiStream(STRING_COL_NOT_NULL)); - InputStream actual = subject.getAsciiStream(STRING_COL_NOT_NULL); - byte[] cbuf = new byte[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals("FOO", new String(cbuf, 0, len, StandardCharsets.US_ASCII)); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getAsciiStream(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetUnicodeStreamLabel() throws SQLException, IOException { - assertNotNull(subject.getUnicodeStream(STRING_COL_NOT_NULL)); - InputStream actual = subject.getUnicodeStream(STRING_COL_NOT_NULL); - byte[] cbuf = new byte[10]; - int len = actual.read(cbuf, 0, cbuf.length); - assertEquals("FOO", new String(cbuf, 0, len, StandardCharsets.UTF_16LE)); - assertEquals(6, len); - assertFalse(subject.wasNull()); - assertNull(subject.getUnicodeStream(STRING_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBinaryStreamLabel() throws SQLException, IOException { - assertNotNull(subject.getBinaryStream(BYTES_COL_NOT_NULL)); - InputStream actual = subject.getBinaryStream(BYTES_COL_NOT_NULL); - byte[] cbuf = new byte[3]; - int len = actual.read(cbuf, 0, cbuf.length); - assertArrayEquals(ByteArray.copyFrom("FOO").toByteArray(), cbuf); - assertEquals(3, len); - assertFalse(subject.wasNull()); - assertNull(subject.getUnicodeStream(BYTES_COL_NULL)); - assertTrue(subject.wasNull()); - } - - @Test - public void testGetBeforeNext() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - thrown.expect(SQLException.class); - thrown.expectMessage( - "FAILED_PRECONDITION: ResultSet is before first row. Call next() first."); - rs.getBigDecimal(LONG_COLINDEX_NOTNULL); - } - } - - @Test - public void testGetAfterLast() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - while (rs.next()) { - // do nothing - } - thrown.expect(SQLException.class); - thrown.expectMessage( - "FAILED_PRECONDITION: ResultSet is after last row. There is no more data available."); - rs.getBigDecimal(LONG_COLINDEX_NOTNULL); - } - } - - @Test - public void testFindIllegalColumnName() throws SQLException { - thrown.expect(SQLException.class); - thrown.expectMessage("INVALID_ARGUMENT: no column with label " + UNKNOWN_COLUMN + " found"); - int index = subject.findColumn(UNKNOWN_COLUMN); - assertEquals(0, index); - } - - @Test - public void testGetRowAndIsFirst() throws SQLException { - try (JdbcResultSet rs = JdbcResultSet.of(mock(Statement.class), getMockResultSet())) { - int row = 0; - while (rs.next()) { - row++; - assertEquals(row, rs.getRow()); - assertEquals(row == 1, rs.isFirst()); - } - } - } - - @Test - public void testGetHoldability() throws SQLException { - assertEquals(java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT, subject.getHoldability()); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcSqlScriptVerifier.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcSqlScriptVerifier.java deleted file mode 100644 index 878b3a6bb0e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcSqlScriptVerifier.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import com.google.rpc.Code; -import java.sql.Array; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.List; - -/** SQL Script verifier for JDBC connections */ -public class JdbcSqlScriptVerifier extends AbstractSqlScriptVerifier { - - static class JdbcGenericStatementResult extends GenericStatementResult { - private final boolean result; - private final long updateCount; - private final ResultSet resultSet; - - private JdbcGenericStatementResult(Statement statement, boolean result) throws SQLException { - this.result = result; - if (result) { - this.resultSet = statement.getResultSet(); - this.updateCount = -1L; - } else { - this.resultSet = null; - this.updateCount = statement.getUpdateCount(); - } - } - - @Override - protected ResultType getResultType() { - if (result) { - return ResultType.RESULT_SET; - } - if (updateCount == -2L) { - return ResultType.NO_RESULT; - } - return ResultType.UPDATE_COUNT; - } - - @Override - protected GenericResultSet getResultSet() { - return new JdbcGenericResultSet(resultSet); - } - - @Override - protected long getUpdateCount() { - return updateCount; - } - } - - static class JdbcGenericResultSet extends GenericResultSet { - private final ResultSet resultSet; - - private JdbcGenericResultSet(ResultSet resultSet) { - this.resultSet = resultSet; - } - - @Override - protected boolean next() throws SQLException { - return resultSet.next(); - } - - @Override - protected Object getValue(String col) throws SQLException { - Object value = resultSet.getObject(col); - if (value instanceof Timestamp) { - return com.google.cloud.Timestamp.of((Timestamp) value); - } else if (value instanceof Array) { - Array array = (Array) value; - switch (array.getBaseType()) { - case Types.BIGINT: - Long[] longs = (Long[]) array.getArray(); - List res = new ArrayList<>(); - for (Long l : longs) { - res.add(l); - } - return res; - default: - throw new IllegalArgumentException( - "Unsupported array base type: " + array.getBaseType()); - } - } - return value; - } - - @Override - protected int getColumnCount() throws Exception { - return resultSet.getMetaData().getColumnCount(); - } - - @Override - protected Object getFirstValue() throws Exception { - String col = resultSet.getMetaData().getColumnName(1); - return getValue(col); - } - } - - public static class JdbcGenericConnection extends GenericConnection { - private final Connection connection; - /** - * Use this to strip comments from a statement before the statement is executed. This should - * only be used when the connection is used in a unit test with a mocked underlying connection. - */ - private boolean stripCommentsBeforeExecute; - - public static JdbcGenericConnection of(Connection connection) { - return new JdbcGenericConnection(connection); - } - - private JdbcGenericConnection(Connection connection) { - this.connection = connection; - } - - @Override - protected GenericStatementResult execute(String sql) throws SQLException { - Statement statement = connection.createStatement(); - if (isStripCommentsBeforeExecute()) { - sql = StatementParser.removeCommentsAndTrim(sql); - } - boolean result = statement.execute(sql); - return new JdbcGenericStatementResult(statement, result); - } - - @Override - public void close() throws Exception { - if (this.connection != null) { - this.connection.close(); - } - } - - boolean isStripCommentsBeforeExecute() { - return stripCommentsBeforeExecute; - } - - void setStripCommentsBeforeExecute(boolean stripCommentsBeforeExecute) { - this.stripCommentsBeforeExecute = stripCommentsBeforeExecute; - } - } - - public JdbcSqlScriptVerifier() {} - - public JdbcSqlScriptVerifier(GenericConnectionProvider connectionProvider) { - super(connectionProvider); - } - - @Override - protected void verifyExpectedException( - String statement, Exception e, String code, String messagePrefix) { - assertThat(e instanceof JdbcSqlException, is(true)); - JdbcSqlException jdbcException = (JdbcSqlException) e; - assertThat(statement, jdbcException.getCode(), is(equalTo(Code.valueOf(code)))); - if (messagePrefix != null) { - assertThat( - statement, - e.getMessage(), - startsWith(messagePrefix.substring(1, messagePrefix.length() - 1))); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcStatementTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcStatementTest.java deleted file mode 100644 index 648261efdf2..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcStatementTest.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import com.google.rpc.Code; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import java.sql.Statement; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.Matchers; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class JdbcStatementTest { - @Rule public final ExpectedException thrown = ExpectedException.none(); - private static final String SELECT = "SELECT 1"; - private static final String UPDATE = "UPDATE FOO SET BAR=1 WHERE BAZ=2"; - private static final String LARGE_UPDATE = "UPDATE FOO SET BAR=1 WHERE 1=1"; - private static final String DDL = "CREATE INDEX FOO ON BAR(ID)"; - - @Rule public final ExpectedException expected = ExpectedException.none(); - - private JdbcStatement createStatement() { - Connection spanner = mock(Connection.class); - - com.google.cloud.spanner.ResultSet resultSet = mock(com.google.cloud.spanner.ResultSet.class); - when(resultSet.next()).thenReturn(true, false); - when(resultSet.getLong(0)).thenReturn(1L); - - StatementResult selectResult = mock(StatementResult.class); - when(selectResult.getResultType()).thenReturn(ResultType.RESULT_SET); - when(selectResult.getResultSet()).thenReturn(resultSet); - when(spanner.execute(com.google.cloud.spanner.Statement.of(SELECT))).thenReturn(selectResult); - - StatementResult updateResult = mock(StatementResult.class); - when(updateResult.getResultType()).thenReturn(ResultType.UPDATE_COUNT); - when(updateResult.getUpdateCount()).thenReturn(1L); - when(spanner.execute(com.google.cloud.spanner.Statement.of(UPDATE))).thenReturn(updateResult); - - StatementResult largeUpdateResult = mock(StatementResult.class); - when(largeUpdateResult.getResultType()).thenReturn(ResultType.UPDATE_COUNT); - when(largeUpdateResult.getUpdateCount()).thenReturn(Integer.MAX_VALUE + 1L); - when(spanner.execute(com.google.cloud.spanner.Statement.of(LARGE_UPDATE))) - .thenReturn(largeUpdateResult); - - StatementResult ddlResult = mock(StatementResult.class); - when(ddlResult.getResultType()).thenReturn(ResultType.NO_RESULT); - when(spanner.execute(com.google.cloud.spanner.Statement.of(DDL))).thenReturn(ddlResult); - - when(spanner.executeQuery(com.google.cloud.spanner.Statement.of(SELECT))).thenReturn(resultSet); - when(spanner.executeQuery(com.google.cloud.spanner.Statement.of(UPDATE))) - .thenThrow( - SpannerExceptionFactory.newSpannerException(ErrorCode.INVALID_ARGUMENT, "not a query")); - when(spanner.executeQuery(com.google.cloud.spanner.Statement.of(DDL))) - .thenThrow( - SpannerExceptionFactory.newSpannerException(ErrorCode.INVALID_ARGUMENT, "not a query")); - - when(spanner.executeUpdate(com.google.cloud.spanner.Statement.of(UPDATE))).thenReturn(1L); - when(spanner.executeUpdate(com.google.cloud.spanner.Statement.of(SELECT))) - .thenThrow( - SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "not an update")); - when(spanner.executeUpdate(com.google.cloud.spanner.Statement.of(DDL))) - .thenThrow( - SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "not an update")); - - when(spanner.executeBatchUpdate(Matchers.anyListOf(com.google.cloud.spanner.Statement.class))) - .thenAnswer( - new Answer() { - @SuppressWarnings("unchecked") - @Override - public long[] answer(InvocationOnMock invocation) throws Throwable { - List statements = - (List) invocation.getArguments()[0]; - if (statements.isEmpty() - || StatementParser.INSTANCE.isDdlStatement(statements.get(0).getSql())) { - return new long[0]; - } - long[] res = - new long - [((List) invocation.getArguments()[0]) - .size()]; - Arrays.fill(res, 1L); - return res; - } - }); - - JdbcConnection connection = mock(JdbcConnection.class); - when(connection.getSpannerConnection()).thenReturn(spanner); - return new JdbcStatement(connection); - } - - @Test - public void testQueryTimeout() throws SQLException { - final String select = "SELECT 1"; - JdbcConnection connection = mock(JdbcConnection.class); - Connection spanner = mock(Connection.class); - when(connection.getSpannerConnection()).thenReturn(spanner); - StatementResult result = mock(StatementResult.class); - when(result.getResultType()).thenReturn(ResultType.RESULT_SET); - when(result.getResultSet()).thenReturn(mock(com.google.cloud.spanner.ResultSet.class)); - when(spanner.execute(com.google.cloud.spanner.Statement.of(select))).thenReturn(result); - try (Statement statement = new JdbcStatement(connection)) { - assertThat(statement.getQueryTimeout(), is(equalTo(0))); - statement.setQueryTimeout(1); - assertThat(statement.getQueryTimeout(), is(equalTo(1))); - statement.setQueryTimeout(99); - assertThat(statement.getQueryTimeout(), is(equalTo(99))); - statement.setQueryTimeout(0); - assertThat(statement.getQueryTimeout(), is(equalTo(0))); - } - - when(spanner.getStatementTimeout(TimeUnit.SECONDS)).thenReturn(1L); - when(spanner.getStatementTimeout(TimeUnit.MILLISECONDS)).thenReturn(1000L); - when(spanner.getStatementTimeout(TimeUnit.MICROSECONDS)).thenReturn(1000000L); - when(spanner.getStatementTimeout(TimeUnit.NANOSECONDS)).thenReturn(1000000000L); - when(spanner.hasStatementTimeout()).thenReturn(true); - try (Statement statement = new JdbcStatement(connection)) { - assertThat(statement.getQueryTimeout(), is(equalTo(0))); - statement.execute(select); - // statement has no timeout, so it should also not be set on the connection - verify(spanner, never()).setStatementTimeout(1L, TimeUnit.SECONDS); - } - try (Statement statement = new JdbcStatement(connection)) { - // now set a query timeout that should temporarily applied to the connection - statement.setQueryTimeout(2); - statement.execute(select); - // assert that it is temporarily set to 2 seconds, and then back to the original 1 second - // value - verify(spanner).setStatementTimeout(2L, TimeUnit.SECONDS); - verify(spanner).setStatementTimeout(1L, TimeUnit.SECONDS); - } - } - - @Test - public void testExecuteWithSelectStatement() throws SQLException { - Statement statement = createStatement(); - boolean res = statement.execute(SELECT); - assertThat(res, is(true)); - assertThat(statement.getUpdateCount(), is(equalTo(JdbcConstants.STATEMENT_RESULT_SET))); - try (ResultSet rs = statement.getResultSet()) { - assertThat(rs, is(notNullValue())); - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - - @Test - public void testExecuteWithUpdateStatement() throws SQLException { - Statement statement = createStatement(); - boolean res = statement.execute(UPDATE); - assertThat(res, is(false)); - assertThat(statement.getResultSet(), is(nullValue())); - assertThat(statement.getUpdateCount(), is(equalTo(1))); - try { - assertThat(statement.execute(LARGE_UPDATE), is(false)); - assertThat(statement.getResultSet(), is(nullValue())); - statement.getUpdateCount(); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.OUT_OF_RANGE))); - } - } - - @Test - public void testExecuteWithDdlStatement() throws SQLException { - Statement statement = createStatement(); - boolean res = statement.execute(DDL); - assertThat(res, is(false)); - assertThat(statement.getResultSet(), is(nullValue())); - assertThat(statement.getUpdateCount(), is(equalTo(JdbcConstants.STATEMENT_NO_RESULT))); - } - - @Test - public void testExecuteWithGeneratedKeys() throws SQLException { - Statement statement = createStatement(); - assertThat(statement.execute(UPDATE, Statement.NO_GENERATED_KEYS), is(false)); - ResultSet keys = statement.getGeneratedKeys(); - assertThat(keys.next(), is(false)); - try { - statement.execute(UPDATE, Statement.RETURN_GENERATED_KEYS); - fail("missing expected exception"); - } catch (SQLFeatureNotSupportedException e) { - // Ignore, this is the expected exception. - } - } - - @Test - public void testExecuteQuery() throws SQLException { - Statement statement = createStatement(); - try (ResultSet rs = statement.executeQuery(SELECT)) { - assertThat(rs, is(notNullValue())); - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(1L))); - } - } - - @Test - public void testExecuteQueryWithUpdateStatement() throws SQLException { - Statement statement = createStatement(); - expected.expect(JdbcExceptionMatcher.matchCodeAndMessage(Code.INVALID_ARGUMENT, "not a query")); - statement.executeQuery(UPDATE); - } - - @Test - public void testExecuteQueryWithDdlStatement() throws SQLException { - Statement statement = createStatement(); - expected.expect(JdbcExceptionMatcher.matchCodeAndMessage(Code.INVALID_ARGUMENT, "not a query")); - statement.executeQuery(DDL); - } - - @Test - public void testExecuteUpdate() throws SQLException { - Statement statement = createStatement(); - assertThat(statement.executeUpdate(UPDATE), is(equalTo(1))); - try { - statement.executeUpdate(LARGE_UPDATE); - fail("missing expected exception"); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode(), is(equalTo(Code.OUT_OF_RANGE))); - } - } - - @Test - public void testExecuteUpdateWithSelectStatement() throws SQLException { - Statement statement = createStatement(); - expected.expect( - JdbcExceptionMatcher.matchCodeAndMessage( - Code.INVALID_ARGUMENT, "The statement is not an update or DDL statement")); - statement.executeUpdate(SELECT); - } - - @Test - public void testExecuteUpdateWithDdlStatement() throws SQLException { - Statement statement = createStatement(); - assertThat(statement.executeUpdate(DDL), is(equalTo(0))); - } - - @Test - public void testExecuteUpdateWithGeneratedKeys() throws SQLException { - Statement statement = createStatement(); - assertThat(statement.executeUpdate(UPDATE, Statement.NO_GENERATED_KEYS), is(equalTo(1))); - ResultSet keys = statement.getGeneratedKeys(); - assertThat(keys.next(), is(false)); - try { - statement.executeUpdate(UPDATE, Statement.RETURN_GENERATED_KEYS); - fail("missing expected exception"); - } catch (SQLFeatureNotSupportedException e) { - // Ignore, this is the expected exception. - } - } - - @Test - public void testMoreResults() throws SQLException { - Statement statement = createStatement(); - assertThat(statement.execute(SELECT), is(true)); - ResultSet rs = statement.getResultSet(); - assertThat(statement.getMoreResults(), is(false)); - assertThat(statement.getResultSet(), is(nullValue())); - assertThat(rs.isClosed(), is(true)); - - assertThat(statement.execute(SELECT), is(true)); - rs = statement.getResultSet(); - assertThat(statement.getMoreResults(Statement.KEEP_CURRENT_RESULT), is(false)); - assertThat(statement.getResultSet(), is(nullValue())); - assertThat(rs.isClosed(), is(false)); - } - - @Test - public void testNoBatchMixing() throws SQLException { - thrown.expect(SQLException.class); - thrown.expectMessage("Mixing DML and DDL statements in a batch is not allowed."); - try (Statement statement = createStatement()) { - statement.addBatch("INSERT INTO FOO (ID, NAME) VALUES (1, 'FOO')"); - statement.addBatch("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)"); - } - } - - @Test - public void testNoBatchQuery() throws SQLException { - thrown.expect(SQLException.class); - thrown.expectMessage( - "The statement is not suitable for batching. Only DML and DDL statements are allowed for batching."); - try (Statement statement = createStatement()) { - statement.addBatch("SELECT * FROM FOO"); - } - } - - @Test - public void testDmlBatch() throws SQLException { - try (Statement statement = createStatement()) { - // Verify that multiple batches can be executed on the same statement. - for (int i = 0; i < 2; i++) { - statement.addBatch("INSERT INTO FOO (ID, NAME) VALUES (1, 'TEST')"); - statement.addBatch("INSERT INTO FOO (ID, NAME) VALUES (2, 'TEST')"); - statement.addBatch("INSERT INTO FOO (ID, NAME) VALUES (3, 'TEST')"); - assertThat(statement.executeBatch(), is(equalTo(new int[] {1, 1, 1}))); - } - } - } - - @Test - public void testConvertUpdateCounts() throws SQLException { - try (JdbcStatement statement = new JdbcStatement(mock(JdbcConnection.class))) { - int[] updateCounts = statement.convertUpdateCounts(new long[] {1L, 2L, 3L}); - assertThat(updateCounts, is(equalTo(new int[] {1, 2, 3}))); - updateCounts = statement.convertUpdateCounts(new long[] {0L, 0L, 0L}); - assertThat(updateCounts, is(equalTo(new int[] {0, 0, 0}))); - - expected.expect(JdbcExceptionMatcher.matchCode(Code.OUT_OF_RANGE)); - statement.convertUpdateCounts(new long[] {1L, Integer.MAX_VALUE + 1L}); - } - } - - @Test - public void testConvertUpdateCountsToSuccessNoInfo() throws SQLException { - try (JdbcStatement statement = new JdbcStatement(mock(JdbcConnection.class))) { - int[] updateCounts = new int[3]; - statement.convertUpdateCountsToSuccessNoInfo(new long[] {1L, 2L, 3L}, updateCounts); - assertThat( - updateCounts, - is( - equalTo( - new int[] { - Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO - }))); - - statement.convertUpdateCountsToSuccessNoInfo(new long[] {0L, 0L, 0L}, updateCounts); - assertThat( - updateCounts, - is( - equalTo( - new int[] { - Statement.EXECUTE_FAILED, Statement.EXECUTE_FAILED, Statement.EXECUTE_FAILED - }))); - - statement.convertUpdateCountsToSuccessNoInfo(new long[] {1L, 0L, 2L}, updateCounts); - assertThat( - updateCounts, - is( - equalTo( - new int[] { - Statement.SUCCESS_NO_INFO, Statement.EXECUTE_FAILED, Statement.SUCCESS_NO_INFO - }))); - - expected.expect(JdbcExceptionMatcher.matchCode(Code.OUT_OF_RANGE)); - statement.convertUpdateCountsToSuccessNoInfo( - new long[] {1L, Integer.MAX_VALUE + 1L}, updateCounts); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTimeoutSqlTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTimeoutSqlTest.java deleted file mode 100644 index 6d743d147c2..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTimeoutSqlTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.jdbc.JdbcConnectionGeneratedSqlScriptTest.TestConnectionProvider; -import java.sql.Connection; -import java.sql.Statement; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * As JDBC connections store the statement timeout on {@link Statement} objects instead of on the - * {@link Connection}, the JDBC driver needs to set and reset the connection timeout on the - * underlying connection after each statement execution. JDBC also uses seconds as the time unit for - * timeouts, while the underlying {@link com.google.cloud.spanner.jdbc.Connection}s use - * milliseconds. This test script tests a number of special cases regarding this. - */ -@RunWith(JUnit4.class) -public class JdbcTimeoutSqlTest { - @Test - public void testTimeoutScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile("TimeoutSqlScriptTest.sql", getClass()); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTypeConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTypeConverterTest.java deleted file mode 100644 index 5978f3ac345..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/JdbcTypeConverterTest.java +++ /dev/null @@ -1,748 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.JdbcTypeConverter.*; -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; - -import com.google.cloud.ByteArray; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.jdbc.JdbcSqlExceptionFactory.JdbcSqlExceptionImpl; -import com.google.rpc.Code; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.sql.Array; -import java.sql.Date; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; -import java.util.TimeZone; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JdbcTypeConverterTest { - private static final Charset UTF8 = Charset.forName("UTF8"); - - @Test - public void testConvertArray() throws SQLException { - Array testValue = JdbcArray.createArray("INT64", new Long[] {1L, 2L, 3L}); - for (Type t : - new Type[] { - Type.bool(), - Type.bytes(), - Type.date(), - Type.float64(), - Type.int64(), - Type.string(), - Type.timestamp() - }) { - assertConvertThrows(testValue, Type.array(t), Boolean.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Float.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.array(t), BigDecimal.class, Code.INVALID_ARGUMENT); - - assertThat(convert(testValue, Type.array(t), Array.class)).isEqualTo(testValue); - assertThat(convert(testValue, Type.array(t), String.class)).isEqualTo("{1,2,3}"); - } - } - - @Test - public void testConvertBool() throws SQLException { - Boolean[] testValues = new Boolean[] {Boolean.TRUE, Boolean.FALSE}; - for (Boolean b : testValues) { - assertThat(convert(b, Type.bool(), Boolean.class)).isEqualTo(b); - assertThat(convert(b, Type.bool(), Byte.class)) - .isEqualTo(Byte.valueOf(b ? (byte) 1 : (byte) 0)); - assertThat(convert(b, Type.bool(), Short.class)) - .isEqualTo(Short.valueOf(b ? (short) 1 : (short) 0)); - assertThat(convert(b, Type.bool(), Integer.class)).isEqualTo(Integer.valueOf(b ? 1 : 0)); - assertThat(convert(b, Type.bool(), Long.class)).isEqualTo(Long.valueOf(b ? 1L : 0L)); - assertThat(convert(b, Type.bool(), Float.class)).isEqualTo(Float.valueOf(b ? 1F : 0F)); - assertThat(convert(b, Type.bool(), Double.class)).isEqualTo(Double.valueOf(b ? 1D : 0D)); - assertThat(convert(b, Type.bool(), BigInteger.class)) - .isEqualTo(b ? BigInteger.ONE : BigInteger.ZERO); - assertThat(convert(b, Type.bool(), BigDecimal.class)) - .isEqualTo(b ? BigDecimal.ONE : BigDecimal.ZERO); - assertThat(convert(b, Type.bool(), String.class)).isEqualTo(String.valueOf(b)); - } - } - - @Test - public void testConvertBytes() throws SQLException { - byte[] testValues = "test".getBytes(UTF8); - assertConvertThrows(testValues, Type.bytes(), Boolean.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Float.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValues, Type.bytes(), BigDecimal.class, Code.INVALID_ARGUMENT); - - assertThat(convert(testValues, Type.bytes(), byte[].class)).isEqualTo(testValues); - assertThat(convert(testValues, Type.bytes(), String.class)).isEqualTo("test"); - } - - private TimeZone[] getTestTimeZones() { - return new TimeZone[] { - TimeZone.getTimeZone("GMT-12:00"), - TimeZone.getTimeZone("GMT-9:00"), - TimeZone.getTimeZone("GMT-1:00"), - TimeZone.getTimeZone("GMT"), - TimeZone.getTimeZone("GMT+1:00"), - TimeZone.getTimeZone("GMT+12:00") - }; - } - - @Test - public void testConvertDate() throws SQLException { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - @SuppressWarnings("deprecation") - Date testValue = new Date(2019 - 1900, 7, 24); - assertConvertThrows(testValue, Type.date(), Boolean.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Float.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.date(), BigDecimal.class, Code.INVALID_ARGUMENT); - - assertThat(convert(testValue, Type.date(), Date.class)).isEqualTo(testValue); - assertThat(convert(testValue, Type.date(), String.class)).isEqualTo("2019-08-24"); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @Test - public void testConvertTimestamp() throws SQLException { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - @SuppressWarnings("deprecation") - Timestamp testValue = new Timestamp(2019 - 1900, 7, 24, 7, 20, 19, 123456789); - assertConvertThrows(testValue, Type.timestamp(), Boolean.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Float.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.timestamp(), BigDecimal.class, Code.INVALID_ARGUMENT); - - assertThat(convert(testValue, Type.timestamp(), Timestamp.class)).isEqualTo(testValue); - int offset = zone.getOffset(testValue.getTime()); - int offsetHours = offset / (60_000 * 60); - DecimalFormat fmt = new DecimalFormat("+##00;-#"); - String offsetString = offset == 0 ? "Z" : fmt.format(offsetHours) + ":00"; - assertThat(convert(testValue, Type.timestamp(), String.class)) - .isEqualTo("2019-08-24T07:20:19.123456789" + offsetString); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @Test - public void testConvertString() throws SQLException { - String testValue = "test"; - assertConvertThrows(testValue, Type.string(), Boolean.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Float.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(testValue, Type.string(), BigDecimal.class, Code.INVALID_ARGUMENT); - - assertThat(convert(testValue, Type.string(), String.class)).isEqualTo(testValue); - assertThat(convert(testValue, Type.string(), byte[].class)).isEqualTo(testValue.getBytes(UTF8)); - } - - @Test - public void testConvertInt64() throws SQLException { - Long[] testValues = - new Long[] { - 0L, - -1L, - 1L, - Long.MIN_VALUE, - Long.MAX_VALUE, - Long.valueOf(Integer.MIN_VALUE), - Long.valueOf(Integer.MAX_VALUE), - Long.valueOf(Integer.MIN_VALUE - 1), - Long.valueOf(Integer.MAX_VALUE + 1), - Long.valueOf(Short.MIN_VALUE), - Long.valueOf(Short.MAX_VALUE), - Long.valueOf(Short.MIN_VALUE - 1), - Long.valueOf(Short.MAX_VALUE + 1), - Long.valueOf(Byte.MIN_VALUE), - Long.valueOf(Byte.MAX_VALUE), - Long.valueOf(Byte.MIN_VALUE - 1), - Long.valueOf(Byte.MAX_VALUE + 1) - }; - testConvertInt64ToNumber(testValues, Long.class, Long.MIN_VALUE, Long.MAX_VALUE); - testConvertInt64ToNumber(testValues, Integer.class, Integer.MIN_VALUE, Integer.MAX_VALUE); - testConvertInt64ToNumber(testValues, Short.class, Short.MIN_VALUE, Short.MAX_VALUE); - testConvertInt64ToNumber(testValues, Byte.class, Byte.MIN_VALUE, Byte.MAX_VALUE); - testConvertInt64ToNumber(testValues, BigInteger.class, Long.MIN_VALUE, Long.MAX_VALUE); - testConvertInt64ToNumber(testValues, BigDecimal.class, Long.MIN_VALUE, Long.MAX_VALUE); - - for (Long l : testValues) { - assertThat(convert(l, Type.int64(), String.class)).isEqualTo(String.valueOf(l)); - assertThat(convert(l, Type.int64(), Boolean.class)).isEqualTo(Boolean.valueOf(l != 0L)); - assertConvertThrows(l, Type.int64(), Double.class, Code.INVALID_ARGUMENT); - assertConvertThrows(l, Type.int64(), Float.class, Code.INVALID_ARGUMENT); - } - } - - private void testConvertInt64ToNumber( - Long[] testValues, Class targetType, Number minValue, Number maxValue) - throws SQLException { - for (Long t : testValues) { - if (t < minValue.longValue() || t > maxValue.longValue()) { - assertConvertThrows(t, Type.int64(), targetType, Code.OUT_OF_RANGE); - } else { - assertThat(((Number) convert(t, Type.int64(), targetType)).longValue()).isEqualTo(t); - assertThat(convert(t, Type.int64(), targetType)).isInstanceOf(targetType); - } - } - } - - @Test - public void testConvertFloat64() throws SQLException { - Double[] testValues = - new Double[] { - 0D, - -1D, - 1D, - Double.MIN_VALUE, - Double.MAX_VALUE, - Double.valueOf(Float.MIN_VALUE), - Double.valueOf(Float.MAX_VALUE), - Double.valueOf(Float.MAX_VALUE + 1D) - }; - for (Double d : testValues) { - assertThat(convert(d, Type.float64(), Double.class)).isEqualTo(d); - if (d > Float.MAX_VALUE || d < -Float.MAX_VALUE) { - assertConvertThrows(d, Type.float64(), Float.class, Code.OUT_OF_RANGE); - } else { - assertThat(convert(d, Type.float64(), Float.class)).isEqualTo(d.floatValue()); - } - assertThat(convert(d, Type.float64(), String.class)).isEqualTo(String.valueOf(d)); - assertThat(convert(d, Type.float64(), Boolean.class)).isEqualTo(Boolean.valueOf(d != 0D)); - assertConvertThrows(d, Type.float64(), Long.class, Code.INVALID_ARGUMENT); - assertConvertThrows(d, Type.float64(), Integer.class, Code.INVALID_ARGUMENT); - assertConvertThrows(d, Type.float64(), Short.class, Code.INVALID_ARGUMENT); - assertConvertThrows(d, Type.float64(), Byte.class, Code.INVALID_ARGUMENT); - assertConvertThrows(d, Type.float64(), BigInteger.class, Code.INVALID_ARGUMENT); - assertConvertThrows(d, Type.float64(), BigDecimal.class, Code.INVALID_ARGUMENT); - } - } - - private void assertConvertThrows(Object t, Type type, Class destinationType, Code code) - throws SQLException { - try { - convert(t, type, destinationType); - fail("missing conversion exception for " + t); - } catch (JdbcSqlExceptionImpl e) { - assertThat(e.getCode()).isEqualTo(code); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testToGoogleDate() { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - assertThat(toGoogleDate(new Date(2019 - 1900, 7, 24))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 8, 24)); - assertThat(toGoogleDate(new Date(2019 - 1900, 0, 1))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 1, 1)); - assertThat(toGoogleDate(new Date(2019 - 1900, 11, 31))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 12, 31)); - assertThat(toGoogleDate(new Date(2016 - 1900, 1, 29))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2016, 2, 29)); - assertThat(toGoogleDate(new Date(2000 - 1900, 1, 29))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2000, 2, 29)); - - assertThat(toGoogleDate(new Time(12, 0, 0))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1)); - assertThat(toGoogleDate(new Time(0, 0, 0))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1)); - assertThat(toGoogleDate(new Time(23, 59, 59))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(1970, 1, 1)); - - assertThat(toGoogleDate(new Timestamp(2019 - 1900, 7, 24, 8, 51, 21, 987))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 8, 24)); - assertThat(toGoogleDate(new Timestamp(2019 - 1900, 0, 1, 0, 0, 0, 0))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 1, 1)); - assertThat(toGoogleDate(new Timestamp(2019 - 1900, 11, 31, 23, 59, 59, 100))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2019, 12, 31)); - assertThat(toGoogleDate(new Timestamp(2016 - 1900, 1, 29, 23, 59, 59, 0))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2016, 2, 29)); - assertThat(toGoogleDate(new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0))) - .isEqualTo(com.google.cloud.Date.fromYearMonthDay(2000, 2, 29)); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @Test - public void testToGoogleDates() { - @SuppressWarnings("deprecation") - Date[] dates = - new Date[] { - new Date(2019 - 1900, 7, 24), - new Date(2019 - 1900, 0, 1), - new Date(2019 - 1900, 11, 31), - new Date(2016 - 1900, 1, 29), - new Date(2000 - 1900, 1, 29) - }; - List expected = - Arrays.asList( - com.google.cloud.Date.fromYearMonthDay(2019, 8, 24), - com.google.cloud.Date.fromYearMonthDay(2019, 1, 1), - com.google.cloud.Date.fromYearMonthDay(2019, 12, 31), - com.google.cloud.Date.fromYearMonthDay(2016, 2, 29), - com.google.cloud.Date.fromYearMonthDay(2000, 2, 29)); - assertThat(toGoogleDates(dates)).isEqualTo(expected); - } - - @SuppressWarnings("deprecation") - @Test - public void testToSqlDate() { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - assertThat(toSqlDate(com.google.cloud.Date.fromYearMonthDay(2019, 8, 24))) - .isEqualTo(new Date(2019 - 1900, 7, 24)); - assertThat(toSqlDate(com.google.cloud.Date.fromYearMonthDay(2019, 1, 1))) - .isEqualTo(new Date(2019 - 1900, 0, 1)); - assertThat(toSqlDate(com.google.cloud.Date.fromYearMonthDay(2019, 12, 31))) - .isEqualTo(new Date(2019 - 1900, 11, 31)); - assertThat(toSqlDate(com.google.cloud.Date.fromYearMonthDay(2016, 2, 29))) - .isEqualTo(new Date(2016 - 1900, 1, 29)); - assertThat(toSqlDate(com.google.cloud.Date.fromYearMonthDay(2000, 2, 29))) - .isEqualTo(new Date(2000 - 1900, 1, 29)); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @Test - public void testToSqlDateWithCalendar() { - for (TimeZone zone : getTestTimeZones()) { - Calendar cal = Calendar.getInstance(zone); - cal.set(2019, 7, 24, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - assertThat( - toSqlDate( - com.google.cloud.Date.fromYearMonthDay(2019, 8, 24), Calendar.getInstance(zone))) - .isEqualTo(new Date(cal.getTimeInMillis())); - - cal.set(2019, 0, 1, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - assertThat( - toSqlDate( - com.google.cloud.Date.fromYearMonthDay(2019, 1, 1), Calendar.getInstance(zone))) - .isEqualTo(new Date(cal.getTimeInMillis())); - - cal.set(2019, 11, 31, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - assertThat( - toSqlDate( - com.google.cloud.Date.fromYearMonthDay(2019, 12, 31), Calendar.getInstance(zone))) - .isEqualTo(new Date(cal.getTimeInMillis())); - - cal.set(2016, 1, 29, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - assertThat( - toSqlDate( - com.google.cloud.Date.fromYearMonthDay(2016, 2, 29), Calendar.getInstance(zone))) - .isEqualTo(new Date(cal.getTimeInMillis())); - - cal.set(2000, 1, 29, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - assertThat( - toSqlDate( - com.google.cloud.Date.fromYearMonthDay(2000, 2, 29), Calendar.getInstance(zone))) - .isEqualTo(new Date(cal.getTimeInMillis())); - } - } - - @Test - public void testToSqlDates() { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - List input = - Arrays.asList( - com.google.cloud.Date.fromYearMonthDay(2019, 8, 24), - com.google.cloud.Date.fromYearMonthDay(2019, 1, 1), - com.google.cloud.Date.fromYearMonthDay(2019, 12, 31), - com.google.cloud.Date.fromYearMonthDay(2016, 2, 29), - com.google.cloud.Date.fromYearMonthDay(2000, 2, 29)); - @SuppressWarnings("deprecation") - List expected = - Arrays.asList( - new Date(2019 - 1900, 7, 24), - new Date(2019 - 1900, 0, 1), - new Date(2019 - 1900, 11, 31), - new Date(2016 - 1900, 1, 29), - new Date(2000 - 1900, 1, 29)); - assertThat(toSqlDates(input)).isEqualTo(expected); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testToSqlTimestamp() throws SQLException { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - List sqlTimestamps = new ArrayList<>(); - List gTimestamps = new ArrayList<>(); - TimeZone.setDefault(zone); - - // Create a timestamp in the current default timezone, but do not set the nanosecond value - // yet, as it would be lost by the ts.getTime() call on the next line. - Timestamp ts = new Timestamp(2019 - 1900, 7, 24, 11 - 2, 23, 1, 0); - ts.setTime(ts.getTime() + zone.getRawOffset()); - ts.setNanos(199800000); - com.google.cloud.Timestamp gts = - ReadOnlyStalenessUtil.parseRfc3339("2019-08-24T11:23:01.1998+02:00"); - assertThat(toSqlTimestamp(gts)).isEqualTo(ts); - sqlTimestamps.add(ts); - gTimestamps.add(gts); - - ts = new Timestamp(2019 - 1900, 11, 31, 23, 59, 59, 0); - ts.setTime(ts.getTime() + zone.getRawOffset()); - ts.setNanos(999999999); - gts = ReadOnlyStalenessUtil.parseRfc3339("2019-12-31T23:59:59.999999999Z"); - assertThat(toSqlTimestamp(gts)).isEqualTo(ts); - sqlTimestamps.add(ts); - gTimestamps.add(gts); - - ts = new Timestamp(2016 - 1900, 1, 29, 12 + 2, 0, 1, 0); - ts.setTime(ts.getTime() + zone.getRawOffset()); - ts.setNanos(1000); - gts = ReadOnlyStalenessUtil.parseRfc3339("2016-02-29T12:00:01.000001000-02:00"); - assertThat(toSqlTimestamp(gts)).isEqualTo(ts); - sqlTimestamps.add(ts); - gTimestamps.add(gts); - - ts = new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0); - ts.setTime(ts.getTime() + zone.getRawOffset()); - ts.setNanos(100000000); - gts = ReadOnlyStalenessUtil.parseRfc3339("2000-02-29T00:00:00.100000000Z"); - assertThat(toSqlTimestamp(gts)).isEqualTo(ts); - sqlTimestamps.add(ts); - gTimestamps.add(gts); - - assertThat(toSqlTimestamps(gTimestamps)).isEqualTo(sqlTimestamps); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @Test - public void testGetAsSqlTimestamp() throws SQLException { - for (TimeZone zone : getTestTimeZones()) { - com.google.cloud.Timestamp gts = - ReadOnlyStalenessUtil.parseRfc3339("2019-08-24T11:23:01.1998+03:00"); - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+03:00")); - cal.set(2019, 7, 24, 11, 23, 1); - cal.set(Calendar.MILLISECOND, 0); - Timestamp ts = new Timestamp(cal.getTimeInMillis() + zone.getRawOffset()); - ts.setNanos(199800000); - assertThat(getAsSqlTimestamp(gts, Calendar.getInstance(zone))).isEqualTo(ts); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2019-12-31T23:59:59.999999999-03:00"); - cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-03:00")); - cal.set(2019, 11, 31, 23, 59, 59); - cal.set(Calendar.MILLISECOND, 0); - ts = new Timestamp(cal.getTimeInMillis() + zone.getRawOffset()); - ts.setNanos(999999999); - assertThat(getAsSqlTimestamp(gts, Calendar.getInstance(zone))).isEqualTo(ts); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2016-02-29T12:00:00Z"); - cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - cal.set(2016, 1, 29, 12, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - ts = new Timestamp(cal.getTimeInMillis() + zone.getRawOffset()); - assertThat(getAsSqlTimestamp(gts, Calendar.getInstance(zone))).isEqualTo(ts); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2000-02-29T00:00:00.000000000-10:00"); - cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-10:00")); - cal.set(2000, 1, 29, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - ts = new Timestamp(cal.getTimeInMillis() + zone.getRawOffset()); - assertThat(getAsSqlTimestamp(gts, Calendar.getInstance(zone))).isEqualTo(ts); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testSetTimestampInCalendar() throws SQLException { - for (TimeZone zone : getTestTimeZones()) { - Calendar cal = Calendar.getInstance(zone); - cal.set(2019, 7, 24, 11, 23, 1); - cal.set(Calendar.MILLISECOND, 0); - Timestamp ts = new Timestamp(2019 - 1900, 7, 24, 11, 23, 1, 0); - Timestamp tsInCal = setTimestampInCalendar(ts, Calendar.getInstance(zone)); - assertThat(tsInCal.getTime()) - .isEqualTo(cal.getTimeInMillis() - TimeZone.getDefault().getOffset(ts.getTime())); - - cal = Calendar.getInstance(zone); - cal.set(2019, 11, 31, 23, 59, 59); - cal.set(Calendar.MILLISECOND, 999); - ts = new Timestamp(2019 - 1900, 11, 31, 23, 59, 59, 999000000); - tsInCal = setTimestampInCalendar(ts, Calendar.getInstance(zone)); - assertThat(tsInCal.getTime()) - .isEqualTo(cal.getTimeInMillis() - TimeZone.getDefault().getOffset(ts.getTime())); - - cal = Calendar.getInstance(zone); - cal.set(2016, 1, 29, 12, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - ts = new Timestamp(2016 - 1900, 1, 29, 12, 0, 0, 0); - tsInCal = setTimestampInCalendar(ts, Calendar.getInstance(zone)); - assertThat(tsInCal.getTime()) - .isEqualTo(cal.getTimeInMillis() - TimeZone.getDefault().getOffset(ts.getTime())); - - cal = Calendar.getInstance(zone); - cal.set(2000, 1, 29, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - ts = new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0); - tsInCal = setTimestampInCalendar(ts, Calendar.getInstance(zone)); - assertThat(tsInCal.getTime()) - .isEqualTo(cal.getTimeInMillis() - TimeZone.getDefault().getOffset(ts.getTime())); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testToGoogleTimestamp() { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - assertThat(toGoogleTimestamp(new Date(2019 - 1900, 7, 24))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 7, 24, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Date(2019 - 1900, 0, 1))) - .isEqualTo(com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 0, 1, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Date(2019 - 1900, 11, 31))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 11, 31, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Date(2016 - 1900, 1, 29))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2016 - 1900, 1, 29, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Date(2000 - 1900, 1, 29))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0))); - - assertThat(toGoogleTimestamp(new Time(12, 0, 0))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(1970 - 1900, 0, 1, 12, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Time(0, 0, 0))) - .isEqualTo(com.google.cloud.Timestamp.of(new Timestamp(1970 - 1900, 0, 1, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Time(23, 59, 59))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(1970 - 1900, 0, 1, 23, 59, 59, 0))); - - assertThat(toGoogleTimestamp(new Timestamp(2019 - 1900, 7, 24, 8, 51, 21, 987))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 7, 24, 8, 51, 21, 987))); - assertThat(toGoogleTimestamp(new Timestamp(2019 - 1900, 0, 1, 0, 0, 0, 0))) - .isEqualTo(com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 0, 1, 0, 0, 0, 0))); - assertThat(toGoogleTimestamp(new Timestamp(2019 - 1900, 11, 31, 23, 59, 59, 100))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2019 - 1900, 11, 31, 23, 59, 59, 100))); - assertThat(toGoogleTimestamp(new Timestamp(2016 - 1900, 1, 29, 23, 59, 59, 0))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2016 - 1900, 1, 29, 23, 59, 59, 0))); - assertThat(toGoogleTimestamp(new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0))) - .isEqualTo( - com.google.cloud.Timestamp.of(new Timestamp(2000 - 1900, 1, 29, 0, 0, 0, 0))); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testToSqlTime() { - TimeZone initialDefault = TimeZone.getDefault(); - try { - for (TimeZone zone : getTestTimeZones()) { - TimeZone.setDefault(zone); - - com.google.cloud.Timestamp gts = - ReadOnlyStalenessUtil.parseRfc3339("2019-08-24T11:23:01.1998+03:00"); - // Subtract 3 hours to compensate for +03 timezone. - Time time = new Time(11 - 3, 23, 1); - time.setTime(time.getTime() + zone.getRawOffset()); - Time convertedTime = toSqlTime(gts); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2019-12-31T23:59:59.999999999Z"); - time = new Time(23, 59, 59); - time.setTime(time.getTime() + zone.getRawOffset()); - convertedTime = toSqlTime(gts); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2016-02-29T12:00:01.000001000-02:00"); - time = new Time(12 + 2, 0, 1); - time.setTime(time.getTime() + zone.getRawOffset()); - convertedTime = toSqlTime(gts); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2000-02-29T00:00:00.100000000Z"); - time = new Time(0, 0, 0); - time.setTime(time.getTime() + zone.getRawOffset()); - convertedTime = toSqlTime(gts); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - } - } finally { - TimeZone.setDefault(initialDefault); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testToSqlTimeWithCalendar() { - for (TimeZone zone : getTestTimeZones()) { - com.google.cloud.Timestamp gts = - ReadOnlyStalenessUtil.parseRfc3339("2019-08-24T11:23:01.1998+03:00"); - // Compensate for +03 - Time time = new Time(11 - 3, 23, 1); - // Compensate for the test timezone. - time.setHours(time.getHours() + ((int) (zone.getRawOffset() / 60_000L / 60))); - // Compensate for the timezone of the environment on the parsed date. - time.setHours( - time.getHours() - + ((int) - (TimeZone.getDefault().getOffset(gts.toSqlTimestamp().getTime()) - / 60_000L - / 60))); - Time convertedTime = toSqlTime(gts, Calendar.getInstance(zone)); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2019-12-31T23:59:59.999999999Z"); - time = new Time(23, 59, 59); - time.setHours(time.getHours() + ((int) (zone.getRawOffset() / 60_000L / 60))); - time.setHours( - time.getHours() - + ((int) - (TimeZone.getDefault().getOffset(gts.toSqlTimestamp().getTime()) - / 60_000L - / 60))); - convertedTime = toSqlTime(gts, Calendar.getInstance(zone)); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2016-02-29T12:00:01.000001000-02:00"); - time = new Time(12 + 2, 0, 1); - time.setHours(time.getHours() + ((int) (zone.getRawOffset() / 60_000L / 60))); - time.setHours( - time.getHours() - + ((int) - (TimeZone.getDefault().getOffset(gts.toSqlTimestamp().getTime()) - / 60_000L - / 60))); - convertedTime = toSqlTime(gts, Calendar.getInstance(zone)); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - - gts = ReadOnlyStalenessUtil.parseRfc3339("2000-02-29T00:00:00.100000000Z"); - time = new Time(0, 0, 0); - time.setHours(time.getHours() + ((int) (zone.getRawOffset() / 60_000L / 60))); - time.setHours( - time.getHours() - + ((int) - (TimeZone.getDefault().getOffset(gts.toSqlTimestamp().getTime()) - / 60_000L - / 60))); - convertedTime = toSqlTime(gts, Calendar.getInstance(zone)); - assertThat(convertedTime.getHours()).isEqualTo(time.getHours()); - assertThat(convertedTime.getMinutes()).isEqualTo(time.getMinutes()); - assertThat(convertedTime.getSeconds()).isEqualTo(time.getSeconds()); - } - } - - @Test - public void testToGoogleBytes() { - assertThat(toGoogleBytes(new byte[][] {"test1".getBytes(UTF8), "test2".getBytes(UTF8)})) - .isEqualTo(Arrays.asList(ByteArray.copyFrom("test1"), ByteArray.copyFrom("test2"))); - } - - @Test - public void testToJavaByteArrays() { - List input = Arrays.asList(ByteArray.copyFrom("test3"), ByteArray.copyFrom("test4")); - List expected = Arrays.asList("test3".getBytes(UTF8), "test4".getBytes(UTF8)); - List output = toJavaByteArrays(input); - assertThat(Arrays.deepEquals(expected.toArray(), output.toArray())).isTrue(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/RandomResultSetGenerator.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/RandomResultSetGenerator.java deleted file mode 100644 index 44e326cf917..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/RandomResultSetGenerator.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2019 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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.api.client.util.Base64; -import com.google.cloud.Date; -import com.google.cloud.Timestamp; -import com.google.protobuf.ListValue; -import com.google.protobuf.NullValue; -import com.google.protobuf.Value; -import com.google.protobuf.util.Timestamps; -import com.google.spanner.v1.ResultSet; -import com.google.spanner.v1.ResultSetMetadata; -import com.google.spanner.v1.StructType; -import com.google.spanner.v1.StructType.Field; -import com.google.spanner.v1.Type; -import com.google.spanner.v1.TypeCode; -import java.util.Random; - -public class RandomResultSetGenerator { - private static final Type TYPES[] = - new Type[] { - Type.newBuilder().setCode(TypeCode.BOOL).build(), - Type.newBuilder().setCode(TypeCode.INT64).build(), - Type.newBuilder().setCode(TypeCode.FLOAT64).build(), - Type.newBuilder().setCode(TypeCode.STRING).build(), - Type.newBuilder().setCode(TypeCode.BYTES).build(), - Type.newBuilder().setCode(TypeCode.DATE).build(), - Type.newBuilder().setCode(TypeCode.TIMESTAMP).build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.BOOL)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.INT64)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.FLOAT64)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.STRING)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.BYTES)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.DATE)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.TIMESTAMP)) - .build(), - }; - - private static final ResultSetMetadata generateMetadata() { - StructType.Builder rowTypeBuilder = StructType.newBuilder(); - for (int col = 0; col < TYPES.length; col++) { - rowTypeBuilder.addFields(Field.newBuilder().setName("COL" + col).setType(TYPES[col])).build(); - } - ResultSetMetadata.Builder builder = ResultSetMetadata.newBuilder(); - builder.setRowType(rowTypeBuilder.build()); - return builder.build(); - } - - private static final ResultSetMetadata METADATA = generateMetadata(); - - private final int rowCount; - private final Random random = new Random(); - - public RandomResultSetGenerator(int rowCount) { - this.rowCount = rowCount; - } - - public ResultSet generate() { - ResultSet.Builder builder = ResultSet.newBuilder(); - for (int row = 0; row < rowCount; row++) { - ListValue.Builder rowBuilder = ListValue.newBuilder(); - for (int col = 0; col < TYPES.length; col++) { - Value.Builder valueBuilder = Value.newBuilder(); - setRandomValue(valueBuilder, TYPES[col]); - rowBuilder.addValues(valueBuilder.build()); - } - builder.addRows(rowBuilder.build()); - } - builder.setMetadata(METADATA); - return builder.build(); - } - - private void setRandomValue(Value.Builder builder, Type type) { - if (randomNull()) { - builder.setNullValue(NullValue.NULL_VALUE); - } else { - switch (type.getCode()) { - case ARRAY: - int length = random.nextInt(20) + 1; - ListValue.Builder arrayBuilder = ListValue.newBuilder(); - for (int i = 0; i < length; i++) { - Value.Builder valueBuilder = Value.newBuilder(); - setRandomValue(valueBuilder, type.getArrayElementType()); - arrayBuilder.addValues(valueBuilder.build()); - } - builder.setListValue(arrayBuilder.build()); - break; - case BOOL: - builder.setBoolValue(random.nextBoolean()); - break; - case STRING: - case BYTES: - byte[] bytes = new byte[random.nextInt(200)]; - random.nextBytes(bytes); - builder.setStringValue(Base64.encodeBase64String(bytes)); - break; - case DATE: - Date date = - Date.fromYearMonthDay( - random.nextInt(2019) + 1, random.nextInt(11) + 1, random.nextInt(28) + 1); - builder.setStringValue(date.toString()); - break; - case FLOAT64: - builder.setNumberValue(random.nextDouble()); - break; - case INT64: - builder.setStringValue(String.valueOf(random.nextLong())); - break; - case TIMESTAMP: - com.google.protobuf.Timestamp ts = - Timestamps.add( - Timestamps.EPOCH, - com.google.protobuf.Duration.newBuilder() - .setSeconds(random.nextInt(100_000_000)) - .setNanos(random.nextInt(1000_000_000)) - .build()); - builder.setStringValue(Timestamp.fromProto(ts).toString()); - break; - case STRUCT: - case TYPE_CODE_UNSPECIFIED: - case UNRECOGNIZED: - default: - throw new IllegalArgumentException("Unknown or unsupported type: " + type.getCode()); - } - } - } - - private boolean randomNull() { - return random.nextInt(10) == 0; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessConverterTest.java deleted file mode 100644 index 830c9085156..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessConverterTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.ClientSideStatementValueConverters.ReadOnlyStalenessConverter; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ReadOnlyStalenessConverterTest { - - static String getAllowedValues( - Class> converterClass) - throws CompileException { - Set statements = ClientSideStatements.INSTANCE.getCompiledStatements(); - for (ClientSideStatementImpl statement : statements) { - if (statement.getSetStatement() != null - && converterClass.getName().endsWith(statement.getSetStatement().getConverterName())) { - return statement.getSetStatement().getAllowedValues(); - } - } - return null; - } - - @Test - public void testConvert() throws CompileException { - String allowedValues = getAllowedValues(ReadOnlyStalenessConverter.class); - assertThat(allowedValues, is(notNullValue())); - ReadOnlyStalenessConverter converter = new ReadOnlyStalenessConverter(allowedValues); - - assertThat(converter.convert("strong"), is(equalTo(TimestampBound.strong()))); - assertThat(converter.convert("Strong"), is(equalTo(TimestampBound.strong()))); - assertThat(converter.convert("STRONG"), is(equalTo(TimestampBound.strong()))); - - assertThat( - converter.convert("read_timestamp 2018-10-01T23:11:15.10001Z"), - is( - equalTo( - TimestampBound.ofReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.10001Z"))))); - assertThat( - converter.convert("Read_Timestamp 2018-10-01T23:11:15.999Z"), - is( - equalTo( - TimestampBound.ofReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.999Z"))))); - assertThat( - converter.convert("READ_TIMESTAMP 2018-10-01T23:11:15.1000Z"), - is( - equalTo( - TimestampBound.ofReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.1000Z"))))); - assertThat( - converter.convert("read_timestamp 2018-10-01T23:11:15.999999999Z"), - is( - equalTo( - TimestampBound.ofReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.999999999Z"))))); - assertThat( - converter.convert("read_timestamp\t2018-10-01T23:11:15.10001Z"), - is( - equalTo( - TimestampBound.ofReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.10001Z"))))); - assertThat(converter.convert("read_timestamp\n2018-10-01T23:11:15.10001Z"), is(nullValue())); - - assertThat( - converter.convert("min_read_timestamp 2018-10-01T23:11:15.10001Z"), - is( - equalTo( - TimestampBound.ofMinReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.10001Z"))))); - assertThat( - converter.convert("Min_Read_Timestamp 2018-10-01T23:11:15.999Z"), - is( - equalTo( - TimestampBound.ofMinReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.999Z"))))); - assertThat( - converter.convert("MIN_READ_TIMESTAMP 2018-10-01T23:11:15.1000Z"), - is( - equalTo( - TimestampBound.ofMinReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.1000Z"))))); - assertThat( - converter.convert("min_read_timestamp 2018-10-01T23:11:15.999999999Z"), - is( - equalTo( - TimestampBound.ofMinReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.999999999Z"))))); - assertThat( - converter.convert("min_read_timestamp\t2018-10-01T23:11:15.10001Z"), - is( - equalTo( - TimestampBound.ofMinReadTimestamp( - Timestamp.parseTimestamp("2018-10-01T23:11:15.10001Z"))))); - assertThat( - converter.convert("min_read_timestamp\n2018-10-01T23:11:15.10001Z"), is(nullValue())); - - assertThat( - converter.convert("exact_staleness 10s"), - is(equalTo(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)))); - assertThat( - converter.convert("Exact_Staleness 100ms"), - is(equalTo(TimestampBound.ofExactStaleness(100L, TimeUnit.MILLISECONDS)))); - assertThat( - converter.convert("EXACT_STALENESS 99999us"), - is(equalTo(TimestampBound.ofExactStaleness(99999L, TimeUnit.MICROSECONDS)))); - assertThat( - converter.convert("exact_staleness 999999999ns"), - is(equalTo(TimestampBound.ofExactStaleness(999999999L, TimeUnit.NANOSECONDS)))); - assertThat( - converter.convert("exact_staleness " + Long.MAX_VALUE + "ns"), - is(equalTo(TimestampBound.ofExactStaleness(Long.MAX_VALUE, TimeUnit.NANOSECONDS)))); - - assertThat( - converter.convert("max_staleness 10s"), - is(equalTo(TimestampBound.ofMaxStaleness(10L, TimeUnit.SECONDS)))); - assertThat( - converter.convert("Max_Staleness 100ms"), - is(equalTo(TimestampBound.ofMaxStaleness(100L, TimeUnit.MILLISECONDS)))); - assertThat( - converter.convert("MAX_STALENESS 99999us"), - is(equalTo(TimestampBound.ofMaxStaleness(99999L, TimeUnit.MICROSECONDS)))); - assertThat( - converter.convert("max_staleness 999999999ns"), - is(equalTo(TimestampBound.ofMaxStaleness(999999999L, TimeUnit.NANOSECONDS)))); - assertThat( - converter.convert("max_staleness " + Long.MAX_VALUE + "ns"), - is(equalTo(TimestampBound.ofMaxStaleness(Long.MAX_VALUE, TimeUnit.NANOSECONDS)))); - - assertThat(converter.convert(""), is(nullValue())); - assertThat(converter.convert(" "), is(nullValue())); - assertThat(converter.convert("random string"), is(nullValue())); - assertThat(converter.convert("read_timestamp"), is(nullValue())); - assertThat(converter.convert("min_read_timestamp"), is(nullValue())); - assertThat(converter.convert("exact_staleness"), is(nullValue())); - assertThat(converter.convert("max_staleness"), is(nullValue())); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessTest.java deleted file mode 100644 index 6c0ca2d48b6..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.NoCredentials; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ReadOnlyTransaction; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.Matchers; - -@RunWith(JUnit4.class) -public class ReadOnlyStalenessTest { - private static final String URI = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database?readOnly=true"; - private static final String SELECT = "select foo from bar"; - - private final DatabaseClient dbClient = mock(DatabaseClient.class); - - private ConnectionImpl createConnection(ConnectionOptions options) { - Spanner spanner = mock(Spanner.class); - SpannerPool spannerPool = mock(SpannerPool.class); - when(spannerPool.getSpanner(any(ConnectionOptions.class), any(ConnectionImpl.class))) - .thenReturn(spanner); - DdlClient ddlClient = mock(DdlClient.class); - ReadOnlyTransaction singleUseReadOnlyTx = mock(ReadOnlyTransaction.class); - when(singleUseReadOnlyTx.executeQuery(Statement.of(SELECT))).thenReturn(mock(ResultSet.class)); - when(dbClient.singleUseReadOnlyTransaction(Matchers.any(TimestampBound.class))) - .thenReturn(singleUseReadOnlyTx); - ReadOnlyTransaction readOnlyTx = mock(ReadOnlyTransaction.class); - when(readOnlyTx.executeQuery(Statement.of(SELECT))).thenReturn(mock(ResultSet.class)); - when(dbClient.readOnlyTransaction(Matchers.any(TimestampBound.class))).thenReturn(readOnlyTx); - - return new ConnectionImpl(options, spannerPool, ddlClient, dbClient); - } - - @Test - public void testDefaultReadOnlyStalenessAutocommitOnce() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(connection.isAutocommit(), is(true)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).singleUseReadOnlyTransaction(TimestampBound.strong()); - } - } - - @Test - public void testDefaultReadOnlyStalenessAutocommitTwice() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(connection.isAutocommit(), is(true)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - connection.execute(Statement.of(SELECT)); - verify(dbClient, times(2)).singleUseReadOnlyTransaction(TimestampBound.strong()); - } - } - - @Test - public void testDefaultReadOnlyStalenessAutocommitChanging() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - assertThat(connection.isAutocommit(), is(true)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).singleUseReadOnlyTransaction(TimestampBound.strong()); - - connection.setReadOnlyStaleness(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - connection.execute(Statement.of(SELECT)); - verify(dbClient) - .singleUseReadOnlyTransaction(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - - connection.setReadOnlyStaleness(TimestampBound.ofMaxStaleness(5L, TimeUnit.SECONDS)); - connection.execute(Statement.of(SELECT)); - verify(dbClient) - .singleUseReadOnlyTransaction(TimestampBound.ofMaxStaleness(5L, TimeUnit.SECONDS)); - - connection.setReadOnlyStaleness(TimestampBound.ofReadTimestamp(Timestamp.MIN_VALUE)); - connection.execute(Statement.of(SELECT)); - verify(dbClient) - .singleUseReadOnlyTransaction(TimestampBound.ofReadTimestamp(Timestamp.MIN_VALUE)); - - connection.setReadOnlyStaleness(TimestampBound.ofMinReadTimestamp(Timestamp.MAX_VALUE)); - connection.execute(Statement.of(SELECT)); - verify(dbClient) - .singleUseReadOnlyTransaction(TimestampBound.ofMinReadTimestamp(Timestamp.MAX_VALUE)); - } - } - - @Test - public void testDefaultReadOnlyStalenessTransactionalOnce() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - assertThat(connection.isAutocommit(), is(false)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).readOnlyTransaction(TimestampBound.strong()); - } - } - - @Test - public void testDefaultReadOnlyStalenessTransactionalTwice() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - assertThat(connection.isAutocommit(), is(false)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - connection.execute(Statement.of(SELECT)); - connection.commit(); - // one transaction - verify(dbClient, times(1)).readOnlyTransaction(TimestampBound.strong()); - - connection.execute(Statement.of(SELECT)); - connection.commit(); - connection.execute(Statement.of(SELECT)); - // two transactions (plus one above) - verify(dbClient, times(3)).readOnlyTransaction(TimestampBound.strong()); - } - } - - @Test - public void testDefaultReadOnlyStalenessTransactionalChanging() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - assertThat(connection.isAutocommit(), is(false)); - assertThat(connection.isReadOnly(), is(true)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).readOnlyTransaction(TimestampBound.strong()); - connection.commit(); - - connection.setReadOnlyStaleness(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).readOnlyTransaction(TimestampBound.ofExactStaleness(10L, TimeUnit.SECONDS)); - connection.commit(); - - connection.setReadOnlyStaleness(TimestampBound.ofReadTimestamp(Timestamp.MIN_VALUE)); - connection.execute(Statement.of(SELECT)); - verify(dbClient).readOnlyTransaction(TimestampBound.ofReadTimestamp(Timestamp.MIN_VALUE)); - connection.commit(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtilTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtilTest.java deleted file mode 100644 index 4c96632f371..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyStalenessUtilTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.durationToString; -import static com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.getTimeUnitAbbreviation; -import static com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.parseRfc3339; -import static com.google.cloud.spanner.jdbc.ReadOnlyStalenessUtil.parseTimeUnit; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.TimestampBound; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ReadOnlyStalenessUtilTest { - - @Test - public void testParseRfc3339() { - Map timestamps = new HashMap<>(); - timestamps.put( - "2018-03-01T10:11:12.999Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 999000000)); - timestamps.put("2018-10-28T02:00:00+02:00", Timestamp.ofTimeSecondsAndNanos(1540684800L, 0)); - timestamps.put("2018-10-28T03:00:00+01:00", Timestamp.ofTimeSecondsAndNanos(1540692000L, 0)); - timestamps.put( - "2018-01-01T00:00:00.000000001Z", Timestamp.ofTimeSecondsAndNanos(1514764800L, 1)); - timestamps.put("2018-10-28T02:00:00Z", Timestamp.ofTimeSecondsAndNanos(1540692000L, 0)); - timestamps.put( - "2018-12-31T23:59:59.999999999Z", Timestamp.ofTimeSecondsAndNanos(1546300799L, 999999999)); - timestamps.put( - "2018-03-01T10:11:12.9999Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 999900000)); - timestamps.put( - "2018-03-01T10:11:12.000000001Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 1)); - timestamps.put( - "2018-03-01T10:11:12.100000000Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 100000000)); - timestamps.put( - "2018-03-01T10:11:12.100000001Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 100000001)); - timestamps.put("2018-03-01T10:11:12-10:00", Timestamp.ofTimeSecondsAndNanos(1519935072L, 0)); - timestamps.put( - "2018-03-01T10:11:12.999999999Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 999999999)); - timestamps.put("2018-03-01T10:11:12-12:00", Timestamp.ofTimeSecondsAndNanos(1519942272L, 0)); - timestamps.put("2018-10-28T03:00:00Z", Timestamp.ofTimeSecondsAndNanos(1540695600L, 0)); - timestamps.put("2018-10-28T02:30:00Z", Timestamp.ofTimeSecondsAndNanos(1540693800L, 0)); - timestamps.put( - "2018-03-01T10:11:12.123Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 123000000)); - timestamps.put("2018-10-28T02:30:00+02:00", Timestamp.ofTimeSecondsAndNanos(1540686600L, 0)); - timestamps.put( - "2018-03-01T10:11:12.123456789Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 123456789)); - timestamps.put( - "2018-03-01T10:11:12.1000Z", Timestamp.ofTimeSecondsAndNanos(1519899072L, 100000000)); - - for (Entry ts : timestamps.entrySet()) { - Timestamp gTimestamp = parseRfc3339(ts.getKey()); - assertThat( - "Seconds for timestamp " + ts + " do not match", - gTimestamp.getSeconds(), - is(equalTo(ts.getValue().getSeconds()))); - assertThat( - "Nanos for timestamp " + ts + " do not match", - gTimestamp.getNanos(), - is(equalTo(ts.getValue().getNanos()))); - } - } - - @Test - public void testParseTimeUnit() { - assertThat(parseTimeUnit("s"), is(equalTo(TimeUnit.SECONDS))); - assertThat(parseTimeUnit("ms"), is(equalTo(TimeUnit.MILLISECONDS))); - assertThat(parseTimeUnit("us"), is(equalTo(TimeUnit.MICROSECONDS))); - assertThat(parseTimeUnit("ns"), is(equalTo(TimeUnit.NANOSECONDS))); - } - - @Test - public void testGetTimeUnitAbbreviation() { - assertThat(getTimeUnitAbbreviation(TimeUnit.SECONDS), is(equalTo("s"))); - assertThat(getTimeUnitAbbreviation(TimeUnit.MILLISECONDS), is(equalTo("ms"))); - assertThat(getTimeUnitAbbreviation(TimeUnit.MICROSECONDS), is(equalTo("us"))); - assertThat(getTimeUnitAbbreviation(TimeUnit.NANOSECONDS), is(equalTo("ns"))); - - List supportedTimeUnits = - Arrays.asList( - TimeUnit.SECONDS, TimeUnit.MILLISECONDS, TimeUnit.MICROSECONDS, TimeUnit.NANOSECONDS); - for (TimeUnit unit : TimeUnit.values()) { - if (supportedTimeUnits.contains(unit)) { - assertThat(getTimeUnitAbbreviation(unit), is(notNullValue())); - } else { - String value = null; - try { - value = getTimeUnitAbbreviation(unit); - } catch (SpannerException e) { - if (e.getErrorCode() == ErrorCode.INVALID_ARGUMENT) { - value = "unsupported"; - } - } - assertThat(value, is(equalTo("unsupported"))); - } - } - } - - @Test - public void testStalenessToString() { - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(10L, TimeUnit.NANOSECONDS))), - is(equalTo("10ns"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(1000L, TimeUnit.NANOSECONDS))), - is(equalTo("1us"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(100000L, TimeUnit.NANOSECONDS))), - is(equalTo("100us"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(999999L, TimeUnit.NANOSECONDS))), - is(equalTo("999999ns"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(1L, TimeUnit.SECONDS))), - is(equalTo("1s"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(1000L, TimeUnit.MILLISECONDS))), - is(equalTo("1s"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(1001L, TimeUnit.MILLISECONDS))), - is(equalTo("1001ms"))); - assertThat( - durationToString( - new ReadOnlyStalenessUtil.MaxStalenessGetter( - TimestampBound.ofMaxStaleness(1000000000L, TimeUnit.NANOSECONDS))), - is(equalTo("1s"))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyTransactionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyTransactionTest.java deleted file mode 100644 index fe7622d934c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadOnlyTransactionTest.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Key; -import com.google.cloud.spanner.KeySet; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.Options.ReadOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState; -import com.google.spanner.v1.ResultSetStats; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ReadOnlyTransactionTest { - @Rule public ExpectedException exception = ExpectedException.none(); - - private static final class SimpleReadOnlyTransaction - implements com.google.cloud.spanner.ReadOnlyTransaction { - private Timestamp readTimestamp = null; - private final TimestampBound staleness; - - private SimpleReadOnlyTransaction(TimestampBound staleness) { - this.staleness = staleness; - } - - @Override - public ResultSet read( - String table, KeySet keys, Iterable columns, ReadOption... options) { - return null; - } - - @Override - public ResultSet readUsingIndex( - String table, String index, KeySet keys, Iterable columns, ReadOption... options) { - return null; - } - - @Override - public Struct readRow(String table, Key key, Iterable columns) { - return null; - } - - @Override - public Struct readRowUsingIndex(String table, String index, Key key, Iterable columns) { - return null; - } - - @Override - public ResultSet executeQuery(Statement statement, QueryOption... options) { - if (readTimestamp == null) { - switch (staleness.getMode()) { - case STRONG: - readTimestamp = Timestamp.now(); - break; - case READ_TIMESTAMP: - readTimestamp = staleness.getReadTimestamp(); - break; - case MIN_READ_TIMESTAMP: - readTimestamp = staleness.getMinReadTimestamp(); - break; - case EXACT_STALENESS: - Calendar cal = Calendar.getInstance(); - cal.add( - Calendar.MILLISECOND, (int) -staleness.getExactStaleness(TimeUnit.MILLISECONDS)); - readTimestamp = Timestamp.of(cal.getTime()); - break; - case MAX_STALENESS: - cal = Calendar.getInstance(); - cal.add(Calendar.MILLISECOND, (int) -staleness.getMaxStaleness(TimeUnit.MILLISECONDS)); - readTimestamp = Timestamp.of(cal.getTime()); - break; - default: - throw new IllegalStateException(); - } - } - return mock(ResultSet.class); - } - - @Override - public ResultSet analyzeQuery(Statement statement, QueryAnalyzeMode queryMode) { - ResultSet res = executeQuery(statement); - when(res.getStats()).thenReturn(ResultSetStats.getDefaultInstance()); - return res; - } - - @Override - public void close() {} - - @Override - public Timestamp getReadTimestamp() { - return readTimestamp; - } - } - - private ReadOnlyTransaction createSubject() { - return createSubject(TimestampBound.strong()); - } - - private ReadOnlyTransaction createSubject(TimestampBound staleness) { - DatabaseClient client = mock(DatabaseClient.class); - when(client.readOnlyTransaction(staleness)) - .thenReturn(new SimpleReadOnlyTransaction(staleness)); - return ReadOnlyTransaction.newBuilder() - .setDatabaseClient(client) - .setReadOnlyStaleness(staleness) - .withStatementExecutor(new StatementExecutor()) - .build(); - } - - @Test - public void testExecuteDdl() { - ParsedStatement ddl = mock(ParsedStatement.class); - when(ddl.getType()).thenReturn(StatementType.DDL); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - createSubject().executeDdl(ddl); - } - - @Test - public void testExecuteUpdate() { - ParsedStatement update = mock(ParsedStatement.class); - when(update.getType()).thenReturn(StatementType.UPDATE); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - createSubject().executeUpdate(update); - } - - @Test - public void testWrite() { - Mutation mutation = Mutation.newInsertBuilder("foo").build(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - createSubject().write(mutation); - } - - @Test - public void testWriteIterable() { - Mutation mutation = Mutation.newInsertBuilder("foo").build(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - createSubject().write(Arrays.asList(mutation, mutation)); - } - - @Test - public void testRunBatch() { - ReadOnlyTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.runBatch(); - } - - @Test - public void testAbortBatch() { - ReadOnlyTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.abortBatch(); - } - - @Test - public void testGetCommitTimestamp() { - ReadOnlyTransaction transaction = createSubject(); - transaction.commit(); - assertThat(transaction.getState(), is(UnitOfWorkState.COMMITTED)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - transaction.getCommitTimestamp(); - } - - @Test - public void testIsReadOnly() { - assertThat(createSubject().isReadOnly(), is(true)); - } - - @Test - public void testExecuteQuery() { - for (TimestampBound staleness : getTestTimestampBounds()) { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - - ReadOnlyTransaction transaction = createSubject(staleness); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.NONE); - assertThat(rs, is(notNullValue())); - assertThat(rs.getStats(), is(nullValue())); - } - } - - @Test - public void testExecuteQueryWithOptionsTest() { - String sql = "SELECT * FROM FOO"; - QueryOption option = Options.prefetchChunks(10000); - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of(sql); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - DatabaseClient client = mock(DatabaseClient.class); - com.google.cloud.spanner.ReadOnlyTransaction tx = - mock(com.google.cloud.spanner.ReadOnlyTransaction.class); - ResultSet resWithOptions = mock(ResultSet.class); - ResultSet resWithoutOptions = mock(ResultSet.class); - when(tx.executeQuery(Statement.of(sql), option)).thenReturn(resWithOptions); - when(tx.executeQuery(Statement.of(sql))).thenReturn(resWithoutOptions); - when(client.readOnlyTransaction(TimestampBound.strong())).thenReturn(tx); - - ReadOnlyTransaction transaction = - ReadOnlyTransaction.newBuilder() - .setDatabaseClient(client) - .setReadOnlyStaleness(TimestampBound.strong()) - .withStatementExecutor(new StatementExecutor()) - .build(); - ResultSet expectedWithOptions = DirectExecuteResultSet.ofResultSet(resWithOptions); - assertThat( - transaction.executeQuery(parsedStatement, AnalyzeMode.NONE, option), - is(equalTo(expectedWithOptions))); - ResultSet expectedWithoutOptions = DirectExecuteResultSet.ofResultSet(resWithoutOptions); - assertThat( - transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), - is(equalTo(expectedWithoutOptions))); - } - - @Test - public void testPlanQuery() { - for (TimestampBound staleness : getTestTimestampBounds()) { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - - ReadOnlyTransaction transaction = createSubject(staleness); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.PLAN); - assertThat(rs, is(notNullValue())); - // get all results and then get the stats - while (rs.next()) { - // do nothing - } - assertThat(rs.getStats(), is(notNullValue())); - } - } - - @Test - public void testProfileQuery() { - for (TimestampBound staleness : getTestTimestampBounds()) { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - - ReadOnlyTransaction transaction = createSubject(staleness); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.PROFILE); - assertThat(rs, is(notNullValue())); - // get all results and then get the stats - while (rs.next()) { - // do nothing - } - assertThat(rs.getStats(), is(notNullValue())); - } - } - - @Test - public void testGetReadTimestamp() { - for (TimestampBound staleness : getTestTimestampBounds()) { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - - ReadOnlyTransaction transaction = createSubject(staleness); - boolean expectedException = false; - try { - transaction.getReadTimestamp(); - } catch (SpannerException e) { - if (e.getErrorCode() == ErrorCode.FAILED_PRECONDITION) { - expectedException = true; - } - } - assertThat(expectedException, is(true)); - assertThat(transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), is(notNullValue())); - assertThat(transaction.getReadTimestamp(), is(notNullValue())); - } - } - - private List getTestTimestampBounds() { - return Arrays.asList( - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(Timestamp.now()), - TimestampBound.ofMinReadTimestamp(Timestamp.now()), - TimestampBound.ofExactStaleness(1L, TimeUnit.SECONDS), - TimestampBound.ofMaxStaleness(100L, TimeUnit.MILLISECONDS)); - } - - @Test - public void testState() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - when(parsedStatement.getSqlWithoutComments()).thenReturn(statement.getSql()); - - ReadOnlyTransaction transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - transaction.commit(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED))); - assertThat(transaction.isActive(), is(false)); - - transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - assertThat(transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), is(notNullValue())); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - - transaction.commit(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED))); - assertThat(transaction.isActive(), is(false)); - - // start a new transaction - transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - transaction.rollback(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.ROLLED_BACK))); - assertThat(transaction.isActive(), is(false)); - - transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - assertThat(transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), is(notNullValue())); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - transaction.rollback(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.ROLLED_BACK))); - assertThat(transaction.isActive(), is(false)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadWriteTransactionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadWriteTransactionTest.java deleted file mode 100644 index f64ff464d48..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReadWriteTransactionTest.java +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionManager.TransactionState; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.spanner.v1.ResultSetStats; -import java.util.Arrays; -import java.util.Collections; -import java.util.concurrent.ExecutionException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class ReadWriteTransactionTest { - - @Rule public final ExpectedException exception = ExpectedException.none(); - - private enum CommitBehavior { - SUCCEED, - FAIL, - ABORT; - } - - private static class SimpleTransactionManager implements TransactionManager { - private TransactionState state; - private Timestamp commitTimestamp; - private TransactionContext txContext; - private CommitBehavior commitBehavior; - - private SimpleTransactionManager(TransactionContext txContext, CommitBehavior commitBehavior) { - this.txContext = txContext; - this.commitBehavior = commitBehavior; - } - - @Override - public TransactionContext begin() { - state = TransactionState.STARTED; - return txContext; - } - - @Override - public void commit() { - switch (commitBehavior) { - case SUCCEED: - commitTimestamp = Timestamp.now(); - state = TransactionState.COMMITTED; - break; - case FAIL: - state = TransactionState.COMMIT_FAILED; - throw SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, "commit failed"); - case ABORT: - state = TransactionState.COMMIT_FAILED; - commitBehavior = CommitBehavior.SUCCEED; - throw SpannerExceptionFactory.newSpannerException(ErrorCode.ABORTED, "commit aborted"); - default: - throw new IllegalStateException(); - } - } - - @Override - public void rollback() { - state = TransactionState.ROLLED_BACK; - } - - @Override - public TransactionContext resetForRetry() { - return txContext; - } - - @Override - public Timestamp getCommitTimestamp() { - return commitTimestamp; - } - - @Override - public TransactionState getState() { - return state; - } - - @Override - public void close() { - if (state != TransactionState.COMMITTED) { - state = TransactionState.ROLLED_BACK; - } - } - } - - private ReadWriteTransaction createSubject() { - return createSubject(CommitBehavior.SUCCEED, false); - } - - private ReadWriteTransaction createSubject(CommitBehavior commitBehavior) { - return createSubject(commitBehavior, false); - } - - private ReadWriteTransaction createSubject( - final CommitBehavior commitBehavior, boolean withRetry) { - DatabaseClient client = mock(DatabaseClient.class); - when(client.transactionManager()) - .thenAnswer( - new Answer() { - @Override - public TransactionManager answer(InvocationOnMock invocation) throws Throwable { - TransactionContext txContext = mock(TransactionContext.class); - when(txContext.executeQuery(any(Statement.class))) - .thenReturn(mock(ResultSet.class)); - ResultSet rsWithStats = mock(ResultSet.class); - when(rsWithStats.getStats()).thenReturn(ResultSetStats.getDefaultInstance()); - when(txContext.analyzeQuery(any(Statement.class), any(QueryAnalyzeMode.class))) - .thenReturn(rsWithStats); - when(txContext.executeUpdate(any(Statement.class))).thenReturn(1L); - return new SimpleTransactionManager(txContext, commitBehavior); - } - }); - return ReadWriteTransaction.newBuilder() - .setDatabaseClient(client) - .setRetryAbortsInternally(withRetry) - .setTransactionRetryListeners(Collections.emptyList()) - .withStatementExecutor(new StatementExecutor()) - .build(); - } - - @Test - public void testExecuteDdl() { - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.DDL); - - ReadWriteTransaction transaction = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - transaction.executeDdl(statement); - } - - @Test - public void testRunBatch() { - ReadWriteTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.runBatch(); - } - - @Test - public void testAbortBatch() { - ReadWriteTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.abortBatch(); - } - - @Test - public void testExecuteQuery() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.NONE); - assertThat(rs, is(notNullValue())); - assertThat(rs.getStats(), is(nullValue())); - } - - @Test - public void testPlanQuery() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.PLAN); - assertThat(rs, is(notNullValue())); - while (rs.next()) { - // do nothing - } - assertThat(rs.getStats(), is(notNullValue())); - } - - @Test - public void testProfileQuery() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - ResultSet rs = transaction.executeQuery(parsedStatement, AnalyzeMode.PROFILE); - assertThat(rs, is(notNullValue())); - while (rs.next()) { - // do nothing - } - assertThat(rs.getStats(), is(notNullValue())); - } - - @Test - public void testExecuteUpdate() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.UPDATE); - when(parsedStatement.isUpdate()).thenReturn(true); - Statement statement = Statement.of("UPDATE FOO SET BAR=1 WHERE ID=2"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - assertThat(transaction.executeUpdate(parsedStatement), is(1L)); - } - - @Test - public void testGetCommitTimestampBeforeCommit() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.UPDATE); - when(parsedStatement.isUpdate()).thenReturn(true); - Statement statement = Statement.of("UPDATE FOO SET BAR=1 WHERE ID=2"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - assertThat(transaction.executeUpdate(parsedStatement), is(1L)); - - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - transaction.getCommitTimestamp(); - } - - @Test - public void testGetCommitTimestampAfterCommit() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.UPDATE); - when(parsedStatement.isUpdate()).thenReturn(true); - Statement statement = Statement.of("UPDATE FOO SET BAR=1 WHERE ID=2"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - assertThat(transaction.executeUpdate(parsedStatement), is(1L)); - transaction.commit(); - - assertThat(transaction.getCommitTimestamp(), is(notNullValue())); - } - - @Test - public void testGetReadTimestamp() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - assertThat(transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), is(notNullValue())); - - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - transaction.getReadTimestamp(); - } - - @Test - public void testState() { - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - - ReadWriteTransaction transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - assertThat(transaction.executeQuery(parsedStatement, AnalyzeMode.NONE), is(notNullValue())); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - - transaction.commit(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED))); - assertThat(transaction.isActive(), is(false)); - - // start a new transaction - transaction = createSubject(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - transaction.rollback(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.ROLLED_BACK))); - assertThat(transaction.isActive(), is(false)); - - // start a new transaction that will fail on commit - transaction = createSubject(CommitBehavior.FAIL); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - try { - transaction.commit(); - } catch (SpannerException e) { - // ignore - } - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMIT_FAILED))); - assertThat(transaction.isActive(), is(false)); - - // start a new transaction that will abort on commit - transaction = createSubject(CommitBehavior.ABORT); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - try { - transaction.commit(); - } catch (AbortedException e) { - // ignore - } - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMIT_FAILED))); - assertThat(transaction.isActive(), is(false)); - - // Start a new transaction that will abort on commit, but with internal retry enabled, so it - // will in the end succeed. - transaction = createSubject(CommitBehavior.ABORT, true); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.STARTED))); - assertThat(transaction.isActive(), is(true)); - transaction.commit(); - assertThat( - transaction.getState(), - is(equalTo(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED))); - assertThat(transaction.isActive(), is(false)); - } - - @Test - public void testIsReadOnly() { - assertThat(createSubject().isReadOnly(), is(false)); - } - - private enum RetryResults { - SAME, - DIFFERENT; - } - - @Test - public void testRetry() { - for (RetryResults results : RetryResults.values()) { - String sql1 = "UPDATE FOO SET BAR=1 WHERE BAZ>=100 AND BAZ<200"; - String sql2 = "UPDATE FOO SET BAR=2 WHERE BAZ>=200 AND BAZ<300"; - DatabaseClient client = mock(DatabaseClient.class); - ParsedStatement update1 = mock(ParsedStatement.class); - when(update1.getType()).thenReturn(StatementType.UPDATE); - when(update1.isUpdate()).thenReturn(true); - when(update1.getStatement()).thenReturn(Statement.of(sql1)); - ParsedStatement update2 = mock(ParsedStatement.class); - when(update2.getType()).thenReturn(StatementType.UPDATE); - when(update2.isUpdate()).thenReturn(true); - when(update2.getStatement()).thenReturn(Statement.of(sql2)); - - TransactionManager txManager = mock(TransactionManager.class); - TransactionContext txContext1 = mock(TransactionContext.class); - when(txManager.begin()).thenReturn(txContext1); - when(txManager.getState()).thenReturn(null, TransactionState.STARTED); - when(client.transactionManager()).thenReturn(txManager); - when(txContext1.executeUpdate(Statement.of(sql1))).thenReturn(90L); - when(txContext1.executeUpdate(Statement.of(sql2))).thenReturn(80L); - - TransactionContext txContext2 = mock(TransactionContext.class); - when(txManager.resetForRetry()).thenReturn(txContext2); - when(client.transactionManager()).thenReturn(txManager); - if (results == RetryResults.SAME) { - when(txContext2.executeUpdate(Statement.of(sql1))).thenReturn(90L); - when(txContext2.executeUpdate(Statement.of(sql2))).thenReturn(80L); - } else if (results == RetryResults.DIFFERENT) { - when(txContext2.executeUpdate(Statement.of(sql1))).thenReturn(90L); - when(txContext2.executeUpdate(Statement.of(sql2))).thenReturn(90L); - } - - // first abort, then do nothing - doThrow(SpannerExceptionFactory.newSpannerException(ErrorCode.ABORTED, "commit aborted")) - .doNothing() - .when(txManager) - .commit(); - - ReadWriteTransaction subject = - ReadWriteTransaction.newBuilder() - .setRetryAbortsInternally(true) - .setTransactionRetryListeners(Collections.emptyList()) - .setDatabaseClient(client) - .withStatementExecutor(new StatementExecutor()) - .build(); - subject.executeUpdate(update1); - subject.executeUpdate(update2); - boolean expectedException = false; - try { - subject.commit(); - } catch (SpannerException e) { - if (results == RetryResults.DIFFERENT && e.getErrorCode() == ErrorCode.ABORTED) { - // expected - expectedException = true; - } else { - throw e; - } - } - assertThat(expectedException, is(results == RetryResults.DIFFERENT)); - } - } - - @Test - public void testChecksumResultSet() throws InterruptedException, ExecutionException { - DatabaseClient client = mock(DatabaseClient.class); - ReadWriteTransaction transaction = - ReadWriteTransaction.newBuilder() - .setRetryAbortsInternally(true) - .setTransactionRetryListeners(Collections.emptyList()) - .setDatabaseClient(client) - .withStatementExecutor(new StatementExecutor()) - .build(); - ParsedStatement parsedStatement = mock(ParsedStatement.class); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - ResultSet delegate1 = - ResultSets.forRows( - Type.struct(StructField.of("ID", Type.int64()), StructField.of("NAME", Type.string())), - Arrays.asList( - Struct.newBuilder().set("ID").to(1l).set("NAME").to("TEST 1").build(), - Struct.newBuilder().set("ID").to(2l).set("NAME").to("TEST 2").build())); - ChecksumResultSet rs1 = - transaction.createChecksumResultSet(delegate1, parsedStatement, AnalyzeMode.NONE); - ResultSet delegate2 = - ResultSets.forRows( - Type.struct(StructField.of("ID", Type.int64()), StructField.of("NAME", Type.string())), - Arrays.asList( - Struct.newBuilder().set("ID").to(1l).set("NAME").to("TEST 1").build(), - Struct.newBuilder().set("ID").to(2l).set("NAME").to("TEST 2").build())); - ChecksumResultSet rs2 = - transaction.createChecksumResultSet(delegate2, parsedStatement, AnalyzeMode.NONE); - // rs1 and rs2 are equal, rs3 contains the same rows, but in a different order - ResultSet delegate3 = - ResultSets.forRows( - Type.struct(StructField.of("ID", Type.int64()), StructField.of("NAME", Type.string())), - Arrays.asList( - Struct.newBuilder().set("ID").to(2l).set("NAME").to("TEST 2").build(), - Struct.newBuilder().set("ID").to(1l).set("NAME").to("TEST 1").build())); - ChecksumResultSet rs3 = - transaction.createChecksumResultSet(delegate3, parsedStatement, AnalyzeMode.NONE); - - // rs4 contains the same rows as rs1 and rs2, but also an additional row - ResultSet delegate4 = - ResultSets.forRows( - Type.struct(StructField.of("ID", Type.int64()), StructField.of("NAME", Type.string())), - Arrays.asList( - Struct.newBuilder().set("ID").to(1l).set("NAME").to("TEST 1").build(), - Struct.newBuilder().set("ID").to(2l).set("NAME").to("TEST 2").build(), - Struct.newBuilder().set("ID").to(3l).set("NAME").to("TEST 3").build())); - ChecksumResultSet rs4 = - transaction.createChecksumResultSet(delegate4, parsedStatement, AnalyzeMode.NONE); - - assertThat(rs1.getChecksum(), is(equalTo(rs2.getChecksum()))); - while (rs1.next() && rs2.next() && rs3.next() && rs4.next()) { - assertThat(rs1.getChecksum(), is(equalTo(rs2.getChecksum()))); - assertThat(rs1.getChecksum(), is(not(equalTo(rs3.getChecksum())))); - assertThat(rs1.getChecksum(), is(equalTo(rs4.getChecksum()))); - } - assertThat(rs1.getChecksum(), is(equalTo(rs2.getChecksum()))); - assertThat(rs1.getChecksum(), is(not(equalTo(rs3.getChecksum())))); - // rs4 contains one more row than rs1, but the last row of rs4 hasn't been consumed yet - assertThat(rs1.getChecksum(), is(equalTo(rs4.getChecksum()))); - assertThat(rs4.next(), is(true)); - assertThat(rs1.getChecksum(), is(not(equalTo(rs4.getChecksum())))); - } - - @Test - public void testChecksumResultSetWithArray() throws InterruptedException, ExecutionException { - DatabaseClient client = mock(DatabaseClient.class); - ReadWriteTransaction transaction = - ReadWriteTransaction.newBuilder() - .setRetryAbortsInternally(true) - .setTransactionRetryListeners(Collections.emptyList()) - .setDatabaseClient(client) - .withStatementExecutor(new StatementExecutor()) - .build(); - ParsedStatement parsedStatement = mock(ParsedStatement.class); - Statement statement = Statement.of("SELECT * FROM FOO"); - when(parsedStatement.getStatement()).thenReturn(statement); - ResultSet delegate1 = - ResultSets.forRows( - Type.struct( - StructField.of("ID", Type.int64()), - StructField.of("PRICES", Type.array(Type.int64()))), - Arrays.asList( - Struct.newBuilder() - .set("ID") - .to(1l) - .set("PRICES") - .toInt64Array(new long[] {1L, 2L}) - .build(), - Struct.newBuilder() - .set("ID") - .to(2l) - .set("PRICES") - .toInt64Array(new long[] {3L, 4L}) - .build())); - ChecksumResultSet rs1 = - transaction.createChecksumResultSet(delegate1, parsedStatement, AnalyzeMode.NONE); - ResultSet delegate2 = - ResultSets.forRows( - Type.struct( - StructField.of("ID", Type.int64()), - StructField.of("PRICES", Type.array(Type.int64()))), - Arrays.asList( - Struct.newBuilder() - .set("ID") - .to(1l) - .set("PRICES") - .toInt64Array(new long[] {1L, 2L}) - .build(), - Struct.newBuilder() - .set("ID") - .to(2l) - .set("PRICES") - .toInt64Array(new long[] {3L, 5L}) - .build())); - ChecksumResultSet rs2 = - transaction.createChecksumResultSet(delegate2, parsedStatement, AnalyzeMode.NONE); - - rs1.next(); - rs2.next(); - assertThat(rs1.getChecksum(), is(equalTo(rs2.getChecksum()))); - rs1.next(); - rs2.next(); - assertThat(rs1.getChecksum(), is(not(equalTo(rs2.getChecksum())))); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSetTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSetTest.java deleted file mode 100644 index 52c2f2600ba..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/ReplaceableForwardingResultSetTest.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.ResultSets; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.Type.StructField; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ReplaceableForwardingResultSetTest { - - private ReplaceableForwardingResultSet createSubject() { - ResultSet delegate = - ResultSets.forRows( - Type.struct(StructField.of("test", Type.int64())), - Arrays.asList(Struct.newBuilder().set("test").to(1L).build())); - return new ReplaceableForwardingResultSet(delegate); - } - - @Test - public void testReplace() { - ResultSet delegate1 = - ResultSets.forRows( - Type.struct(StructField.of("test", Type.int64())), - Arrays.asList( - Struct.newBuilder().set("test").to(1L).build(), - Struct.newBuilder().set("test").to(2L).build())); - // First verify the behavior without replacing. - try (ResultSet rs = new ReplaceableForwardingResultSet(delegate1)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("test"), is(equalTo(1L))); - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("test"), is(equalTo(2L))); - assertThat(rs.next(), is(false)); - } - - delegate1 = - ResultSets.forRows( - Type.struct(StructField.of("test", Type.int64())), - Arrays.asList( - Struct.newBuilder().set("test").to(1L).build(), - Struct.newBuilder().set("test").to(2L).build())); - ResultSet delegate2 = - ResultSets.forRows( - Type.struct(StructField.of("test", Type.int64())), - Arrays.asList( - Struct.newBuilder().set("test").to(1L).build(), - Struct.newBuilder().set("test").to(3L).build())); - // Then verify the behavior with replacing. - try (ReplaceableForwardingResultSet rs = new ReplaceableForwardingResultSet(delegate1)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("test"), is(equalTo(1L))); - // Advance the delegate result set that will be used as replacement. - delegate2.next(); - // Replace the result set. - rs.replaceDelegate(delegate2); - // Verify that the replacement is being used. - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("test"), is(equalTo(3L))); - assertThat(rs.next(), is(false)); - } - } - - @Test - public void testMethodCallBeforeNext() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = Arrays.asList("getStats", "next", "close", "equals", "hashCode"); - ReplaceableForwardingResultSet subject = createSubject(); - // Test that all methods throw an IllegalStateException except the excluded methods when called - // before a call to ResultSet#next(). - callMethods(subject, excludedMethods, IllegalStateException.class); - } - - @Test - public void testMethodCallAfterClose() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = - Arrays.asList( - "getStats", - "next", - "close", - "getType", - "getColumnCount", - "getColumnIndex", - "getColumnType", - "ofResultSet", - "equals", - "hashCode"); - ReplaceableForwardingResultSet subject = createSubject(); - subject.next(); - subject.close(); - // Test that all methods throw an SpannerException except the excluded methods when called on a - // closed ResultSet. - callMethods(subject, excludedMethods, SpannerException.class); - } - - @Test - public void testMethodCallAfterNextHasReturnedFalse() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - List excludedMethods = - Arrays.asList( - "getStats", - "next", - "close", - "getType", - "getColumnCount", - "getColumnIndex", - "getColumnType", - "ofResultSet", - "equals", - "hashCode"); - ReplaceableForwardingResultSet subject = createSubject(); - subject.next(); - subject.next(); - // Test that all methods throw an IndexOutOfBoundsException except the excluded methods when - // called after a call to ResultSet#next() has returned false. - callMethods(subject, excludedMethods, IndexOutOfBoundsException.class); - } - - private void callMethods( - ReplaceableForwardingResultSet subject, - List excludedMethods, - Class expectedException) - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - for (Method method : ReplaceableForwardingResultSet.class.getDeclaredMethods()) { - if (Modifier.isPublic(method.getModifiers()) && !excludedMethods.contains(method.getName())) { - boolean exception = false; - int numberOfParameters = method.getParameterTypes().length; - Class firstParameterType = null; - if (numberOfParameters == 1) { - firstParameterType = method.getParameterTypes()[0]; - } - try { - switch (numberOfParameters) { - case 0: - method.invoke(subject); - break; - case 1: - if (firstParameterType == String.class) { - method.invoke(subject, "test"); - } else if (firstParameterType == int.class) { - method.invoke(subject, 0); - } else { - fail("unknown parameter type"); - } - break; - default: - fail("method with more than 1 parameter is unknown"); - } - } catch (InvocationTargetException e) { - if (e.getCause().getClass().equals(expectedException)) { - // expected - exception = true; - } else { - throw e; - } - } - assertThat( - method.getName() + " did not throw an IllegalStateException", exception, is(true)); - } - } - } - - @Test - public void testValidMethodCall() - throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - ResultSet delegate = mock(ResultSet.class); - when(delegate.next()).thenReturn(true, true, false); - try (ReplaceableForwardingResultSet subject = new ReplaceableForwardingResultSet(delegate)) { - subject.next(); - - // Cloud Spanner result sets use zero-based column indices, as opposed to the one-based column - // indices used by JDBC. The subject.getBoolean(0) and further zero-based calls below should - // therefore not cause any exceptions. - subject.getBoolean(0); - verify(delegate).getBoolean(0); - subject.getBoolean("test0"); - verify(delegate).getBoolean("test0"); - subject.getBooleanArray(1); - verify(delegate).getBooleanArray(1); - subject.getBooleanArray("test1"); - verify(delegate).getBooleanArray("test1"); - subject.getBooleanList(2); - verify(delegate).getBooleanList(2); - subject.getBooleanList("test2"); - verify(delegate).getBooleanList("test2"); - - subject.getBytes(0); - verify(delegate).getBytes(0); - subject.getBytes("test0"); - verify(delegate).getBytes("test0"); - subject.getBytesList(2); - verify(delegate).getBytesList(2); - subject.getBytesList("test2"); - verify(delegate).getBytesList("test2"); - - subject.getDate(0); - verify(delegate).getDate(0); - subject.getDate("test0"); - verify(delegate).getDate("test0"); - subject.getDateList(2); - verify(delegate).getDateList(2); - subject.getDateList("test2"); - verify(delegate).getDateList("test2"); - - subject.getDouble(0); - verify(delegate).getDouble(0); - subject.getDouble("test0"); - verify(delegate).getDouble("test0"); - subject.getDoubleArray(1); - verify(delegate).getDoubleArray(1); - subject.getDoubleArray("test1"); - verify(delegate).getDoubleArray("test1"); - subject.getDoubleList(2); - verify(delegate).getDoubleList(2); - subject.getDoubleList("test2"); - verify(delegate).getDoubleList("test2"); - - subject.getLong(0); - verify(delegate).getLong(0); - subject.getLong("test0"); - verify(delegate).getLong("test0"); - subject.getLongArray(1); - verify(delegate).getLongArray(1); - subject.getLongArray("test1"); - verify(delegate).getLongArray("test1"); - subject.getLongList(2); - verify(delegate).getLongList(2); - subject.getLongList("test2"); - verify(delegate).getLongList("test2"); - - subject.getString(0); - verify(delegate).getString(0); - subject.getString("test0"); - verify(delegate).getString("test0"); - subject.getStringList(2); - verify(delegate).getStringList(2); - subject.getStringList("test2"); - verify(delegate).getStringList("test2"); - - subject.getStructList(0); - subject.getStructList("test0"); - - subject.getTimestamp(0); - verify(delegate).getTimestamp(0); - subject.getTimestamp("test0"); - verify(delegate).getTimestamp("test0"); - subject.getTimestampList(2); - verify(delegate).getTimestampList(2); - subject.getTimestampList("test2"); - verify(delegate).getTimestampList("test2"); - - subject.getColumnCount(); - verify(delegate).getColumnCount(); - subject.getColumnIndex("test"); - verify(delegate).getColumnIndex("test"); - subject.getColumnType(100); - verify(delegate).getColumnType(100); - subject.getColumnType("test"); - verify(delegate).getColumnType("test"); - subject.getCurrentRowAsStruct(); - verify(delegate).getCurrentRowAsStruct(); - subject.getType(); - verify(delegate).getType(); - subject.isNull(50); - verify(delegate).isNull(50); - subject.isNull("test"); - verify(delegate).isNull("test"); - - while (subject.next()) { - // ignore - } - subject.getStats(); - verify(delegate).getStats(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessSqlScriptTest.java deleted file mode 100644 index de32e0f5bc0..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessSqlScriptTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class SetReadOnlyStalenessSqlScriptTest { - - static class TestConnectionProvider implements GenericConnectionProvider { - @Override - public GenericConnection getConnection() { - return SpannerGenericConnection.of( - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(ConnectionImplTest.URI) - .build())); - } - } - - @Test - public void testSetReadOnlyStalenessScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile("SetReadOnlyStalenessTest.sql", getClass()); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetStatementTimeoutSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetStatementTimeoutSqlScriptTest.java deleted file mode 100644 index 90afdf05baf..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SetStatementTimeoutSqlScriptTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnectionProvider; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class SetStatementTimeoutSqlScriptTest { - - static class TestConnectionProvider implements GenericConnectionProvider { - @Override - public GenericConnection getConnection() { - return SpannerGenericConnection.of( - ConnectionImplTest.createConnection( - ConnectionOptions.newBuilder() - .setUri(ConnectionImplTest.URI) - .setCredentials(NoCredentials.getInstance()) - .build())); - } - } - - @Test - public void testSetStatementTimeoutScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new TestConnectionProvider()); - verifier.verifyStatementsInFile("SetStatementTimeoutTest.sql", getClass()); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SingleUseTransactionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SingleUseTransactionTest.java deleted file mode 100644 index b9890c5d4d3..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SingleUseTransactionTest.java +++ /dev/null @@ -1,740 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Key; -import com.google.cloud.spanner.KeySet; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.Options.QueryOption; -import com.google.cloud.spanner.Options.ReadOption; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Struct; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionRunner; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import com.google.cloud.spanner.jdbc.StatementParser.StatementType; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import com.google.spanner.v1.ResultSetStats; -import java.util.Arrays; -import java.util.Calendar; -import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class SingleUseTransactionTest { - private static final String VALID_QUERY = "SELECT * FROM FOO"; - private static final String INVALID_QUERY = "SELECT * FROM BAR"; - private static final String SLOW_QUERY = "SELECT * FROM SLOW_TABLE"; - private static final String VALID_UPDATE = "UPDATE FOO SET BAR=1"; - private static final String INVALID_UPDATE = "UPDATE BAR SET FOO=1"; - private static final String SLOW_UPDATE = "UPDATE SLOW_TABLE SET FOO=1"; - private static final long VALID_UPDATE_COUNT = 99L; - - @Rule public ExpectedException exception = ExpectedException.none(); - - private final StatementExecutor executor = new StatementExecutor(); - - private enum CommitBehavior { - SUCCEED, - FAIL, - ABORT; - } - - private static class SimpleTransactionManager implements TransactionManager { - private TransactionState state; - private Timestamp commitTimestamp; - private TransactionContext txContext; - private CommitBehavior commitBehavior; - - private SimpleTransactionManager(TransactionContext txContext, CommitBehavior commitBehavior) { - this.txContext = txContext; - this.commitBehavior = commitBehavior; - } - - @Override - public TransactionContext begin() { - state = TransactionState.STARTED; - return txContext; - } - - @Override - public void commit() { - switch (commitBehavior) { - case SUCCEED: - commitTimestamp = Timestamp.now(); - state = TransactionState.COMMITTED; - break; - case FAIL: - state = TransactionState.COMMIT_FAILED; - throw SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, "commit failed"); - case ABORT: - state = TransactionState.COMMIT_FAILED; - commitBehavior = CommitBehavior.SUCCEED; - throw SpannerExceptionFactory.newSpannerException(ErrorCode.ABORTED, "commit aborted"); - default: - throw new IllegalStateException(); - } - } - - @Override - public void rollback() { - state = TransactionState.ROLLED_BACK; - } - - @Override - public TransactionContext resetForRetry() { - return txContext; - } - - @Override - public Timestamp getCommitTimestamp() { - return commitTimestamp; - } - - @Override - public TransactionState getState() { - return state; - } - - @Override - public void close() { - if (state != TransactionState.COMMITTED) { - state = TransactionState.ROLLED_BACK; - } - } - } - - private static final class SimpleReadOnlyTransaction - implements com.google.cloud.spanner.ReadOnlyTransaction { - private Timestamp readTimestamp = null; - private final TimestampBound staleness; - - private SimpleReadOnlyTransaction(TimestampBound staleness) { - this.staleness = staleness; - } - - @Override - public ResultSet read( - String table, KeySet keys, Iterable columns, ReadOption... options) { - return null; - } - - @Override - public ResultSet readUsingIndex( - String table, String index, KeySet keys, Iterable columns, ReadOption... options) { - return null; - } - - @Override - public Struct readRow(String table, Key key, Iterable columns) { - return null; - } - - @Override - public Struct readRowUsingIndex(String table, String index, Key key, Iterable columns) { - return null; - } - - @Override - public ResultSet executeQuery(Statement statement, QueryOption... options) { - if (statement.equals(Statement.of(VALID_QUERY))) { - if (readTimestamp == null) { - switch (staleness.getMode()) { - case STRONG: - readTimestamp = Timestamp.now(); - break; - case READ_TIMESTAMP: - readTimestamp = staleness.getReadTimestamp(); - break; - case MIN_READ_TIMESTAMP: - readTimestamp = staleness.getMinReadTimestamp(); - break; - case EXACT_STALENESS: - Calendar cal = Calendar.getInstance(); - cal.add( - Calendar.MILLISECOND, (int) -staleness.getExactStaleness(TimeUnit.MILLISECONDS)); - readTimestamp = Timestamp.of(cal.getTime()); - break; - case MAX_STALENESS: - cal = Calendar.getInstance(); - cal.add( - Calendar.MILLISECOND, (int) -staleness.getMaxStaleness(TimeUnit.MILLISECONDS)); - readTimestamp = Timestamp.of(cal.getTime()); - break; - default: - throw new IllegalStateException(); - } - } - return mock(ResultSet.class); - } else if (statement.equals(Statement.of(SLOW_QUERY))) { - try { - Thread.sleep(10L); - } catch (InterruptedException e) { - // ignore - } - readTimestamp = Timestamp.now(); - return mock(ResultSet.class); - } else if (statement.equals(Statement.of(INVALID_QUERY))) { - throw SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, "invalid query"); - } else { - throw new IllegalArgumentException(); - } - } - - @Override - public ResultSet analyzeQuery(Statement statement, QueryAnalyzeMode queryMode) { - ResultSet rs = executeQuery(statement); - when(rs.getStats()).thenReturn(ResultSetStats.getDefaultInstance()); - return rs; - } - - @Override - public void close() {} - - @Override - public Timestamp getReadTimestamp() { - return readTimestamp; - } - } - - private DdlClient createDefaultMockDdlClient() { - try { - DdlClient ddlClient = mock(DdlClient.class); - @SuppressWarnings("unchecked") - final OperationFuture operation = - mock(OperationFuture.class); - when(operation.get()).thenReturn(null); - when(ddlClient.executeDdl(anyString())).thenCallRealMethod(); - when(ddlClient.executeDdl(anyListOf(String.class))).thenReturn(operation); - return ddlClient; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private SingleUseTransaction createSubject() { - return createSubject( - createDefaultMockDdlClient(), - false, - TimestampBound.strong(), - AutocommitDmlMode.TRANSACTIONAL, - CommitBehavior.SUCCEED, - 0L); - } - - private SingleUseTransaction createSubjectWithTimeout(long timeout) { - return createSubject( - createDefaultMockDdlClient(), - false, - TimestampBound.strong(), - AutocommitDmlMode.TRANSACTIONAL, - CommitBehavior.SUCCEED, - timeout); - } - - private SingleUseTransaction createSubject(AutocommitDmlMode dmlMode) { - return createSubject( - createDefaultMockDdlClient(), - false, - TimestampBound.strong(), - dmlMode, - CommitBehavior.SUCCEED, - 0L); - } - - private SingleUseTransaction createSubject(CommitBehavior commitBehavior) { - return createSubject( - createDefaultMockDdlClient(), - false, - TimestampBound.strong(), - AutocommitDmlMode.TRANSACTIONAL, - commitBehavior, - 0L); - } - - private SingleUseTransaction createDdlSubject(DdlClient ddlClient) { - return createSubject( - ddlClient, - false, - TimestampBound.strong(), - AutocommitDmlMode.TRANSACTIONAL, - CommitBehavior.SUCCEED, - 0L); - } - - private SingleUseTransaction createReadOnlySubject(TimestampBound staleness) { - return createSubject( - createDefaultMockDdlClient(), - true, - staleness, - AutocommitDmlMode.TRANSACTIONAL, - CommitBehavior.SUCCEED, - 0L); - } - - private SingleUseTransaction createSubject( - DdlClient ddlClient, - boolean readOnly, - TimestampBound staleness, - AutocommitDmlMode dmlMode, - final CommitBehavior commitBehavior, - long timeout) { - DatabaseClient dbClient = mock(DatabaseClient.class); - com.google.cloud.spanner.ReadOnlyTransaction singleUse = - new SimpleReadOnlyTransaction(staleness); - when(dbClient.singleUseReadOnlyTransaction(staleness)).thenReturn(singleUse); - - TransactionContext txContext = mock(TransactionContext.class); - when(txContext.executeUpdate(Statement.of(VALID_UPDATE))).thenReturn(VALID_UPDATE_COUNT); - when(txContext.executeUpdate(Statement.of(SLOW_UPDATE))) - .thenAnswer( - new Answer() { - @Override - public Long answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(10L); - return VALID_UPDATE_COUNT; - } - }); - when(txContext.executeUpdate(Statement.of(INVALID_UPDATE))) - .thenThrow( - SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, "invalid update")); - SimpleTransactionManager txManager = new SimpleTransactionManager(txContext, commitBehavior); - when(dbClient.transactionManager()).thenReturn(txManager); - - when(dbClient.executePartitionedUpdate(Statement.of(VALID_UPDATE))) - .thenReturn(VALID_UPDATE_COUNT); - when(dbClient.executePartitionedUpdate(Statement.of(INVALID_UPDATE))) - .thenThrow( - SpannerExceptionFactory.newSpannerException(ErrorCode.UNKNOWN, "invalid update")); - - when(dbClient.readWriteTransaction()) - .thenAnswer( - new Answer() { - @Override - public TransactionRunner answer(InvocationOnMock invocation) throws Throwable { - TransactionRunner runner = - new TransactionRunner() { - private Timestamp commitTimestamp; - - @SuppressWarnings("unchecked") - @Override - public T run(TransactionCallable callable) { - if (commitBehavior == CommitBehavior.SUCCEED) { - this.commitTimestamp = Timestamp.now(); - return (T) Long.valueOf(1L); - } else if (commitBehavior == CommitBehavior.FAIL) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNKNOWN, "commit failed"); - } else { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.ABORTED, "commit aborted"); - } - } - - @Override - public Timestamp getCommitTimestamp() { - if (commitTimestamp == null) { - throw new IllegalStateException("no commit timestamp"); - } - return commitTimestamp; - } - - @Override - public TransactionRunner allowNestedTransaction() { - return this; - } - }; - return runner; - } - }); - - return SingleUseTransaction.newBuilder() - .setDatabaseClient(dbClient) - .setDdlClient(ddlClient) - .setAutocommitDmlMode(dmlMode) - .setReadOnly(readOnly) - .setReadOnlyStaleness(staleness) - .setStatementTimeout( - timeout == 0L - ? StatementExecutor.StatementTimeout.nullTimeout() - : StatementExecutor.StatementTimeout.of(timeout, TimeUnit.MILLISECONDS)) - .withStatementExecutor(executor) - .build(); - } - - private ParsedStatement createParsedDdl(String sql) { - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.DDL); - when(statement.getStatement()).thenReturn(Statement.of(sql)); - when(statement.getSqlWithoutComments()).thenReturn(sql); - return statement; - } - - private ParsedStatement createParsedQuery(String sql) { - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.QUERY); - when(statement.isQuery()).thenReturn(true); - when(statement.getStatement()).thenReturn(Statement.of(sql)); - return statement; - } - - private ParsedStatement createParsedUpdate(String sql) { - ParsedStatement statement = mock(ParsedStatement.class); - when(statement.getType()).thenReturn(StatementType.UPDATE); - when(statement.isUpdate()).thenReturn(true); - when(statement.getStatement()).thenReturn(Statement.of(sql)); - return statement; - } - - private List getTestTimestampBounds() { - return Arrays.asList( - TimestampBound.strong(), - TimestampBound.ofReadTimestamp(Timestamp.now()), - TimestampBound.ofMinReadTimestamp(Timestamp.now()), - TimestampBound.ofExactStaleness(1L, TimeUnit.SECONDS), - TimestampBound.ofMaxStaleness(100L, TimeUnit.MILLISECONDS)); - } - - @Test - public void testCommit() { - SingleUseTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.commit(); - } - - @Test - public void testRollback() { - SingleUseTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.rollback(); - } - - @Test - public void testRunBatch() { - SingleUseTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.runBatch(); - } - - @Test - public void testAbortBatch() { - SingleUseTransaction subject = createSubject(); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.abortBatch(); - } - - @Test - public void testExecuteDdl() { - String sql = "CREATE TABLE FOO"; - ParsedStatement ddl = createParsedDdl(sql); - DdlClient ddlClient = createDefaultMockDdlClient(); - SingleUseTransaction subject = createDdlSubject(ddlClient); - subject.executeDdl(ddl); - verify(ddlClient).executeDdl(sql); - } - - @Test - public void testExecuteQuery() { - for (TimestampBound staleness : getTestTimestampBounds()) { - for (AnalyzeMode analyzeMode : AnalyzeMode.values()) { - SingleUseTransaction subject = createReadOnlySubject(staleness); - ResultSet rs = subject.executeQuery(createParsedQuery(VALID_QUERY), analyzeMode); - assertThat(rs, is(notNullValue())); - assertThat(subject.getReadTimestamp(), is(notNullValue())); - assertThat( - subject.getState(), - is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - while (rs.next()) { - // just loop to the end to get stats - } - if (analyzeMode == AnalyzeMode.NONE) { - assertThat(rs.getStats(), is(nullValue())); - } else { - assertThat(rs.getStats(), is(notNullValue())); - } - } - } - for (TimestampBound staleness : getTestTimestampBounds()) { - SingleUseTransaction subject = createReadOnlySubject(staleness); - boolean expectedException = false; - try { - subject.executeQuery(createParsedQuery(INVALID_QUERY), AnalyzeMode.NONE); - } catch (SpannerException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertThat( - subject.getState(), - is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMIT_FAILED)); - } - } - - @Test - public void testExecuteQueryWithOptionsTest() { - String sql = "SELECT * FROM FOO"; - QueryOption option = Options.prefetchChunks(10000); - ParsedStatement parsedStatement = mock(ParsedStatement.class); - when(parsedStatement.getType()).thenReturn(StatementType.QUERY); - when(parsedStatement.isQuery()).thenReturn(true); - Statement statement = Statement.of(sql); - when(parsedStatement.getStatement()).thenReturn(statement); - DatabaseClient client = mock(DatabaseClient.class); - com.google.cloud.spanner.ReadOnlyTransaction tx = - mock(com.google.cloud.spanner.ReadOnlyTransaction.class); - when(tx.executeQuery(Statement.of(sql), option)).thenReturn(mock(ResultSet.class)); - when(client.singleUseReadOnlyTransaction(TimestampBound.strong())).thenReturn(tx); - - SingleUseTransaction transaction = - SingleUseTransaction.newBuilder() - .setDatabaseClient(client) - .setDdlClient(mock(DdlClient.class)) - .setAutocommitDmlMode(AutocommitDmlMode.TRANSACTIONAL) - .withStatementExecutor(executor) - .setReadOnlyStaleness(TimestampBound.strong()) - .build(); - assertThat( - transaction.executeQuery(parsedStatement, AnalyzeMode.NONE, option), is(notNullValue())); - } - - @Test - public void testExecuteUpdate_Transactional_Valid() { - ParsedStatement update = createParsedUpdate(VALID_UPDATE); - SingleUseTransaction subject = createSubject(); - long updateCount = subject.executeUpdate(update); - assertThat(updateCount, is(equalTo(VALID_UPDATE_COUNT))); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - assertThat( - subject.getState(), is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - } - - @Test - public void testExecuteUpdate_Transactional_Invalid() { - ParsedStatement update = createParsedUpdate(INVALID_UPDATE); - SingleUseTransaction subject = createSubject(); - exception.expect( - SpannerExceptionMatcher.matchCodeAndMessage(ErrorCode.UNKNOWN, "invalid update")); - subject.executeUpdate(update); - } - - @Test - public void testExecuteUpdate_Transactional_Valid_FailedCommit() { - ParsedStatement update = createParsedUpdate(VALID_UPDATE); - SingleUseTransaction subject = createSubject(CommitBehavior.FAIL); - exception.expect( - SpannerExceptionMatcher.matchCodeAndMessage(ErrorCode.UNKNOWN, "commit failed")); - subject.executeUpdate(update); - } - - @Test - public void testExecuteUpdate_Transactional_Valid_AbortedCommit() { - ParsedStatement update = createParsedUpdate(VALID_UPDATE); - SingleUseTransaction subject = createSubject(CommitBehavior.ABORT); - // even though the transaction aborts at first, it will be retried and eventually succeed - long updateCount = subject.executeUpdate(update); - assertThat(updateCount, is(equalTo(VALID_UPDATE_COUNT))); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - assertThat( - subject.getState(), is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - } - - @Test - public void testExecuteUpdate_Partitioned_Valid() { - ParsedStatement update = createParsedUpdate(VALID_UPDATE); - SingleUseTransaction subject = createSubject(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - long updateCount = subject.executeUpdate(update); - assertThat(updateCount, is(equalTo(VALID_UPDATE_COUNT))); - assertThat( - subject.getState(), is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - } - - @Test - public void testExecuteUpdate_Partitioned_Invalid() { - ParsedStatement update = createParsedUpdate(INVALID_UPDATE); - SingleUseTransaction subject = createSubject(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - exception.expect( - SpannerExceptionMatcher.matchCodeAndMessage(ErrorCode.UNKNOWN, "invalid update")); - subject.executeUpdate(update); - } - - @Test - public void testWrite() { - SingleUseTransaction subject = createSubject(); - subject.write(Mutation.newInsertBuilder("FOO").build()); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - assertThat( - subject.getState(), is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - } - - @Test - public void testWriteFail() { - SingleUseTransaction subject = createSubject(CommitBehavior.FAIL); - exception.expect( - SpannerExceptionMatcher.matchCodeAndMessage(ErrorCode.UNKNOWN, "commit failed")); - subject.write(Mutation.newInsertBuilder("FOO").build()); - } - - @Test - public void testWriteIterable() { - SingleUseTransaction subject = createSubject(); - Mutation mutation = Mutation.newInsertBuilder("FOO").build(); - subject.write(Arrays.asList(mutation, mutation)); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - assertThat( - subject.getState(), is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMITTED)); - } - - @Test - public void testWriteIterableFail() { - SingleUseTransaction subject = createSubject(CommitBehavior.FAIL); - Mutation mutation = Mutation.newInsertBuilder("FOO").build(); - exception.expect( - SpannerExceptionMatcher.matchCodeAndMessage(ErrorCode.UNKNOWN, "commit failed")); - subject.write(Arrays.asList(mutation, mutation)); - } - - @Test - public void testMultiUse() { - for (TimestampBound staleness : getTestTimestampBounds()) { - SingleUseTransaction subject = createReadOnlySubject(staleness); - ResultSet rs = subject.executeQuery(createParsedQuery(VALID_QUERY), AnalyzeMode.NONE); - assertThat(rs, is(notNullValue())); - assertThat(subject.getReadTimestamp(), is(notNullValue())); - boolean expectedException = false; - try { - subject.executeQuery(createParsedQuery(VALID_QUERY), AnalyzeMode.NONE); - } catch (IllegalStateException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - } - - String sql = "CREATE TABLE FOO"; - ParsedStatement ddl = createParsedDdl(sql); - DdlClient ddlClient = createDefaultMockDdlClient(); - SingleUseTransaction subject = createDdlSubject(ddlClient); - subject.executeDdl(ddl); - verify(ddlClient).executeDdl(sql); - boolean expectedException = false; - try { - subject.executeDdl(ddl); - } catch (IllegalStateException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - - ParsedStatement update = createParsedUpdate(VALID_UPDATE); - subject = createSubject(); - long updateCount = subject.executeUpdate(update); - assertThat(updateCount, is(equalTo(VALID_UPDATE_COUNT))); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - expectedException = false; - try { - subject.executeUpdate(update); - } catch (IllegalStateException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - - subject = createSubject(); - subject.write(Mutation.newInsertBuilder("FOO").build()); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - expectedException = false; - try { - subject.write(Mutation.newInsertBuilder("FOO").build()); - } catch (IllegalStateException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - - subject = createSubject(); - Mutation mutation = Mutation.newInsertBuilder("FOO").build(); - subject.write(Arrays.asList(mutation, mutation)); - assertThat(subject.getCommitTimestamp(), is(notNullValue())); - expectedException = false; - try { - subject.write(Arrays.asList(mutation, mutation)); - } catch (IllegalStateException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - } - - @Test - public void testExecuteQueryWithTimeout() { - SingleUseTransaction subject = createSubjectWithTimeout(1L); - try { - subject.executeQuery(createParsedQuery(SLOW_QUERY), AnalyzeMode.NONE); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.DEADLINE_EXCEEDED) { - throw e; - } - } - assertThat( - subject.getState(), - is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMIT_FAILED)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getReadTimestamp(); - } - - @Test - public void testExecuteUpdateWithTimeout() { - SingleUseTransaction subject = createSubjectWithTimeout(1L); - boolean timeoutException = false; - try { - subject.executeUpdate(createParsedUpdate(SLOW_UPDATE)); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.DEADLINE_EXCEEDED) { - throw e; - } - timeoutException = true; - } - assertThat(timeoutException, is(true)); - assertThat( - subject.getState(), - is(com.google.cloud.spanner.jdbc.UnitOfWork.UnitOfWorkState.COMMIT_FAILED)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getCommitTimestamp(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerExceptionMatcher.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerExceptionMatcher.java deleted file mode 100644 index 81cb883201e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerExceptionMatcher.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.SpannerException; -import com.google.common.base.Preconditions; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - -public final class SpannerExceptionMatcher extends BaseMatcher { - private final ErrorCode errorCode; - private final String message; - - public static SpannerExceptionMatcher matchCode(ErrorCode errorCode) { - Preconditions.checkNotNull(errorCode); - return new SpannerExceptionMatcher(errorCode, null); - } - - public static SpannerExceptionMatcher matchCodeAndMessage(ErrorCode errorCode, String message) { - Preconditions.checkNotNull(errorCode); - Preconditions.checkNotNull(message); - return new SpannerExceptionMatcher(errorCode, message); - } - - private SpannerExceptionMatcher(ErrorCode errorCode, String message) { - this.errorCode = errorCode; - this.message = message; - } - - @Override - public boolean matches(Object item) { - if (item instanceof SpannerException) { - SpannerException exception = (SpannerException) item; - if (message == null) { - return exception.getErrorCode().equals(errorCode); - } - return exception.getErrorCode().equals(errorCode) - && exception.getMessage().equals(errorCode.name() + ": " + message); - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText(SpannerException.class.getName() + " with code " + errorCode.name()); - if (message != null) { - description.appendText(" - " + SpannerException.class.getName() + " with message " + message); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerJdbcExceptionMatcher.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerJdbcExceptionMatcher.java deleted file mode 100644 index 5a1663c871b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerJdbcExceptionMatcher.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import com.google.common.base.Preconditions; -import io.grpc.Status.Code; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - -public final class SpannerJdbcExceptionMatcher extends BaseMatcher { - private final Class exceptionClass; - private final Code errorCode; - private final String message; - - public static SpannerJdbcExceptionMatcher matchCode( - Class exceptionClass, Code errorCode) { - Preconditions.checkNotNull(exceptionClass); - Preconditions.checkNotNull(errorCode); - return new SpannerJdbcExceptionMatcher(exceptionClass, errorCode, null); - } - - public static SpannerJdbcExceptionMatcher matchCodeAndMessage( - Class exceptionClass, Code errorCode, String message) { - Preconditions.checkNotNull(exceptionClass); - Preconditions.checkNotNull(errorCode); - Preconditions.checkNotNull(message); - return new SpannerJdbcExceptionMatcher(exceptionClass, errorCode, message); - } - - private SpannerJdbcExceptionMatcher(Class exceptionClass, Code errorCode, String message) { - this.exceptionClass = exceptionClass; - this.errorCode = errorCode; - this.message = message; - } - - @Override - public boolean matches(Object item) { - if (exceptionClass.isAssignableFrom(item.getClass())) { - JdbcSqlException exception = (JdbcSqlException) item; - if (message == null) { - return exception.getErrorCode() == errorCode.value(); - } - return exception.getErrorCode() == errorCode.value() - && exception.getMessage().endsWith(": " + message); - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText(exceptionClass.getName() + " with code " + errorCode.name()); - if (message != null) { - description.appendText(" - " + JdbcSqlException.class.getName() + " with message " + message); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerPoolTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerPoolTest.java deleted file mode 100644 index a4b8e37240e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SpannerPoolTest.java +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.google.auth.oauth2.GoogleCredentials; -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.jdbc.ConnectionImpl.LeakedConnectionException; -import com.google.cloud.spanner.jdbc.SpannerPool.CheckAndCloseSpannersMode; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.logging.Handler; -import java.util.logging.Logger; -import java.util.logging.StreamHandler; -import org.junit.AfterClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class SpannerPoolTest { - private static final String URI = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - private ConnectionImpl connection1 = mock(ConnectionImpl.class); - private ConnectionImpl connection2 = mock(ConnectionImpl.class); - private ConnectionImpl connection3 = mock(ConnectionImpl.class); - private GoogleCredentials credentials1 = mock(GoogleCredentials.class); - private GoogleCredentials credentials2 = mock(GoogleCredentials.class); - private ConnectionOptions options1 = mock(ConnectionOptions.class); - private ConnectionOptions options2 = mock(ConnectionOptions.class); - private ConnectionOptions options3 = mock(ConnectionOptions.class); - private ConnectionOptions options4 = mock(ConnectionOptions.class); - - private SpannerPool createSubjectAndMocks() { - return createSubjectAndMocks(0L); - } - - private SpannerPool createSubjectAndMocks(long closeSpannerAfterMillisecondsUnused) { - SpannerPool pool = - new SpannerPool(closeSpannerAfterMillisecondsUnused) { - @Override - Spanner createSpanner(SpannerPoolKey key) { - return mock(Spanner.class); - } - }; - - when(options1.getCredentials()).thenReturn(credentials1); - when(options1.getProjectId()).thenReturn("test-project-1"); - when(options2.getCredentials()).thenReturn(credentials2); - when(options2.getProjectId()).thenReturn("test-project-1"); - - when(options3.getCredentials()).thenReturn(credentials1); - when(options3.getProjectId()).thenReturn("test-project-2"); - when(options4.getCredentials()).thenReturn(credentials2); - when(options4.getProjectId()).thenReturn("test-project-2"); - - return pool; - } - - @AfterClass - public static void closeSpannerPool() { - SpannerPool.closeSpannerPool(); - } - - @Test - public void testGetSpanner() { - SpannerPool pool = createSubjectAndMocks(); - Spanner spanner1; - Spanner spanner2; - - // assert equal - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options1, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - spanner1 = pool.getSpanner(options2, connection1); - spanner2 = pool.getSpanner(options2, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - spanner1 = pool.getSpanner(options3, connection1); - spanner2 = pool.getSpanner(options3, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - spanner1 = pool.getSpanner(options4, connection1); - spanner2 = pool.getSpanner(options4, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - - // assert not equal - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options2, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options3, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options4, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - spanner1 = pool.getSpanner(options2, connection1); - spanner2 = pool.getSpanner(options3, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - spanner1 = pool.getSpanner(options2, connection1); - spanner2 = pool.getSpanner(options4, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - spanner1 = pool.getSpanner(options3, connection1); - spanner2 = pool.getSpanner(options4, connection2); - assertThat(spanner1, not(equalTo(spanner2))); - } - - @Test - public void testRemoveConnection() { - SpannerPool pool = createSubjectAndMocks(); - Spanner spanner1; - Spanner spanner2; - - // assert equal - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options1, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - // one connection removed, assert that we would still get the same Spanner - pool.removeConnection(options1, connection1); - spanner1 = pool.getSpanner(options1, connection1); - assertThat(spanner1, is(equalTo(spanner2))); - // remove two connections, assert that we would still get the same Spanner, as Spanners are not - // directly closed and removed. - pool.removeConnection(options1, connection1); - pool.removeConnection(options1, connection2); - spanner1 = pool.getSpanner(options1, connection1); - assertThat(spanner1, is(equalTo(spanner2))); - // remove the last connection again - pool.removeConnection(options1, connection1); - } - - private static Logger log = Logger.getLogger(SpannerPool.class.getName()); - private static OutputStream logCapturingStream; - private static StreamHandler customLogHandler; - - private void attachLogCapturer() { - logCapturingStream = new ByteArrayOutputStream(); - Logger currentLogger = log; - Handler[] handlers = new Handler[0]; - while (handlers.length == 0 && currentLogger != null) { - handlers = currentLogger.getHandlers(); - currentLogger = currentLogger.getParent(); - } - if (handlers.length == 0) { - throw new IllegalStateException("no handlers found for logger"); - } - customLogHandler = new StreamHandler(logCapturingStream, handlers[0].getFormatter()); - log.addHandler(customLogHandler); - } - - public String getTestCapturedLog() throws IOException { - customLogHandler.flush(); - return logCapturingStream.toString(); - } - - @Test - public void testRemoveConnectionOptionsNotRegistered() throws IOException { - attachLogCapturer(); - final String expectedLogPart = "There is no Spanner registered for ConnectionOptions"; - SpannerPool pool = createSubjectAndMocks(); - pool.getSpanner(options1, connection1); - pool.removeConnection(options2, connection1); - String capturedLog = getTestCapturedLog(); - assertThat(capturedLog.contains(expectedLogPart), is(true)); - } - - @Test - public void testRemoveConnectionConnectionNotRegistered() throws IOException { - attachLogCapturer(); - final String expectedLogPart = "There are no connections registered for ConnectionOptions"; - SpannerPool pool = createSubjectAndMocks(); - pool.getSpanner(options1, connection1); - pool.removeConnection(options1, connection2); - String capturedLog = getTestCapturedLog(); - assertThat(capturedLog.contains(expectedLogPart), is(true)); - } - - @Test - public void testRemoveConnectionConnectionAlreadyRemoved() throws IOException { - attachLogCapturer(); - final String expectedLogPart = "There are no connections registered for ConnectionOptions"; - SpannerPool pool = createSubjectAndMocks(); - pool.getSpanner(options1, connection1); - pool.removeConnection(options1, connection1); - pool.removeConnection(options1, connection1); - String capturedLog = getTestCapturedLog(); - assertThat(capturedLog.contains(expectedLogPart), is(true)); - } - - @Test - public void testCloseSpanner() throws IOException { - SpannerPool pool = createSubjectAndMocks(); - Spanner spanner = pool.getSpanner(options1, connection1); - // verify that closing is not possible until all connections have been removed - boolean exception = false; - try { - pool.checkAndCloseSpanners(); - } catch (SpannerException e) { - exception = e.getErrorCode() == ErrorCode.FAILED_PRECONDITION; - } - assertThat(exception, is(true)); - - // remove the connection and verify that it is possible to close - pool.removeConnection(options1, connection1); - pool.checkAndCloseSpanners(); - verify(spanner).close(); - - final String expectedLogPart = - "WARNING: There is/are 1 connection(s) still open. Close all connections before stopping the application"; - Spanner spanner2 = pool.getSpanner(options1, connection1); - pool.checkAndCloseSpanners(CheckAndCloseSpannersMode.WARN); - String capturedLog = getTestCapturedLog(); - assertThat(capturedLog.contains(expectedLogPart), is(true)); - verify(spanner2, never()).close(); - - // remove the connection and verify that it is possible to close - pool.removeConnection(options1, connection1); - pool.checkAndCloseSpanners(CheckAndCloseSpannersMode.WARN); - verify(spanner2).close(); - } - - @Test - public void testLeakedConnection() throws IOException { - ConnectionOptions options = - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(); - // create an actual connection object but not in a try-with-resources block - Connection connection = options.getConnection(); - // try to close the application which should fail - try { - ConnectionOptions.closeSpanner(); - fail("missing expected exception"); - } catch (SpannerException e) { - assertThat(e.getErrorCode(), is(equalTo(ErrorCode.FAILED_PRECONDITION))); - } - String capturedLog = getTestCapturedLog(); - assertThat(capturedLog.contains(LeakedConnectionException.class.getName()), is(true)); - assertThat(capturedLog.contains("testLeakedConnection"), is(true)); - // Now close the connection to avoid trouble with other test cases. - connection.close(); - } - - @Test - public void testCloseUnusedSpanners() { - SpannerPool pool = createSubjectAndMocks(); - Spanner spanner1; - Spanner spanner2; - Spanner spanner3; - - // create two connections that use the same Spanner - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options1, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - - // all spanners are in use, this should have no effect - pool.closeUnusedSpanners(-1L); - verify(spanner1, never()).close(); - - // close one connection. This should also have no effect. - pool.removeConnection(options1, connection1); - pool.closeUnusedSpanners(-1L); - verify(spanner1, never()).close(); - - // close the other connection as well, the Spanner object should now be closed. - pool.removeConnection(options1, connection2); - pool.closeUnusedSpanners(-1L); - verify(spanner1).close(); - - // create three connections that use two different Spanners - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options2, connection2); - spanner3 = pool.getSpanner(options2, connection3); - assertThat(spanner1, not(equalTo(spanner2))); - assertThat(spanner2, is(equalTo(spanner3))); - - // all spanners are in use, this should have no effect - pool.closeUnusedSpanners(-1L); - verify(spanner1, never()).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection1. That should also mark spanner1 as no longer in use - pool.removeConnection(options1, connection1); - pool.closeUnusedSpanners(-1L); - verify(spanner1).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection2. That should have no effect, as connection3 is still using spanner2 - pool.removeConnection(options2, connection2); - pool.closeUnusedSpanners(-1L); - verify(spanner1).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection3. Now all should be closed. - pool.removeConnection(options2, connection3); - pool.closeUnusedSpanners(-1L); - verify(spanner1).close(); - verify(spanner2).close(); - verify(spanner3).close(); - } - - /** Allow the automatic close test to be run multiple times to ensure it is stable */ - private static final int NUMBER_OF_AUTOMATIC_CLOSE_TEST_RUNS = 1; - - private static final long TEST_AUTOMATIC_CLOSE_TIMEOUT = 2L; - private static final long SLEEP_BEFORE_VERIFICATION = 100L; - - @Test - public void testAutomaticCloser() throws InterruptedException { - for (int testRun = 0; testRun < NUMBER_OF_AUTOMATIC_CLOSE_TEST_RUNS; testRun++) { - // create a pool that will close unused spanners after 5 milliseconds - SpannerPool pool = createSubjectAndMocks(TEST_AUTOMATIC_CLOSE_TIMEOUT); - Spanner spanner1; - Spanner spanner2; - Spanner spanner3; - - // create two connections that use the same Spanner - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options1, connection2); - assertThat(spanner1, is(equalTo(spanner2))); - - // all spanners are in use, this should have no effect - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1, never()).close(); - - // close one connection. This should also have no effect. - pool.removeConnection(options1, connection1); - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1, never()).close(); - - // close the other connection as well, the Spanner object should now be closed. - pool.removeConnection(options1, connection2); - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1).close(); - - // create three connections that use two different Spanners - spanner1 = pool.getSpanner(options1, connection1); - spanner2 = pool.getSpanner(options2, connection2); - spanner3 = pool.getSpanner(options2, connection3); - assertThat(spanner1, not(equalTo(spanner2))); - assertThat(spanner2, is(equalTo(spanner3))); - - // all spanners are in use, this should have no effect - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1, never()).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection1. That should also mark spanner1 as no longer in use - pool.removeConnection(options1, connection1); - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection2. That should have no effect, as connection3 is still using spanner2 - pool.removeConnection(options2, connection2); - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1).close(); - verify(spanner2, never()).close(); - verify(spanner3, never()).close(); - - // close connection3. Now all should be closed. - pool.removeConnection(options2, connection3); - Thread.sleep(SLEEP_BEFORE_VERIFICATION); - verify(spanner1).close(); - verify(spanner2).close(); - verify(spanner3).close(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlScriptVerifier.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlScriptVerifier.java deleted file mode 100644 index c32f3907657..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlScriptVerifier.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.Type; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; - -/** - * SQL script verifier implementation for Spanner {@link com.google.cloud.spanner.jdbc.Connection} - * - * @see AbstractSqlScriptVerifier for more information - */ -public class SqlScriptVerifier extends AbstractSqlScriptVerifier { - - static class ConnectionGenericStatementResult extends GenericStatementResult { - private final StatementResult result; - - private ConnectionGenericStatementResult(StatementResult result) { - this.result = result; - } - - @Override - protected ResultType getResultType() { - return result.getResultType(); - } - - @Override - protected GenericResultSet getResultSet() { - return new ConnectionGenericResultSet(result.getResultSet()); - } - - @Override - protected long getUpdateCount() { - return result.getUpdateCount(); - } - } - - static class ConnectionGenericResultSet extends GenericResultSet { - private final ResultSet resultSet; - - private ConnectionGenericResultSet(ResultSet resultSet) { - this.resultSet = resultSet; - } - - @Override - protected boolean next() { - return resultSet.next(); - } - - @Override - protected Object getValue(String col) { - if (resultSet.isNull(col)) { - return null; - } - Type type = resultSet.getColumnType(col); - switch (type.getCode()) { - case ARRAY: - return getArrayValue(resultSet, col, type.getArrayElementType()); - case BOOL: - return resultSet.getBoolean(col); - case BYTES: - return resultSet.getBytes(col); - case DATE: - return resultSet.getDate(col); - case FLOAT64: - return resultSet.getDouble(col); - case INT64: - return resultSet.getLong(col); - case STRING: - return resultSet.getString(col); - case TIMESTAMP: - return resultSet.getTimestamp(col); - case STRUCT: - throw new IllegalArgumentException("type struct not supported"); - } - throw new IllegalArgumentException("unknown type: " + type); - } - - private Object getArrayValue(ResultSet rs, String col, Type type) { - switch (type.getCode()) { - case BOOL: - return rs.getBooleanList(col); - case BYTES: - return rs.getBytesList(col); - case DATE: - return rs.getDateList(col); - case FLOAT64: - return rs.getDoubleList(col); - case INT64: - return rs.getLongList(col); - case STRING: - return rs.getStringList(col); - case STRUCT: - return rs.getStructList(col); - case TIMESTAMP: - return rs.getTimestampList(col); - case ARRAY: - throw new IllegalArgumentException("array of array not supported"); - } - throw new IllegalArgumentException("unknown type: " + type); - } - - @Override - protected int getColumnCount() throws Exception { - return resultSet.getColumnCount(); - } - - @Override - protected Object getFirstValue() throws Exception { - return getValue(resultSet.getType().getStructFields().get(0).getName()); - } - } - - public static class SpannerGenericConnection extends GenericConnection { - private final Connection connection; - - public static SpannerGenericConnection of(Connection connection) { - return new SpannerGenericConnection(connection); - } - - private SpannerGenericConnection(Connection connection) { - this.connection = connection; - } - - @Override - protected GenericStatementResult execute(String sql) { - return new ConnectionGenericStatementResult(connection.execute(Statement.of(sql))); - } - - @Override - public void close() throws Exception { - if (this.connection != null) { - this.connection.close(); - } - } - } - - public SqlScriptVerifier() { - this(null); - } - - public SqlScriptVerifier(GenericConnectionProvider provider) { - super(provider); - } - - @Override - protected void verifyExpectedException( - String statement, Exception e, String code, String messagePrefix) { - assertThat(e instanceof SpannerException, is(true)); - SpannerException spannerException = (SpannerException) e; - assertThat( - statement + " resulted in " + spannerException.toString(), - spannerException.getErrorCode(), - is(equalTo(ErrorCode.valueOf(code)))); - if (messagePrefix != null) { - assertThat( - statement, - e.getMessage(), - startsWith(messagePrefix.substring(1, messagePrefix.length() - 1))); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlTestScriptsGenerator.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlTestScriptsGenerator.java deleted file mode 100644 index 875ca0a08e4..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/SqlTestScriptsGenerator.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -/** Class that runs all generators of SQL test scripts for the Connection API */ -public class SqlTestScriptsGenerator { - - /** Main method for generating the test script */ - public static void main(String[] args) throws Exception { - ClientSideStatementsTest.generateTestScript(); - ConnectionImplGeneratedSqlScriptTest.generateTestScript(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementParserTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementParserTest.java deleted file mode 100644 index 9bfef7546ac..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementParserTest.java +++ /dev/null @@ -1,692 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.*; - -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.StatementParser.ParsedStatement; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.junit.Test; - -public class StatementParserTest { - public static final String COPYRIGHT_PATTERN = - "\\/\\*\n" - + " \\* Copyright \\d{4} Google LLC\n" - + " \\*\n" - + " \\* Licensed under the Apache License, Version 2.0 \\(the \"License\"\\);\n" - + " \\* you may not use this file except in compliance with the License.\n" - + " \\* You may obtain a copy of the License at\n" - + " \\*\n" - + " \\* http://www.apache.org/licenses/LICENSE-2.0\n" - + " \\*\n" - + " \\* Unless required by applicable law or agreed to in writing, software\n" - + " \\* distributed under the License is distributed on an \"AS IS\" BASIS,\n" - + " \\* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" - + " \\* See the License for the specific language governing permissions and\n" - + " \\* limitations under the License.\n" - + " \\*\\/\n"; - private final StatementParser parser = StatementParser.INSTANCE; - private static final Pattern EXPECT_PATTERN = Pattern.compile("(?is)\\s*(?:@EXPECT)\\s+'(.*)'"); - - @Test - public void testRemoveComments() { - List statements = readStatementsFromFile("CommentsTest.sql"); - String currentlyExpected = ""; - for (String statement : statements) { - String sql = statement.trim(); - if (sql.startsWith("@EXPECT")) { - Matcher matcher = EXPECT_PATTERN.matcher(sql); - if (matcher.matches()) { - currentlyExpected = matcher.group(1); - } else { - throw new IllegalArgumentException("Unknown @EXPECT statement: " + sql); - } - } else { - assertThat( - StatementParser.removeCommentsAndTrim(statement), is(equalTo(currentlyExpected))); - } - } - - assertThat(StatementParser.removeCommentsAndTrim(""), is(equalTo(""))); - assertThat( - StatementParser.removeCommentsAndTrim("SELECT * FROM FOO"), - is(equalTo("SELECT * FROM FOO"))); - assertThat( - StatementParser.removeCommentsAndTrim("-- This is a one line comment\nSELECT * FROM FOO"), - is(equalTo("SELECT * FROM FOO"))); - assertThat( - StatementParser.removeCommentsAndTrim( - "/* This is a simple multi line comment */\nSELECT * FROM FOO"), - is(equalTo("SELECT * FROM FOO"))); - assertThat( - StatementParser.removeCommentsAndTrim( - "/* This is a \nmulti line comment */\nSELECT * FROM FOO"), - is(equalTo("SELECT * FROM FOO"))); - assertThat( - StatementParser.removeCommentsAndTrim( - "/* This\nis\na\nmulti\nline\ncomment */\nSELECT * FROM FOO"), - is(equalTo("SELECT * FROM FOO"))); - } - - @Test - public void testStatementWithCommentContainingSlash() { - String sql = - "/*\n" - + " * Script for testing invalid/unrecognized statements\n" - + " */\n" - + "\n" - + "-- MERGE into test comment MERGE -- \n" - + "@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement'\n" - + "MERGE INTO Singers s\n" - + "/*** test ****/" - + "USING (VALUES (1, 'John', 'Doe')) v\n" - + "ON v.column1 = s.SingerId\n" - + "WHEN NOT MATCHED \n" - + " INSERT VALUES (v.column1, v.column2, v.column3)\n" - + "WHEN MATCHED\n" - + " UPDATE SET FirstName = v.column2,\n" - + " LastName = v.column3;"; - String sqlWithoutComments = - "@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement'\n" - + "MERGE INTO Singers s\n" - + "USING (VALUES (1, 'John', 'Doe')) v\n" - + "ON v.column1 = s.SingerId\n" - + "WHEN NOT MATCHED \n" - + " INSERT VALUES (v.column1, v.column2, v.column3)\n" - + "WHEN MATCHED\n" - + " UPDATE SET FirstName = v.column2,\n" - + " LastName = v.column3"; - ParsedStatement statement = parser.parse(Statement.of(sql)); - assertThat(statement.getSqlWithoutComments(), is(equalTo(sqlWithoutComments))); - } - - @Test - public void testStatementWithCommentContainingSlashAndNoAsteriskOnNewLine() { - String sql = - "/*\n" - + " * Script for testing invalid/unrecognized statements\n" - + " foo bar baz" - + " */\n" - + "\n" - + "-- MERGE INTO test comment MERGE\n" - + "@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement'\n" - + "MERGE INTO Singers s\n" - + "USING (VALUES (1, 'John', 'Doe')) v\n" - + "ON v.column1 = s.SingerId\n" - + "-- test again --\n" - + "WHEN NOT MATCHED \n" - + " INSERT VALUES (v.column1, v.column2, v.column3)\n" - + "WHEN MATCHED\n" - + " UPDATE SET FirstName = v.column2,\n" - + " LastName = v.column3;"; - String sqlWithoutComments = - "@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement'\n" - + "MERGE INTO Singers s\n" - + "USING (VALUES (1, 'John', 'Doe')) v\n" - + "ON v.column1 = s.SingerId\n" - + "\nWHEN NOT MATCHED \n" - + " INSERT VALUES (v.column1, v.column2, v.column3)\n" - + "WHEN MATCHED\n" - + " UPDATE SET FirstName = v.column2,\n" - + " LastName = v.column3"; - ParsedStatement statement = parser.parse(Statement.of(sql)); - assertThat(statement.getSqlWithoutComments(), is(equalTo(sqlWithoutComments))); - } - - @Test - public void testStatementWithHashTagSingleLineComment() { - assertThat( - parser - .parse(Statement.of("# this is a comment\nselect * from foo")) - .getSqlWithoutComments(), - is(equalTo("select * from foo"))); - assertThat( - parser.parse(Statement.of("select * from foo\n#this is a comment")).getSqlWithoutComments(), - is(equalTo("select * from foo"))); - assertThat( - parser - .parse(Statement.of("select *\nfrom foo # this is a comment\nwhere bar=1")) - .getSqlWithoutComments(), - is(equalTo("select *\nfrom foo \nwhere bar=1"))); - } - - @Test - public void testIsDdlStatement() { - assertFalse(parser.isDdlStatement("")); - assertFalse(parser.isDdlStatement("random text")); - assertFalse(parser.isDdlStatement("CREATETABLE")); - assertFalse(parser.isDdlStatement("CCREATE TABLE")); - assertFalse(parser.isDdlStatement("SELECT 1")); - assertFalse(parser.isDdlStatement("SELECT FOO FROM BAR")); - assertFalse(parser.isDdlStatement("INSERT INTO FOO (ID, NAME) VALUES (1, 'NAME')")); - assertFalse(parser.isDdlStatement("UPDATE FOO SET NAME='NAME' WHERE ID=1")); - assertFalse(parser.isDdlStatement("DELETE FROM FOO")); - - assertTrue( - parser.isDdlStatement("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - assertTrue(parser.isDdlStatement("alter table foo add Description string(100)")); - assertTrue(parser.isDdlStatement("drop table foo")); - assertTrue(parser.isDdlStatement("Create index BAR on foo (name)")); - - assertTrue( - parser - .parse( - Statement.of( - "\t\tCREATE\n\t TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "\n\n\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "-- this is a comment\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "/* multi line comment\n* with more information on the next line\n*/\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "/** java doc comment\n* with more information on the next line\n*/\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "-- SELECT in a single line comment \nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "/* SELECT in a multi line comment\n* with more information on the next line\n*/\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - assertTrue( - parser - .parse( - Statement.of( - "/** SELECT in a java doc comment\n* with more information on the next line\n*/\nCREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")) - .isDdl()); - } - - @Test - public void testIsQuery() { - assertFalse(parser.isQuery("")); - assertFalse(parser.isQuery("random text")); - assertFalse(parser.isQuery("SELECT1")); - assertFalse(parser.isQuery("SSELECT 1")); - assertTrue(parser.isQuery("SELECT 1")); - assertTrue(parser.isQuery("select 1")); - assertTrue(parser.isQuery("SELECT foo FROM bar WHERE id=@id")); - assertFalse(parser.isQuery("INSERT INTO FOO (ID, NAME) VALUES (1, 'NAME')")); - assertFalse(parser.isQuery("UPDATE FOO SET NAME='NAME' WHERE ID=1")); - assertFalse(parser.isQuery("DELETE FROM FOO")); - assertFalse(parser.isQuery("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - assertFalse(parser.isQuery("alter table foo add Description string(100)")); - assertFalse(parser.isQuery("drop table foo")); - assertFalse(parser.isQuery("Create index BAR on foo (name)")); - assertTrue(parser.isQuery("select * from foo")); - assertFalse(parser.isQuery("INSERT INTO FOO (ID, NAME) SELECT ID+1, NAME FROM FOO")); - - assertTrue(parser.parse(Statement.of("-- this is a comment\nselect * from foo")).isQuery()); - assertTrue( - parser - .parse( - Statement.of( - "/* multi line comment\n* with more information on the next line\n*/\nSELECT ID, NAME\nFROM\tTEST\n\tWHERE ID=1")) - .isQuery()); - assertTrue( - parser - .parse( - Statement.of( - "/** java doc comment\n* with more information on the next line\n*/\nselect max(id) from test")) - .isQuery()); - assertTrue( - parser.parse(Statement.of("-- INSERT in a single line comment \n select 1")).isQuery()); - assertTrue( - parser - .parse( - Statement.of( - "/* UPDATE in a multi line comment\n* with more information on the next line\n*/\nSELECT 1")) - .isQuery()); - assertTrue( - parser - .parse( - Statement.of( - "/** DELETE in a java doc comment\n* with more information on the next line\n*/\n\n\n\n -- UPDATE test\nSELECT 1")) - .isQuery()); - } - - @Test - public void testQueryHints() { - // Valid query hints. - assertTrue(parser.isQuery("@{JOIN_METHOD=HASH_JOIN} SELECT * FROM PersonsTable")); - assertTrue(parser.isQuery("@ {JOIN_METHOD=HASH_JOIN} SELECT * FROM PersonsTable")); - assertTrue(parser.isQuery("@{ JOIN_METHOD=HASH_JOIN} SELECT * FROM PersonsTable")); - assertTrue(parser.isQuery("@{JOIN_METHOD=HASH_JOIN } SELECT * FROM PersonsTable")); - assertTrue(parser.isQuery("@{JOIN_METHOD=HASH_JOIN}\nSELECT * FROM PersonsTable")); - assertTrue(parser.isQuery("@{\nJOIN_METHOD = HASH_JOIN \t}\n\t SELECT * FROM PersonsTable")); - assertTrue( - parser.isQuery( - "@{JOIN_METHOD=HASH_JOIN}\n -- Single line comment\nSELECT * FROM PersonsTable")); - assertTrue( - parser.isQuery( - "@{JOIN_METHOD=HASH_JOIN}\n /* Multi line comment\n with more comments\n */SELECT * FROM PersonsTable")); - - // Invalid query hints. - assertFalse(parser.isQuery("@{JOIN_METHOD=HASH_JOIN SELECT * FROM PersonsTable")); - assertFalse(parser.isQuery("@JOIN_METHOD=HASH_JOIN} SELECT * FROM PersonsTable")); - assertFalse(parser.isQuery("@JOIN_METHOD=HASH_JOIN SELECT * FROM PersonsTable")); - } - - @Test - public void testIsUpdate_InsertStatements() { - assertFalse(parser.isUpdateStatement("")); - assertFalse(parser.isUpdateStatement("random text")); - assertFalse(parser.isUpdateStatement("INSERTINTO FOO (ID) VALUES (1)")); - assertFalse(parser.isUpdateStatement("IINSERT INTO FOO (ID) VALUES (1)")); - assertTrue(parser.isUpdateStatement("INSERT INTO FOO (ID) VALUES (1)")); - assertTrue(parser.isUpdateStatement("insert into foo (id) values (1)")); - assertTrue(parser.isUpdateStatement("INSERT into Foo (id)\nSELECT id FROM bar WHERE id=@id")); - assertFalse(parser.isUpdateStatement("SELECT 1")); - assertFalse(parser.isUpdateStatement("SELECT NAME FROM FOO WHERE ID=1")); - assertFalse( - parser.isUpdateStatement("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - assertFalse(parser.isUpdateStatement("alter table foo add Description string(100)")); - assertFalse(parser.isUpdateStatement("drop table foo")); - assertFalse(parser.isUpdateStatement("Create index BAR on foo (name)")); - assertFalse(parser.isUpdateStatement("select * from foo")); - assertTrue(parser.isUpdateStatement("INSERT INTO FOO (ID, NAME) SELECT ID+1, NAME FROM FOO")); - assertTrue( - parser - .parse(Statement.of("-- this is a comment\ninsert into foo (id) values (1)")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* multi line comment\n* with more information on the next line\n*/\nINSERT INTO FOO\n(ID)\tVALUES\n\t(1)")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** java doc comment\n* with more information on the next line\n*/\nInsert intO foo (id) select 1")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "-- SELECT in a single line comment \n insert into foo (id) values (1)")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* CREATE in a multi line comment\n* with more information on the next line\n*/\nINSERT INTO FOO (ID) VALUES (1)")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** DROP in a java doc comment\n* with more information on the next line\n*/\n\n\n\n -- SELECT test\ninsert into foo (id) values (1)")) - .isUpdate()); - } - - @Test - public void testIsUpdate_UpdateStatements() { - assertFalse(parser.isUpdateStatement("")); - assertFalse(parser.isUpdateStatement("random text")); - assertFalse(parser.isUpdateStatement("UPDATEFOO SET NAME='foo' WHERE ID=1")); - assertFalse(parser.isUpdateStatement("UUPDATE FOO SET NAME='foo' WHERE ID=1")); - assertTrue(parser.isUpdateStatement("UPDATE FOO SET NAME='foo' WHERE ID=1")); - assertTrue(parser.isUpdateStatement("update foo set name='foo' where id=1")); - assertTrue( - parser.isUpdateStatement("update foo set name=\n(SELECT name FROM bar WHERE id=@id)")); - assertFalse(parser.isUpdateStatement("SELECT 1")); - assertFalse(parser.isUpdateStatement("SELECT NAME FROM FOO WHERE ID=1")); - assertFalse( - parser.isUpdateStatement("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - assertFalse(parser.isUpdateStatement("alter table foo add Description string(100)")); - assertFalse(parser.isUpdateStatement("drop table foo")); - assertFalse(parser.isUpdateStatement("Create index BAR on foo (name)")); - assertFalse(parser.isUpdateStatement("select * from foo")); - assertTrue( - parser.isUpdateStatement( - "UPDATE FOO SET NAME=(SELECT NAME FROM FOO) WHERE ID=(SELECT ID+1 FROM FOO)")); - - assertTrue( - parser - .parse(Statement.of("-- this is a comment\nupdate foo set name='foo' where id=@id")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* multi line comment\n* with more information on the next line\n*/\nUPDATE FOO\nSET NAME=\t'foo'\n\tWHERE ID=1")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** java doc comment\n* with more information on the next line\n*/\nUPDATE FOO SET NAME=(select 'bar')")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of("-- SELECT in a single line comment \n update foo set name='bar'")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* CREATE in a multi line comment\n* with more information on the next line\n*/\nUPDATE FOO SET NAME='BAR'")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** DROP in a java doc comment\n* with more information on the next line\n*/\n\n\n\n -- SELECT test\nupdate foo set bar='foo'")) - .isUpdate()); - } - - @Test - public void testIsUpdate_DeleteStatements() { - assertFalse(parser.isUpdateStatement("")); - assertFalse(parser.isUpdateStatement("random text")); - assertFalse(parser.isUpdateStatement("DELETEFROM FOO WHERE ID=1")); - assertFalse(parser.isUpdateStatement("DDELETE FROM FOO WHERE ID=1")); - assertTrue(parser.isUpdateStatement("DELETE FROM FOO WHERE ID=1")); - assertTrue(parser.isUpdateStatement("delete from foo where id=1")); - assertTrue( - parser.isUpdateStatement( - "delete from foo where name=\n(SELECT name FROM bar WHERE id=@id)")); - assertFalse(parser.isUpdateStatement("SELECT 1")); - assertFalse(parser.isUpdateStatement("SELECT NAME FROM FOO WHERE ID=1")); - assertFalse( - parser.isUpdateStatement("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - assertFalse(parser.isUpdateStatement("alter table foo add Description string(100)")); - assertFalse(parser.isUpdateStatement("drop table foo")); - assertFalse(parser.isUpdateStatement("Create index BAR on foo (name)")); - assertFalse(parser.isUpdateStatement("select * from foo")); - assertTrue( - parser.isUpdateStatement( - "UPDATE FOO SET NAME=(SELECT NAME FROM FOO) WHERE ID=(SELECT ID+1 FROM FOO)")); - - assertTrue( - parser - .parse(Statement.of("-- this is a comment\ndelete from foo where id=@id")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* multi line comment\n* with more information on the next line\n*/\nDELETE FROM FOO\n\n\tWHERE ID=1")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** java doc comment\n* with more information on the next line\n*/\nDELETE FROM FOO WHERE NAME=(select 'bar')")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "-- SELECT in a single line comment \n delete from foo where name='bar'")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/* CREATE in a multi line comment\n* with more information on the next line\n*/\nDELETE FROM FOO WHERE NAME='BAR'")) - .isUpdate()); - assertTrue( - parser - .parse( - Statement.of( - "/** DROP in a java doc comment\n* with more information on the next line\n*/\n\n\n\n -- SELECT test\ndelete from foo where bar='foo'")) - .isUpdate()); - } - - @Test - public void testParseStatementsWithNoParameters() throws CompileException { - for (ClientSideStatementImpl statement : getAllStatements()) { - if (statement.getSetStatement() == null) { - for (String testStatement : statement.getExampleStatements()) { - testParseStatement(testStatement, statement.getClass()); - } - } - } - } - - @Test - public void testParseStatementsWithOneParameterAtTheEnd() throws CompileException { - for (ClientSideStatementImpl statement : getAllStatements()) { - if (statement.getSetStatement() != null) { - for (String testStatement : statement.getExampleStatements()) { - testParseStatementWithOneParameterAtTheEnd(testStatement, statement.getClass()); - } - } - } - } - - private Set getAllStatements() throws CompileException { - return ClientSideStatements.INSTANCE.getCompiledStatements(); - } - - private void assertParsing( - String value, Class statementClass) { - assertThat(this.parse(value), is(equalTo(statementClass))); - } - - private void testParseStatement( - String statement, Class statementClass) { - assertThat( - "\"" + statement + "\" should be " + statementClass.getName(), - this.parse(statement), - is(equalTo(statementClass))); - assertParsing(upper(statement), statementClass); - assertParsing(lower(statement), statementClass); - assertParsing(withSpaces(statement), statementClass); - assertParsing(withTabs(statement), statementClass); - assertParsing(withLinefeeds(statement), statementClass); - assertParsing(withLeadingSpaces(statement), statementClass); - assertParsing(withLeadingTabs(statement), statementClass); - assertParsing(withLeadingLinefeeds(statement), statementClass); - assertParsing(withTrailingSpaces(statement), statementClass); - assertParsing(withTrailingTabs(statement), statementClass); - assertParsing(withTrailingLinefeeds(statement), statementClass); - - assertThat(parse(withInvalidPrefix(statement)), is(nullValue())); - assertThat(parse(withInvalidSuffix(statement)), is(nullValue())); - - assertNull(parse(withPrefix("%", statement))); - assertNull(parse(withPrefix("_", statement))); - assertNull(parse(withPrefix("&", statement))); - assertNull(parse(withPrefix("$", statement))); - assertNull(parse(withPrefix("@", statement))); - assertNull(parse(withPrefix("!", statement))); - assertNull(parse(withPrefix("*", statement))); - assertNull(parse(withPrefix("(", statement))); - assertNull(parse(withPrefix(")", statement))); - - assertThat( - withSuffix("%", statement) + " is not a valid statement", - parse(withSuffix("%", statement)), - is(nullValue())); - assertNull(parse(withSuffix("_", statement))); - assertNull(parse(withSuffix("&", statement))); - assertNull(parse(withSuffix("$", statement))); - assertNull(parse(withSuffix("@", statement))); - assertNull(parse(withSuffix("!", statement))); - assertNull(parse(withSuffix("*", statement))); - assertNull(parse(withSuffix("(", statement))); - assertNull(parse(withSuffix(")", statement))); - } - - private void testParseStatementWithOneParameterAtTheEnd( - String statement, Class statementClass) { - assertThat( - "\"" + statement + "\" should be " + statementClass.getName(), - this.parse(statement), - is(equalTo(statementClass))); - assertParsing(upper(statement), statementClass); - assertParsing(lower(statement), statementClass); - assertParsing(withSpaces(statement), statementClass); - assertParsing(withTabs(statement), statementClass); - assertParsing(withLinefeeds(statement), statementClass); - assertParsing(withLeadingSpaces(statement), statementClass); - assertParsing(withLeadingTabs(statement), statementClass); - assertParsing(withLeadingLinefeeds(statement), statementClass); - assertParsing(withTrailingSpaces(statement), statementClass); - assertParsing(withTrailingTabs(statement), statementClass); - assertParsing(withTrailingLinefeeds(statement), statementClass); - - assertNull(parse(withInvalidPrefix(statement))); - assertParsing(withInvalidSuffix(statement), statementClass); - - assertNull(parse(withPrefix("%", statement))); - assertNull(parse(withPrefix("_", statement))); - assertNull(parse(withPrefix("&", statement))); - assertNull(parse(withPrefix("$", statement))); - assertNull(parse(withPrefix("@", statement))); - assertNull(parse(withPrefix("!", statement))); - assertNull(parse(withPrefix("*", statement))); - assertNull(parse(withPrefix("(", statement))); - assertNull(parse(withPrefix(")", statement))); - - assertParsing(withSuffix("%", statement), statementClass); - assertParsing(withSuffix("_", statement), statementClass); - assertParsing(withSuffix("&", statement), statementClass); - assertParsing(withSuffix("$", statement), statementClass); - assertParsing(withSuffix("@", statement), statementClass); - assertParsing(withSuffix("!", statement), statementClass); - assertParsing(withSuffix("*", statement), statementClass); - assertParsing(withSuffix("(", statement), statementClass); - assertParsing(withSuffix(")", statement), statementClass); - } - - @SuppressWarnings("unchecked") - private Class parse(String statement) { - ClientSideStatementImpl optional = parser.parseClientSideStatement(statement); - return optional != null ? (Class) optional.getClass() : null; - } - - private String upper(String statement) { - return statement.toUpperCase(); - } - - private String lower(String statement) { - return statement.toLowerCase(); - } - - private String withLeadingSpaces(String statement) { - return " " + statement; - } - - private String withLeadingTabs(String statement) { - return "\t\t\t" + statement; - } - - private String withLeadingLinefeeds(String statement) { - return "\n\n\n" + statement; - } - - private String withTrailingSpaces(String statement) { - return statement + " "; - } - - private String withTrailingTabs(String statement) { - return statement + "\t\t"; - } - - private String withTrailingLinefeeds(String statement) { - return statement + "\n\n"; - } - - private String withSpaces(String statement) { - return statement.replaceAll(" ", " "); - } - - private String withTabs(String statement) { - return statement.replaceAll(" ", "\t"); - } - - private String withLinefeeds(String statement) { - return statement.replaceAll(" ", "\n"); - } - - private String withInvalidPrefix(String statement) { - return "foo " + statement; - } - - private String withInvalidSuffix(String statement) { - return statement + " bar"; - } - - private String withPrefix(String prefix, String statement) { - return prefix + statement; - } - - private String withSuffix(String suffix, String statement) { - return statement + suffix; - } - - private List readStatementsFromFile(String filename) { - File file = new File(getClass().getResource(filename).getFile()); - StringBuilder builder = new StringBuilder(); - try (Scanner scanner = new Scanner(file)) { - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - builder.append(line).append("\n"); - } - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - String script = builder.toString().replaceAll(COPYRIGHT_PATTERN, ""); - String[] array = script.split(";"); - List res = new ArrayList<>(array.length); - for (String statement : array) { - if (statement != null && statement.trim().length() > 0) { - res.add(statement); - } - } - return res; - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementResultImplTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementResultImplTest.java deleted file mode 100644 index a9f06ce5716..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementResultImplTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.jdbc.StatementResult.ClientSideStatementType; -import com.google.cloud.spanner.jdbc.StatementResult.ResultType; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class StatementResultImplTest { - @Rule public ExpectedException exception = ExpectedException.none(); - - @Test - public void testNoResultGetResultSet() { - StatementResult subject = StatementResultImpl.noResult(); - assertThat(subject.getResultType(), is(equalTo(ResultType.NO_RESULT))); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getResultSet(); - } - - @Test - public void testNoResultGetUpdateCount() { - StatementResult subject = StatementResultImpl.noResult(); - assertThat(subject.getResultType(), is(equalTo(ResultType.NO_RESULT))); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getUpdateCount(); - } - - @Test - public void testResultSetGetResultSet() { - StatementResult subject = StatementResultImpl.of(mock(ResultSet.class)); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat(subject.getResultSet(), is(notNullValue())); - } - - @Test - public void testResultSetGetUpdateCount() { - StatementResult subject = StatementResultImpl.of(mock(ResultSet.class)); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getUpdateCount(); - } - - @Test - public void testUpdateCountGetResultSet() { - StatementResult subject = StatementResultImpl.of(1L); - assertThat(subject.getResultType(), is(equalTo(ResultType.UPDATE_COUNT))); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - subject.getResultSet(); - } - - @Test - public void testUpdateCountGetUpdateCount() { - StatementResult subject = StatementResultImpl.of(1L); - assertThat(subject.getResultType(), is(equalTo(ResultType.UPDATE_COUNT))); - assertThat(subject.getUpdateCount(), is(notNullValue())); - } - - @Test - public void testBooleanResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet("foo", Boolean.TRUE, ClientSideStatementType.SHOW_AUTOCOMMIT); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), is(equalTo(ClientSideStatementType.SHOW_AUTOCOMMIT))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat(subject.getResultSet().getBoolean("foo"), is(true)); - assertThat(subject.getResultSet().next(), is(false)); - } - - @Test - public void testLongResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet("foo", 10L, ClientSideStatementType.SHOW_READ_ONLY_STALENESS); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), - is(equalTo(ClientSideStatementType.SHOW_READ_ONLY_STALENESS))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat(subject.getResultSet().getLong("foo"), is(equalTo(10L))); - assertThat(subject.getResultSet().next(), is(false)); - } - - @Test - public void testLongArrayResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet( - "foo", new long[] {1L, 2L, 3L}, ClientSideStatementType.SHOW_RETRY_ABORTS_INTERNALLY); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), - is(equalTo(ClientSideStatementType.SHOW_RETRY_ABORTS_INTERNALLY))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat(subject.getResultSet().getLongArray("foo"), is(equalTo(new long[] {1L, 2L, 3L}))); - assertThat(subject.getResultSet().next(), is(false)); - } - - @Test - public void testStringResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet( - "foo", "bar", ClientSideStatementType.SHOW_READ_ONLY_STALENESS); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), - is(equalTo(ClientSideStatementType.SHOW_READ_ONLY_STALENESS))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat(subject.getResultSet().getString("foo"), is(equalTo("bar"))); - assertThat(subject.getResultSet().next(), is(false)); - } - - @Test - public void testEnumResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet( - "foo", TransactionMode.READ_ONLY_TRANSACTION, ClientSideStatementType.SHOW_READONLY); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), is(equalTo(ClientSideStatementType.SHOW_READONLY))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat( - subject.getResultSet().getString("foo"), - is(equalTo(TransactionMode.READ_ONLY_TRANSACTION.toString()))); - assertThat(subject.getResultSet().next(), is(false)); - } - - @Test - public void testTimestampResultSetGetResultSet() { - StatementResult subject = - StatementResultImpl.resultSet( - "foo", - Timestamp.ofTimeSecondsAndNanos(10L, 10), - ClientSideStatementType.SHOW_READ_TIMESTAMP); - assertThat(subject.getResultType(), is(equalTo(ResultType.RESULT_SET))); - assertThat( - subject.getClientSideStatementType(), - is(equalTo(ClientSideStatementType.SHOW_READ_TIMESTAMP))); - assertThat(subject.getResultSet(), is(notNullValue())); - assertThat(subject.getResultSet().next(), is(true)); - assertThat( - subject.getResultSet().getTimestamp("foo"), - is(equalTo(Timestamp.ofTimeSecondsAndNanos(10L, 10)))); - assertThat(subject.getResultSet().next(), is(false)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementTimeoutTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementTimeoutTest.java deleted file mode 100644 index 03eb5a1b63d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/StatementTimeoutTest.java +++ /dev/null @@ -1,1192 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.gax.longrunning.OperationFuture; -import com.google.cloud.NoCredentials; -import com.google.cloud.spanner.DatabaseClient; -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.ReadOnlyTransaction; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Spanner; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.SpannerExceptionFactory; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.TimestampBound; -import com.google.cloud.spanner.TransactionContext; -import com.google.cloud.spanner.TransactionManager; -import com.google.cloud.spanner.TransactionManager.TransactionState; -import com.google.cloud.spanner.jdbc.AbstractConnectionImplTest.ConnectionConsumer; -import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.Matchers; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -@RunWith(JUnit4.class) -public class StatementTimeoutTest { - private static final String URI = - "cloudspanner:/projects/test-project-123/instances/test-instance/databases/test-database"; - private static final String SLOW_SELECT = "SELECT foo FROM bar"; - private static final String INVALID_SELECT = "SELECT FROM bar"; // missing columns / * - private static final String FAST_SELECT = "SELECT fast_column FROM fast_table"; - private static final String SLOW_DDL = "CREATE TABLE foo"; - private static final String FAST_DDL = "CREATE TABLE fast_table"; - private static final String SLOW_UPDATE = "UPDATE foo SET col1=1 WHERE id=2"; - private static final String FAST_UPDATE = "UPDATE fast_table SET foo=1 WHERE bar=2"; - - /** Execution time for statements that have been defined as slow. */ - private static final long EXECUTION_TIME_SLOW_STATEMENT = 10_000L; - /** - * This timeout should be high enough that it will never be exceeded, even on a slow build - * environment, but still significantly lower than the expected execution time of the slow - * statements. - */ - private static final long TIMEOUT_FOR_FAST_STATEMENTS = 1000L; - - /** - * This timeout should be low enough that it will not make the test case unnecessarily slow, but - * still high enough that it would normally not be exceeded for a statement that is executed - * directly. - */ - private static final long TIMEOUT_FOR_SLOW_STATEMENTS = 20L; - /** - * The number of milliseconds to wait before cancelling a query should be high enough to not cause - * flakiness on a slow environment, but at the same time low enough that it does not slow down the - * test case unnecessarily. - */ - private static final int WAIT_BEFORE_CANCEL = 100; - - private enum CommitRollbackBehavior { - FAST, - SLOW_COMMIT, - SLOW_ROLLBACK; - } - - @Rule public ExpectedException expected = ExpectedException.none(); - - private static final class DelayedQueryExecution implements Answer { - @Override - public ResultSet answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(EXECUTION_TIME_SLOW_STATEMENT); - return mock(ResultSet.class); - } - } - - private DdlClient createDefaultMockDdlClient(final long waitForMillis) { - try { - DdlClient ddlClient = mock(DdlClient.class); - UpdateDatabaseDdlMetadata metadata = UpdateDatabaseDdlMetadata.getDefaultInstance(); - ApiFuture futureMetadata = ApiFutures.immediateFuture(metadata); - @SuppressWarnings("unchecked") - final OperationFuture operation = - mock(OperationFuture.class); - if (waitForMillis > 0L) { - when(operation.get()) - .thenAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(waitForMillis); - return null; - } - }); - } else { - when(operation.get()).thenReturn(null); - } - when(operation.getMetadata()).thenReturn(futureMetadata); - when(ddlClient.executeDdl(SLOW_DDL)).thenCallRealMethod(); - when(ddlClient.executeDdl(anyListOf(String.class))).thenReturn(operation); - - @SuppressWarnings("unchecked") - final OperationFuture fastOperation = - mock(OperationFuture.class); - when(fastOperation.isDone()).thenReturn(true); - when(fastOperation.get()).thenReturn(null); - when(fastOperation.getMetadata()).thenReturn(futureMetadata); - when(ddlClient.executeDdl(FAST_DDL)).thenReturn(fastOperation); - when(ddlClient.executeDdl(Arrays.asList(FAST_DDL))).thenReturn(fastOperation); - return ddlClient; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private ConnectionImpl createConnection(ConnectionOptions options) { - return createConnection(options, CommitRollbackBehavior.FAST); - } - - /** - * Creates a connection on which the statements {@link StatementTimeoutTest#SLOW_SELECT} and - * {@link StatementTimeoutTest#SLOW_DDL} will take at least 10,000 milliseconds - */ - private ConnectionImpl createConnection( - ConnectionOptions options, final CommitRollbackBehavior commitRollbackBehavior) { - DatabaseClient dbClient = mock(DatabaseClient.class); - Spanner spanner = mock(Spanner.class); - SpannerPool spannerPool = mock(SpannerPool.class); - when(spannerPool.getSpanner(any(ConnectionOptions.class), any(ConnectionImpl.class))) - .thenReturn(spanner); - DdlClient ddlClient = createDefaultMockDdlClient(EXECUTION_TIME_SLOW_STATEMENT); - final ResultSet invalidResultSet = mock(ResultSet.class); - when(invalidResultSet.next()) - .thenThrow( - SpannerExceptionFactory.newSpannerException( - ErrorCode.INVALID_ARGUMENT, "invalid query")); - - ReadOnlyTransaction singleUseReadOnlyTx = mock(ReadOnlyTransaction.class); - when(singleUseReadOnlyTx.executeQuery(Statement.of(SLOW_SELECT))) - .thenAnswer(new DelayedQueryExecution()); - when(singleUseReadOnlyTx.executeQuery(Statement.of(FAST_SELECT))) - .thenReturn(mock(ResultSet.class)); - when(singleUseReadOnlyTx.executeQuery(Statement.of(INVALID_SELECT))) - .thenReturn(invalidResultSet); - when(dbClient.singleUseReadOnlyTransaction(Matchers.any(TimestampBound.class))) - .thenReturn(singleUseReadOnlyTx); - - ReadOnlyTransaction readOnlyTx = mock(ReadOnlyTransaction.class); - when(readOnlyTx.executeQuery(Statement.of(SLOW_SELECT))) - .thenAnswer(new DelayedQueryExecution()); - when(readOnlyTx.executeQuery(Statement.of(FAST_SELECT))).thenReturn(mock(ResultSet.class)); - when(readOnlyTx.executeQuery(Statement.of(INVALID_SELECT))).thenReturn(invalidResultSet); - when(dbClient.readOnlyTransaction(Matchers.any(TimestampBound.class))).thenReturn(readOnlyTx); - - when(dbClient.transactionManager()) - .thenAnswer( - new Answer() { - @Override - public TransactionManager answer(InvocationOnMock invocation) throws Throwable { - TransactionManager txManager = mock(TransactionManager.class); - when(txManager.getState()).thenReturn(null, TransactionState.STARTED); - when(txManager.begin()) - .thenAnswer( - new Answer() { - @Override - public TransactionContext answer(InvocationOnMock invocation) - throws Throwable { - TransactionContext txContext = mock(TransactionContext.class); - when(txContext.executeQuery(Statement.of(SLOW_SELECT))) - .thenAnswer(new DelayedQueryExecution()); - when(txContext.executeQuery(Statement.of(FAST_SELECT))) - .thenReturn(mock(ResultSet.class)); - when(txContext.executeQuery(Statement.of(INVALID_SELECT))) - .thenReturn(invalidResultSet); - when(txContext.executeUpdate(Statement.of(SLOW_UPDATE))) - .thenAnswer( - new Answer() { - @Override - public Long answer(InvocationOnMock invocation) - throws Throwable { - Thread.sleep(EXECUTION_TIME_SLOW_STATEMENT); - return 1L; - } - }); - when(txContext.executeUpdate(Statement.of(FAST_UPDATE))).thenReturn(1L); - return txContext; - } - }); - if (commitRollbackBehavior == CommitRollbackBehavior.SLOW_COMMIT) { - doAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(EXECUTION_TIME_SLOW_STATEMENT); - return null; - } - }) - .when(txManager) - .commit(); - } - if (commitRollbackBehavior == CommitRollbackBehavior.SLOW_ROLLBACK) { - doAnswer( - new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(EXECUTION_TIME_SLOW_STATEMENT); - return null; - } - }) - .when(txManager) - .rollback(); - } - - return txManager; - } - }); - when(dbClient.executePartitionedUpdate(Statement.of(FAST_UPDATE))).thenReturn(1L); - when(dbClient.executePartitionedUpdate(Statement.of(SLOW_UPDATE))) - .thenAnswer( - new Answer() { - @Override - public Long answer(InvocationOnMock invocation) throws Throwable { - Thread.sleep(EXECUTION_TIME_SLOW_STATEMENT); - return 1L; - } - }); - return new ConnectionImpl(options, spannerPool, ddlClient, dbClient); - } - - @Test - public void testTimeoutExceptionReadOnlyAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testTimeoutExceptionReadOnlyAutocommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionReadOnlyTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testTimeoutExceptionReadOnlyTransactionMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // do a rollback without any chance of a timeout - connection.clearStatementTimeout(); - connection.rollback(); - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitSlowUpdate() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.execute(Statement.of(SLOW_UPDATE)); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitSlowUpdateMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.execute(Statement.of(SLOW_UPDATE)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new update that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.execute(Statement.of(FAST_UPDATE)).getUpdateCount(), is(equalTo(1L))); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitSlowCommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(), - CommitRollbackBehavior.SLOW_COMMIT)) { - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - // First verify that the fast update does not timeout when in transactional mode (as it is the - // commit that is slow). - connection.setAutocommit(false); - connection.execute(Statement.of(FAST_UPDATE)); - connection.rollback(); - - // Then verify that the update does timeout when executed in autocommit mode, as the commit - // gRPC call will be slow. - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - connection.setAutocommit(true); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.execute(Statement.of(FAST_UPDATE)); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitSlowCommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(), - CommitRollbackBehavior.SLOW_COMMIT)) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.execute(Statement.of(FAST_UPDATE)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionReadWriteAutocommitPartitioned() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommitDmlMode(AutocommitDmlMode.PARTITIONED_NON_ATOMIC); - // first verify that the fast update does not timeout - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - connection.execute(Statement.of(FAST_UPDATE)); - - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.execute(Statement.of(SLOW_UPDATE)); - } - } - - @Test - public void testTimeoutExceptionReadWriteTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testTimeoutExceptionReadWriteTransactionMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - // Assert that multiple statements after each other will timeout the first time, and then - // throw a SpannerException with code FAILED_PRECONDITION. - boolean timedOut = false; - for (int i = 0; i < 2; i++) { - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - if (i == 0) { - assertThat(e.getErrorCode(), is(equalTo(ErrorCode.DEADLINE_EXCEEDED))); - timedOut = true; - } else { - assertThat(e.getErrorCode(), is(equalTo(ErrorCode.FAILED_PRECONDITION))); - } - } - } - assertThat(timedOut, is(true)); - // do a rollback without any chance of a timeout - connection.clearStatementTimeout(); - connection.rollback(); - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionReadWriteTransactionalSlowCommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(), - CommitRollbackBehavior.SLOW_COMMIT)) { - connection.setAutocommit(false); - - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - connection.executeQuery(Statement.of(FAST_SELECT)); - - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.commit(); - } - } - - @Test - public void testTimeoutExceptionReadWriteTransactionalSlowRollback() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(), - CommitRollbackBehavior.SLOW_ROLLBACK)) { - connection.setAutocommit(false); - - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - connection.executeQuery(Statement.of(FAST_SELECT)); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.rollback(); - } - } - - private static final class ConnectionReadOnlyAutocommit implements ConnectionConsumer { - @Override - public void accept(Connection t) { - t.setReadOnly(true); - } - } - - @Test - public void testInterruptedExceptionReadOnlyAutocommit() - throws InterruptedException, ExecutionException { - testInterruptedException(new ConnectionReadOnlyAutocommit()); - } - - private static final class ConnectionReadOnlyTransactional implements ConnectionConsumer { - @Override - public void accept(Connection t) { - t.setReadOnly(true); - t.setAutocommit(false); - } - } - - @Test - public void testInterruptedExceptionReadOnlyTransactional() - throws InterruptedException, ExecutionException { - testInterruptedException(new ConnectionReadOnlyTransactional()); - } - - private static final class ConnectionReadWriteAutocommit implements ConnectionConsumer { - @Override - public void accept(Connection t) {} - } - - @Test - public void testInterruptedExceptionReadWriteAutocommit() - throws InterruptedException, ExecutionException { - testInterruptedException(new ConnectionReadWriteAutocommit()); - } - - private static final class ConnectionReadWriteTransactional implements ConnectionConsumer { - @Override - public void accept(Connection t) { - t.setAutocommit(false); - } - } - - @Test - public void testInterruptedExceptionReadWriteTransactional() - throws InterruptedException, ExecutionException { - testInterruptedException(new ConnectionReadWriteTransactional()); - } - - private void testInterruptedException(final ConnectionConsumer consumer) - throws InterruptedException, ExecutionException { - ExecutorService executor = Executors.newSingleThreadExecutor(); - Future future = - executor.submit( - new Callable() { - @Override - public Boolean call() throws Exception { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - consumer.accept(connection); - connection.setStatementTimeout(10000L, TimeUnit.MILLISECONDS); - - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - if (e.getErrorCode() == ErrorCode.CANCELLED) { - return Boolean.TRUE; - } else { - return Boolean.FALSE; - } - } - return Boolean.FALSE; - } - }); - // wait a little bit to ensure that the task has started - Thread.sleep(10L); - executor.shutdownNow(); - assertThat(future.get(), is(true)); - } - - @Test - public void testInvalidQueryReadOnlyAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setUri(URI) - .setCredentials(NoCredentials.getInstance()) - .build())) { - connection.setReadOnly(true); - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.INVALID_ARGUMENT)); - connection.executeQuery(Statement.of(INVALID_SELECT)); - } - } - - @Test - public void testInvalidQueryReadOnlyTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.INVALID_ARGUMENT)); - connection.executeQuery(Statement.of(INVALID_SELECT)); - } - } - - @Test - public void testInvalidQueryReadWriteAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.INVALID_ARGUMENT)); - connection.executeQuery(Statement.of(INVALID_SELECT)); - } - } - - @Test - public void testInvalidQueryReadWriteTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.INVALID_ARGUMENT)); - connection.executeQuery(Statement.of(INVALID_SELECT)); - } - } - - @Test - public void testCancelReadOnlyAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testCancelReadOnlyAutocommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - boolean cancelled = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - cancelled = e.getErrorCode() == ErrorCode.CANCELLED; - } - assertThat(cancelled, is(true)); - - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testCancelReadOnlyTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setAutocommit(false); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testCancelReadOnlyTransactionalMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setReadOnly(true); - connection.setAutocommit(false); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - boolean cancelled = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - cancelled = e.getErrorCode() == ErrorCode.CANCELLED; - } - assertThat(cancelled, is(true)); - - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - // rollback and do another fast query - connection.rollback(); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testCancelReadWriteAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testCancelReadWriteAutocommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - boolean cancelled = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - cancelled = e.getErrorCode() == ErrorCode.CANCELLED; - } - assertThat(cancelled, is(true)); - - // try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testCancelReadWriteAutocommitSlowUpdate() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.execute(Statement.of(SLOW_UPDATE)); - } - } - - @Test - public void testCancelReadWriteAutocommitSlowCommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build(), - CommitRollbackBehavior.SLOW_COMMIT)) { - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.execute(Statement.of(FAST_UPDATE)); - } - } - - @Test - public void testCancelReadWriteTransactional() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.executeQuery(Statement.of(SLOW_SELECT)); - } - } - - @Test - public void testCancelReadWriteTransactionalMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - boolean cancelled = false; - try { - connection.executeQuery(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - cancelled = e.getErrorCode() == ErrorCode.CANCELLED; - } - assertThat(cancelled, is(true)); - // Rollback the transaction as it is no longer usable. - connection.rollback(); - - // Try to do a new query that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.executeQuery(Statement.of(FAST_SELECT)), is(notNullValue())); - } - } - - @Test - public void testCancelDdlBatch() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.startBatchDdl(); - connection.execute(Statement.of(SLOW_DDL)); - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.runBatch(); - } - } - - @Test - public void testCancelDdlAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - Executors.newSingleThreadScheduledExecutor() - .schedule( - new Runnable() { - @Override - public void run() { - connection.cancel(); - } - }, - WAIT_BEFORE_CANCEL, - TimeUnit.MILLISECONDS); - - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.CANCELLED)); - connection.execute(Statement.of(SLOW_DDL)); - } - } - - @Test - public void testTimeoutExceptionDdlAutocommit() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.execute(Statement.of(SLOW_DDL)); - } - } - - @Test - public void testTimeoutExceptionDdlAutocommitMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - try { - connection.execute(Statement.of(SLOW_DDL)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new DDL statement that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - assertThat(connection.execute(Statement.of(FAST_DDL)), is(notNullValue())); - } - } - - @Test - public void testTimeoutExceptionDdlBatch() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.startBatchDdl(); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - - // the following statement will NOT timeout as the statement is only buffered locally - connection.execute(Statement.of(SLOW_DDL)); - // the commit sends the statement to the server and should timeout - expected.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - connection.runBatch(); - } - } - - @Test - public void testTimeoutExceptionDdlBatchMultipleStatements() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - connection.setAutocommit(false); - connection.setStatementTimeout(TIMEOUT_FOR_SLOW_STATEMENTS, TimeUnit.MILLISECONDS); - - // assert that multiple statements after each other also time out - for (int i = 0; i < 2; i++) { - boolean timedOut = false; - connection.startBatchDdl(); - connection.execute(Statement.of(SLOW_DDL)); - try { - connection.runBatch(); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - // try to do a new DDL statement that is fast. - connection.setStatementTimeout(TIMEOUT_FOR_FAST_STATEMENTS, TimeUnit.MILLISECONDS); - connection.startBatchDdl(); - assertThat(connection.execute(Statement.of(FAST_DDL)), is(notNullValue())); - connection.runBatch(); - } - } - - @Test - public void testTimeoutDifferentTimeUnits() { - try (Connection connection = - createConnection( - ConnectionOptions.newBuilder() - .setCredentials(NoCredentials.getInstance()) - .setUri(URI) - .build())) { - for (TimeUnit unit : ReadOnlyStalenessUtil.SUPPORTED_UNITS) { - connection.setStatementTimeout(1L, unit); - boolean timedOut = false; - try { - connection.execute(Statement.of(SLOW_SELECT)); - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/TransactionModeConverterTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/TransactionModeConverterTest.java deleted file mode 100644 index 8e14e608709..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/TransactionModeConverterTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.jdbc.ClientSideStatementImpl.CompileException; -import com.google.cloud.spanner.jdbc.ClientSideStatementValueConverters.TransactionModeConverter; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class TransactionModeConverterTest { - - @Test - public void testConvert() throws CompileException { - String allowedValues = - ReadOnlyStalenessConverterTest.getAllowedValues(TransactionModeConverter.class); - assertThat(allowedValues, is(notNullValue())); - TransactionModeConverter converter = new TransactionModeConverter(allowedValues); - assertThat( - converter.convert("read write"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat( - converter.convert("READ WRITE"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat( - converter.convert("Read Write"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat( - converter.convert("read write"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat( - converter.convert("READ\nWRITE"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - assertThat( - converter.convert("Read\tWrite"), is(equalTo(TransactionMode.READ_WRITE_TRANSACTION))); - - assertThat(converter.convert("read only"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat(converter.convert("READ ONLY"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat(converter.convert("Read Only"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat( - converter.convert("read only"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat(converter.convert("READ\nONLY"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - assertThat(converter.convert("Read\tOnly"), is(equalTo(TransactionMode.READ_ONLY_TRANSACTION))); - - assertThat(converter.convert(""), is(nullValue())); - assertThat(converter.convert(" "), is(nullValue())); - assertThat(converter.convert("random string"), is(nullValue())); - assertThat(converter.convert("read_write"), is(nullValue())); - assertThat(converter.convert("Read_Write"), is(nullValue())); - assertThat(converter.convert("READ_WRITE"), is(nullValue())); - assertThat(converter.convert("read_only"), is(nullValue())); - assertThat(converter.convert("Read_Only"), is(nullValue())); - assertThat(converter.convert("READ_ONLY"), is(nullValue())); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITBulkConnectionTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITBulkConnectionTest.java deleted file mode 100644 index a99b5ada67c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITBulkConnectionTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test opening multiple generic (not JDBC) Spanner connections. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITBulkConnectionTest extends ITAbstractSpannerTest { - private static final int NUMBER_OF_TEST_CONNECTIONS = 250; - - @Test - public void testBulkCreateConnectionsSingleThreaded() { - List connections = new ArrayList<>(); - for (int i = 0; i < NUMBER_OF_TEST_CONNECTIONS; i++) { - connections.add(createConnection()); - } - for (ITConnection connection : connections) { - try (ResultSet rs = connection.executeQuery(Statement.of("select 1"))) { - assertThat(rs.next(), is(true)); - assertThat(connection.getReadTimestamp(), is(notNullValue())); - } - } - for (ITConnection connection : connections) { - connection.close(); - } - // close Spanner instances explicitly. This method will throw an exception if there are any - // connections still open in the pool - closeSpanner(); - } - - @Test - public void testBulkCreateConnectionsMultiThreaded() throws InterruptedException { - ExecutorService executor = Executors.newFixedThreadPool(50); - for (int i = 0; i < NUMBER_OF_TEST_CONNECTIONS; i++) { - executor.submit( - new Callable() { - @Override - public Void call() throws Exception { - try (ITConnection connection = createConnection()) { - try (ResultSet rs = connection.executeQuery(Statement.of("select 1"))) { - assertThat(rs.next(), is(true)); - assertThat(connection.getReadTimestamp(), is(notNullValue())); - } - } - return null; - } - }); - } - executor.shutdown(); - executor.awaitTermination(10L, TimeUnit.SECONDS); - // close Spanner instances explicitly. This method will throw an exception if there are any - // connections still open in the pool - closeSpanner(); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITDdlTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITDdlTest.java deleted file mode 100644 index 1642c26bf57..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITDdlTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Execute DDL statements using the generic connection API. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITDdlTest extends ITAbstractSpannerTest { - - @Test - public void testSqlScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new ITConnectionProvider()); - verifier.verifyStatementsInFile("ITDdlTest.sql", SqlScriptVerifier.class); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcConnectTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcConnectTest.java deleted file mode 100644 index cef3148e311..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcConnectTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcDataSource; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Properties; -import javax.sql.DataSource; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * There are three different possibilities to specify the properties of a jdbc connection: - * - *
    - *
  1. Specify properties in the connection URL - *
  2. Pass a {@link Properties} object to the {@link DriverManager} - *
  3. Set the properties on a {@link DataSource} - *
- * - * This class tests all three possibilities. - */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITJdbcConnectTest extends ITAbstractJdbcTest { - - private String createBaseUrl() { - StringBuilder url = - new StringBuilder("jdbc:cloudspanner:/").append(getDatabase().getId().getName()); - return url.toString(); - } - - private void testDefaultConnection(Connection connection) throws SQLException { - assertThat(connection.isWrapperFor(CloudSpannerJdbcConnection.class), is(true)); - CloudSpannerJdbcConnection cs = connection.unwrap(CloudSpannerJdbcConnection.class); - assertThat(cs.getAutoCommit(), is(true)); - assertThat(cs.isReadOnly(), is(false)); - try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(1))); - } - cs.setAutoCommit(false); - assertThat(cs.isRetryAbortsInternally(), is(true)); - } - - private void testNonDefaultConnection(Connection connection) throws SQLException { - assertThat(connection.isWrapperFor(CloudSpannerJdbcConnection.class), is(true)); - CloudSpannerJdbcConnection cs = connection.unwrap(CloudSpannerJdbcConnection.class); - assertThat(cs.getAutoCommit(), is(false)); - assertThat(cs.isReadOnly(), is(true)); - try (ResultSet rs = connection.createStatement().executeQuery("SELECT 1")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(1))); - } - connection.commit(); - cs.setReadOnly(false); - assertThat(cs.isRetryAbortsInternally(), is(false)); - } - - @Test - public void testConnectWithURLWithDefaultValues() throws SQLException { - String url = createBaseUrl(); - if (hasValidKeyFile()) { - url = url + "?credentials=" + getKeyFile(); - } - try (Connection connection = DriverManager.getConnection(url)) { - testDefaultConnection(connection); - } - } - - @Test - public void testConnectWithURLWithNonDefaultValues() throws SQLException { - String url = createBaseUrl(); - url = url + "?autocommit=false;readonly=true;retryAbortsInternally=false"; - if (hasValidKeyFile()) { - url = url + ";credentials=" + getKeyFile(); - } - try (Connection connection = DriverManager.getConnection(url)) { - testNonDefaultConnection(connection); - } - } - - @Test - public void testConnectWithPropertiesWithDefaultValues() throws SQLException { - String url = createBaseUrl(); - Properties properties = new Properties(); - if (hasValidKeyFile()) { - properties.setProperty("credentials", getKeyFile()); - } - try (Connection connection = DriverManager.getConnection(url, properties)) { - testDefaultConnection(connection); - } - } - - @Test - public void testConnectWithPropertiesWithNonDefaultValues() throws SQLException { - String url = createBaseUrl(); - Properties properties = new Properties(); - if (hasValidKeyFile()) { - properties.setProperty("credentials", getKeyFile()); - } - properties.setProperty("autocommit", "false"); - properties.setProperty("readonly", "true"); - properties.setProperty("retryAbortsInternally", "false"); - try (Connection connection = DriverManager.getConnection(url, properties)) { - testNonDefaultConnection(connection); - } - } - - @Test - public void testConnectWithPropertiesWithConflictingValues() throws SQLException { - String url = createBaseUrl(); - url = url + "?autocommit=false;readonly=true;retryAbortsInternally=false"; - if (hasValidKeyFile()) { - url = url + ";credentials=" + getKeyFile(); - } - Properties properties = new Properties(); - properties.setProperty("autocommit", "true"); - properties.setProperty("readonly", "false"); - properties.setProperty("retryAbortsInternally", "true"); - try (Connection connection = DriverManager.getConnection(url, properties)) { - testNonDefaultConnection(connection); - } - } - - @Test - public void testConnectWithDataSourceWithDefaultValues() throws SQLException { - JdbcDataSource ds = new JdbcDataSource(); - ds.setUrl(createBaseUrl()); - if (hasValidKeyFile()) { - ds.setCredentials(getKeyFile()); - } - try (Connection connection = ds.getConnection()) { - testDefaultConnection(connection); - } - } - - @Test - public void testConnectWithDataSourceWithNonDefaultValues() throws SQLException { - JdbcDataSource ds = new JdbcDataSource(); - ds.setUrl(createBaseUrl()); - if (hasValidKeyFile()) { - ds.setCredentials(getKeyFile()); - } - ds.setAutocommit(false); - ds.setReadonly(true); - ds.setRetryAbortsInternally(false); - try (Connection connection = ds.getConnection()) { - testNonDefaultConnection(connection); - } - } - - @Test - public void testConnectWithDataSourceWithConflictingValues() throws SQLException { - // Try with non-default values in URL and default values in data source. The values in the URL - // should take precedent. - String url = createBaseUrl(); - url = url + "?autocommit=false;readonly=true;retryAbortsInternally=false"; - if (hasValidKeyFile()) { - url = url + ";credentials=" + getKeyFile(); - } - JdbcDataSource ds = new JdbcDataSource(); - ds.setUrl(url); - ds.setAutocommit(true); - ds.setReadonly(false); - ds.setRetryAbortsInternally(true); - try (Connection connection = ds.getConnection()) { - testNonDefaultConnection(connection); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java deleted file mode 100644 index 124664dc7cf..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDatabaseMetaDataTest.java +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Integration tests for {@link DatabaseMetaData} implementation for Spanner. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITJdbcDatabaseMetaDataTest extends ITAbstractJdbcTest { - private static final String DEFAULT_CATALOG = ""; - private static final String DEFAULT_SCHEMA = ""; - private static final String SINGERS_TABLE = "Singers"; - private static final String ALBUMS_TABLE = "Albums"; - private static final String SONGS_TABLE = "Songs"; - private static final String TABLE_WITH_ALL_COLS = "TableWithAllColumnTypes"; - - @Override - protected boolean doCreateMusicTables() { - return true; - } - - private static final class Column { - private final String name; - private final int type; - private final String typeName; - private final Integer colSize; - private final Integer decimalDigits; - private final Integer radix; - private final boolean nullable; - private final Integer charOctetLength; - - private Column( - String name, - int type, - String typeName, - Integer colSize, - Integer decimalDigits, - Integer radix, - boolean nullable, - Integer charOctetLength) { - this.name = name; - this.type = type; - this.typeName = typeName; - this.colSize = colSize; - this.decimalDigits = decimalDigits; - this.radix = radix; - this.nullable = nullable; - this.charOctetLength = charOctetLength; - } - } - - private static final List EXPECTED_COLUMNS = - Arrays.asList( - new Column("ColInt64", Types.BIGINT, "INT64", 19, null, 10, false, null), - new Column("ColFloat64", Types.DOUBLE, "FLOAT64", 15, 16, 2, false, null), - new Column("ColBool", Types.BOOLEAN, "BOOL", null, null, null, false, null), - new Column("ColString", Types.NVARCHAR, "STRING(100)", 100, null, null, false, 100), - new Column( - "ColStringMax", Types.NVARCHAR, "STRING(MAX)", 2621440, null, null, false, 2621440), - new Column("ColBytes", Types.BINARY, "BYTES(100)", 100, null, null, false, null), - new Column("ColBytesMax", Types.BINARY, "BYTES(MAX)", 10485760, null, null, false, null), - new Column("ColDate", Types.DATE, "DATE", 10, null, null, false, null), - new Column("ColTimestamp", Types.TIMESTAMP, "TIMESTAMP", 35, null, null, false, null), - new Column("ColCommitTS", Types.TIMESTAMP, "TIMESTAMP", 35, null, null, false, null), - new Column("ColInt64Array", Types.ARRAY, "ARRAY", 19, null, 10, true, null), - new Column("ColFloat64Array", Types.ARRAY, "ARRAY", 15, 16, 2, true, null), - new Column("ColBoolArray", Types.ARRAY, "ARRAY", null, null, null, true, null), - new Column( - "ColStringArray", Types.ARRAY, "ARRAY", 100, null, null, true, 100), - new Column( - "ColStringMaxArray", - Types.ARRAY, - "ARRAY", - 2621440, - null, - null, - true, - 2621440), - new Column( - "ColBytesArray", Types.ARRAY, "ARRAY", 100, null, null, true, null), - new Column( - "ColBytesMaxArray", - Types.ARRAY, - "ARRAY", - 10485760, - null, - null, - true, - null), - new Column("ColDateArray", Types.ARRAY, "ARRAY", 10, null, null, true, null), - new Column( - "ColTimestampArray", Types.ARRAY, "ARRAY", 35, null, null, true, null)); - - @Test - public void testGetColumns() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection - .getMetaData() - .getColumns(DEFAULT_CATALOG, DEFAULT_SCHEMA, TABLE_WITH_ALL_COLS, null)) { - int pos = 1; - for (Column col : EXPECTED_COLUMNS) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(TABLE_WITH_ALL_COLS))); - assertThat(rs.getString("COLUMN_NAME"), is(equalTo(col.name))); - assertThat(rs.getInt("DATA_TYPE"), is(equalTo(col.type))); - assertThat(rs.getString("TYPE_NAME"), is(equalTo(col.typeName))); - if (col.colSize == null) { - assertThat(rs.getInt("COLUMN_SIZE"), is(equalTo(0))); - assertThat(rs.wasNull(), is(true)); - } else { - assertThat(rs.getInt("COLUMN_SIZE"), is(equalTo(col.colSize))); - } - rs.getObject("BUFFER_LENGTH"); // just assert that it exists - if (col.decimalDigits == null) { - assertThat(rs.getInt("DECIMAL_DIGITS"), is(equalTo(0))); - assertThat(rs.wasNull(), is(true)); - } else { - assertThat(rs.getInt("DECIMAL_DIGITS"), is(equalTo(col.decimalDigits))); - } - if (col.radix == null) { - assertThat(rs.getInt("NUM_PREC_RADIX"), is(equalTo(0))); - assertThat(rs.wasNull(), is(true)); - } else { - assertThat(rs.getInt("NUM_PREC_RADIX"), is(equalTo(col.radix))); - } - assertThat( - rs.getInt("NULLABLE"), - is( - equalTo( - col.nullable - ? DatabaseMetaData.columnNullable - : DatabaseMetaData.columnNoNulls))); - assertThat(rs.getString("REMARKS"), is(nullValue())); - assertThat(rs.getString("COLUMN_DEF"), is(nullValue())); - assertThat(rs.getInt("SQL_DATA_TYPE"), is(equalTo(0))); - assertThat(rs.getInt("SQL_DATETIME_SUB"), is(equalTo(0))); - if (col.charOctetLength == null) { - assertThat(rs.getInt("CHAR_OCTET_LENGTH"), is(equalTo(0))); - assertThat(rs.wasNull(), is(true)); - } else { - assertThat(rs.getInt("CHAR_OCTET_LENGTH"), is(equalTo(col.charOctetLength))); - } - assertThat(rs.getInt("ORDINAL_POSITION"), is(equalTo(pos))); - assertThat(rs.getString("IS_NULLABLE"), is(equalTo(col.nullable ? "YES" : "NO"))); - assertThat(rs.getString("SCOPE_CATALOG"), is(nullValue())); - assertThat(rs.getString("SCOPE_SCHEMA"), is(nullValue())); - assertThat(rs.getString("SCOPE_TABLE"), is(nullValue())); - assertThat(rs.getShort("SOURCE_DATA_TYPE"), is(equalTo((short) 0))); - assertThat(rs.wasNull(), is(true)); - assertThat(rs.getString("IS_AUTOINCREMENT"), is(equalTo("NO"))); - assertThat(rs.getString("IS_GENERATEDCOLUMN"), is(equalTo("NO"))); - assertThat(rs.getMetaData().getColumnCount(), is(equalTo(24))); - - pos++; - } - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testGetCrossReferences() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection - .getMetaData() - .getCrossReference( - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - SINGERS_TABLE, - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - ALBUMS_TABLE)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo("Singers"))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo("Albums"))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 1))); - assertThat( - rs.getShort("UPDATE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyNoAction))); - assertThat( - rs.getShort("DELETE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat( - rs.getShort("DEFERRABILITY"), - is(equalTo((short) DatabaseMetaData.importedKeyNotDeferrable))); - } - try (ResultSet rs = - connection - .getMetaData() - .getCrossReference( - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - ALBUMS_TABLE, - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - SONGS_TABLE)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo("Albums"))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo("Songs"))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 1))); - assertThat( - rs.getShort("UPDATE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyNoAction))); - assertThat( - rs.getShort("DELETE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat( - rs.getShort("DEFERRABILITY"), - is(equalTo((short) DatabaseMetaData.importedKeyNotDeferrable))); - - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo("Albums"))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("AlbumId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(""))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo("Songs"))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("AlbumId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 2))); - assertThat( - rs.getShort("UPDATE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyNoAction))); - assertThat( - rs.getShort("DELETE_RULE"), is(equalTo((short) DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat( - rs.getShort("DEFERRABILITY"), - is(equalTo((short) DatabaseMetaData.importedKeyNotDeferrable))); - } - // try getting self-references - try (ResultSet rs = - connection - .getMetaData() - .getCrossReference( - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - ALBUMS_TABLE, - DEFAULT_CATALOG, - DEFAULT_SCHEMA, - ALBUMS_TABLE)) { - assertThat(rs.next(), is(false)); - } - // try getting all cross-references in the database - try (ResultSet rs = - connection.getMetaData().getCrossReference(null, null, null, null, null, null)) { - for (int i = 0; i < 3; i++) { - assertThat(rs.next(), is(true)); - } - assertThat(rs.next(), is(false)); - } - } - } - - private static final class IndexInfo { - private final String tableName; - private final boolean nonUnique; - private final String indexName; - private final short ordinalPosition; - private final String columnName; - private final String ascDesc; - - private IndexInfo( - String tableName, - boolean nonUnique, - String indexName, - int ordinalPosition, - String columnName, - String ascDesc) { - this.tableName = tableName; - this.nonUnique = nonUnique; - this.indexName = indexName; - this.ordinalPosition = (short) ordinalPosition; - this.columnName = columnName; - this.ascDesc = ascDesc; - } - } - - private static final List EXPECTED_INDICES = - Arrays.asList( - new IndexInfo("Albums", false, "PRIMARY_KEY", 1, "SingerId", "A"), - new IndexInfo("Albums", false, "PRIMARY_KEY", 2, "AlbumId", "A"), - new IndexInfo("Albums", true, "AlbumsByAlbumTitle", 1, "AlbumTitle", "A"), - new IndexInfo("Albums", true, "AlbumsByAlbumTitle2", 0, "MarketingBudget", null), - new IndexInfo("Albums", true, "AlbumsByAlbumTitle2", 1, "AlbumTitle", "A"), - new IndexInfo("Concerts", false, "PRIMARY_KEY", 1, "VenueId", "A"), - new IndexInfo("Concerts", false, "PRIMARY_KEY", 2, "SingerId", "A"), - new IndexInfo("Concerts", false, "PRIMARY_KEY", 3, "ConcertDate", "A"), - new IndexInfo("Singers", false, "PRIMARY_KEY", 1, "SingerId", "A"), - new IndexInfo("Singers", true, "SingersByFirstLastName", 1, "FirstName", "A"), - new IndexInfo("Singers", true, "SingersByFirstLastName", 2, "LastName", "A"), - new IndexInfo("Songs", false, "PRIMARY_KEY", 1, "SingerId", "A"), - new IndexInfo("Songs", false, "PRIMARY_KEY", 2, "AlbumId", "A"), - new IndexInfo("Songs", false, "PRIMARY_KEY", 3, "TrackId", "A"), - new IndexInfo("Songs", false, "SongsBySingerAlbumSongNameDesc", 1, "SingerId", "A"), - new IndexInfo("Songs", false, "SongsBySingerAlbumSongNameDesc", 2, "AlbumId", "A"), - new IndexInfo("Songs", false, "SongsBySingerAlbumSongNameDesc", 3, "SongName", "D"), - new IndexInfo("Songs", true, "SongsBySongName", 1, "SongName", "A"), - new IndexInfo("TableWithAllColumnTypes", false, "PRIMARY_KEY", 1, "ColInt64", "A")); - - @Test - public void testGetIndexInfo() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection - .getMetaData() - .getIndexInfo(DEFAULT_CATALOG, DEFAULT_SCHEMA, null, false, false)) { - - for (IndexInfo index : EXPECTED_INDICES) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(index.tableName))); - assertThat(rs.getBoolean("NON_UNIQUE"), is(index.nonUnique)); - assertThat(rs.getString("INDEX_QUALIFIER"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("INDEX_NAME"), is(equalTo(index.indexName))); - if (index.indexName.equals("PRIMARY_KEY")) { - assertThat(rs.getShort("TYPE"), is(equalTo(DatabaseMetaData.tableIndexClustered))); - } else { - assertThat(rs.getShort("TYPE"), is(equalTo(DatabaseMetaData.tableIndexHashed))); - } - assertThat(rs.getShort("ORDINAL_POSITION"), is(equalTo(index.ordinalPosition))); - if (index.ordinalPosition == 0) { - assertThat(rs.wasNull(), is(true)); - } - assertThat(rs.getString("COLUMN_NAME"), is(equalTo(index.columnName))); - assertThat(rs.getString("ASC_OR_DESC"), is(equalTo(index.ascDesc))); - assertThat(rs.getInt("CARDINALITY"), is(equalTo(-1))); - assertThat(rs.getInt("PAGES"), is(equalTo(-1))); - assertThat(rs.getString("FILTER_CONDITION"), is(nullValue())); - } - // all indices found - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testGetExportedKeys() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection - .getMetaData() - .getExportedKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, SINGERS_TABLE)) { - assertKeysSingersAlbums(rs); - } - try (ResultSet rs = - connection.getMetaData().getExportedKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, ALBUMS_TABLE)) { - assertKeysAlbumsSongs(rs); - } - } - } - - @Test - public void testGetImportedKeys() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection.getMetaData().getImportedKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, ALBUMS_TABLE)) { - assertKeysSingersAlbums(rs); - } - try (ResultSet rs = - connection.getMetaData().getImportedKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, SONGS_TABLE)) { - assertKeysAlbumsSongs(rs); - } - } - } - - private void assertKeysSingersAlbums(ResultSet rs) throws SQLException { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo(SINGERS_TABLE))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo(ALBUMS_TABLE))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 1))); - assertThat(rs.getInt("UPDATE_RULE"), is(equalTo(DatabaseMetaData.importedKeyRestrict))); - assertThat(rs.getInt("DELETE_RULE"), is(equalTo(DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.getInt("DEFERRABILITY"), is(equalTo(DatabaseMetaData.importedKeyNotDeferrable))); - assertThat(rs.next(), is(false)); - } - - private void assertKeysAlbumsSongs(ResultSet rs) throws SQLException { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo(ALBUMS_TABLE))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo(SONGS_TABLE))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 1))); - assertThat(rs.getInt("UPDATE_RULE"), is(equalTo(DatabaseMetaData.importedKeyRestrict))); - assertThat(rs.getInt("DELETE_RULE"), is(equalTo(DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.getInt("DEFERRABILITY"), is(equalTo(DatabaseMetaData.importedKeyNotDeferrable))); - - assertThat(rs.next(), is(true)); - assertThat(rs.getString("PKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("PKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("PKTABLE_NAME"), is(equalTo(ALBUMS_TABLE))); - assertThat(rs.getString("PKCOLUMN_NAME"), is(equalTo("AlbumId"))); - assertThat(rs.getString("FKTABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("FKTABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("FKTABLE_NAME"), is(equalTo(SONGS_TABLE))); - assertThat(rs.getString("FKCOLUMN_NAME"), is(equalTo("AlbumId"))); - assertThat(rs.getShort("KEY_SEQ"), is(equalTo((short) 2))); - assertThat(rs.getInt("UPDATE_RULE"), is(equalTo(DatabaseMetaData.importedKeyRestrict))); - assertThat(rs.getInt("DELETE_RULE"), is(equalTo(DatabaseMetaData.importedKeyCascade))); - assertThat(rs.getString("FK_NAME"), is(nullValue())); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.getInt("DEFERRABILITY"), is(equalTo(DatabaseMetaData.importedKeyNotDeferrable))); - assertThat(rs.next(), is(false)); - } - - @Test - public void testGetPrimaryKeys() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection.getMetaData().getPrimaryKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, SINGERS_TABLE)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(SINGERS_TABLE))); - assertThat(rs.getString("COLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getInt("KEY_SEQ"), is(equalTo(1))); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.next(), is(false)); - } - try (ResultSet rs = - connection.getMetaData().getPrimaryKeys(DEFAULT_CATALOG, DEFAULT_SCHEMA, ALBUMS_TABLE)) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(ALBUMS_TABLE))); - assertThat(rs.getString("COLUMN_NAME"), is(equalTo("SingerId"))); - assertThat(rs.getInt("KEY_SEQ"), is(equalTo(1))); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(ALBUMS_TABLE))); - assertThat(rs.getString("COLUMN_NAME"), is(equalTo("AlbumId"))); - assertThat(rs.getInt("KEY_SEQ"), is(equalTo(2))); - assertThat(rs.getString("PK_NAME"), is(equalTo("PRIMARY_KEY"))); - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testGetSchemas() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = connection.getMetaData().getSchemas()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo("INFORMATION_SCHEMA"))); - assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo("SPANNER_SYS"))); - assertThat(rs.getString("TABLE_CATALOG"), is(equalTo(DEFAULT_CATALOG))); - } - } - } - - private static final class Table { - private final String name; - - private Table(String name) { - this.name = name; - } - } - - private static final List EXPECTED_TABLES = - Arrays.asList( - new Table("Albums"), - new Table("Concerts"), - new Table("Singers"), - new Table("Songs"), - new Table("TableWithAllColumnTypes")); - - @Test - public void testGetTables() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection.getMetaData().getTables(DEFAULT_CATALOG, DEFAULT_SCHEMA, null, null)) { - for (Table table : EXPECTED_TABLES) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("TABLE_CAT"), is(equalTo(DEFAULT_CATALOG))); - assertThat(rs.getString("TABLE_SCHEM"), is(equalTo(DEFAULT_SCHEMA))); - assertThat(rs.getString("TABLE_NAME"), is(equalTo(table.name))); - assertThat(rs.getString("TABLE_TYPE"), is(equalTo("TABLE"))); - assertThat(rs.getString("REMARKS"), is(nullValue())); - assertThat(rs.getString("TYPE_CAT"), is(nullValue())); - assertThat(rs.getString("TYPE_SCHEM"), is(nullValue())); - assertThat(rs.getString("TYPE_NAME"), is(nullValue())); - assertThat(rs.getString("SELF_REFERENCING_COL_NAME"), is(nullValue())); - assertThat(rs.getString("REF_GENERATION"), is(nullValue())); - } - assertThat(rs.next(), is(false)); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDdlTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDdlTest.java deleted file mode 100644 index 4fe79a3febd..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcDdlTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Execute DDL statements using JDBC. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITJdbcDdlTest extends ITAbstractJdbcTest { - - @Test - public void testSqlScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new ITJdbcConnectionProvider()); - verifier.verifyStatementsInFile("ITDdlTest.sql", SqlScriptVerifier.class); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPreparedStatementTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPreparedStatementTest.java deleted file mode 100644 index 40b17452d84..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPreparedStatementTest.java +++ /dev/null @@ -1,941 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.api.client.util.Base64; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.common.base.Strings; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.StringReader; -import java.sql.BatchUpdateException; -import java.sql.Connection; -import java.sql.Date; -import java.sql.ParameterMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.Scanner; -import java.util.TimeZone; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -/** Integration tests for JDBC {@link PreparedStatement}s. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITJdbcPreparedStatementTest extends ITAbstractJdbcTest { - private static final class Singer { - private final long singerId; - private final String firstName; - private final String lastName; - private final byte[] singerInfo; - private final Date birthDate; - - private static Singer of(String values) { - String[] array = values.split(","); - if (array.length != 5) { - throw new IllegalArgumentException(values); - } - return new Singer( - Long.valueOf(array[0]), // singer id - array[1].substring(1, array[1].length() - 1), // first name - array[2].substring(1, array[2].length() - 1), // last name - parseBytes(array[3].substring(13, array[3].length() - 2)), // singer info - parseDate(array[4].substring(6, array[4].length() - 1)) // birth date - ); - } - - private Singer( - long singerId, String firstName, String lastName, byte[] singerInfo, Date birthDate) { - this.singerId = singerId; - this.firstName = firstName; - this.lastName = lastName; - this.singerInfo = singerInfo; - this.birthDate = birthDate; - } - } - - private static final class Album { - private final long singerId; - private final long albumId; - private final String albumTitle; - private final long marketingBudget; - - private static Album of(String values) { - String[] array = values.split(","); - if (array.length != 4) { - throw new IllegalArgumentException(values); - } - return new Album( - Long.valueOf(array[0]), // singer id - Long.valueOf(array[1]), // album id - array[2].substring(1, array[2].length() - 1), // album title - Long.valueOf(array[3]) // marketing budget - ); - } - - private Album(long singerId, long albumId, String albumTitle, long marketingBudget) { - this.singerId = singerId; - this.albumId = albumId; - this.albumTitle = albumTitle; - this.marketingBudget = marketingBudget; - } - } - - private static final class Song { - private final long singerId; - private final long albumId; - private final long songId; - private final String songName; - private final long duration; - private final String songGenre; - - private static Song of(String values) { - String[] array = values.split(","); - if (array.length != 6) { - throw new IllegalArgumentException(values); - } - return new Song( - Long.valueOf(array[0]), // singer id - Long.valueOf(array[1]), // album id - Long.valueOf(array[2]), // song id - array[3].substring(1, array[3].length() - 1), // song name - Long.valueOf(array[4]), // duration - array[5].substring(1, array[5].length() - 1)); - } - - private Song( - long singerId, - long albumId, - long songId, - String songName, - long duration, - String songGenre) { - this.singerId = singerId; - this.albumId = albumId; - this.songId = songId; - this.songName = songName; - this.duration = duration; - this.songGenre = songGenre; - } - } - - private static final class Concert { - private final long venueId; - private final long singerId; - private final Date concertDate; - private final Timestamp beginTime; - private final Timestamp endTime; - private final Long[] ticketPrices; - - private static Concert of(String values) { - values = values.replaceAll("\\[(\\d+),(\\d+),(\\d+),(\\d+)\\]", "[$1;$2;$3;$4]"); - String[] array = values.split(","); - if (array.length != 6) { - throw new IllegalArgumentException(values); - } - return new Concert( - Long.valueOf(array[0]), // venue id - Long.valueOf(array[1]), // singer id - parseDate(array[2].substring(6, array[2].length() - 1)), // concert date - parseTimestamp(array[3].substring(11, array[3].length() - 1)), // begin time - parseTimestamp(array[4].substring(11, array[4].length() - 1)), // end time - parseLongArray(array[5]) // ticket prices - ); - } - - private Concert( - long venueId, - long singerId, - Date concertDate, - Timestamp beginTime, - Timestamp endTime, - Long[] ticketPrices) { - this.venueId = venueId; - this.singerId = singerId; - this.concertDate = concertDate; - this.beginTime = beginTime; - this.endTime = endTime; - this.ticketPrices = ticketPrices; - } - } - - private static Date parseDate(String value) { - try { - return Date.valueOf(value); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException(value); - } - } - - private static Timestamp parseTimestamp(String value) { - try { - return Timestamp.valueOf(value.replace('T', ' ').replace("Z", "")); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException(value); - } - } - - private static Long[] parseLongArray(String value) { - String[] values = value.substring(1, value.length() - 1).split(";"); - Long[] res = new Long[values.length]; - for (int index = 0; index < values.length; index++) { - res[index] = Long.valueOf(values[index]); - } - return res; - } - - private static byte[] parseBytes(String value) { - return Base64.decodeBase64(value); - } - - private List createSingers() { - List res = new ArrayList<>(); - for (String singerValue : readValuesFromFile("Singers.txt")) { - res.add(Singer.of(singerValue)); - } - return res; - } - - private List createAlbums() { - List res = new ArrayList<>(); - for (String albumValue : readValuesFromFile("Albums.txt")) { - res.add(Album.of(albumValue)); - } - return res; - } - - private List createSongs() { - List res = new ArrayList<>(); - for (String songValue : readValuesFromFile("Songs.txt")) { - res.add(Song.of(songValue)); - } - return res; - } - - private List createConcerts() { - List res = new ArrayList<>(); - for (String concertValue : readValuesFromFile("Concerts.txt")) { - res.add(Concert.of(concertValue)); - } - return res; - } - - @Override - protected boolean doCreateMusicTables() { - return true; - } - - @Test - public void test01_InsertTestData() throws SQLException { - try (Connection connection = createConnection()) { - connection.setAutoCommit(false); - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) values (?,?,?,?,?)")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 5); - for (Singer singer : createSingers()) { - ps.setByte(1, (byte) singer.singerId); - ps.setString(2, singer.firstName); - ps.setString(3, singer.lastName); - ps.setBytes(4, singer.singerInfo); - ps.setDate(5, singer.birthDate); - - assertInsertSingerParameterMetadata(ps.getParameterMetaData()); - ps.addBatch(); - // check that adding the current params to a batch will not reset the meta data - assertInsertSingerParameterMetadata(ps.getParameterMetaData()); - } - int[] results = ps.executeBatch(); - for (int res : results) { - assertThat(res, is(equalTo(1))); - } - } - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (?,?,?,?)")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 4); - for (Album album : createAlbums()) { - ps.setLong(1, album.singerId); - ps.setLong(2, album.albumId); - ps.setString(3, album.albumTitle); - ps.setLong(4, album.marketingBudget); - assertInsertAlbumParameterMetadata(ps.getParameterMetaData()); - assertThat(ps.executeUpdate(), is(equalTo(1))); - // check that calling executeUpdate will not reset the meta data - assertInsertAlbumParameterMetadata(ps.getParameterMetaData()); - } - } - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (?,?,?,?,?,?);")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 6); - for (Song song : createSongs()) { - ps.setByte(1, (byte) song.singerId); - ps.setInt(2, (int) song.albumId); - ps.setShort(3, (short) song.songId); - ps.setNString(4, song.songName); - ps.setLong(5, song.duration); - ps.setCharacterStream(6, new StringReader(song.songGenre)); - assertInsertSongParameterMetadata(ps.getParameterMetaData()); - assertThat(ps.executeUpdate(), is(equalTo(1))); - // check that calling executeUpdate will not reset the meta data - assertInsertSongParameterMetadata(ps.getParameterMetaData()); - } - } - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (?,?,?,?,?,?);")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 6); - for (Concert concert : createConcerts()) { - ps.setLong(1, concert.venueId); - ps.setLong(2, concert.singerId); - ps.setDate(3, concert.concertDate); - ps.setTimestamp(4, concert.beginTime); - ps.setTimestamp(5, concert.endTime); - ps.setArray(6, connection.createArrayOf("INT64", concert.ticketPrices)); - assertInsertConcertParameterMetadata(ps.getParameterMetaData()); - assertThat(ps.executeUpdate(), is(equalTo(1))); - // check that calling executeUpdate will not reset the meta data - assertInsertConcertParameterMetadata(ps.getParameterMetaData()); - } - } - connection.commit(); - } - } - - @Test - public void test02_VerifyTestData() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = - connection.createStatement().executeQuery("SELECT COUNT(*) FROM Singers")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(30))); - assertThat(rs.next(), is(false)); - } - try (ResultSet rs = - connection.createStatement().executeQuery("SELECT COUNT(*) FROM Albums")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getByte(1), is(equalTo((byte) 60))); - assertThat(rs.next(), is(false)); - } - try (ResultSet rs = connection.createStatement().executeQuery("SELECT COUNT(*) FROM Songs")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getShort(1), is(equalTo((short) 149))); - assertThat(rs.next(), is(false)); - } - try (ResultSet rs = - connection.createStatement().executeQuery("SELECT COUNT(*) FROM Concerts")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(100L))); - assertThat(rs.next(), is(false)); - } - try (PreparedStatement ps = - connection.prepareStatement("SELECT * FROM Concerts WHERE VenueId=? AND SingerId=?")) { - ps.setLong(1, 1L); - ps.setLong(2, 1L); - // Expected: - // (1,1,DATE '2003-06-19',TIMESTAMP '2003-06-19T12:30:05Z',TIMESTAMP - // '2003-06-19T18:57:15Z',[11,93,140,923]); - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(1L))); - assertThat(rs.getLong(2), is(equalTo(1L))); - assertThat(rs.getDate(3), is(equalTo(Date.valueOf("2003-06-19")))); - assertThat(rs.getTimestamp(4), is(equalTo(Timestamp.valueOf("2003-06-19 12:30:05")))); - assertThat(rs.getTimestamp(5), is(equalTo(Timestamp.valueOf("2003-06-19 18:57:15")))); - assertThat(((Long[]) rs.getArray(6).getArray())[0], is(equalTo(11L))); - } - } - } - } - - @SuppressWarnings("deprecation") - @Test - public void test03_Dates() throws SQLException { - List expectedValues = new ArrayList<>(); - expectedValues.add("2008-01-01"); - expectedValues.add("2000-01-01"); - expectedValues.add("1900-01-01"); - expectedValues.add("2000-02-29"); - expectedValues.add("2004-02-29"); - expectedValues.add("2018-12-31"); - expectedValues.add("2015-11-15"); - expectedValues.add("2015-11-15"); - expectedValues.add("2015-11-15"); - - List testDates = new ArrayList<>(); - testDates.add(Date.valueOf("2008-01-01")); - testDates.add(Date.valueOf("2000-01-01")); - testDates.add(Date.valueOf("1900-01-01")); - testDates.add(Date.valueOf("2000-02-29")); - testDates.add(Date.valueOf("2004-02-29")); - testDates.add(Date.valueOf("2018-12-31")); - - // Cloud Spanner does not store any timezone information, meaning that it shouldn't matter in - // what timezone a date is sent to Cloud Spanner, the same date in the local timezone (or the - // requested timezone) should be returned. - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - cal.clear(); - cal.set(2015, 10, 15, 10, 0, 0); - testDates.add(new Date(cal.getTimeInMillis())); - - cal = Calendar.getInstance(TimeZone.getTimeZone("CET")); - cal.clear(); - cal.set(2015, 10, 15, 10, 0, 0); - testDates.add(new Date(cal.getTimeInMillis())); - - cal = Calendar.getInstance(TimeZone.getTimeZone("PST")); - cal.clear(); - cal.set(2015, 10, 15, 10, 0, 0); - testDates.add(new Date(cal.getTimeInMillis())); - - List calendars = new ArrayList<>(); - calendars.add(null); - calendars.add(Calendar.getInstance()); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("UTC"))); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("CET"))); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("PST"))); - - try (Connection connection = createConnection()) { - for (Calendar testCalendar : calendars) { - int index = 0; - for (Date testDate : testDates) { - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (?,?,?,?,?,?);")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 6); - ps.setLong(1, 100); - ps.setLong(2, 19); - ps.setDate(3, testDate); - ps.setTimestamp(4, new Timestamp(System.currentTimeMillis())); - ps.setTimestamp(5, new Timestamp(System.currentTimeMillis())); - ps.setArray(6, connection.createArrayOf("INT64", new Long[] {})); - ps.executeUpdate(); - } - - try (PreparedStatement ps = - connection.prepareStatement( - "SELECT * FROM Concerts WHERE VenueId=? AND SingerId=?")) { - ps.setLong(1, 100L); - ps.setLong(2, 19L); - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - if (testCalendar == null) { - assertThat(rs.getDate(3), is(equalTo(Date.valueOf(expectedValues.get(index))))); - } else { - // Parse the date in the local timezone. - Date date = Date.valueOf(expectedValues.get(index)); - // Create a calendar in the test timezone with only the date part set. - Calendar localCalendar = Calendar.getInstance(testCalendar.getTimeZone()); - localCalendar.clear(); - localCalendar.set(date.getYear() + 1900, date.getMonth(), date.getDate()); - // Check that the actual time of the date returned by the ResultSet is equal to the - // local time in the timezone of the Calendar that is used. - assertThat( - rs.getDate(3, testCalendar), - is(equalTo(new Date(localCalendar.getTimeInMillis())))); - } - } - } - connection - .createStatement() - .execute("DELETE FROM Concerts WHERE VenueId=100 AND SingerId=19"); - index++; - } - } - } - } - - @Test - public void test04_Timestamps() throws SQLException { - List expectedValues = new ArrayList<>(); - expectedValues.add("2008-01-01 10:00:00"); - expectedValues.add("2000-01-01 00:00:00"); - expectedValues.add("1900-01-01 12:13:14"); - expectedValues.add("2000-02-29 02:00:00"); - expectedValues.add("2004-02-29 03:00:00"); - expectedValues.add("2018-12-31 23:59:59"); - expectedValues.add("2015-11-15 10:00:00"); - expectedValues.add("2015-11-15 10:00:00"); - expectedValues.add("2015-11-15 10:00:00"); - - List timezones = new ArrayList<>(); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getDefault()); - timezones.add(TimeZone.getTimeZone("UTC")); - timezones.add(TimeZone.getTimeZone("CET")); - timezones.add(TimeZone.getTimeZone("PST")); - - List testTimestamps = new ArrayList<>(); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(0))); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(1))); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(2))); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(3))); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(4))); - testTimestamps.add(Timestamp.valueOf(expectedValues.get(5))); - - // Cloud Spanner does not store any timezone information, but does store the timestamp in UTC - // format. - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - cal.clear(); - cal.set(2015, 10, 15); - testTimestamps.add(new Timestamp(cal.getTimeInMillis())); - - cal = Calendar.getInstance(TimeZone.getTimeZone("CET")); - cal.clear(); - cal.set(2015, 10, 15); - testTimestamps.add(new Timestamp(cal.getTimeInMillis())); - - cal = Calendar.getInstance(TimeZone.getTimeZone("PST")); - cal.clear(); - cal.set(2015, 10, 15); - testTimestamps.add(new Timestamp(cal.getTimeInMillis())); - - List calendars = new ArrayList<>(); - calendars.add(null); - calendars.add(Calendar.getInstance()); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("UTC"))); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("CET"))); - calendars.add(Calendar.getInstance(TimeZone.getTimeZone("PST"))); - - try (Connection connection = createConnection()) { - for (Calendar testCalendar : calendars) { - for (Timestamp testTimestamp : testTimestamps) { - try (PreparedStatement ps = - connection.prepareStatement( - "INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (?,?,?,?,?,?);")) { - assertDefaultParameterMetaData(ps.getParameterMetaData(), 6); - ps.setLong(1, 100); - ps.setLong(2, 19); - ps.setDate(3, new Date(System.currentTimeMillis())); - // Cloud Spanner will store the timestamp in UTC and no other timezone information. - ps.setTimestamp(4, testTimestamp); - ps.setTimestamp(5, testTimestamp, testCalendar); - ps.setArray(6, connection.createArrayOf("INT64", new Long[] {})); - ps.executeUpdate(); - } - - try (PreparedStatement ps = - connection.prepareStatement( - "SELECT * FROM Concerts WHERE VenueId=? AND SingerId=?")) { - ps.setLong(1, 100L); - ps.setLong(2, 19L); - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - - // First test the timestamp that was sent to Spanner using the default timezone. - // Get the timestamp in the default timezone. - Timestamp inDefaultTZ = rs.getTimestamp(4); - assertThat(inDefaultTZ.getTime(), is(equalTo(testTimestamp.getTime()))); - // Then get it in the test timezone. - if (testCalendar != null) { - Timestamp inOtherTZ = rs.getTimestamp(4, testCalendar); - assertThat( - inOtherTZ.getTime(), - is( - equalTo( - testTimestamp.getTime() + testCalendar.getTimeZone().getRawOffset()))); - } - - // Then test the timestamp that was sent to Spanner using a specific timezone. - // Get the timestamp in the default timezone. - inDefaultTZ = rs.getTimestamp(5); - if (testCalendar == null) { - assertThat(inDefaultTZ.getTime(), is(equalTo(testTimestamp.getTime()))); - } else { - assertThat( - inDefaultTZ.getTime(), - is( - equalTo( - testTimestamp.getTime() - testCalendar.getTimeZone().getRawOffset()))); - } - // Then get it in the test timezone. - if (testCalendar != null) { - Timestamp inOtherTZ = rs.getTimestamp(5, testCalendar); - assertThat(inOtherTZ.getTime(), is(equalTo(testTimestamp.getTime()))); - } - } - } - connection - .createStatement() - .execute("DELETE FROM Concerts WHERE VenueId=100 AND SingerId=19"); - } - } - } - } - - @Test - public void test05_BatchUpdates() throws SQLException { - for (boolean autocommit : new boolean[] {true, false}) { - try (Connection con1 = createConnection(); - Connection con2 = createConnection()) { - con1.setAutoCommit(autocommit); - int[] updateCounts; - String[] params = new String[] {"A%", "B%", "C%"}; - try (PreparedStatement ps = - con1.prepareStatement("UPDATE Singers SET FirstName=LastName WHERE LastName LIKE ?")) { - for (String param : params) { - ps.setString(1, param); - ps.addBatch(); - } - updateCounts = ps.executeBatch(); - } - assertThat(updateCounts.length, is(equalTo(params.length))); - long totalUpdated = 0; - try (PreparedStatement ps = - con1.prepareStatement("SELECT COUNT(*) FROM Singers WHERE LastName LIKE ?")) { - for (int i = 0; i < updateCounts.length; i++) { - ps.setString(1, params[i]); - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - assertThat(updateCounts[i], is(equalTo(rs.getInt(1)))); - totalUpdated += updateCounts[i]; - } - } - } - // Check whether the updated values are readable on the second connection. - try (ResultSet rs = - con2.createStatement() - .executeQuery("SELECT COUNT(*) FROM Singers WHERE FirstName=LastName")) { - assertThat(rs.next(), is(true)); - if (autocommit) { - assertThat(rs.getLong(1), is(equalTo(totalUpdated))); - } else { - assertThat(rs.getLong(1), is(equalTo(0L))); - } - } - // If not in autocommit mode --> commit and verify. - if (!autocommit) { - con1.commit(); - try (ResultSet rs = - con2.createStatement() - .executeQuery("SELECT COUNT(*) FROM Singers WHERE FirstName=LastName")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(totalUpdated))); - } - } - // Set first names to null for the updated records for the next test run. - assertThat( - con2.createStatement() - .executeUpdate("UPDATE Singers SET FirstName=null WHERE FirstName=LastName"), - is(equalTo((int) totalUpdated))); - } - } - } - - @Test - public void test06_BatchUpdatesWithException() throws SQLException { - for (boolean autocommit : new boolean[] {true, false}) { - try (Connection con1 = createConnection(); - Connection con2 = createConnection()) { - con1.setAutoCommit(autocommit); - String[] params = new String[] {"A%", "B%", "C%", "D%"}; - // Statement number three will fail because the value is too long for the column. - int[] updateValues = new int[] {1, 1, 1024, 1}; - try (PreparedStatement ps = - con1.prepareStatement("UPDATE Singers SET FirstName=? WHERE LastName LIKE ?")) { - for (int i = 0; i < params.length; i++) { - ps.setString(1, Strings.repeat("not too long", updateValues[i])); - ps.setString(2, params[i]); - ps.addBatch(); - } - ps.executeBatch(); - fail("missing expected BatchUpdateException"); - } catch (BatchUpdateException e) { - assertThat(e.getUpdateCounts().length, is(equalTo(2))); - } - // If not in autocommit mode --> rollback before the next run. - if (!autocommit) { - con1.rollback(); - } - // Set first names to null for the updated records for the next test run. - try (PreparedStatement ps = - con2.prepareStatement("UPDATE Singers SET FirstName=null WHERE FirstName=?")) { - ps.setString(1, "not too long"); - } - } - } - } - - @Test - public void test07_StatementBatchUpdateWithException() throws SQLException { - try (Connection con = createConnection()) { - // The following statements will fail because the value is too long. - try (Statement statement = con.createStatement()) { - statement.addBatch( - String.format( - "UPDATE Singers SET FirstName='%s' WHERE LastName LIKE 'A%%'", - Strings.repeat("too long", 1024))); - statement.addBatch( - String.format( - "UPDATE Singers SET FirstName='%s' WHERE LastName LIKE 'B%%'", - Strings.repeat("too long", 1024))); - statement.executeBatch(); - fail("missing expected BatchUpdateException"); - } catch (BatchUpdateException e) { - assertThat(e.getUpdateCounts(), is(notNullValue())); - } - // The following statements will fail because the table does not exist. - try (Statement statement = con.createStatement()) { - statement.addBatch( - String.format( - "UPDATE Non_Existent_Table SET FirstName='%s' WHERE LastName LIKE 'A%%'", - Strings.repeat("too long", 1024))); - statement.addBatch( - String.format( - "UPDATE Non_Existent_Table SET FirstName='%s' WHERE LastName LIKE 'B%%'", - Strings.repeat("too long", 1024))); - statement.executeBatch(); - fail(); - } catch (BatchUpdateException e) { - assertThat(e.getUpdateCounts(), is(notNullValue())); - } - // The following statements will fail because the primary key values conflict. - try (Statement statement = con.createStatement()) { - statement.addBatch( - "INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (9999, 'Test', 'Test', NULL, NULL)"); - statement.addBatch( - "INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (9999, 'Test', 'Test', NULL, NULL)"); - statement.executeBatch(); - fail(); - } catch (BatchUpdateException e) { - assertThat(e.getUpdateCounts(), is(notNullValue())); - } - } - } - - private void assertDefaultParameterMetaData(ParameterMetaData pmd, int expectedParamCount) - throws SQLException { - assertThat(pmd.getParameterCount(), is(equalTo(expectedParamCount))); - for (int param = 1; param <= expectedParamCount; param++) { - assertThat(pmd.getParameterType(param), is(equalTo(Types.OTHER))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("OTHER"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(nullValue())); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - } - - private List readValuesFromFile(String filename) { - File file = new File(getClass().getResource(filename).getFile()); - StringBuilder builder = new StringBuilder(); - try (Scanner scanner = new Scanner(file)) { - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - builder.append(line).append("\n"); - } - scanner.close(); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - String[] array = builder.toString().split(";"); - List res = new ArrayList<>(array.length); - for (String statement : array) { - if (statement != null && statement.trim().length() > 0) { - // strip the ( and ) - res.add(statement.trim().substring(1, statement.trim().length() - 1)); - } - } - return res; - } - - private void assertInsertSingerParameterMetadata(ParameterMetaData pmd) throws SQLException { - assertThat(pmd.getParameterCount(), is(equalTo(5))); - assertByteParam(pmd, 1); - assertStringParam(pmd, 2); - assertStringParam(pmd, 3); - assertBytesParam(pmd, 4); - assertDateParam(pmd, 5); - } - - private void assertInsertAlbumParameterMetadata(ParameterMetaData pmd) throws SQLException { - assertThat(pmd.getParameterCount(), is(equalTo(4))); - assertLongParam(pmd, 1); - assertLongParam(pmd, 2); - assertStringParam(pmd, 3); - assertLongParam(pmd, 4); - } - - private void assertInsertSongParameterMetadata(ParameterMetaData pmd) throws SQLException { - assertThat(pmd.getParameterCount(), is(equalTo(6))); - assertByteParam(pmd, 1); - assertIntParam(pmd, 2); - assertShortParam(pmd, 3); - assertNStringParam(pmd, 4); - assertLongParam(pmd, 5); - assertStringReaderParam(pmd, 6); - } - - private void assertInsertConcertParameterMetadata(ParameterMetaData pmd) throws SQLException { - assertThat(pmd.getParameterCount(), is(equalTo(6))); - assertLongParam(pmd, 1); - assertLongParam(pmd, 2); - assertDateParam(pmd, 3); - assertTimestampParam(pmd, 4); - assertTimestampParam(pmd, 5); - assertLongArrayParam(pmd, 6); - } - - private void assertLongParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.BIGINT))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("INT64"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Long.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(true)); - } - - private void assertIntParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.INTEGER))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("INT64"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Integer.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(true)); - } - - private void assertShortParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.SMALLINT))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("INT64"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Short.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(true)); - } - - private void assertByteParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.TINYINT))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("INT64"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Byte.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(true)); - } - - private void assertStringParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.NVARCHAR))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("STRING"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(String.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertNStringParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.NVARCHAR))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("STRING"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(String.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertStringReaderParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.NVARCHAR))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("STRING"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(StringReader.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertBytesParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.BINARY))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("BYTES"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(byte[].class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertDateParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.DATE))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("DATE"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Date.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertTimestampParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.TIMESTAMP))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("TIMESTAMP"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat(pmd.getParameterClassName(param), is(equalTo(Timestamp.class.getName()))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } - - private void assertLongArrayParam(ParameterMetaData pmd, int param) throws SQLException { - assertThat(pmd.getParameterType(param), is(equalTo(Types.ARRAY))); - assertThat(pmd.getParameterTypeName(param), is(equalTo("ARRAY"))); - assertThat(pmd.getPrecision(param), is(equalTo(0))); - assertThat(pmd.getScale(param), is(equalTo(0))); - assertThat( - pmd.getParameterClassName(param), is(equalTo("com.google.cloud.spanner.jdbc.JdbcArray"))); - assertThat(pmd.getParameterMode(param), is(equalTo(ParameterMetaData.parameterModeIn))); - assertThat(pmd.isNullable(param), is(equalTo(ParameterMetaData.parameterNullableUnknown))); - assertThat(pmd.isSigned(param), is(false)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadOnlyTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadOnlyTest.java deleted file mode 100644 index 8e083f592ec..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadOnlyTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.math.BigInteger; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** This test class runs a SQL script for testing a connection in read-only mode. */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITJdbcReadOnlyTest extends ITAbstractJdbcTest { - private static final long TEST_ROWS_COUNT = 1000L; - - @Rule public ExpectedException exception = ExpectedException.none(); - - @Override - protected void appendConnectionUri(StringBuilder url) { - url.append(";readOnly=true"); - } - - @Before - public void createTestTables() throws Exception { - try (CloudSpannerJdbcConnection connection = createConnection()) { - if (!(tableExists(connection, "NUMBERS") && tableExists(connection, "PRIME_NUMBERS"))) { - // create tables - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new ITJdbcConnectionProvider()); - verifier.verifyStatementsInFile( - "ITReadOnlySpannerTest_CreateTables.sql", SqlScriptVerifier.class); - - // fill tables with data - connection.setAutoCommit(false); - connection.setReadOnly(false); - for (long number = 1L; number <= TEST_ROWS_COUNT; number++) { - connection.bufferedWrite( - Mutation.newInsertBuilder("NUMBERS") - .set("number") - .to(number) - .set("name") - .to(Long.toBinaryString(number)) - .build()); - } - for (long number = 1L; number <= TEST_ROWS_COUNT; number++) { - if (BigInteger.valueOf(number).isProbablePrime(Integer.MAX_VALUE)) { - connection.bufferedWrite( - Mutation.newInsertBuilder("PRIME_NUMBERS") - .set("prime_number") - .to(number) - .set("binary_representation") - .to(Long.toBinaryString(number)) - .build()); - } - } - connection.commit(); - } - } - } - - @Test - public void testSqlScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new ITJdbcConnectionProvider()); - verifier.verifyStatementsInFile("ITReadOnlySpannerTest.sql", SqlScriptVerifier.class); - } - - @Test - public void testMultipleOpenResultSets() throws InterruptedException, SQLException { - try (Connection connection = createConnection()) { - final java.sql.ResultSet rs1 = - connection.createStatement().executeQuery("SELECT * FROM PRIME_NUMBERS"); - final java.sql.ResultSet rs2 = - connection.createStatement().executeQuery("SELECT * FROM NUMBERS"); - ExecutorService exec = Executors.newFixedThreadPool(2); - exec.submit( - new Runnable() { - @Override - public void run() { - try { - while (rs1.next()) {} - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - }); - exec.submit( - new Runnable() { - @Override - public void run() { - try { - while (rs2.next()) {} - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - }); - exec.shutdown(); - exec.awaitTermination(1000L, TimeUnit.SECONDS); - rs1.close(); - rs2.close(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadWriteAutocommitTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadWriteAutocommitTest.java deleted file mode 100644 index 315cdc17e19..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcReadWriteAutocommitTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import org.junit.FixMethodOrder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITJdbcReadWriteAutocommitTest extends ITAbstractJdbcTest { - - @Rule public ExpectedException exception = ExpectedException.none(); - - @Override - protected void appendConnectionUri(StringBuilder uri) { - uri.append(";autocommit=true"); - } - - @Override - public boolean doCreateDefaultTestTable() { - return true; - } - - @Test - public void test01_SqlScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(new ITJdbcConnectionProvider()); - verifier.verifyStatementsInFile( - "ITReadWriteAutocommitSpannerTest.sql", SqlScriptVerifier.class); - } - - @Test - public void test02_WriteMutation() throws Exception { - try (CloudSpannerJdbcConnection connection = createConnection()) { - connection.write( - Mutation.newInsertBuilder("TEST").set("ID").to(9999L).set("NAME").to("FOO").build()); - java.sql.Statement statement = connection.createStatement(); - statement.execute("SHOW VARIABLE COMMIT_TIMESTAMP"); - try (java.sql.ResultSet rs = statement.getResultSet()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getTimestamp(1), is(notNullValue())); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSimpleStatementsTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSimpleStatementsTest.java deleted file mode 100644 index 4a71bfd5c35..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSimpleStatementsTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test executing simple statements through JDBC. */ -@RunWith(JUnit4.class) -@Category(IntegrationTest.class) -public class ITJdbcSimpleStatementsTest extends ITAbstractJdbcTest { - @Rule public final ExpectedException expected = ExpectedException.none(); - - @Test - public void testSelect1() throws SQLException { - try (Connection connection = createConnection()) { - try (ResultSet rs = connection.createStatement().executeQuery("select 1")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(1))); - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testSelect1PreparedStatement() throws SQLException { - try (Connection connection = createConnection()) { - try (PreparedStatement ps = connection.prepareStatement("select 1")) { - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(1))); - assertThat(rs.next(), is(false)); - } - } - } - } - - @Test - public void testPreparedStatement() throws SQLException { - String sql = - "select * from (select 1 as number union all select 2 union all select 3) numbers where number=?"; - try (Connection connection = createConnection()) { - try (PreparedStatement ps = connection.prepareStatement(sql)) { - for (int i = 1; i <= 3; i++) { - ps.setInt(1, i); - try (ResultSet rs = ps.executeQuery()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getInt(1), is(equalTo(i))); - assertThat(rs.next(), is(false)); - } - } - } - } - } - - @Test - public void testBatchedDdlStatements() throws SQLException { - // Execute a successful batch of DDL statements. - try (Connection connection = createConnection()) { - try (Statement statement = connection.createStatement()) { - statement.addBatch( - "CREATE TABLE FOO1 (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID)"); - statement.addBatch( - "CREATE TABLE FOO2 (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID)"); - int[] updateCounts = statement.executeBatch(); - assertThat( - updateCounts, - is(equalTo(new int[] {Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO}))); - } - try (ResultSet rs = - connection - .createStatement() - .executeQuery( - "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='' AND TABLE_NAME LIKE 'FOO%'")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(2L))); - } - } - // Execute a batch of DDL statements that contains a statement that will fail. - try (Connection connection = createConnection()) { - // First create a couple of test records that will cause the index creation to fail. - try (Statement statement = connection.createStatement()) { - statement.executeUpdate("INSERT INTO FOO1 (ID, NAME) VALUES (1,'TEST')"); - statement.executeUpdate("INSERT INTO FOO1 (ID, NAME) VALUES (2,'TEST')"); - } - boolean gotExpectedException = false; - try (Statement statement = connection.createStatement()) { - statement.addBatch( - "CREATE TABLE FOO3 (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID)"); - statement.addBatch("CREATE UNIQUE INDEX IDX_FOO1_UNIQUE ON FOO1 (NAME)"); - statement.executeBatch(); - } catch (SQLException e) { - gotExpectedException = true; - } - assertThat(gotExpectedException, is(true)); - // The table should have been created, the index should not. - try (ResultSet rs = - connection - .createStatement() - .executeQuery( - "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='' AND TABLE_NAME LIKE 'FOO%'")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(3L))); - } - try (ResultSet rs = - connection - .createStatement() - .executeQuery( - "SELECT COUNT(*) FROM INFORMATION_SCHEMA.INDEXES WHERE TABLE_SCHEMA='' AND INDEX_NAME='IDX_FOO1_UNIQUE'")) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(1), is(equalTo(0L))); - } - } - } - - @Test - public void testAddBatchWhenAlreadyInBatch() throws SQLException { - expected.expect(SQLException.class); - expected.expectMessage( - "Calling addBatch() is not allowed when a DML or DDL batch has been started on the connection."); - try (Connection connection = createConnection()) { - connection.createStatement().execute("START BATCH DML"); - connection.createStatement().addBatch("INSERT INTO Singers (SingerId) VALUES (-1)"); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlMusicScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlMusicScriptTest.java deleted file mode 100644 index 29b0b054d5e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlMusicScriptTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier.JdbcGenericConnection; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.sql.Connection; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITJdbcSqlMusicScriptTest extends ITAbstractJdbcTest { - private static final String SCRIPT_FILE = "ITSqlMusicScriptTest.sql"; - - @Test - public void testRunScript() throws Exception { - JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(); - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), SCRIPT_FILE, SqlScriptVerifier.class); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java deleted file mode 100644 index cc133466294..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcSqlScriptTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractJdbcTest; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier; -import com.google.cloud.spanner.jdbc.JdbcSqlScriptVerifier.JdbcGenericConnection; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -/** - * Integration test that creates and fills a test database entirely using only sql scripts, and then - * performs all possible operations on this test database using only sql scripts. This test uses the - * JDBC driver for Spanner. - */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITJdbcSqlScriptTest extends ITAbstractJdbcTest { - private static final String CREATE_TABLES_FILE = "ITSqlScriptTest_CreateTables.sql"; - private static final String INSERT_AND_VERIFY_TEST_DATA = "ITSqlScriptTest_InsertTestData.sql"; - private static final String TEST_GET_READ_TIMESTAMP = "ITSqlScriptTest_TestGetReadTimestamp.sql"; - private static final String TEST_GET_COMMIT_TIMESTAMP = - "ITSqlScriptTest_TestGetCommitTimestamp.sql"; - private static final String TEST_TEMPORARY_TRANSACTIONS = - "ITSqlScriptTest_TestTemporaryTransactions.sql"; - private static final String TEST_TRANSACTION_MODE = "ITSqlScriptTest_TestTransactionMode.sql"; - private static final String TEST_TRANSACTION_MODE_READ_ONLY = - "ITSqlScriptTest_TestTransactionMode_ReadOnly.sql"; - private static final String TEST_READ_ONLY_STALENESS = - "ITSqlScriptTest_TestReadOnlyStaleness.sql"; - private static final String TEST_AUTOCOMMIT_DML_MODE = - "ITSqlScriptTest_TestAutocommitDmlMode.sql"; - private static final String TEST_AUTOCOMMIT_READ_ONLY = - "ITSqlScriptTest_TestAutocommitReadOnly.sql"; - private static final String TEST_STATEMENT_TIMEOUT = "ITSqlScriptTest_TestStatementTimeout.sql"; - private static final String TEST_SET_STATEMENTS = "ITSqlScriptTest_TestSetStatements.sql"; - private static final String TEST_INVALID_STATEMENTS = "ITSqlScriptTest_TestInvalidStatements.sql"; - - private final JdbcSqlScriptVerifier verifier = new JdbcSqlScriptVerifier(); - - /** Create test tables and verify their existence */ - @Test - public void test01_CreateTables() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), CREATE_TABLES_FILE, SqlScriptVerifier.class); - } - } - - /** Insert some test data */ - @Test - public void test02_InsertTestData() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), - INSERT_AND_VERIFY_TEST_DATA, - SqlScriptVerifier.class); - } - } - - @Test - public void test03_TestGetReadTimestamp() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_GET_READ_TIMESTAMP, SqlScriptVerifier.class); - } - } - - @Test - public void test04_TestGetCommitTimestamp() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_GET_COMMIT_TIMESTAMP, SqlScriptVerifier.class); - } - } - - @Test - public void test05_TestTemporaryTransactions() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), - TEST_TEMPORARY_TRANSACTIONS, - SqlScriptVerifier.class); - } - } - - @Test - public void test06_TestTransactionMode() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_TRANSACTION_MODE, SqlScriptVerifier.class); - } - } - - @Test - public void test07_TestTransactionModeReadOnly() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), - TEST_TRANSACTION_MODE_READ_ONLY, - SqlScriptVerifier.class); - } - } - - @Test - public void test08_TestReadOnlyStaleness() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_READ_ONLY_STALENESS, SqlScriptVerifier.class); - } - } - - @Test - public void test09_TestAutocommitDmlMode() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_AUTOCOMMIT_DML_MODE, SqlScriptVerifier.class); - } - } - - @Test - public void test10_TestAutocommitReadOnly() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_AUTOCOMMIT_READ_ONLY, SqlScriptVerifier.class); - } - } - - @Test - public void test11_TestStatementTimeout() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_STATEMENT_TIMEOUT, SqlScriptVerifier.class); - } - try (Connection connection = createConnection()) { - // Create a statement with a query timeout, but do not set a statement timeout on the - // connection. SHOW STATEMENT_TIMEOUT should then return a null value. - Statement statement = connection.createStatement(); - statement.setQueryTimeout(1); - statement.execute("SHOW VARIABLE STATEMENT_TIMEOUT"); - try (ResultSet rs = statement.getResultSet()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("STATEMENT_TIMEOUT"), is(nullValue())); - } - - // Now set a STATEMENT_TIMEOUT on the connection that is different from the query timeout of - // the statement. SHOW STATEMENT_TIMEOUT should now return the STATEMENT_TIMEOUT of the - // connection. - statement.execute("SET STATEMENT_TIMEOUT='100ms'"); - statement.execute("SHOW VARIABLE STATEMENT_TIMEOUT"); - try (ResultSet rs = statement.getResultSet()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("STATEMENT_TIMEOUT"), is(equalTo("100ms"))); - } - - // Remove the statement timeout again, and verify that SHOW STATEMENT_TIMEOUT once again - // returns null. - statement.execute("SET STATEMENT_TIMEOUT=NULL"); - statement.execute("SHOW VARIABLE STATEMENT_TIMEOUT"); - try (ResultSet rs = statement.getResultSet()) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("STATEMENT_TIMEOUT"), is(nullValue())); - } - } - } - - @Test - public void test12_TestSetStatements() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_SET_STATEMENTS, SqlScriptVerifier.class); - } - } - - @Test - public void test13_TestInvalidStatements() throws Exception { - try (Connection connection = createConnection()) { - verifier.verifyStatementsInFile( - JdbcGenericConnection.of(connection), TEST_INVALID_STATEMENTS, SqlScriptVerifier.class); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadOnlySpannerTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadOnlySpannerTest.java deleted file mode 100644 index b3aa8ea751c..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadOnlySpannerTest.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SpannerExceptionMatcher; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.math.BigInteger; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * This test class runs a SQL script for testing a connection in read-only mode, but also contains a - * number of separate test methods that cannot be expressed in a pure SQL test. - */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITReadOnlySpannerTest extends ITAbstractSpannerTest { - private static final Logger logger = Logger.getLogger(ITReadOnlySpannerTest.class.getName()); - private static final long TEST_ROWS_COUNT = 1000L; - - @Rule public ExpectedException exception = ExpectedException.none(); - - @Override - protected void appendConnectionUri(StringBuilder url) { - url.append(";readOnly=true"); - } - - @Before - public void createTestTables() throws Exception { - try (ITConnection connection = createConnection()) { - if (!(tableExists(connection, "NUMBERS") && tableExists(connection, "PRIME_NUMBERS"))) { - // create tables - SqlScriptVerifier verifier = new SqlScriptVerifier(new ITConnectionProvider()); - verifier.verifyStatementsInFile( - "ITReadOnlySpannerTest_CreateTables.sql", SqlScriptVerifier.class); - - // fill tables with data - connection.setAutocommit(false); - connection.setReadOnly(false); - for (long number = 1L; number <= TEST_ROWS_COUNT; number++) { - connection.bufferedWrite( - Mutation.newInsertBuilder("NUMBERS") - .set("number") - .to(number) - .set("name") - .to(Long.toBinaryString(number)) - .build()); - } - for (long number = 1L; number <= TEST_ROWS_COUNT; number++) { - if (BigInteger.valueOf(number).isProbablePrime(Integer.MAX_VALUE)) { - connection.bufferedWrite( - Mutation.newInsertBuilder("PRIME_NUMBERS") - .set("prime_number") - .to(number) - .set("binary_representation") - .to(Long.toBinaryString(number)) - .build()); - } - } - connection.commit(); - } - } - } - - @Test - public void testSqlScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new ITConnectionProvider()); - verifier.verifyStatementsInFile("ITReadOnlySpannerTest.sql", SqlScriptVerifier.class); - } - - @Test - public void testStatementTimeoutTransactional() throws Exception { - try (ITConnection connection = createConnection()) { - connection.beginTransaction(); - connection.setStatementTimeout(1L, TimeUnit.MILLISECONDS); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - try (ResultSet rs = - connection.executeQuery( - Statement.of( - "SELECT (SELECT COUNT(*) FROM PRIME_NUMBERS)/(SELECT COUNT(*) FROM NUMBERS) AS PRIME_NUMBER_RATIO"))) {} - // should never be reached - connection.commit(); - } - } - - @Test - public void testStatementTimeoutTransactionalMultipleStatements() throws Exception { - long startTime = System.currentTimeMillis(); - try (ITConnection connection = createConnection()) { - connection.beginTransaction(); - for (int i = 0; i < 3; i++) { - boolean timedOut = false; - connection.setStatementTimeout(1L, TimeUnit.MILLISECONDS); - try (ResultSet rs = - connection.executeQuery( - Statement.of( - "SELECT (SELECT COUNT(*) FROM PRIME_NUMBERS)/(SELECT COUNT(*) FROM NUMBERS) AS PRIME_NUMBER_RATIO"))) { - } catch (SpannerException e) { - timedOut = e.getErrorCode() == ErrorCode.DEADLINE_EXCEEDED; - } - assertThat(timedOut, is(true)); - } - connection.commit(); - } - long endTime = System.currentTimeMillis(); - long executionTime = endTime - startTime; - if (executionTime > 25L) { - logger.warning("Total test execution time exceeded 25 milliseconds: " + executionTime); - } else { - logger.info("Total test execution time: " + executionTime); - } - } - - @Test - public void testStatementTimeoutAutocommit() throws Exception { - try (ITConnection connection = createConnection()) { - assertThat(connection.isAutocommit(), is(true)); - connection.setStatementTimeout(1L, TimeUnit.MILLISECONDS); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.DEADLINE_EXCEEDED)); - try (ResultSet rs = - connection.executeQuery( - Statement.of( - "SELECT (SELECT COUNT(*) FROM PRIME_NUMBERS)/(SELECT COUNT(*) FROM NUMBERS) AS PRIME_NUMBER_RATIO"))) {} - } - } - - @Test - public void testAnalyzeQuery() { - try (ITConnection connection = createConnection()) { - for (QueryAnalyzeMode mode : QueryAnalyzeMode.values()) { - try (ResultSet rs = - connection.analyzeQuery( - Statement.of( - "SELECT (SELECT COUNT(*) FROM PRIME_NUMBERS)/(SELECT COUNT(*) FROM NUMBERS) AS PRIME_NUMBER_RATIO"), - mode)) { - // next has not yet returned false - assertThat(rs.getStats(), is(nullValue())); - while (rs.next()) { - // ignore - } - assertThat(rs.getStats(), is(notNullValue())); - } - } - } - } - - @Test - public void testQueryWithOptions() { - try (ITConnection connection = createConnection()) { - try (ResultSet rs = - connection.executeQuery( - Statement.of( - "SELECT (SELECT CAST(COUNT(*) AS FLOAT64) FROM PRIME_NUMBERS)/(SELECT COUNT(*) FROM NUMBERS) AS PRIME_NUMBER_RATIO"), - Options.prefetchChunks(100000))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getDouble(0), is(notNullValue())); - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testMultipleOpenResultSets() throws InterruptedException { - try (ITConnection connection = createConnection()) { - final ResultSet rs1 = connection.executeQuery(Statement.of("SELECT * FROM PRIME_NUMBERS")); - final ResultSet rs2 = connection.executeQuery(Statement.of("SELECT * FROM NUMBERS")); - ExecutorService exec = Executors.newFixedThreadPool(2); - exec.submit( - new Runnable() { - @Override - public void run() { - while (rs1.next()) {} - } - }); - exec.submit( - new Runnable() { - @Override - public void run() { - while (rs2.next()) {} - } - }); - exec.shutdown(); - exec.awaitTermination(1000L, TimeUnit.SECONDS); - rs1.close(); - rs2.close(); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadWriteAutocommitSpannerTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadWriteAutocommitSpannerTest.java deleted file mode 100644 index aa464fd4b75..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITReadWriteAutocommitSpannerTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerBatchUpdateException; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; -import org.junit.FixMethodOrder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITReadWriteAutocommitSpannerTest extends ITAbstractSpannerTest { - - @Rule public ExpectedException exception = ExpectedException.none(); - - @Override - protected void appendConnectionUri(StringBuilder uri) { - uri.append(";autocommit=true"); - } - - @Override - public boolean doCreateDefaultTestTable() { - return true; - } - - @Test - public void test01_SqlScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new ITConnectionProvider()); - verifier.verifyStatementsInFile( - "ITReadWriteAutocommitSpannerTest.sql", SqlScriptVerifier.class); - } - - @Test - public void test02_WriteMutation() throws Exception { - try (ITConnection connection = createConnection()) { - connection.write( - Mutation.newInsertBuilder("TEST").set("ID").to(9999L).set("NAME").to("FOO").build()); - assertThat(connection.getCommitTimestamp(), is(notNullValue())); - } - } - - @Test - public void test03_MultipleStatements_WithTimeouts() throws InterruptedException { - try (ITConnection connection = createConnection()) { - // do an insert that should succeed - assertThat( - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1000, 'test')")), - is(equalTo(1L))); - // check that the insert succeeded - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM TEST WHERE ID=1000"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("test"))); - assertThat(rs.next(), is(false)); - } - - // do an update that should time out - connection.setStatementTimeout(1L, TimeUnit.MILLISECONDS); - try { - connection.executeUpdate(Statement.of("UPDATE TEST SET NAME='test18' WHERE ID=1000")); - } catch (SpannerException e) { - if (e.getErrorCode() != ErrorCode.DEADLINE_EXCEEDED) { - throw e; - } - } - // remove the timeout setting - connection.clearStatementTimeout(); - - // do a delete that should succeed - connection.executeUpdate(Statement.of("DELETE FROM TEST WHERE ID=1000")); - // verify that the delete did succeed - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM TEST WHERE ID=1000"))) { - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void test04_BatchUpdate() { - try (ITConnection connection = createConnection()) { - long[] updateCounts = - connection.executeBatchUpdate( - Arrays.asList( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (10, 'Batch value 1')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (11, 'Batch value 2')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (12, 'Batch value 3')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (13, 'Batch value 4')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (14, 'Batch value 5')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (15, 'Batch value 6')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (16, 'Batch value 7')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (17, 'Batch value 8')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (18, 'Batch value 9')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (19, 'Batch value 10')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (20, 'Batch value 11')"))); - assertThat( - updateCounts, is(equalTo(new long[] {1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L}))); - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT COUNT(*) FROM TEST WHERE ID>=10 AND ID<=20"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(0), is(equalTo(11L))); - } - } - } - - @Test - public void test05_BatchUpdateWithException() { - try (ITConnection con1 = createConnection(); - ITConnection con2 = createConnection()) { - try { - con1.executeBatchUpdate( - Arrays.asList( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (21, 'Batch value 1')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (22, 'Batch value 2')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (23, 'Batch value 3')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (24, 'Batch value 4')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (25, 'Batch value 5')"), - Statement.of("INSERT INTO TEST_NOT_FOUND (ID, NAME) VALUES (26, 'Batch value 6')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (27, 'Batch value 7')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (28, 'Batch value 8')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (29, 'Batch value 9')"), - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (30, 'Batch value 10')"))); - fail("Missing batch update exception"); - } catch (SpannerBatchUpdateException e) { - assertThat(e.getUpdateCounts(), is(equalTo(new long[] {1L, 1L, 1L, 1L, 1L}))); - } - // Verify that the values cannot be read on the connection that did the insert. - try (ResultSet rs = - con1.executeQuery(Statement.of("SELECT COUNT(*) FROM TEST WHERE ID>=21 AND ID<=30"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(0), is(equalTo(0L))); - } - // Verify that the values can also not be read on another connection. - try (ResultSet rs = - con2.executeQuery(Statement.of("SELECT COUNT(*) FROM TEST WHERE ID>=21 AND ID<=30"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(0), is(equalTo(0L))); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlMusicScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlMusicScriptTest.java deleted file mode 100644 index c8a0b897767..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlMusicScriptTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.AbortedDueToConcurrentModificationException; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.AbstractSqlScriptVerifier.GenericConnection; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import java.util.ArrayList; -import java.util.List; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -/** - * Integration test that runs one long sql script using the default Singers/Albums/Songs/Concerts - * data model - */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITSqlMusicScriptTest extends ITAbstractSpannerTest { - private static final String SCRIPT_FILE = "ITSqlMusicScriptTest.sql"; - - @Test - public void test01_RunScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(); - try (GenericConnection connection = SpannerGenericConnection.of(createConnection())) { - verifier.verifyStatementsInFile(connection, SCRIPT_FILE, SqlScriptVerifier.class); - } - } - - @Test - public void test02_RunAbortedTest() { - final long SINGER_ID = 2L; - final long VENUE_ID = 68L; - final long NUMBER_OF_SINGERS = 30L; - final long NUMBER_OF_ALBUMS = 60L; - final long NUMBER_OF_SONGS = 149L; - final long NUMBER_OF_CONCERTS = 100L; - long numberOfSongs = 0L; - AbortInterceptor interceptor = new AbortInterceptor(0.0D); - try (ITConnection connection = createConnection(interceptor)) { - connection.setAutocommit(false); - connection.setRetryAbortsInternally(true); - // Read all data from the different music tables in the transaction - // The previous test deleted the first two Singers records. - long expectedId = 3L; - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM Singers ORDER BY SingerId"))) { - while (rs.next()) { - assertThat(rs.getLong("SingerId"), is(equalTo(expectedId))); - expectedId++; - } - } - assertThat(expectedId, is(equalTo(NUMBER_OF_SINGERS + 1L))); - expectedId = 3L; - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM Albums ORDER BY AlbumId"))) { - while (rs.next()) { - assertThat(rs.getLong("AlbumId"), is(equalTo(expectedId))); - expectedId++; - // 31 and 32 were deleted by the first test script. - if (expectedId == 31L || expectedId == 32L) { - expectedId = 33L; - } - } - } - assertThat(expectedId, is(equalTo(NUMBER_OF_ALBUMS + 1L))); - expectedId = 1L; - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM Songs ORDER BY TrackId"))) { - while (rs.next()) { - assertThat(rs.getLong("TrackId"), is(equalTo(expectedId))); - expectedId++; - numberOfSongs++; - // 40, 64, 76, 86 and 96 were deleted by the first test script. - if (expectedId == 40L - || expectedId == 64L - || expectedId == 76L - || expectedId == 86L - || expectedId == 96L) { - expectedId++; - } - } - } - assertThat(expectedId, is(equalTo(NUMBER_OF_SONGS + 1L))); - // Concerts are not in the table hierarchy, so no records have been deleted. - expectedId = 1L; - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT * FROM Concerts ORDER BY VenueId"))) { - while (rs.next()) { - assertThat(rs.getLong("VenueId"), is(equalTo(expectedId))); - expectedId++; - } - } - assertThat(expectedId, is(equalTo(NUMBER_OF_CONCERTS + 1L))); - - // make one small concurrent change in a different transaction - List originalPrices; - List newPrices; - try (ITConnection connection2 = createConnection()) { - assertThat(connection2.isAutocommit(), is(true)); - try (ResultSet rs = - connection2.executeQuery( - Statement.newBuilder( - "SELECT TicketPrices FROM Concerts WHERE SingerId=@singer AND VenueId=@venue") - .bind("singer") - .to(SINGER_ID) - .bind("venue") - .to(VENUE_ID) - .build())) { - assertThat(rs.next(), is(true)); - originalPrices = rs.getLongList(0); - // increase one of the prices by 1 - newPrices = new ArrayList<>(originalPrices); - newPrices.set(1, originalPrices.get(1) + 1); - connection2.executeUpdate( - Statement.newBuilder( - "UPDATE Concerts SET TicketPrices=@prices WHERE SingerId=@singer AND VenueId=@venue") - .bind("prices") - .toInt64Array(newPrices) - .bind("singer") - .to(SINGER_ID) - .bind("venue") - .to(VENUE_ID) - .build()); - } - } - - // try to add a new song and then try to commit, but trigger an abort on commit - connection.bufferedWrite( - Mutation.newInsertBuilder("Songs") - .set("SingerId") - .to(3L) - .set("AlbumId") - .to(3L) - .set("TrackId") - .to(1L) - .set("SongName") - .to("Aborted") - .set("Duration") - .to(1L) - .set("SongGenre") - .to("Unknown") - .build()); - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // the transaction retry should fail because of the concurrent modification - boolean expectedException = false; - try { - connection.commit(); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - // verify that the commit aborted, an internal retry was started and then aborted because of - // the concurrent modification - assertThat(expectedException, is(true)); - // verify that the prices were changed - try (ResultSet rs = - connection.executeQuery( - Statement.newBuilder( - "SELECT TicketPrices FROM Concerts WHERE SingerId=@singer AND VenueId=@venue") - .bind("singer") - .to(SINGER_ID) - .bind("venue") - .to(VENUE_ID) - .build())) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLongList(0), is(equalTo(newPrices))); - } - // verify that the new song was not written to the database - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) FROM Songs"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong(0), is(equalTo(numberOfSongs))); - } - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlScriptTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlScriptTest.java deleted file mode 100644 index 9f60ae6ccb0..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITSqlScriptTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier.SpannerGenericConnection; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -/** - * Integration test that creates and fills a test database entirely using only sql scripts, and then - * performs all possible operations on this test database using only sql scripts. This test uses the - * generic connection API. - */ -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ITSqlScriptTest extends ITAbstractSpannerTest { - private static final String CREATE_TABLES_FILE = "ITSqlScriptTest_CreateTables.sql"; - private static final String INSERT_AND_VERIFY_TEST_DATA = "ITSqlScriptTest_InsertTestData.sql"; - private static final String TEST_GET_READ_TIMESTAMP = "ITSqlScriptTest_TestGetReadTimestamp.sql"; - private static final String TEST_GET_COMMIT_TIMESTAMP = - "ITSqlScriptTest_TestGetCommitTimestamp.sql"; - private static final String TEST_TEMPORARY_TRANSACTIONS = - "ITSqlScriptTest_TestTemporaryTransactions.sql"; - private static final String TEST_TRANSACTION_MODE = "ITSqlScriptTest_TestTransactionMode.sql"; - private static final String TEST_TRANSACTION_MODE_READ_ONLY = - "ITSqlScriptTest_TestTransactionMode_ReadOnly.sql"; - private static final String TEST_READ_ONLY_STALENESS = - "ITSqlScriptTest_TestReadOnlyStaleness.sql"; - private static final String TEST_AUTOCOMMIT_DML_MODE = - "ITSqlScriptTest_TestAutocommitDmlMode.sql"; - private static final String TEST_AUTOCOMMIT_READ_ONLY = - "ITSqlScriptTest_TestAutocommitReadOnly.sql"; - private static final String TEST_STATEMENT_TIMEOUT = "ITSqlScriptTest_TestStatementTimeout.sql"; - private static final String TEST_SET_STATEMENTS = "ITSqlScriptTest_TestSetStatements.sql"; - private static final String TEST_INVALID_STATEMENTS = "ITSqlScriptTest_TestInvalidStatements.sql"; - - private final SqlScriptVerifier verifier = new SqlScriptVerifier(); - - @Test - public void test01_CreateTables() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), CREATE_TABLES_FILE, SqlScriptVerifier.class); - } - } - - @Test - public void test02_InsertTestData() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - INSERT_AND_VERIFY_TEST_DATA, - SqlScriptVerifier.class); - } - } - - @Test - public void test03_TestGetReadTimestamp() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_GET_READ_TIMESTAMP, - SqlScriptVerifier.class); - } - } - - @Test - public void test04_TestGetCommitTimestamp() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_GET_COMMIT_TIMESTAMP, - SqlScriptVerifier.class); - } - } - - @Test - public void test05_TestTemporaryTransactions() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_TEMPORARY_TRANSACTIONS, - SqlScriptVerifier.class); - } - } - - @Test - public void test06_TestTransactionMode() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), TEST_TRANSACTION_MODE, SqlScriptVerifier.class); - } - } - - @Test - public void test07_TestTransactionModeReadOnly() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_TRANSACTION_MODE_READ_ONLY, - SqlScriptVerifier.class); - } - } - - @Test - public void test08_TestReadOnlyStaleness() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_READ_ONLY_STALENESS, - SqlScriptVerifier.class); - } - } - - @Test - public void test09_TestAutocommitDmlMode() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_AUTOCOMMIT_DML_MODE, - SqlScriptVerifier.class); - } - } - - @Test - public void test10_TestAutocommitReadOnly() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_AUTOCOMMIT_READ_ONLY, - SqlScriptVerifier.class); - } - } - - @Test - public void test11_TestStatementTimeout() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), TEST_STATEMENT_TIMEOUT, SqlScriptVerifier.class); - } - } - - @Test - public void test12_TestSetStatements() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), TEST_SET_STATEMENTS, SqlScriptVerifier.class); - } - } - - @Test - public void test13_TestInvalidStatements() throws Exception { - try (ITConnection connection = createConnection()) { - verifier.verifyStatementsInFile( - SpannerGenericConnection.of(connection), - TEST_INVALID_STATEMENTS, - SqlScriptVerifier.class); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionModeTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionModeTest.java deleted file mode 100644 index 19c204a7525..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionModeTest.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.spanner.ErrorCode; -import com.google.cloud.spanner.IntegrationTest; -import com.google.cloud.spanner.Key; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.SpannerExceptionMatcher; -import com.google.cloud.spanner.jdbc.SqlScriptVerifier; -import java.util.Arrays; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@Category(IntegrationTest.class) -@RunWith(JUnit4.class) -public class ITTransactionModeTest extends ITAbstractSpannerTest { - @Rule public ExpectedException exception = ExpectedException.none(); - - @Override - public void appendConnectionUri(StringBuilder uri) { - uri.append("?autocommit=false"); - } - - @Override - public boolean doCreateDefaultTestTable() { - return true; - } - - @Test - public void testSqlScript() throws Exception { - SqlScriptVerifier verifier = new SqlScriptVerifier(new ITConnectionProvider()); - verifier.verifyStatementsInFile("ITTransactionModeTest.sql", SqlScriptVerifier.class); - } - - @Test - public void testDoAllowBufferedWriteInReadWriteTransaction() { - try (ITConnection connection = createConnection()) { - assertThat(connection.isAutocommit(), is(false)); - connection.bufferedWrite( - Mutation.newInsertBuilder("TEST").set("ID").to(1L).set("NAME").to("TEST").build()); - connection.commit(); - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT NAME FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST"))); - assertThat(rs.next(), is(false)); - } - connection.bufferedWrite( - Mutation.newUpdateBuilder("TEST").set("ID").to(1L).set("NAME").to("TEST2").build()); - connection.commit(); - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT NAME FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST2"))); - assertThat(rs.next(), is(false)); - } - connection.bufferedWrite(Mutation.delete("TEST", Key.of(1L))); - connection.commit(); - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT NAME FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testDoAllowBufferedWriteIterableInReadWriteTransaction() { - try (ITConnection connection = createConnection()) { - assertThat(connection.isAutocommit(), is(false)); - connection.bufferedWrite( - Arrays.asList( - Mutation.newInsertBuilder("TEST").set("ID").to(1L).set("NAME").to("TEST-1").build(), - Mutation.newInsertBuilder("TEST").set("ID").to(2L).set("NAME").to("TEST-2").build())); - connection.commit(); - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT NAME FROM TEST WHERE ID IN (1,2) ORDER BY ID"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST-1"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST-2"))); - assertThat(rs.next(), is(false)); - } - connection.bufferedWrite( - Arrays.asList( - Mutation.newUpdateBuilder("TEST").set("ID").to(1L).set("NAME").to("TEST-1-2").build(), - Mutation.newUpdateBuilder("TEST") - .set("ID") - .to(2L) - .set("NAME") - .to("TEST-2-2") - .build())); - connection.commit(); - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT NAME FROM TEST WHERE ID IN (1,2) ORDER BY ID"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST-1-2"))); - assertThat(rs.next(), is(true)); - assertThat(rs.getString("NAME"), is(equalTo("TEST-2-2"))); - assertThat(rs.next(), is(false)); - } - connection.bufferedWrite( - Arrays.asList(Mutation.delete("TEST", Key.of(1L)), Mutation.delete("TEST", Key.of(2L)))); - connection.commit(); - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT NAME FROM TEST WHERE ID IN (1,2) ORDER BY ID"))) { - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testDoNotAllowBufferedWriteInReadOnlyTransaction() { - try (ITConnection connection = createConnection()) { - connection.execute(Statement.of("SET TRANSACTION READ ONLY")); - assertThat(connection.isAutocommit(), is(false)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.bufferedWrite(Mutation.newInsertBuilder("FOO").set("ID").to(1L).build()); - } - } - - @Test - public void testDoNotAllowBufferedWriteIterableInReadOnlyTransaction() { - try (ITConnection connection = createConnection()) { - connection.execute(Statement.of("SET TRANSACTION READ ONLY")); - assertThat(connection.isAutocommit(), is(false)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.bufferedWrite( - Arrays.asList( - Mutation.newInsertBuilder("FOO").set("ID").to(1L).build(), - Mutation.newInsertBuilder("FOO").set("ID").to(2L).build())); - } - } - - @Test - public void testDoNotAllowBufferedWriteInDdlBatch() { - try (ITConnection connection = createConnection()) { - connection.startBatchDdl(); - assertThat(connection.isAutocommit(), is(false)); - assertThat(connection.isDdlBatchActive(), is(true)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.bufferedWrite(Mutation.newInsertBuilder("FOO").set("ID").to(1L).build()); - } - } - - @Test - public void testDoNotAllowBufferedWriteIterableInDdlBatch() { - try (ITConnection connection = createConnection()) { - connection.startBatchDdl(); - assertThat(connection.isAutocommit(), is(false)); - assertThat(connection.isDdlBatchActive(), is(true)); - exception.expect(SpannerExceptionMatcher.matchCode(ErrorCode.FAILED_PRECONDITION)); - connection.bufferedWrite( - Arrays.asList( - Mutation.newInsertBuilder("FOO").set("ID").to(1L).build(), - Mutation.newInsertBuilder("FOO").set("ID").to(2L).build())); - } - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionRetryTest.java b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionRetryTest.java deleted file mode 100644 index 159ca7e6c9e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/java/com/google/cloud/spanner/jdbc/it/ITTransactionRetryTest.java +++ /dev/null @@ -1,1567 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -package com.google.cloud.spanner.jdbc.it; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.AbortedDueToConcurrentModificationException; -import com.google.cloud.spanner.AbortedException; -import com.google.cloud.spanner.KeySet; -import com.google.cloud.spanner.Mutation; -import com.google.cloud.spanner.ResultSet; -import com.google.cloud.spanner.SpannerException; -import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.jdbc.ITAbstractSpannerTest; -import com.google.cloud.spanner.jdbc.TransactionRetryListener; -import java.sql.Connection; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * This integration test tests the different scenarios for automatically retrying read/write - * transactions, both when possible and when the transaction must abort because of a concurrent - * update. - */ -@RunWith(JUnit4.class) -public class ITTransactionRetryTest extends ITAbstractSpannerTest { - private static final Logger logger = Logger.getLogger(ITTransactionRetryTest.class.getName()); - - @Rule public TestName testName = new TestName(); - - @Override - protected void appendConnectionUri(StringBuilder uri) { - uri.append(";autocommit=false;retryAbortsInternally=true"); - } - - @Override - public boolean doCreateDefaultTestTable() { - return true; - } - - /** Clear the test table before each test run */ - @Before - public void clearTable() { - try (ITConnection connection = createConnection()) { - connection.bufferedWrite(Mutation.delete("TEST", KeySet.all())); - connection.commit(); - } - } - - @Before - public void clearStatistics() { - RETRY_STATISTICS.clear(); - } - - @Before - public void logStart() { - logger.fine( - "--------------------------------------------------------------\n" - + testName.getMethodName() - + " started"); - } - - @After - public void logFinished() { - logger.fine( - "--------------------------------------------------------------\n" - + testName.getMethodName() - + " finished"); - } - - /** Simple data structure to keep track of retry statistics */ - private static class RetryStatistics { - private int totalRetryAttemptsStarted; - private int totalRetryAttemptsFinished; - private int totalSuccessfulRetries; - private int totalErroredRetries; - private int totalNestedAborts; - private int totalMaxAttemptsExceeded; - private int totalConcurrentModifications; - - private void clear() { - totalRetryAttemptsStarted = 0; - totalRetryAttemptsFinished = 0; - totalSuccessfulRetries = 0; - totalErroredRetries = 0; - totalNestedAborts = 0; - totalMaxAttemptsExceeded = 0; - totalConcurrentModifications = 0; - } - } - - /** - * Static to allow access from the {@link CountTransactionRetryListener}. Statistics are - * automatically cleared before each test case. - */ - public static final RetryStatistics RETRY_STATISTICS = new RetryStatistics(); - - /** - * Simple {@link TransactionRetryListener} that keeps track of the total count of the different - * transaction retry events of a {@link Connection}. Note that as {@link - * TransactionRetryListener}s are instantiated once per connection, the listener keeps track of - * the total statistics of a connection and not only of the last transaction. - */ - public static class CountTransactionRetryListener implements TransactionRetryListener { - - @Override - public void retryStarting(Timestamp transactionStarted, long transactionId, int retryAttempt) { - RETRY_STATISTICS.totalRetryAttemptsStarted++; - } - - @Override - public void retryFinished( - Timestamp transactionStarted, long transactionId, int retryAttempt, RetryResult result) { - RETRY_STATISTICS.totalRetryAttemptsFinished++; - switch (result) { - case RETRY_ABORTED_AND_MAX_ATTEMPTS_EXCEEDED: - RETRY_STATISTICS.totalMaxAttemptsExceeded++; - break; - case RETRY_ABORTED_AND_RESTARTING: - RETRY_STATISTICS.totalNestedAborts++; - break; - case RETRY_ABORTED_DUE_TO_CONCURRENT_MODIFICATION: - RETRY_STATISTICS.totalConcurrentModifications++; - break; - case RETRY_ERROR: - RETRY_STATISTICS.totalErroredRetries++; - break; - case RETRY_SUCCESSFUL: - RETRY_STATISTICS.totalSuccessfulRetries++; - break; - default: - break; - } - } - } - - /** Test successful retry when the commit aborts */ - @Test - public void testCommitAborted() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // do an insert - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // do a commit that will first abort, and then on retry will succeed - connection.commit(); - assertThat(RETRY_STATISTICS.totalRetryAttemptsStarted >= 1, is(true)); - assertThat(RETRY_STATISTICS.totalRetryAttemptsFinished >= 1, is(true)); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - assertThat(RETRY_STATISTICS.totalErroredRetries, is(equalTo(0))); - assertThat(RETRY_STATISTICS.totalConcurrentModifications, is(equalTo(0))); - assertThat(RETRY_STATISTICS.totalMaxAttemptsExceeded, is(equalTo(0))); - // verify that the insert succeeded - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry when an insert statement aborts */ - @Test - public void testInsertAborted() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // do an insert that will abort - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - // do a commit - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that the insert succeeded - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry when an update statement aborts */ - @Test - public void testUpdateAborted() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // insert a test record - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // do an update that will abort - connection.executeUpdate(Statement.of("UPDATE TEST SET NAME='update aborted' WHERE ID=1")); - // do a commit - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that the update succeeded - try (ResultSet rs = - connection.executeQuery( - Statement.of( - "SELECT COUNT(*) AS C FROM TEST WHERE ID=1 AND NAME='update aborted'"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry when a query aborts */ - @Test - public void testQueryAborted() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // insert a test record - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - // do a query that will abort - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - // do a commit - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that the update succeeded - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry when a call to {@link ResultSet#next()} aborts */ - @Test - public void testNextCallAborted() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // do a query - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - // the first record should be accessible without any problems - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(1L))); - - // indicate that the next statement should abort - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(2L))); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // there should be only two records - assertThat(rs.next(), is(false)); - } - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that the transaction succeeded - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(2L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry after multiple aborts */ - @Test - public void testMultipleAborts() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // do three inserts which all will abort and retry - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 3, is(true)); - assertThat( - RETRY_STATISTICS.totalNestedAborts, - is(equalTo(RETRY_STATISTICS.totalSuccessfulRetries - 3))); - // verify that the insert succeeded - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(3L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** - * Tests that a transaction retry can be successful after a select, as long as the select returns - * the same results during the retry - */ - @Test - public void testAbortAfterSelect() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // verify that the there is no test record - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(0L))); - assertThat(rs.next(), is(false)); - } - // insert a test record - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - // select the test record - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(1L))); - assertThat(rs.getString("NAME"), is(equalTo("test 1"))); - assertThat(rs.next(), is(false)); - } - // do another insert that will abort and retry - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the first test record again - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(1L))); - assertThat(rs.getString("NAME"), is(equalTo("test 1"))); - assertThat(rs.next(), is(false)); - } - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - } - } - - /** - * Test a successful retry when a {@link ResultSet} has been consumed half way. The {@link - * ResultSet} should still be at the same position and still behave as if the original transaction - * did not abort. - */ - @Test - public void testAbortWithResultSetHalfway() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - // iterate one step - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(1L))); - // do another insert that will abort and retry - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - // iterate another step - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(2L))); - // ensure we are at the end of the result set - assertThat(rs.next(), is(false)); - } - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that all the inserts succeeded - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(3L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** Test successful retry after a {@link ResultSet} has been fully consumed. */ - @Test - public void testAbortWithResultSetFullyConsumed() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records and iterate over them - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing, just consume the result set - } - } - // do another insert that will abort and retry - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - // verify that all the inserts succeeded - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(3L))); - assertThat(rs.next(), is(false)); - } - } - } - - @Test - public void testAbortWithConcurrentInsert() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records and consume the entire result set - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing - } - } - // open a new connection and transaction and do an additional insert - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (4, 'test 4')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertRetryStatistics(1, 1, 0); - } - } - - @Test - public void testAbortWithConcurrentDelete() { - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // open a new connection and select the two test records - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // select the test records and consume the entire result set - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing - } - } - // open a new connection and transaction and remove one of the test records - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("DELETE FROM TEST WHERE ID=1")); - connection2.commit(); - } - // now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertRetryStatistics(1, 1, 0); - } - } - - @Test - public void testAbortWithConcurrentUpdate() { - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // open a new connection and select the two test records - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // select the test records and consume the entire result set - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing - } - } - // open a new connection and transaction and update one of the test records - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("UPDATE TEST SET NAME='test updated' WHERE ID=2")); - connection2.commit(); - } - // now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertRetryStatistics(1, 1, 0); - } - } - - /** - * Test that shows that a transaction retry is possible even when there is a concurrent insert - * that has an impact on a query that has been executed, as long as the user hasn't actually seen - * the relevant part of the result of the query - */ - @Test - public void testAbortWithUnseenConcurrentInsert() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records and consume part of the result set - ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID")); - assertThat(rs.next(), is(true)); - assertThat(rs.next(), is(true)); - // Open a new connection and transaction and do an additional insert. This insert will be - // included in a retry of the above query, but this has not yet been 'seen' by the user, - // hence is not a problem for retrying the transaction. - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // now try to do an insert that will abort. The retry should still succeed. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - int currentRetryCount = RETRY_STATISTICS.totalRetryAttemptsStarted; - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (4, 'test 4')")); - assertThat(RETRY_STATISTICS.totalRetryAttemptsStarted >= currentRetryCount + 1, is(true)); - // Consume the rest of the result set. The insert by the other transaction should now be - // included in the result set as the transaction retried. Although this means that the result - // is different after a retry, it is not different as seen by the user, as the user didn't - // know that the result set did not have any more results before the transaction retry. - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(3L))); - // record with id 4 should not be visible, as it was added to the transaction after the query - // was executed - assertThat(rs.next(), is(false)); - rs.close(); - connection.commit(); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= 1, is(true)); - } - } - - /** - * This test shows what happens when an abort occurs on a call to {@link ResultSet#next()} on a - * {@link ResultSet} that has an concurrent insert. As long as the user hasn't consumed the {@link - * ResultSet} so far that the concurrent insert has been seen, the retry will succeed. When the - * user has consumed the {@link ResultSet} to the point where the concurrent insert is visible, - * the retry will fail. - */ - @Test - public void testAbortWithUnseenConcurrentInsertAbortOnNext() { - // no calls to next(), this should succeed - assertThat(testAbortWithUnseenConcurrentInsertAbortOnNext(0) >= 1, is(true)); - // 1 call to next() should also succeed, as there were 2 records in the original result set - assertThat(testAbortWithUnseenConcurrentInsertAbortOnNext(1) >= 1, is(true)); - // 2 calls to next() should also succeed, as there were 2 records in the original result set and - // the user doesn't know yet that the next call to next() will return true instead of false - // after the concurrent insert - assertThat(testAbortWithUnseenConcurrentInsertAbortOnNext(2) >= 1, is(true)); - - boolean expectedException = false; - try { - // 3 calls to next() should fail, as the user would now see the inserted record - testAbortWithUnseenConcurrentInsertAbortOnNext(3); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - } - - private int testAbortWithUnseenConcurrentInsertAbortOnNext(int callsToNext) - throws AbortedDueToConcurrentModificationException { - int retries = 0; - clearTable(); - clearStatistics(); - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - int totalRecordsSeen = 0; - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records and consume part or all of the result set - ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID")); - for (int counter = 0; counter < callsToNext; counter++) { - if (rs.next()) { - totalRecordsSeen++; - } - } - // Open a new connection and transaction and do an additional insert. This insert will be - // included in a retry of the above query. Any transaction retry will fail/succeed depending - // on whether the user has consumed enough of the result set to potentially have seen this - // insert. - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // Now consume the rest of the result set, but trigger a transaction retry by aborting the - // first next() call. Without a retry, the result set should only contain 2 records. With a - // successful retry, the result set contains 3 results. The retry will only succeed as long - // as the user has not consumed enough of the result set to know whether there should have - // been a record with ID 3 or not. - - // First verify that the transaction has not yet retried. - int currentRetryCount = RETRY_STATISTICS.totalRetryAttemptsStarted; - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - - // Try to consume the rest of the result set. - // This will fail with an AbortedDueToConcurrentModificationException if the retry fails. - while (rs.next()) { - totalRecordsSeen++; - if (totalRecordsSeen == 3) { - assertThat(rs.getLong("ID"), is(equalTo(3L))); - } - } - // Verify that the transaction retried. - assertThat(RETRY_STATISTICS.totalSuccessfulRetries > currentRetryCount, is(true)); - rs.close(); - connection.commit(); - retries = RETRY_STATISTICS.totalSuccessfulRetries; - } - return retries; - } - - /** - * Test that shows that a transaction that has aborted is considered to be rolled back, and new - * statements will be executed in a new transaction - */ - @Test - public void testAbortWithConcurrentInsertAndContinue() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // Select the test records and consume the entire result set. - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing - } - } - // Open a new connection and transaction and do an additional insert - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // Now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (4, 'test 4')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertRetryStatistics(1, 1, 0); - // the next statement should be in a new transaction as the previous transaction rolled back - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - // there should be one record from the transaction on connection2 - assertThat(rs.next(), is(true)); - assertThat(rs.next(), is(false)); - } - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. The transaction aborts at commit - *
  2. A retry starts and succeeds - *
  3. The commit is applied again and aborts again - *
  4. The retry is started again and then succeeds - *
- */ - @Test - public void testAbortTwiceOnCommit() { - AbortInterceptor interceptor = - new AbortInterceptor(0) { - private int commitCount = 0; - - @Override - protected boolean shouldAbort(String statement, ExecutionStep step) { - if ("COMMIT".equalsIgnoreCase(statement)) { - commitCount++; - return commitCount <= 2; - } - return false; - } - }; - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - connection.commit(); - // Assert that the transaction was retried twice. - assertRetryStatistics(2, 0, 2); - // Verify that the insert succeeded. - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. The transaction aborts at commit - *
  2. A retry starts and then aborts at the insert statement - *
  3. The retry is restarted and then succeeds - *
- */ - @Test - public void testNestedAbortOnInsert() { - AbortInterceptor interceptor = - new AbortInterceptor(0) { - private int commitCount = 0; - private int insertCount = 0; - - @Override - protected boolean shouldAbort(String statement, ExecutionStep step) { - if ("COMMIT".equalsIgnoreCase(statement)) { - commitCount++; - return commitCount == 1; - } else if (statement.startsWith("INSERT INTO TEST")) { - insertCount++; - return insertCount == 2; - } - return false; - } - }; - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - connection.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test aborted')")); - connection.commit(); - // Assert that the transaction was retried (a restarted retry is counted as one successful - // retry). - assertRetryStatistics(2, 0, 1); - assertThat(RETRY_STATISTICS.totalNestedAborts > 0, is(true)); - // Verify that the insert succeeded. - try (ResultSet rs = - connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE ID=1"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(1L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. The transaction aborts at commit - *
  2. A retry starts and then aborts at a next call in a result set - *
  3. The retry is restarted and then succeeds - *
- */ - @Test - public void testNestedAbortOnNextCall() { - AbortInterceptor interceptor = - new AbortInterceptor(0) { - private int nextCallsDuringRetry = 0; - private int commitCount = 0; - - @Override - protected boolean shouldAbort(String statement, ExecutionStep step) { - if ("COMMIT".equalsIgnoreCase(statement)) { - // Note that commit always has ExecutionStep == EXECUTE_STATEMENT, as a commit can - // never - // really be retried (it is always the last statement in a transaction, and if it - // fails - // because of an aborted exception, the entire transaction is retried, and the commit - // statement is then applied again). - commitCount++; - return commitCount == 1; - } else if (statement.equals("SELECT * FROM TEST ORDER BY ID") - && step == ExecutionStep.RETRY_NEXT_ON_RESULT_SET) { - nextCallsDuringRetry++; - return nextCallsDuringRetry == 1; - } - return false; - } - }; - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // Insert two test records. - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // Select the test records. - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - // Iterate one step. This step should abort during the retry the first time. - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(1L))); - // Do another insert that will not be visible to the result set. - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - // iterate another step - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("ID"), is(equalTo(2L))); - // Ensure we are at the end of the result set. - assertThat(rs.next(), is(false)); - } - connection.commit(); - // Verify that the transaction retried. - assertRetryStatistics(2, 0, 1); - assertThat(RETRY_STATISTICS.totalNestedAborts > 0, is(true)); - // Verify that all the inserts succeeded. - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT COUNT(*) AS C FROM TEST"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(3L))); - assertThat(rs.next(), is(false)); - } - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. Transaction 1 does two inserts in table TEST - *
  2. Transaction 1 selects all records from table TEST - *
  3. Transaction 2 inserts a record into TEST - *
  4. Transaction 1 does another insert into TEST that aborts - *
  5. Transaction 1 starts a retry that aborts at the SELECT statement (i.e. before the - * concurrent modification has been seen) - *
  6. Transaction 1 restarts the retry that now aborts due to a concurrent modification - * exception - *
- */ - @Test - public void testNestedAbortWithConcurrentInsert() { - AbortInterceptor interceptor = - new AbortInterceptor(0) { - private boolean alreadyAborted = false; - - @Override - protected boolean shouldAbort(String statement, ExecutionStep step) { - // Abort during retry on the select statement. - if (!alreadyAborted - && statement.equals("SELECT * FROM TEST ORDER BY ID") - && step == ExecutionStep.RETRY_STATEMENT) { - alreadyAborted = true; - return true; - } - return super.shouldAbort(statement, step); - } - }; - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert two test records - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - // select the test records and consume the entire result set - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing - } - } - // open a new connection and transaction and do an additional insert - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // Now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (4, 'test 4')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertThat(expectedException, is(true)); - assertRetryStatistics(2, 1, 0); - assertThat(RETRY_STATISTICS.totalNestedAborts > 0, is(true)); - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit - *
  2. Transaction 1 updates the names of all records in the TEST table - *
  3. Transaction 2 inserts a record in the TEST table and commits - *
  4. Transaction 1 does another insert into TEST that aborts - *
  5. Transaction 1 starts a retry that aborts due to a concurrent modification exception as - * the number of updated records will be different - *
- */ - @Test - public void testAbortWithDifferentUpdateCount() { - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // open a new connection and update one of the records - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - connection.executeUpdate( - Statement.of("UPDATE TEST SET NAME='test update that will fail' WHERE TRUE")); - // open a new connection and transaction and update the same test record - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - connection2.commit(); - } - // Now try to do an insert that will abort. The retry should now fail as there has been a - // concurrent modification. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (4, 'test 4')")); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - assertRetryStatistics(1, 1, 0); - assertThat(expectedException, is(true)); - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit - *
  2. Try to query a non-existing table. This will lead to an exception. - *
  3. Query all the records from the TEST table and consume the result set - *
  4. Insert another record into TEST that aborts - *
  5. The transaction successfully retries - *
- */ - @Test - public void testAbortWithExceptionOnSelect() { - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // do a select that will fail - boolean expectedException = false; - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM FOO"))) { - while (rs.next()) { - // do nothing - } - } catch (SpannerException e) { - // expected - expectedException = true; - } - assertThat(expectedException, is(true)); - // do a select that will succeed - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // now try to do an insert that will abort. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - assertRetryStatistics(1, 0, 1); - } - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit. - *
  2. Try to query the non-existing table FOO. This will lead to an exception. - *
  3. Query all the records from the TEST table and consume the result set. - *
  4. Open another connection and create the table FOO. - *
  5. Insert another record into TEST that aborts. - *
  6. The transaction is internally retried. The retry fails as the SELECT statement on FOO - * will now succeed. - *
- */ - @Test - public void testAbortWithExceptionOnSelectAndConcurrentModification() { - boolean abortedDueToConcurrentModification = false; - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // do a select that will fail - boolean expectedException = false; - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM FOO"))) { - while (rs.next()) { - // do nothing - } - } catch (SpannerException e) { - // expected - expectedException = true; - } - assertThat(expectedException, is(true)); - // do a select that will succeed - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // CREATE FOO - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute( - Statement.of("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - } - // Now try to do an insert that will abort. The subsequent retry will fail as the SELECT * - // FROM FOO now returns a result. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - abortedDueToConcurrentModification = true; - } - } - // DROP FOO regardless of the result to avoid any interference with other test cases - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute(Statement.of("DROP TABLE FOO")); - } - assertThat(abortedDueToConcurrentModification, is(true)); - assertRetryStatistics(1, 1, 0); - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit. - *
  2. Try to insert a record in the non-existing table FOO. This will lead to an exception. - *
  3. Query all the records from the TEST table and consume the result set. - *
  4. Open another connection and create the table FOO. - *
  5. Insert another record into TEST that aborts. - *
  6. The transaction is internally retried. The retry fails as the insert statement on FOO - * will now succeed. - *
- */ - @Test - public void testAbortWithExceptionOnInsertAndConcurrentModification() { - boolean abortedDueToConcurrentModification = false; - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // do an insert that will fail - boolean expectedException = false; - try { - connection.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (1, 'test 1')")); - } catch (SpannerException e) { - // expected - expectedException = true; - } - assertThat(expectedException, is(true)); - // do a select that will succeed - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // CREATE FOO - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute( - Statement.of("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - } - // Now try to do an insert that will abort. The subsequent retry will fail as the INSERT INTO - // FOO now succeeds. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - abortedDueToConcurrentModification = true; - } - } - // DROP FOO regardless of the result to avoid any interference with other test cases - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute(Statement.of("DROP TABLE FOO")); - } - assertThat(abortedDueToConcurrentModification, is(true)); - assertRetryStatistics(1, 1, 0); - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit. - *
  2. Create the table FOO and insert a test record. - *
  3. Query the table FOO. - *
  4. Query all the records from the TEST table and consume the result set. - *
  5. Open another connection and drop the table FOO. - *
  6. Insert another record into TEST that aborts. - *
  7. The transaction is internally retried. The retry fails as the SELECT statement on FOO - * will now fail. - *
- */ - @Test - public void testAbortWithDroppedTableConcurrentModification() { - boolean abortedDueToConcurrentModification = false; - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // CREATE FOO - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute( - Statement.of("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - connection2.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (1, 'test 1')")); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM FOO"))) { - while (rs.next()) { - // do nothing - } - } - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // DROP FOO using a different connection - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute(Statement.of("DROP TABLE FOO")); - } - // Now try to do an insert that will abort. The subsequent retry will fail as the SELECT * - // FROM FOO now fails. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - abortedDueToConcurrentModification = true; - } - } - assertThat(abortedDueToConcurrentModification, is(true)); - assertRetryStatistics(1, 1, 0); - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit. - *
  2. Create the table FOO and insert a test record and commit. - *
  3. Insert another record into the table FOO. - *
  4. Query all the records from the TEST table and consume the result set. - *
  5. Open another connection and drop the table FOO. - *
  6. Insert another record into TEST that aborts. - *
  7. The transaction is internally retried. The retry fails as the INSERT statement on FOO - * will now fail. - *
- */ - @Test - public void testAbortWithInsertOnDroppedTableConcurrentModification() { - boolean abortedDueToConcurrentModification = false; - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // CREATE FOO - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute( - Statement.of("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - connection2.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (1, 'test 1')")); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert a record into FOO - connection.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (2, 'test 2')")); - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // DROP FOO using a different connection - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute(Statement.of("DROP TABLE FOO")); - } - // Now try to do an insert that will abort. The subsequent retry will fail as the INSERT INTO - // FOO now fails. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - try { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (3, 'test 3')")); - } catch (AbortedDueToConcurrentModificationException e) { - abortedDueToConcurrentModification = true; - } - } - assertThat(abortedDueToConcurrentModification, is(true)); - assertRetryStatistics(1, 1, 0); - } - - /** - * Test that shows the following: - * - *
    - *
  1. Insert two records into table TEST and commit. - *
  2. Create the table FOO and insert two test records and commit. - *
  3. Query all the records from the TEST table and consume the result set. - *
  4. Query all the records from the FOO table and consume only part of the result set. - *
  5. Open another connection and drop the table FOO. - *
  6. Try to consume the rest of the FOO result set. This aborts. - *
  7. The transaction is internally retried. The retry fails as the SELECT statement on FOO - * will now fail. - *
- */ - @Test - public void testAbortWithCursorHalfwayDroppedTableConcurrentModification() { - boolean abortedDueToConcurrentModification = false; - AbortInterceptor interceptor = new AbortInterceptor(0); - // first insert two test records - try (ITConnection connection = createConnection()) { - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection.executeUpdate(Statement.of("INSERT INTO TEST (ID, NAME) VALUES (2, 'test 2')")); - connection.commit(); - } - // CREATE FOO - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute( - Statement.of("CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID)")); - connection2.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (1, 'test 1')")); - connection2.executeUpdate(Statement.of("INSERT INTO FOO (ID, NAME) VALUES (2, 'test 2')")); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST"))) { - while (rs.next()) { - // do nothing - } - } - // SELECT FROM FOO and consume part of the result set - ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM FOO")); - assertThat(rs.next(), is(true)); - // DROP FOO using a different connection - try (ITConnection connection2 = createConnection()) { - connection2.setAutocommit(true); - connection2.execute(Statement.of("DROP TABLE FOO")); - } - // try to continue to consume the result set, but this will now abort. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - try { - // This will fail as the retry will not succeed. - rs.next(); - } catch (AbortedDueToConcurrentModificationException e) { - abortedDueToConcurrentModification = true; - } finally { - rs.close(); - } - } - assertThat(abortedDueToConcurrentModification, is(true)); - assertRetryStatistics(1, 1, 0); - } - - /** Test the successful retry of a transaction with a large {@link ResultSet} */ - @Test - public void testRetryLargeResultSet() { - final int NUMBER_OF_TEST_RECORDS = 100000; - final long UPDATED_RECORDS = 1000L; - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = createConnection()) { - // insert test records - for (int i = 0; i < NUMBER_OF_TEST_RECORDS; i++) { - connection.bufferedWrite( - Mutation.newInsertBuilder("TEST").set("ID").to(i).set("NAME").to("test " + i).build()); - if (i % 1000 == 0) { - connection.commit(); - } - } - connection.commit(); - } - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // select the test records and iterate over them - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing, just consume the result set - } - } - // Do an update that will abort and retry. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - connection.executeUpdate( - Statement.newBuilder("UPDATE TEST SET NAME='updated' WHERE ID<@max_id") - .bind("max_id") - .to(UPDATED_RECORDS) - .build()); - connection.commit(); - // verify that the update succeeded - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE NAME='updated'"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(UPDATED_RECORDS))); - assertThat(rs.next(), is(false)); - } - // Verify that the transaction retried. - assertRetryStatistics(1, 0, 1); - } - } - - /** Test the successful retry of a transaction with a high chance of multiple aborts */ - @Test - public void testRetryHighAbortRate() { - final int NUMBER_OF_TEST_RECORDS = 10000; - final long UPDATED_RECORDS = 1000L; - // abort on 25% of all statements - AbortInterceptor interceptor = new AbortInterceptor(0.25D); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // insert test records - for (int i = 0; i < NUMBER_OF_TEST_RECORDS; i++) { - connection.bufferedWrite( - Mutation.newInsertBuilder("TEST").set("ID").to(i).set("NAME").to("test " + i).build()); - if (i % 1000 == 0) { - connection.commit(); - } - } - connection.commit(); - // select the test records and iterate over them - // reduce the abort rate to 0.01% as each next() call could abort - interceptor.setProbability(0.0001D); - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - while (rs.next()) { - // do nothing, just consume the result set - } - } - // increase the abort rate to 50% - interceptor.setProbability(0.50D); - connection.executeUpdate( - Statement.newBuilder("UPDATE TEST SET NAME='updated' WHERE ID<@max_id") - .bind("max_id") - .to(UPDATED_RECORDS) - .build()); - connection.commit(); - // verify that the update succeeded - try (ResultSet rs = - connection.executeQuery( - Statement.of("SELECT COUNT(*) AS C FROM TEST WHERE NAME='updated'"))) { - assertThat(rs.next(), is(true)); - assertThat(rs.getLong("C"), is(equalTo(UPDATED_RECORDS))); - assertThat(rs.next(), is(false)); - } - connection.commit(); - } catch (AbortedException e) { - // This could happen if the number of aborts exceeds the max number of retries. - logger.log(Level.FINE, "testRetryHighAbortRate aborted because of too many retries", e); - } - logger.fine("Total number of retries started: " + RETRY_STATISTICS.totalRetryAttemptsStarted); - logger.fine("Total number of retries finished: " + RETRY_STATISTICS.totalRetryAttemptsFinished); - logger.fine("Total number of retries successful: " + RETRY_STATISTICS.totalSuccessfulRetries); - logger.fine("Total number of retries aborted: " + RETRY_STATISTICS.totalNestedAborts); - logger.fine( - "Total number of times the max retry count was exceeded: " - + RETRY_STATISTICS.totalMaxAttemptsExceeded); - } - - @Test - public void testAbortWithConcurrentInsertOnEmptyTable() { - AbortInterceptor interceptor = new AbortInterceptor(0); - try (ITConnection connection = - createConnection(interceptor, new CountTransactionRetryListener())) { - // select the test records but do not consume the result set - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - // Open a new connection and transaction and do an insert. This insert will be - // included in a retry of the above query, but this has not yet been 'seen' by the user, - // hence is not a problem for retrying the transaction. - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection2.commit(); - } - // Now try to consume the result set, but the call to next() will throw an AbortedException. - // The retry should still succeed. - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - int currentSuccessfulRetryCount = RETRY_STATISTICS.totalSuccessfulRetries; - assertThat(rs.next(), is(true)); - assertThat( - RETRY_STATISTICS.totalSuccessfulRetries, is(equalTo(currentSuccessfulRetryCount + 1))); - assertThat(rs.next(), is(false)); - } - connection.commit(); - - // Now do the same, but this time we will consume the empty result set. The retry should now - // fail. - clearTable(); - clearStatistics(); - try (ResultSet rs = connection.executeQuery(Statement.of("SELECT * FROM TEST ORDER BY ID"))) { - assertThat(rs.next(), is(false)); - // Open a new connection and transaction and do an insert. This insert will be - // included in a retry of the above query, and this time it will cause the retry to fail. - try (ITConnection connection2 = createConnection()) { - connection2.executeUpdate( - Statement.of("INSERT INTO TEST (ID, NAME) VALUES (1, 'test 1')")); - connection2.commit(); - } - // this time the abort will occur on the call to commit() - interceptor.setProbability(1.0); - interceptor.setOnlyInjectOnce(true); - boolean expectedException = false; - try { - connection.commit(); - } catch (AbortedDueToConcurrentModificationException e) { - expectedException = true; - } - // No successful retries. - assertRetryStatistics(1, 1, 0); - assertThat(expectedException, is(true)); - } - } - } - - private void assertRetryStatistics( - int minAttemptsStartedExpected, - int concurrentModificationsExpected, - int successfulRetriesExpected) { - assertThat(RETRY_STATISTICS.totalRetryAttemptsStarted >= minAttemptsStartedExpected, is(true)); - assertThat( - RETRY_STATISTICS.totalConcurrentModifications, - is(equalTo(concurrentModificationsExpected))); - assertThat(RETRY_STATISTICS.totalSuccessfulRetries >= successfulRetriesExpected, is(true)); - } -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.sql deleted file mode 100644 index fe8afd86e97..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ClientSideStatementsTest.sql +++ /dev/null @@ -1,11078 +0,0 @@ -NEW_CONNECTION; -show variable autocommit; -NEW_CONNECTION; -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -show variable autocommit; -NEW_CONNECTION; - show variable autocommit; -NEW_CONNECTION; - show variable autocommit; -NEW_CONNECTION; - - - -show variable autocommit; -NEW_CONNECTION; -show variable autocommit ; -NEW_CONNECTION; -show variable autocommit ; -NEW_CONNECTION; -show variable autocommit - -; -NEW_CONNECTION; -show variable autocommit; -NEW_CONNECTION; -show variable autocommit; -NEW_CONNECTION; -show -variable -autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable autocommit; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-autocommit; -NEW_CONNECTION; -show variable readonly; -NEW_CONNECTION; -SHOW VARIABLE READONLY; -NEW_CONNECTION; -show variable readonly; -NEW_CONNECTION; - show variable readonly; -NEW_CONNECTION; - show variable readonly; -NEW_CONNECTION; - - - -show variable readonly; -NEW_CONNECTION; -show variable readonly ; -NEW_CONNECTION; -show variable readonly ; -NEW_CONNECTION; -show variable readonly - -; -NEW_CONNECTION; -show variable readonly; -NEW_CONNECTION; -show variable readonly; -NEW_CONNECTION; -show -variable -readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable readonly; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable readonly/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-readonly; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -SHOW VARIABLE RETRY_ABORTS_INTERNALLY; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; - show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; - show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; - - - -show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally ; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally ; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally - -; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -show -variable -retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally bar; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally%; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally_; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally&; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally$; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally@; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally!; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally*; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally(; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally); -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally-; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally+; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally-#; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally/; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally\; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally?; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally-/; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally/#; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable retry_aborts_internally; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable retry_aborts_internally/-; -NEW_CONNECTION; -set readonly=false; -set autocommit=false; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-retry_aborts_internally; -NEW_CONNECTION; -show variable autocommit_dml_mode; -NEW_CONNECTION; -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -show variable autocommit_dml_mode; -NEW_CONNECTION; - show variable autocommit_dml_mode; -NEW_CONNECTION; - show variable autocommit_dml_mode; -NEW_CONNECTION; - - - -show variable autocommit_dml_mode; -NEW_CONNECTION; -show variable autocommit_dml_mode ; -NEW_CONNECTION; -show variable autocommit_dml_mode ; -NEW_CONNECTION; -show variable autocommit_dml_mode - -; -NEW_CONNECTION; -show variable autocommit_dml_mode; -NEW_CONNECTION; -show variable autocommit_dml_mode; -NEW_CONNECTION; -show -variable -autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable autocommit_dml_mode; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable autocommit_dml_mode/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-autocommit_dml_mode; -NEW_CONNECTION; -show variable statement_timeout; -NEW_CONNECTION; -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -show variable statement_timeout; -NEW_CONNECTION; - show variable statement_timeout; -NEW_CONNECTION; - show variable statement_timeout; -NEW_CONNECTION; - - - -show variable statement_timeout; -NEW_CONNECTION; -show variable statement_timeout ; -NEW_CONNECTION; -show variable statement_timeout ; -NEW_CONNECTION; -show variable statement_timeout - -; -NEW_CONNECTION; -show variable statement_timeout; -NEW_CONNECTION; -show variable statement_timeout; -NEW_CONNECTION; -show -variable -statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable statement_timeout; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable statement_timeout/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-statement_timeout; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; - show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; - show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; - - - -show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp ; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp ; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp - -; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -show -variable -read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp bar; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp%; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp_; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp&; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp$; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp@; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp!; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp*; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp(; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp); -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp-; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp+; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp-#; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp/; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp\; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp?; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp-/; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp/#; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable read_timestamp; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_timestamp/-; -NEW_CONNECTION; -set readonly = true; -SELECT 1 AS TEST; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-read_timestamp; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; - show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; - show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; - - - -show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp ; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp ; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp - -; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -show -variable -commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp bar; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp%; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp_; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp&; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp$; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp@; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp!; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp*; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp(; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp); -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp-; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp+; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp-#; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp/; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp\; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp?; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp-/; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp/#; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable commit_timestamp; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable commit_timestamp/-; -NEW_CONNECTION; -update foo set bar=1; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-commit_timestamp; -NEW_CONNECTION; -show variable read_only_staleness; -NEW_CONNECTION; -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -show variable read_only_staleness; -NEW_CONNECTION; - show variable read_only_staleness; -NEW_CONNECTION; - show variable read_only_staleness; -NEW_CONNECTION; - - - -show variable read_only_staleness; -NEW_CONNECTION; -show variable read_only_staleness ; -NEW_CONNECTION; -show variable read_only_staleness ; -NEW_CONNECTION; -show variable read_only_staleness - -; -NEW_CONNECTION; -show variable read_only_staleness; -NEW_CONNECTION; -show variable read_only_staleness; -NEW_CONNECTION; -show -variable -read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable%read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable_read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable&read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable$read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable@read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable!read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable*read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable(read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable)read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable+read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-#read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable\read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable?read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable-/read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/#read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-show variable read_only_staleness; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable read_only_staleness/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -show variable/-read_only_staleness; -NEW_CONNECTION; -begin; -NEW_CONNECTION; -BEGIN; -NEW_CONNECTION; -begin; -NEW_CONNECTION; - begin; -NEW_CONNECTION; - begin; -NEW_CONNECTION; - - - -begin; -NEW_CONNECTION; -begin ; -NEW_CONNECTION; -begin ; -NEW_CONNECTION; -begin - -; -NEW_CONNECTION; -begin; -NEW_CONNECTION; -begin; -NEW_CONNECTION; -begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-begin; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/-; -NEW_CONNECTION; -start; -NEW_CONNECTION; -START; -NEW_CONNECTION; -start; -NEW_CONNECTION; - start; -NEW_CONNECTION; - start; -NEW_CONNECTION; - - - -start; -NEW_CONNECTION; -start ; -NEW_CONNECTION; -start ; -NEW_CONNECTION; -start - -; -NEW_CONNECTION; -start; -NEW_CONNECTION; -start; -NEW_CONNECTION; -start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-start; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/-; -NEW_CONNECTION; -begin transaction; -NEW_CONNECTION; -BEGIN TRANSACTION; -NEW_CONNECTION; -begin transaction; -NEW_CONNECTION; - begin transaction; -NEW_CONNECTION; - begin transaction; -NEW_CONNECTION; - - - -begin transaction; -NEW_CONNECTION; -begin transaction ; -NEW_CONNECTION; -begin transaction ; -NEW_CONNECTION; -begin transaction - -; -NEW_CONNECTION; -begin transaction; -NEW_CONNECTION; -begin transaction; -NEW_CONNECTION; -begin -transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin%transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin_transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin&transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin$transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin@transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin!transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin*transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin(transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin)transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin+transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-#transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin\transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin?transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin-/transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/#transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-begin transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin transaction/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -begin/-transaction; -NEW_CONNECTION; -start transaction; -NEW_CONNECTION; -START TRANSACTION; -NEW_CONNECTION; -start transaction; -NEW_CONNECTION; - start transaction; -NEW_CONNECTION; - start transaction; -NEW_CONNECTION; - - - -start transaction; -NEW_CONNECTION; -start transaction ; -NEW_CONNECTION; -start transaction ; -NEW_CONNECTION; -start transaction - -; -NEW_CONNECTION; -start transaction; -NEW_CONNECTION; -start transaction; -NEW_CONNECTION; -start -transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start%transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start_transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start&transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start$transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start@transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start!transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start*transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start(transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start)transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start+transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-#transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start\transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start?transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start-/transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/#transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-start transaction; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start transaction/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start/-transaction; -NEW_CONNECTION; -begin transaction; -commit; -NEW_CONNECTION; -begin transaction; -COMMIT; -NEW_CONNECTION; -begin transaction; -commit; -NEW_CONNECTION; -begin transaction; - commit; -NEW_CONNECTION; -begin transaction; - commit; -NEW_CONNECTION; -begin transaction; - - - -commit; -NEW_CONNECTION; -begin transaction; -commit ; -NEW_CONNECTION; -begin transaction; -commit ; -NEW_CONNECTION; -begin transaction; -commit - -; -NEW_CONNECTION; -begin transaction; -commit; -NEW_CONNECTION; -begin transaction; -commit; -NEW_CONNECTION; -begin transaction; -commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit bar; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -%commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -_commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -&commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -$commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -@commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -!commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -*commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -(commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -)commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -+commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --#commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -\commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -?commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --/commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-commit; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/-; -NEW_CONNECTION; -begin transaction; -commit transaction; -NEW_CONNECTION; -begin transaction; -COMMIT TRANSACTION; -NEW_CONNECTION; -begin transaction; -commit transaction; -NEW_CONNECTION; -begin transaction; - commit transaction; -NEW_CONNECTION; -begin transaction; - commit transaction; -NEW_CONNECTION; -begin transaction; - - - -commit transaction; -NEW_CONNECTION; -begin transaction; -commit transaction ; -NEW_CONNECTION; -begin transaction; -commit transaction ; -NEW_CONNECTION; -begin transaction; -commit transaction - -; -NEW_CONNECTION; -begin transaction; -commit transaction; -NEW_CONNECTION; -begin transaction; -commit transaction; -NEW_CONNECTION; -begin transaction; -commit -transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction bar; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -%commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit%transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -_commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit_transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -&commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit&transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -$commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit$transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -@commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit@transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -!commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit!transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -*commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit*transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -(commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit(transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -)commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit)transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -+commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit+transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --#commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-#transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -\commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit\transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -?commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit?transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --/commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit-/transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/#transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-commit transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit transaction/-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -commit/-transaction; -NEW_CONNECTION; -begin transaction; -rollback; -NEW_CONNECTION; -begin transaction; -ROLLBACK; -NEW_CONNECTION; -begin transaction; -rollback; -NEW_CONNECTION; -begin transaction; - rollback; -NEW_CONNECTION; -begin transaction; - rollback; -NEW_CONNECTION; -begin transaction; - - - -rollback; -NEW_CONNECTION; -begin transaction; -rollback ; -NEW_CONNECTION; -begin transaction; -rollback ; -NEW_CONNECTION; -begin transaction; -rollback - -; -NEW_CONNECTION; -begin transaction; -rollback; -NEW_CONNECTION; -begin transaction; -rollback; -NEW_CONNECTION; -begin transaction; -rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback bar; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -%rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -_rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -&rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -$rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -@rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -!rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -*rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -(rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -)rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -+rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --#rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -\rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -?rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --/rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-rollback; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/-; -NEW_CONNECTION; -begin transaction; -rollback transaction; -NEW_CONNECTION; -begin transaction; -ROLLBACK TRANSACTION; -NEW_CONNECTION; -begin transaction; -rollback transaction; -NEW_CONNECTION; -begin transaction; - rollback transaction; -NEW_CONNECTION; -begin transaction; - rollback transaction; -NEW_CONNECTION; -begin transaction; - - - -rollback transaction; -NEW_CONNECTION; -begin transaction; -rollback transaction ; -NEW_CONNECTION; -begin transaction; -rollback transaction ; -NEW_CONNECTION; -begin transaction; -rollback transaction - -; -NEW_CONNECTION; -begin transaction; -rollback transaction; -NEW_CONNECTION; -begin transaction; -rollback transaction; -NEW_CONNECTION; -begin transaction; -rollback -transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction bar; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -%rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction%; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback%transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -_rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction_; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback_transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -&rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction&; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback&transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -$rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction$; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback$transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -@rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction@; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback@transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -!rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction!; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback!transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -*rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction*; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback*transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -(rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction(; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback(transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -)rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction); -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback)transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -+rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction+; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback+transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --#rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction-#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-#transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -\rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction\; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback\transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -?rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction?; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback?transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT --/rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction-/; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback-/transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction/#; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/#transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-rollback transaction; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback transaction/-; -NEW_CONNECTION; -begin transaction; -@EXPECT EXCEPTION INVALID_ARGUMENT -rollback/-transaction; -NEW_CONNECTION; -start batch ddl; -NEW_CONNECTION; -START BATCH DDL; -NEW_CONNECTION; -start batch ddl; -NEW_CONNECTION; - start batch ddl; -NEW_CONNECTION; - start batch ddl; -NEW_CONNECTION; - - - -start batch ddl; -NEW_CONNECTION; -start batch ddl ; -NEW_CONNECTION; -start batch ddl ; -NEW_CONNECTION; -start batch ddl - -; -NEW_CONNECTION; -start batch ddl; -NEW_CONNECTION; -start batch ddl; -NEW_CONNECTION; -start -batch -ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch%ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch_ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch&ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch$ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch@ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch!ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch*ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch(ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch)ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch+ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-#ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch\ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch?ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-/ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/#ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-start batch ddl; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch ddl/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/-ddl; -NEW_CONNECTION; -start batch dml; -NEW_CONNECTION; -START BATCH DML; -NEW_CONNECTION; -start batch dml; -NEW_CONNECTION; - start batch dml; -NEW_CONNECTION; - start batch dml; -NEW_CONNECTION; - - - -start batch dml; -NEW_CONNECTION; -start batch dml ; -NEW_CONNECTION; -start batch dml ; -NEW_CONNECTION; -start batch dml - -; -NEW_CONNECTION; -start batch dml; -NEW_CONNECTION; -start batch dml; -NEW_CONNECTION; -start -batch -dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch%dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch_dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch&dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch$dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch@dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch!dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch*dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch(dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch)dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch+dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-#dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch\dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch?dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch-/dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/#dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-start batch dml; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch dml/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -start batch/-dml; -NEW_CONNECTION; -start batch ddl; -run batch; -NEW_CONNECTION; -start batch ddl; -RUN BATCH; -NEW_CONNECTION; -start batch ddl; -run batch; -NEW_CONNECTION; -start batch ddl; - run batch; -NEW_CONNECTION; -start batch ddl; - run batch; -NEW_CONNECTION; -start batch ddl; - - - -run batch; -NEW_CONNECTION; -start batch ddl; -run batch ; -NEW_CONNECTION; -start batch ddl; -run batch ; -NEW_CONNECTION; -start batch ddl; -run batch - -; -NEW_CONNECTION; -start batch ddl; -run batch; -NEW_CONNECTION; -start batch ddl; -run batch; -NEW_CONNECTION; -start batch ddl; -run -batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch bar; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -%run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch%; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run%batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -_run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch_; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run_batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -&run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch&; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run&batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -$run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch$; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run$batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -@run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch@; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run@batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -!run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch!; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run!batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -*run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch*; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run*batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -(run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch(; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run(batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -)run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch); -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run)batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch-; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run-batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -+run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch+; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run+batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --#run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch-#; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run-#batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch/; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run/batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -\run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch\; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run\batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -?run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch?; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run?batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --/run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch-/; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run-/batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch/#; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run/#batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-run batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run batch/-; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -run/-batch; -NEW_CONNECTION; -start batch ddl; -abort batch; -NEW_CONNECTION; -start batch ddl; -ABORT BATCH; -NEW_CONNECTION; -start batch ddl; -abort batch; -NEW_CONNECTION; -start batch ddl; - abort batch; -NEW_CONNECTION; -start batch ddl; - abort batch; -NEW_CONNECTION; -start batch ddl; - - - -abort batch; -NEW_CONNECTION; -start batch ddl; -abort batch ; -NEW_CONNECTION; -start batch ddl; -abort batch ; -NEW_CONNECTION; -start batch ddl; -abort batch - -; -NEW_CONNECTION; -start batch ddl; -abort batch; -NEW_CONNECTION; -start batch ddl; -abort batch; -NEW_CONNECTION; -start batch ddl; -abort -batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch bar; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -%abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch%; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort%batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -_abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch_; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort_batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -&abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch&; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort&batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -$abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch$; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort$batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -@abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch@; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort@batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -!abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch!; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort!batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -*abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch*; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort*batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -(abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch(; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort(batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -)abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch); -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort)batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch-; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort-batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -+abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch+; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort+batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --#abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch-#; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort-#batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch/; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort/batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -\abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch\; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort\batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -?abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch?; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort?batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT --/abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch-/; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort-/batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch/#; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort/#batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-abort batch; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort batch/-; -NEW_CONNECTION; -start batch ddl; -@EXPECT EXCEPTION INVALID_ARGUMENT -abort/-batch; -NEW_CONNECTION; -set autocommit = true; -NEW_CONNECTION; -SET AUTOCOMMIT = TRUE; -NEW_CONNECTION; -set autocommit = true; -NEW_CONNECTION; - set autocommit = true; -NEW_CONNECTION; - set autocommit = true; -NEW_CONNECTION; - - - -set autocommit = true; -NEW_CONNECTION; -set autocommit = true ; -NEW_CONNECTION; -set autocommit = true ; -NEW_CONNECTION; -set autocommit = true - -; -NEW_CONNECTION; -set autocommit = true; -NEW_CONNECTION; -set autocommit = true; -NEW_CONNECTION; -set -autocommit -= -true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =%true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =_true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =&true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =$true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =@true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =!true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =*true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =(true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =)true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =+true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-#true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =\true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =?true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-/true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/#true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set autocommit = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = true/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/-true; -NEW_CONNECTION; -set autocommit = false; -NEW_CONNECTION; -SET AUTOCOMMIT = FALSE; -NEW_CONNECTION; -set autocommit = false; -NEW_CONNECTION; - set autocommit = false; -NEW_CONNECTION; - set autocommit = false; -NEW_CONNECTION; - - - -set autocommit = false; -NEW_CONNECTION; -set autocommit = false ; -NEW_CONNECTION; -set autocommit = false ; -NEW_CONNECTION; -set autocommit = false - -; -NEW_CONNECTION; -set autocommit = false; -NEW_CONNECTION; -set autocommit = false; -NEW_CONNECTION; -set -autocommit -= -false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =%false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =_false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =&false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =$false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =@false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =!false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =*false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =(false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =)false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =+false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-#false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =\false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =?false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =-/false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/#false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set autocommit = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit = false/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit =/-false; -NEW_CONNECTION; -set readonly = true; -NEW_CONNECTION; -SET READONLY = TRUE; -NEW_CONNECTION; -set readonly = true; -NEW_CONNECTION; - set readonly = true; -NEW_CONNECTION; - set readonly = true; -NEW_CONNECTION; - - - -set readonly = true; -NEW_CONNECTION; -set readonly = true ; -NEW_CONNECTION; -set readonly = true ; -NEW_CONNECTION; -set readonly = true - -; -NEW_CONNECTION; -set readonly = true; -NEW_CONNECTION; -set readonly = true; -NEW_CONNECTION; -set -readonly -= -true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =%true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =_true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =&true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =$true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =@true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =!true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =*true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =(true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =)true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =+true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-#true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =\true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =?true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-/true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/#true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set readonly = true; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = true/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/-true; -NEW_CONNECTION; -set readonly = false; -NEW_CONNECTION; -SET READONLY = FALSE; -NEW_CONNECTION; -set readonly = false; -NEW_CONNECTION; - set readonly = false; -NEW_CONNECTION; - set readonly = false; -NEW_CONNECTION; - - - -set readonly = false; -NEW_CONNECTION; -set readonly = false ; -NEW_CONNECTION; -set readonly = false ; -NEW_CONNECTION; -set readonly = false - -; -NEW_CONNECTION; -set readonly = false; -NEW_CONNECTION; -set readonly = false; -NEW_CONNECTION; -set -readonly -= -false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =%false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =_false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =&false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =$false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =@false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =!false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =*false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =(false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =)false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =+false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-#false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =\false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =?false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =-/false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/#false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set readonly = false; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly = false/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set readonly =/-false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -SET RETRY_ABORTS_INTERNALLY = TRUE; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - - - -set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true ; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true ; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true - -; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set -retry_aborts_internally -= -true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true bar; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true%; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =%true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true_; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =_true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true&; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =&true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true$; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =$true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true@; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =@true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true!; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =!true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true*; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =*true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true(; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =(true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true); -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =)true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true-; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true+; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =+true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true-#; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-#true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true/; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true\; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =\true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true?; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =?true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true-/; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-/true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true/#; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/#true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set retry_aborts_internally = true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = true/-; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/-true; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -SET RETRY_ABORTS_INTERNALLY = FALSE; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; - - - -set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false ; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false ; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false - -; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -set -retry_aborts_internally -= -false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false bar; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false%; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =%false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false_; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =_false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false&; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =&false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false$; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =$false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false@; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =@false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false!; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =!false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false*; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =*false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false(; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =(false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false); -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =)false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false-; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false+; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =+false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false-#; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-#false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false/; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false\; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =\false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false?; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =?false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false-/; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =-/false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false/#; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/#false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set retry_aborts_internally = false; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally = false/-; -NEW_CONNECTION; -set readonly = false; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set retry_aborts_internally =/-false; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -set autocommit_dml_mode='partitioned_non_atomic'; -NEW_CONNECTION; - set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; - set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; - - - -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC' ; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC' ; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC' - -; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -set -autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -NEW_CONNECTION; -set autocommit_dml_mode='transactional'; -NEW_CONNECTION; - set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; - set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; - - - -set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL' ; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL' ; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL' - -; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -set -autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set autocommit_dml_mode='TRANSACTIONAL'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-autocommit_dml_mode='TRANSACTIONAL'; -NEW_CONNECTION; -set statement_timeout=null; -NEW_CONNECTION; -SET STATEMENT_TIMEOUT=NULL; -NEW_CONNECTION; -set statement_timeout=null; -NEW_CONNECTION; - set statement_timeout=null; -NEW_CONNECTION; - set statement_timeout=null; -NEW_CONNECTION; - - - -set statement_timeout=null; -NEW_CONNECTION; -set statement_timeout=null ; -NEW_CONNECTION; -set statement_timeout=null ; -NEW_CONNECTION; -set statement_timeout=null - -; -NEW_CONNECTION; -set statement_timeout=null; -NEW_CONNECTION; -set statement_timeout=null; -NEW_CONNECTION; -set -statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set statement_timeout=null; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout=null/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-statement_timeout=null; -NEW_CONNECTION; -set statement_timeout='1s'; -NEW_CONNECTION; -SET STATEMENT_TIMEOUT='1S'; -NEW_CONNECTION; -set statement_timeout='1s'; -NEW_CONNECTION; - set statement_timeout='1s'; -NEW_CONNECTION; - set statement_timeout='1s'; -NEW_CONNECTION; - - - -set statement_timeout='1s'; -NEW_CONNECTION; -set statement_timeout='1s' ; -NEW_CONNECTION; -set statement_timeout='1s' ; -NEW_CONNECTION; -set statement_timeout='1s' - -; -NEW_CONNECTION; -set statement_timeout='1s'; -NEW_CONNECTION; -set statement_timeout='1s'; -NEW_CONNECTION; -set -statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set statement_timeout='1s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='1s'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-statement_timeout='1s'; -NEW_CONNECTION; -set statement_timeout='100ms'; -NEW_CONNECTION; -SET STATEMENT_TIMEOUT='100MS'; -NEW_CONNECTION; -set statement_timeout='100ms'; -NEW_CONNECTION; - set statement_timeout='100ms'; -NEW_CONNECTION; - set statement_timeout='100ms'; -NEW_CONNECTION; - - - -set statement_timeout='100ms'; -NEW_CONNECTION; -set statement_timeout='100ms' ; -NEW_CONNECTION; -set statement_timeout='100ms' ; -NEW_CONNECTION; -set statement_timeout='100ms' - -; -NEW_CONNECTION; -set statement_timeout='100ms'; -NEW_CONNECTION; -set statement_timeout='100ms'; -NEW_CONNECTION; -set -statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set statement_timeout='100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='100ms'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-statement_timeout='100ms'; -NEW_CONNECTION; -set statement_timeout='10000us'; -NEW_CONNECTION; -SET STATEMENT_TIMEOUT='10000US'; -NEW_CONNECTION; -set statement_timeout='10000us'; -NEW_CONNECTION; - set statement_timeout='10000us'; -NEW_CONNECTION; - set statement_timeout='10000us'; -NEW_CONNECTION; - - - -set statement_timeout='10000us'; -NEW_CONNECTION; -set statement_timeout='10000us' ; -NEW_CONNECTION; -set statement_timeout='10000us' ; -NEW_CONNECTION; -set statement_timeout='10000us' - -; -NEW_CONNECTION; -set statement_timeout='10000us'; -NEW_CONNECTION; -set statement_timeout='10000us'; -NEW_CONNECTION; -set -statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set statement_timeout='10000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='10000us'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-statement_timeout='10000us'; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -SET STATEMENT_TIMEOUT='9223372036854775807NS'; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; - set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; - set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; - - - -set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns' ; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns' ; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns' - -; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -set -statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set statement_timeout='9223372036854775807ns'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-statement_timeout='9223372036854775807ns'; -NEW_CONNECTION; -set autocommit = false; -set transaction read only; -NEW_CONNECTION; -set autocommit = false; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -set autocommit = false; -set transaction read only; -NEW_CONNECTION; -set autocommit = false; - set transaction read only; -NEW_CONNECTION; -set autocommit = false; - set transaction read only; -NEW_CONNECTION; -set autocommit = false; - - - -set transaction read only; -NEW_CONNECTION; -set autocommit = false; -set transaction read only ; -NEW_CONNECTION; -set autocommit = false; -set transaction read only ; -NEW_CONNECTION; -set autocommit = false; -set transaction read only - -; -NEW_CONNECTION; -set autocommit = false; -set transaction read only; -NEW_CONNECTION; -set autocommit = false; -set transaction read only; -NEW_CONNECTION; -set autocommit = false; -set -transaction -read -only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only bar; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only%; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read%only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only_; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read_only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only&; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read&only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only$; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read$only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only@; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read@only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only!; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read!only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only*; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read*only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only(; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read(only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only); -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read)only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only-; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only+; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read+only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only-#; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-#only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only/; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only\; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read\only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only?; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read?only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only-/; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-/only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only/#; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/#only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set transaction read only; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read only/-; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/-only; -NEW_CONNECTION; -set autocommit = false; -set transaction read write; -NEW_CONNECTION; -set autocommit = false; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -set autocommit = false; -set transaction read write; -NEW_CONNECTION; -set autocommit = false; - set transaction read write; -NEW_CONNECTION; -set autocommit = false; - set transaction read write; -NEW_CONNECTION; -set autocommit = false; - - - -set transaction read write; -NEW_CONNECTION; -set autocommit = false; -set transaction read write ; -NEW_CONNECTION; -set autocommit = false; -set transaction read write ; -NEW_CONNECTION; -set autocommit = false; -set transaction read write - -; -NEW_CONNECTION; -set autocommit = false; -set transaction read write; -NEW_CONNECTION; -set autocommit = false; -set transaction read write; -NEW_CONNECTION; -set autocommit = false; -set -transaction -read -write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write bar; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write%; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read%write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write_; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read_write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write&; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read&write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write$; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read$write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write@; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read@write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write!; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read!write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write*; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read*write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write(; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read(write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write); -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read)write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write-; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write+; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read+write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write-#; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-#write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write/; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write\; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read\write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write?; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read?write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write-/; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read-/write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write/#; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/#write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set transaction read write; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read write/-; -NEW_CONNECTION; -set autocommit = false; -@EXPECT EXCEPTION INVALID_ARGUMENT -set transaction read/-write; -NEW_CONNECTION; -set read_only_staleness='STRONG'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -set read_only_staleness='strong'; -NEW_CONNECTION; - set read_only_staleness='STRONG'; -NEW_CONNECTION; - set read_only_staleness='STRONG'; -NEW_CONNECTION; - - - -set read_only_staleness='STRONG'; -NEW_CONNECTION; -set read_only_staleness='STRONG' ; -NEW_CONNECTION; -set read_only_staleness='STRONG' ; -NEW_CONNECTION; -set read_only_staleness='STRONG' - -; -NEW_CONNECTION; -set read_only_staleness='STRONG'; -NEW_CONNECTION; -set read_only_staleness='STRONG'; -NEW_CONNECTION; -set -read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set%read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set_read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set&read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set$read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set@read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set!read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set*read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set(read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set)read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set+read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-#read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set\read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set?read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set-/read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/#read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='STRONG'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='STRONG'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set/-read_only_staleness='STRONG'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -set read_only_staleness='min_read_timestamp 2018-01-02t03:04:05.123-08:00'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; - - - -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00' - -; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -set -read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP%2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP_2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP&2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP$2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP@2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP!2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP*2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP(2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP)2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP+2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-#2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP\2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP?2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-/2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/#2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123-08:00'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/-2018-01-02T03:04:05.123-08:00'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -set read_only_staleness='min_read_timestamp 2018-01-02t03:04:05.123z'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; - - - -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z' - -; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -set -read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP%2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP_2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP&2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP$2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP@2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP!2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP*2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP(2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP)2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP+2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-#2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP\2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP?2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-/2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/#2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123Z'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/-2018-01-02T03:04:05.123Z'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -set read_only_staleness='min_read_timestamp 2018-01-02t03:04:05.123+07:45'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; - set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; - - - -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45' ; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45' - -; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -set -read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP%2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP_2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP&2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP$2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP@2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP!2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP*2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP(2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP)2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP+2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-#2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP\2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP?2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP-/2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/#2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP 2018-01-02T03:04:05.123+07:45'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MIN_READ_TIMESTAMP/-2018-01-02T03:04:05.123+07:45'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -set read_only_staleness='read_timestamp 2018-01-02t03:04:05.54321-07:00'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; - - - -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00' - -; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -set -read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP%2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP_2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP&2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP$2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP@2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP!2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP*2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP(2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP)2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP+2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-#2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP\2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP?2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-/2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/#2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321-07:00'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/-2018-01-02T03:04:05.54321-07:00'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -set read_only_staleness='read_timestamp 2018-01-02t03:04:05.54321z'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; - - - -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z' - -; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -set -read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP%2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP_2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP&2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP$2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP@2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP!2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP*2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP(2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP)2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP+2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-#2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP\2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP?2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-/2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/#2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321Z'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/-2018-01-02T03:04:05.54321Z'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -set read_only_staleness='read_timestamp 2018-01-02t03:04:05.54321+05:30'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; - set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; - - - -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30' ; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30' - -; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -set -read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP%2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP_2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP&2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP$2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP@2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP!2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP*2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP(2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP)2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP+2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-#2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP\2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP?2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP-/2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/#2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP 2018-01-02T03:04:05.54321+05:30'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='READ_TIMESTAMP/-2018-01-02T03:04:05.54321+05:30'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MAX_STALENESS 12S'; -NEW_CONNECTION; -set read_only_staleness='max_staleness 12s'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; - - - -set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s' - -; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -set -read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS%12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS_12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS&12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS$12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS@12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS!12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS*12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS(12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS)12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS+12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-#12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS\12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS?12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-/12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/#12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MAX_STALENESS 12s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 12s'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/-12s'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MAX_STALENESS 100MS'; -NEW_CONNECTION; -set read_only_staleness='max_staleness 100ms'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; - - - -set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms' - -; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -set -read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS%100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS_100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS&100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS$100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS@100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS!100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS*100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS(100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS)100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS+100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-#100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS\100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS?100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-/100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/#100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MAX_STALENESS 100ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 100ms'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/-100ms'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MAX_STALENESS 99999US'; -NEW_CONNECTION; -set read_only_staleness='max_staleness 99999us'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; - - - -set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us' - -; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -set -read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS%99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS_99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS&99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS$99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS@99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS!99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS*99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS(99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS)99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS+99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-#99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS\99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS?99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-/99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/#99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MAX_STALENESS 99999us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 99999us'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/-99999us'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='MAX_STALENESS 10NS'; -NEW_CONNECTION; -set read_only_staleness='max_staleness 10ns'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; - set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; - - - -set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns' ; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns' - -; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -set -read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS%10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS_10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS&10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS$10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS@10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS!10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS*10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS(10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS)10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS+10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-#10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS\10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS?10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS-/10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/#10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='MAX_STALENESS 10ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS 10ns'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='MAX_STALENESS/-10ns'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 15S'; -NEW_CONNECTION; -set read_only_staleness='exact_staleness 15s'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; - - - -set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s' - -; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -set -read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS%15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS_15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS&15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS$15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS@15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS!15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS*15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS(15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS)15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS+15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-#15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS\15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS?15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-/15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/#15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='EXACT_STALENESS 15s'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15s'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/-15s'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1500MS'; -NEW_CONNECTION; -set read_only_staleness='exact_staleness 1500ms'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; - - - -set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms' - -; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -set -read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS%1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS_1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS&1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS$1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS@1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS!1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS*1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS(1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS)1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS+1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-#1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS\1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS?1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-/1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/#1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='EXACT_STALENESS 1500ms'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 1500ms'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/-1500ms'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 15000000US'; -NEW_CONNECTION; -set read_only_staleness='exact_staleness 15000000us'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; - - - -set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us' - -; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -set -read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS%15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS_15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS&15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS$15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS@15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS!15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS*15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS(15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS)15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS+15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-#15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS\15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS?15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-/15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/#15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='EXACT_STALENESS 15000000us'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 15000000us'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/-15000000us'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 9999NS'; -NEW_CONNECTION; -set read_only_staleness='exact_staleness 9999ns'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; - set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; - - - -set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns' ; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns' - -; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -set -read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -foo set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns' bar; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -%set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'%; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS%9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -_set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'_; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS_9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -&set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'&; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS&9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -$set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'$; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS$9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -@set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'@; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS@9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -!set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'!; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS!9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -*set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'*; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS*9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -(set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'(; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS(9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -)set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'); -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS)9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -+set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'+; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS+9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --#set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'-#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-#9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -\set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'\; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS\9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -?set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'?; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS?9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT --/set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'-/; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS-/9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/#set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'/#; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/#9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -/-set read_only_staleness='EXACT_STALENESS 9999ns'; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS 9999ns'/-; -NEW_CONNECTION; -@EXPECT EXCEPTION INVALID_ARGUMENT -set read_only_staleness='EXACT_STALENESS/-9999ns'; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/CommentsTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/CommentsTest.sql deleted file mode 100644 index 916a35d9ef1..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/CommentsTest.sql +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -@EXPECT 'SELECT 1'; -SELECT 1; --- This is a single line comment -SELECT 1; -# This is a single line comment -SELECT 1; -/* This is a multi line comment on one line */ -SELECT 1; -/* This - is - a - multiline - comment -*/ -SELECT 1; -/* This - * is - * a - * multiline - * comment - */ -SELECT 1; -/** This is a javadoc style comment on one line*/ -SELECT 1; -/** This - is - a - javadoc - style - comment - on - multiple - lines -*/ -SELECT 1; -/** This - * is - * a - * javadoc - * style - * comment - * on - * multiple - * lines - */ -SELECT 1; - -@EXPECT 'SELECT -1'; --- First comment -SELECT-- second comment -1; -# First comment -SELECT# second comment -1; --- First comment -SELECT-- second comment -1--third comment -; -# First comment -SELECT# second comment -1#Third comment -; -/* First comment */ -SELECT/* second comment */ -1; -/* First comment */ -SELECT/* second comment */ -1/* Third comment */ -; - - -@EXPECT 'SELECT -1'; --- First comment -SELECT -- second comment -1 ; -# First comment -SELECT # second comment -1 ; --- First comment -SELECT -- second comment -1 --third comment -; -# First comment -SELECT # second comment -1 #Third comment -; -/* First comment */ -SELECT /* second comment */ -1 ; -/* First comment */ -SELECT /* second comment */ -1 /* Third comment */ -; - -@EXPECT 'SELECT "TEST -- This is not a comment"'; -SELECT "TEST -- This is not a comment"; --- This is a comment -SELECT "TEST -- This is not a comment"; --- This is a comment -SELECT "TEST -- This is not a comment" -- This is a comment; - -@EXPECT 'SELECT "TEST # This is not a comment"'; -SELECT "TEST # This is not a comment"; -# This is a comment -SELECT "TEST # This is not a comment"; -# This is a comment -SELECT "TEST # This is not a comment" # This is a comment; - -@EXPECT 'SELECT "TEST /* This is not a comment */"'; -SELECT "TEST /* This is not a comment */"; -/* This is a comment */ -SELECT "TEST /* This is not a comment */"; -/* This is a comment */ -SELECT "TEST /* This is not a comment */" /* This is a comment */; - -@EXPECT 'SELECT 'TEST -- This is not a comment''; -SELECT 'TEST -- This is not a comment'; --- This is a comment -SELECT 'TEST -- This is not a comment'; --- This is a comment -SELECT 'TEST -- This is not a comment' -- This is a comment; - -@EXPECT 'SELECT 'TEST # This is not a comment''; -SELECT 'TEST # This is not a comment'; -# This is a comment -SELECT 'TEST # This is not a comment'; -# This is a comment -SELECT 'TEST # This is not a comment' # This is a comment; - -@EXPECT 'SELECT 'TEST /* This is not a comment */''; -SELECT 'TEST /* This is not a comment */'; -/* This is a comment */ -SELECT 'TEST /* This is not a comment */'; -/* This is a comment */ -SELECT 'TEST /* This is not a comment */' /* This is a comment */; - -@EXPECT 'SELECT '''TEST --- This is not a comment -''''; -SELECT '''TEST --- This is not a comment -'''; --- This is a comment -SELECT '''TEST --- This is not a comment -'''; --- This is a comment -SELECT '''TEST --- This is not a comment -''' -- This is a comment; - -@EXPECT 'SELECT '''TEST -# This is not a comment -''''; -SELECT '''TEST -# This is not a comment -'''; -# This is a comment -SELECT '''TEST -# This is not a comment -'''; -# This is a comment -SELECT '''TEST -# This is not a comment -''' # This is a comment; - -@EXPECT 'SELECT '''TEST -/* This is not a comment */ -''''; -SELECT '''TEST -/* This is not a comment */ -'''; -/* This is a comment */ -SELECT '''TEST -/* This is not a comment */ -'''; -/* This is a comment */ -SELECT '''TEST -/* This is not a comment */ -''' /* This is a comment */; - - -@EXPECT 'SELECT """TEST --- This is not a comment -"""'; -SELECT """TEST --- This is not a comment -"""; --- This is a comment -SELECT """TEST --- This is not a comment -"""; --- This is a comment -SELECT """TEST --- This is not a comment -""" -- This is a comment; - -@EXPECT 'SELECT """TEST -# This is not a comment -"""'; -SELECT """TEST -# This is not a comment -"""; -# This is a comment -SELECT """TEST -# This is not a comment -"""; -# This is a comment -SELECT """TEST -# This is not a comment -""" # This is a comment; - -@EXPECT 'SELECT """TEST -/* This is not a comment */ -"""'; -SELECT """TEST -/* This is not a comment */ -"""; -/* This is a comment */ -SELECT """TEST -/* This is not a comment */ -"""; -/* This is a comment */ -SELECT """TEST -/* This is not a comment */ -""" /* This is a comment */; - - - -@EXPECT 'SELECT ```TEST --- This is not a comment -```'; -SELECT ```TEST --- This is not a comment -```; --- This is a comment -SELECT ```TEST --- This is not a comment -```; --- This is a comment -SELECT ```TEST --- This is not a comment -``` -- This is a comment; - -@EXPECT 'SELECT ```TEST -# This is not a comment -```'; -SELECT ```TEST -# This is not a comment -```; -# This is a comment -SELECT ```TEST -# This is not a comment -```; -# This is a comment -SELECT ```TEST -# This is not a comment -``` # This is a comment; - -@EXPECT 'SELECT ```TEST -/* This is not a comment */ -```'; -SELECT ```TEST -/* This is not a comment */ -```; -/* This is a comment */ -SELECT ```TEST -/* This is not a comment */ -```; -/* This is a comment */ -SELECT ```TEST -/* This is not a comment */ -``` /* This is a comment */; - - -@EXPECT 'SELECT 1'; -/* This is a comment /* this is still a comment */ -SELECT 1; -/** This is a javadoc style comment /* this is still a comment */ -SELECT 1; -/** This is a javadoc style comment /** this is still a comment */ -SELECT 1; -/** This is a javadoc style comment /** this is still a comment **/ -SELECT 1; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.sql deleted file mode 100644 index c7650856164..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ConnectionImplGeneratedSqlScriptTest.sql +++ /dev/null @@ -1,11201 +0,0 @@ -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:54.904000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:54.904000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:54.904000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:54.986000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:54.986000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:54.986000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:54.986000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.049000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.049000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.049000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.049000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.100000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.100000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.100000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.100000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.147000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.147000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.147000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.147000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.196000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.196000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.196000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.196000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.237000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.237000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.237000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.284000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.284000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.284000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.377000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.377000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.377000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.377000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.430000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.430000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.430000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.430000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.491000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.491000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.491000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.491000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.524000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.524000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.594000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.594000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.594000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.594000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.650000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.650000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.650000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.650000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.687000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.687000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.687000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-07-31T10:46:55.687000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.716000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.716000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.716000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.754000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.754000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.754000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.806000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.806000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.806000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.836000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.836000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.836000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.874000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.874000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.874000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.915000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.915000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.970000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.970000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:55.995000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:55.995000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:55.995000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.013000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.013000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.013000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.029000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.029000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.066000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.066000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.066000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.104000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.104000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT UPDATE_COUNT 1 -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DDL; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -START BATCH DML; -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.132000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.132000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.132000000Z'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=FALSE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.157000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.157000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.157000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.175000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.175000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.175000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.203000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.203000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.203000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.262000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.262000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READONLY=TRUE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='STRONG'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.291000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.291000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.311000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.311000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.311000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.334000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.334000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.334000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -ABORT BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',FALSE -SHOW VARIABLE AUTOCOMMIT; -SET AUTOCOMMIT=TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT',TRUE -SHOW VARIABLE AUTOCOMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET TRANSACTION READ ONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET TRANSACTION READ WRITE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DDL; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -START BATCH DML; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -ROLLBACK; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READONLY=FALSE; -@EXPECT RESULT_SET 'READONLY',FALSE -SHOW VARIABLE READONLY; -SET READONLY=TRUE; -@EXPECT RESULT_SET 'READONLY',TRUE -SHOW VARIABLE READONLY; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2019-07-31T10:46:56.355000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-07-31T10:46:56.355000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2019-07-31T10:46:56.355000000Z'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='EXACT_STALENESS 100us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 100us' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS' -SHOW VARIABLE READ_ONLY_STALENESS; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -COMMIT; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; -BEGIN TRANSACTION; -SELECT 1 AS TEST; -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE foo SET bar=1; -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -@EXPECT EXCEPTION FAILED_PRECONDITION -BEGIN TRANSACTION; -NEW_CONNECTION; -SET READONLY=TRUE; -SET AUTOCOMMIT=FALSE; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITDdlTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITDdlTest.sql deleted file mode 100644 index 2dea0423151..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITDdlTest.sql +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -NEW_CONNECTION; --- Create table in autocommit mode - -@EXPECT RESULT_SET 'AUTOCOMMIT',true -SHOW VARIABLE AUTOCOMMIT; -@EXPECT RESULT_SET 'READONLY',false -SHOW VARIABLE READONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_DDL_AUTOCOMMIT'; - -CREATE TABLE VALID_DDL_AUTOCOMMIT (ID INT64 NOT NULL, BAR STRING(100)) PRIMARY KEY (ID); - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_DDL_AUTOCOMMIT'; - - -NEW_CONNECTION; --- Try to create a table with an invalid SQL statement - -@EXPECT RESULT_SET 'AUTOCOMMIT',true -SHOW VARIABLE AUTOCOMMIT; -@EXPECT RESULT_SET 'READONLY',false -SHOW VARIABLE READONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='INVALID_DDL_AUTOCOMMIT'; - -@EXPECT EXCEPTION INVALID_ARGUMENT -CREATE TABLE INVALID_DDL_AUTOCOMMIT (ID INT64 NOT NULL, BAZ STRING(100), MISSING_DATA_TYPE_COL) PRIMARY KEY (ID); - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='INVALID_DDL_AUTOCOMMIT'; - - -NEW_CONNECTION; --- Try to create a new table in a DDL_BATCH - --- Check that the table is not present -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_SINGLE_DDL_IN_DDL_BATCH'; - --- Change to DDL batch mode -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - --- Execute the create table statement, but do not commit yet -CREATE TABLE VALID_SINGLE_DDL_IN_DDL_BATCH (ID INT64 NOT NULL, BAR STRING(100)) PRIMARY KEY (ID); - -NEW_CONNECTION; --- Transaction has not been committed, so the table should not be present --- We do this in a new transaction, as selects are not allowed in a DDL_BATCH -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_SINGLE_DDL_IN_DDL_BATCH'; - --- Change to DDL batch mode again -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - --- Execute the create table statement and do a commit -CREATE TABLE VALID_SINGLE_DDL_IN_DDL_BATCH (ID INT64 NOT NULL, BAR STRING(100)) PRIMARY KEY (ID); -RUN BATCH; - --- Go back to AUTOCOMMIT mode and check that the table was created -SET AUTOCOMMIT = TRUE; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_SINGLE_DDL_IN_DDL_BATCH'; - - -NEW_CONNECTION; --- Create two tables in one batch - --- First ensure that the tables do not exist -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_MULTIPLE_DDL_IN_DDL_BATCH_1' OR TABLE_NAME='VALID_MULTIPLE_DDL_IN_DDL_BATCH_2'; - --- Change to DDL batch mode -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - --- Create two tables -CREATE TABLE VALID_MULTIPLE_DDL_IN_DDL_BATCH_1 (ID INT64 NOT NULL, BAR STRING(100)) PRIMARY KEY (ID); -CREATE TABLE VALID_MULTIPLE_DDL_IN_DDL_BATCH_2 (ID INT64 NOT NULL, BAR STRING(100)) PRIMARY KEY (ID); --- Run the batch -RUN BATCH; - --- Switch to autocommit and verify that both tables exist -SET AUTOCOMMIT = TRUE; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='VALID_MULTIPLE_DDL_IN_DDL_BATCH_1' OR TABLE_NAME='VALID_MULTIPLE_DDL_IN_DDL_BATCH_2'; - - -NEW_CONNECTION; -/* - * Do a test that shows that a DDL batch might only execute some of the statements, - * for example if data in a table prevents a unique index from being created. - */ -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - -CREATE TABLE TEST1 (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); -CREATE TABLE TEST2 (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); -RUN BATCH; - -SET AUTOCOMMIT = TRUE; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='TEST1' OR TABLE_NAME='TEST2'; - --- Fill the second table with some data that will prevent us from creating a unique index on --- the name column. -INSERT INTO TEST2 (ID, NAME) VALUES (1, 'TEST'); -INSERT INTO TEST2 (ID, NAME) VALUES (2, 'TEST'); - --- Ensure the indices that we are to create do not exist -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE (TABLE_NAME='TEST1' AND INDEX_NAME='IDX_TEST1') - OR (TABLE_NAME='TEST2' AND INDEX_NAME='IDX_TEST2'); - --- Try to create two unique indices in one batch -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - -CREATE UNIQUE INDEX IDX_TEST1 ON TEST1 (NAME); -CREATE UNIQUE INDEX IDX_TEST2 ON TEST2 (NAME); - -@EXPECT EXCEPTION FAILED_PRECONDITION -RUN BATCH; - -SET AUTOCOMMIT = TRUE; - --- Ensure that IDX_TEST1 was created and IDX_TEST2 was not. -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE TABLE_NAME='TEST1' AND INDEX_NAME='IDX_TEST1'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE TABLE_NAME='TEST2' AND INDEX_NAME='IDX_TEST2'; - -NEW_CONNECTION; -/* Verify that empty DDL batches are accepted. */ -START BATCH DDL; -RUN BATCH; - -START BATCH DDL; -ABORT BATCH; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest.sql deleted file mode 100644 index 8f8f6694481..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest.sql +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -NEW_CONNECTION; - --- Test a couple of count queries to ensure the presence of the data -@EXPECT RESULT_SET 'READONLY',true -SHOW VARIABLE READONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - --- Assert that there is a read timestamp -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -NEW_CONNECTION; --- Test two selects in one temporary transaction -@EXPECT RESULT_SET 'READONLY',true -SHOW VARIABLE READONLY; - -BEGIN; - -@EXPECT RESULT_SET 'NUMBER',1 -SELECT NUMBER -FROM NUMBERS -WHERE NUMBER=1; - -@PUT 'READ_TIMESTAMP1' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET 'PRIME_NUMBER',13 -SELECT PRIME_NUMBER -FROM PRIME_NUMBERS -WHERE PRIME_NUMBER=13; - -@PUT 'READ_TIMESTAMP2' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT EQUAL 'READ_TIMESTAMP1','READ_TIMESTAMP2'; - -COMMIT; - -NEW_CONNECTION; - -/* - * ------------------------------------------------------------------------------------------------ - * | Test different read only staleness values in autocommit mode | - * ------------------------------------------------------------------------------------------------ - */ - ---TimestampBound.ofReadTimestamp(Timestamp.now()), - -@PUT 'CURRENT_TIMESTAMP' -SELECT CURRENT_TIMESTAMP(); - -SET READ_ONLY_STALENESS = 'READ_TIMESTAMP %%CURRENT_TIMESTAMP%%'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@PUT 'READ_TIMESTAMP1' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@PUT 'READ_TIMESTAMP2' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT EQUAL 'READ_TIMESTAMP1','READ_TIMESTAMP2'; -@EXPECT EQUAL 'READ_TIMESTAMP1','CURRENT_TIMESTAMP'; - -NEW_CONNECTION; ---TimestampBound.ofMinReadTimestamp(Timestamp.now()), - -@PUT 'CURRENT_TIMESTAMP' -SELECT CURRENT_TIMESTAMP(); - -SET READ_ONLY_STALENESS = 'MIN_READ_TIMESTAMP %%CURRENT_TIMESTAMP%%'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; ---TimestampBound.ofExactStaleness(100, TimeUnit.MILLISECONDS), - -SET READ_ONLY_STALENESS = 'EXACT_STALENESS 100ms'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; ---TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS) - -SET READ_ONLY_STALENESS = 'MAX_STALENESS 10s'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; ---TimestampBound.strong() - -SET READ_ONLY_STALENESS = 'STRONG'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; -/* - * ------------------------------------------------------------------------------------------------ - * | Test the same read only staleness values in transactional mode | - * ------------------------------------------------------------------------------------------------ - */ - ---TimestampBound.ofReadTimestamp(Timestamp.now()), - -@PUT 'CURRENT_TIMESTAMP' -SELECT CURRENT_TIMESTAMP(); - -SET AUTOCOMMIT = FALSE; - -SET READ_ONLY_STALENESS = 'READ_TIMESTAMP %%CURRENT_TIMESTAMP%%'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@PUT 'READ_TIMESTAMP1' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@PUT 'READ_TIMESTAMP2' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT EQUAL 'READ_TIMESTAMP1','READ_TIMESTAMP2'; -@EXPECT EQUAL 'READ_TIMESTAMP1','CURRENT_TIMESTAMP'; - -COMMIT; - -NEW_CONNECTION; ---TimestampBound.ofMinReadTimestamp(Timestamp.now()), - -@PUT 'CURRENT_TIMESTAMP' -SELECT CURRENT_TIMESTAMP(); - -SET AUTOCOMMIT = FALSE; - -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS = 'MIN_READ_TIMESTAMP %%CURRENT_TIMESTAMP%%'; - - -NEW_CONNECTION; ---TimestampBound.ofExactStaleness(100, TimeUnit.MILLISECONDS), -SET AUTOCOMMIT = FALSE; - -SET READ_ONLY_STALENESS = 'EXACT_STALENESS 100ms'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@PUT 'READ_TIMESTAMP1' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@PUT 'READ_TIMESTAMP2' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT EQUAL 'READ_TIMESTAMP1','READ_TIMESTAMP2'; - -COMMIT; - - -NEW_CONNECTION; ---TimestampBound.ofMaxStaleness(10, TimeUnit.SECONDS) -SET AUTOCOMMIT = FALSE; - -@EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS = 'MAX_STALENESS 10s'; - - -NEW_CONNECTION; ---TimestampBound.strong() -SET AUTOCOMMIT = FALSE; - -SET READ_ONLY_STALENESS = 'STRONG'; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1000 AS EXPECTED FROM NUMBERS; - -@PUT 'READ_TIMESTAMP1' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 168 AS EXPECTED FROM PRIME_NUMBERS; - -@PUT 'READ_TIMESTAMP2' -SHOW VARIABLE READ_TIMESTAMP; - -@EXPECT EQUAL 'READ_TIMESTAMP1','READ_TIMESTAMP2'; - -COMMIT; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest_CreateTables.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest_CreateTables.sql deleted file mode 100644 index 5ba95f80d45..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadOnlySpannerTest_CreateTables.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -NEW_CONNECTION; - -SET READONLY = FALSE; -START BATCH DDL; - -CREATE TABLE NUMBERS (NUMBER INT64 NOT NULL, NAME STRING(200) NOT NULL) PRIMARY KEY (NUMBER); -CREATE TABLE PRIME_NUMBERS (PRIME_NUMBER INT64 NOT NULL, BINARY_REPRESENTATION STRING(MAX) NOT NULL) PRIMARY KEY (PRIME_NUMBER); -RUN BATCH; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadWriteAutocommitSpannerTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadWriteAutocommitSpannerTest.sql deleted file mode 100644 index 1a5a5cb8d4d..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITReadWriteAutocommitSpannerTest.sql +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -NEW_CONNECTION; - -@EXPECT RESULT_SET 'TEST',1 -SELECT 1 AS TEST; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; -INSERT INTO TEST (ID, NAME) VALUES (1, 'test'); - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - - -NEW_CONNECTION; - -@EXPECT RESULT_SET 'ID',1 -SELECT * -FROM TEST; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - - -NEW_CONNECTION; -@EXPECT UPDATE_COUNT 1 -INSERT INTO TEST (ID, NAME) VALUES (2, 'FOO'); - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED FROM TEST; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Do an update in partioned_non_atomic mode -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; - -@EXPECT UPDATE_COUNT 1 -UPDATE TEST SET NAME = 'partitioned' WHERE ID=2; - --- Reset dml mode to transactional -SET AUTOCOMMIT_DML_MODE='TRANSACTIONAL'; - -@EXPECT RESULT_SET 'NAME','partitioned' -SELECT NAME FROM TEST WHERE ID=2; - --- Set a statement timeout that should never be reached -SET STATEMENT_TIMEOUT = '10000s'; - -@EXPECT RESULT_SET 'NAME','partitioned' -SELECT NAME FROM TEST WHERE ID=2; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Set a statement timeout that should always be exceeded -SET STATEMENT_TIMEOUT = '1ns'; - -@EXPECT EXCEPTION DEADLINE_EXCEEDED -SELECT NAME FROM TEST WHERE ID=2; - --- Turn off statement timeouts -SET STATEMENT_TIMEOUT = null; --- There should be no read timestamp available -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - --- Set a statement timeout that should never be reached -SET STATEMENT_TIMEOUT = '10000s'; - -@EXPECT UPDATE_COUNT 1 -INSERT INTO TEST (ID, NAME) VALUES (3, 'test'); - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Set a statement timeout that should always be exceeded -SET STATEMENT_TIMEOUT = '1ns'; --- And then try to do an insert -@EXPECT EXCEPTION DEADLINE_EXCEEDED -INSERT INTO TEST (ID, NAME) VALUES (4, 'test'); - --- Turn off statement timeouts -SET STATEMENT_TIMEOUT = null; --- Delete record with id 4 if it exists (even though the statement timed out, --- there is still a small chance that the statement did succeed) -DELETE FROM TEST WHERE ID=4; - --- Verify that a timeout means there's no commit timestamp -SET STATEMENT_TIMEOUT = '1ns'; - -@EXPECT EXCEPTION DEADLINE_EXCEEDED -INSERT INTO TEST (ID, NAME) VALUES (4, 'test'); - -SET STATEMENT_TIMEOUT = null; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - - -NEW_CONNECTION; --- Execute a number of statements on one connection -DELETE FROM TEST WHERE ID=4; - -@EXPECT UPDATE_COUNT 1 -INSERT INTO TEST (ID, NAME) VALUES (4, 'test'); - -@EXPECT RESULT_SET 'NAME','test' -SELECT * FROM TEST WHERE ID=4; - -@EXPECT UPDATE_COUNT 1 -UPDATE TEST SET NAME='test18' WHERE ID=4; - -@EXPECT RESULT_SET 'NAME','test18' -SELECT * FROM TEST WHERE ID=4; - -@EXPECT UPDATE_COUNT 1 -DELETE FROM TEST WHERE ID=4; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM TEST -WHERE ID=4; - - -NEW_CONNECTION; --- Test primary key violation - -@EXPECT UPDATE_COUNT 1 -INSERT INTO TEST (ID, NAME) VALUES (4, 'test'); - -@EXPECT EXCEPTION ALREADY_EXISTS -INSERT INTO TEST (ID, NAME) VALUES (4, 'should not be there'); - ---Check that the second insert failed -@EXPECT RESULT_SET 'NAME','test' -SELECT * FROM TEST WHERE ID=4; - - -NEW_CONNECTION; --- Test multiple timeouts after each other on the same connection -SET STATEMENT_TIMEOUT = '1ns'; - -@EXPECT EXCEPTION DEADLINE_EXCEEDED -SELECT NAME FROM TEST WHERE ID=2; - -@EXPECT EXCEPTION DEADLINE_EXCEEDED -SELECT NAME FROM TEST WHERE ID=2; - -@EXPECT EXCEPTION DEADLINE_EXCEEDED -SELECT NAME FROM TEST WHERE ID=2; - - -NEW_CONNECTION; --- Execute a DML batch. -START BATCH DML; -@EXPECT UPDATE_COUNT -1 -INSERT INTO TEST (ID, NAME) VALUES (10, 'Batched insert 1'); -@EXPECT UPDATE_COUNT -1 -INSERT INTO TEST (ID, NAME) VALUES (11, 'Batched insert 2'); -@EXPECT UPDATE_COUNT -1 -INSERT INTO TEST (ID, NAME) VALUES (12, 'Batched insert 3'); -@EXPECT RESULT_SET 'UPDATE_COUNTS',[1,1,1] -RUN BATCH; - --- Verify that the records were inserted. -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 3 AS EXPECTED -FROM TEST -WHERE ID IN (10,11,12); - - --- Execute a DML batch with an error. -START BATCH DML; -@EXPECT UPDATE_COUNT -1 -DELETE FROM TEST WHERE ID IN (10,11,12); -@EXPECT UPDATE_COUNT -1 -DELETE FROM TEST_NOT_FOUND WHERE ID IN (10,11,12); --- Returns an error because of the second statement. -@EXPECT EXCEPTION INVALID_ARGUMENT -RUN BATCH; - --- Verify that the records were not deleted. -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 3 AS EXPECTED -FROM TEST -WHERE ID IN (10,11,12); - -START BATCH DML; -@EXPECT UPDATE_COUNT -1 -DELETE FROM TEST WHERE ID=10; -DELETE FROM TEST WHERE ID=11; -DELETE FROM TEST WHERE ID=12; -@EXPECT RESULT_SET 'UPDATE_COUNTS',[1,1,1] -RUN BATCH; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlMusicScriptTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlMusicScriptTest.sql deleted file mode 100644 index 93218da9765..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlMusicScriptTest.sql +++ /dev/null @@ -1,670 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/** - * SQL script that uses the standard Singers/Albums/Songs/Concerts data model for testing the Connection API. - */ - -SET AUTOCOMMIT = FALSE; -START BATCH DDL; - -CREATE TABLE Singers ( - SingerId INT64 NOT NULL, - FirstName STRING(1024), - LastName STRING(1024), - SingerInfo BYTES(MAX), - BirthDate DATE -) PRIMARY KEY(SingerId); - -CREATE INDEX SingersByFirstLastName ON Singers(FirstName, LastName); - -CREATE TABLE Albums ( - SingerId INT64 NOT NULL, - AlbumId INT64 NOT NULL, - AlbumTitle STRING(MAX), - MarketingBudget INT64 -) PRIMARY KEY(SingerId, AlbumId), - INTERLEAVE IN PARENT Singers ON DELETE CASCADE; - -CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle); - -CREATE INDEX AlbumsByAlbumTitle2 ON Albums(AlbumTitle) STORING (MarketingBudget); - -CREATE TABLE Songs ( - SingerId INT64 NOT NULL, - AlbumId INT64 NOT NULL, - TrackId INT64 NOT NULL, - SongName STRING(MAX), - Duration INT64, - SongGenre STRING(25) -) PRIMARY KEY(SingerId, AlbumId, TrackId), - INTERLEAVE IN PARENT Albums ON DELETE CASCADE; - -CREATE INDEX SongsBySingerAlbumSongNameDesc ON Songs(SingerId, AlbumId, SongName DESC), INTERLEAVE IN Albums; - -CREATE INDEX SongsBySongName ON Songs(SongName); - -CREATE TABLE Concerts ( - VenueId INT64 NOT NULL, - SingerId INT64 NOT NULL, - ConcertDate DATE NOT NULL, - BeginTime TIMESTAMP, - EndTime TIMESTAMP, - TicketPrices ARRAY -) PRIMARY KEY(VenueId, SingerId, ConcertDate); - -RUN BATCH; - --- Check that all tables and indices were created -SET AUTOCOMMIT = TRUE; - -@EXPECT RESULT_SET -SELECT TABLE_NAME AS ACTUAL, 'Singers' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Singers'; - -@EXPECT RESULT_SET -SELECT TABLE_NAME AS ACTUAL, 'Albums' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Albums'; - -@EXPECT RESULT_SET -SELECT TABLE_NAME AS ACTUAL, 'Songs' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Songs'; - -@EXPECT RESULT_SET -SELECT TABLE_NAME AS ACTUAL, 'Concerts' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Concerts'; - -@EXPECT RESULT_SET -SELECT INDEX_NAME AS ACTUAL, 'SingersByFirstLastName' AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE INDEX_NAME='SingersByFirstLastName' AND TABLE_NAME='Singers'; - -@EXPECT RESULT_SET -SELECT INDEX_NAME AS ACTUAL, 'AlbumsByAlbumTitle' AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE INDEX_NAME='AlbumsByAlbumTitle' AND TABLE_NAME='Albums'; - -@EXPECT RESULT_SET -SELECT INDEX_NAME AS ACTUAL, 'AlbumsByAlbumTitle2' AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE INDEX_NAME='AlbumsByAlbumTitle2' AND TABLE_NAME='Albums'; - -@EXPECT RESULT_SET -SELECT INDEX_NAME AS ACTUAL, 'SongsBySingerAlbumSongNameDesc' AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE INDEX_NAME='SongsBySingerAlbumSongNameDesc' AND TABLE_NAME='Songs'; - -@EXPECT RESULT_SET -SELECT INDEX_NAME AS ACTUAL, 'SongsBySongName' AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE INDEX_NAME='SongsBySongName' AND TABLE_NAME='Songs'; - -@EXPECT RESULT_SET -SELECT PARENT_TABLE_NAME AS ACTUAL, 'Singers' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Albums'; - -@EXPECT RESULT_SET -SELECT PARENT_TABLE_NAME AS ACTUAL, 'Albums' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Songs'; - --- Insert test data -SET AUTOCOMMIT = FALSE; -SET TRANSACTION READ WRITE; - -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (1,'First 1','Last 1',FROM_BASE64('TIX0lfKhZyUjI+F5VXYQ9O/SXgQh4kT4Ktnp7BYPnTmAps2DA2YuulryUp9UD21JxGY1oq+UYQ/HYeN5eZ6aY31ualSCN417oWJH2yeZweByeGpxJ3XQ3tVnjbz2AYfaZ8IAap0v5EbUN/ATQT3H6NBb3qM+RzVK/VszGOxs0i8+aT6rXH3hsfXbgL36zXChrSxDNT4TjxhAjPA1YiDPqw=='),DATE '1906-04-28'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (2,'First 2','Last 2',FROM_BASE64('RtIHMSnQrvv1/aZEhBtP/JBfDe1dLjgRqGOQ/5qr3uYhdId6wthztQel0bD4Ucypl6L6/Lc56rz9PfvwKmvlBuMGr87zBvi1q3O/O74/4MTOl6Nic/3ltzxA7GEIgyKAcbKYdApPdMGMOG2Vx4p8nbPaPwMBr6hcp68A5xG/FLTreNVv2IVZx7NMSw3lqe3AV2uYdKWJp4zFB+qshsCmkA=='),DATE '1922-11-17'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (3,'First 3','Last 3',FROM_BASE64('VF6u7dM6mIY0RebnEh6E0jYajqZcfGH9b9HeotdCvUzpbOo7wJfqPMLZP3QVYnG416BFPct7Bl90EsbNE8FA/4EwUk8SU65N86PZGRoUUXEeTvaojCjVeqTByM0GQ+nROb73Kd0cW/TURRGv3ihLCMQdWIH8iGgCtjN3G+7vBavsinnnToCdSPlJxweyYKTdo+JwdqL3kVFk2O1QymuaHA=='),DATE '1935-11-08'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (4,'First 4','Last 4',FROM_BASE64('8YrvnC8FyWLGLTcv7D/fUKLxX+UqYiz6U0WOJHWyneRCDIFKsLSue3lhtbW+MnsrveL0WFmHHXRTdQ91EWzhvqdIJf4JIyk/Ndmq6mouM0n36EUeTAPQU7Wg4bxsrzggyD5FNvvuimLLpKuQBDZY1os7Xw/bksWUJ7XzZwy90pfDrgtGb4DdWZ1EJ6x71C2IMuzCnzhoV7/E15tXjiOfkg=='),DATE '1945-03-23'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (5,'First 5','Last 5',FROM_BASE64('BOItWwCAuhUAwZxfmh3F3KK6+Ne+KqShIZA/uCHi72wJOY0V3/Y/f5M8XhE+MLwz0VvLANU3Y6sHonGw8d09YkAZEo034Z2Q+YEEfFCwIhUIM+VTfwOkuRYgeU1SXBXjcZc5zsicakqYA82O3cd1RsFW+mmAO/bBcbSqraxuBR/5DYnbKrL9b5q9xqL+kQRMm2ZwoWpQP24Xke3lRlQlYg=='),DATE '1953-06-03'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (6,'First 6','Last 6',FROM_BASE64('Tz+o/44KGH34c7DzY4R/H7v0Uk4HyLV4yzjZ9VApDkhwiNKi33JspiLxfG43UvDpk0nLfRSbwu9h7p69H5NPNs9FyGaLxmqmKlP4/vohRJffbyLPEcGl3uSFRg7tnWcrlyegS03MotT9wXQNfjiAFwDh70jsxd7LnowepMMjk+qt+R8MaZkyZyL/AuE300N5P2D5i7shkS4F3IudQihtIA=='),DATE '1956-02-07'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (7,'First 7','Last 7',FROM_BASE64('r1QqmO+/0+e/J616waBJQVciDvuaLuRahdtZaCC5Tq95VxwIXfZE0Hisj0SER3+3A53DZw0qClcMOdPVTufwrKhAwggyqbtQ54UR2Q/dwAA1rHzikSS9JCyY3ksTQgUYmvcvtlfnNo/RA222yDyJMQ9sBcpJAs5cAbac0X4v8DgWicueJtQe2ohZMh4r7L9LydHW+B8DpqAa2yZWEzHoPw=='),DATE '1969-05-26'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (8,'First 8','Last 8',FROM_BASE64('IEcPp2dPGDIGotq157CMyokgh2eh5buNTqUu6JQfmbpb4vOuNFzFNrljhnFIxqj+PWAhkjjNhcYTHCmwAM5USSjrpyObo6P8KHe1ctENtgzVZ6Ym3OiKydVLsQGltVOFSpT4l/sM2aGc3AiAPkjAncCZudrMy57MtDcIUCwz1I8giEzB2ZOhlSaR2v8Vs+62+KiZOWGFnoVnen4lWywHEw=='),DATE '1978-11-08'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (9,'First 9','Last 9',FROM_BASE64('uNTiTW4e9PZuRNhywFSLAkMtLpkS/+g3J3FWuiI7kAjyWHzIJMX/KswTyyiUKasn1lcdrIieGN1wiyyXU0+o9kbCuCeT4RfrC+tSqh4rm5pbY+JaR65DtbzfGw3TrWkwoHhfxU/ftnZ14v6H3xAMVM22P3rphR833b1jc1lz3R/mdcTN0dEYhzrgCCtpoOygZZpmN8yOUR3AG0oErN1pyw=='),DATE '1987-07-04'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (10,'First 10','Last 10',FROM_BASE64('ZLpjMKSfhG9zjm/ACvA5TwB/djEWviypBYklKeuTwodVKUYciGavmgm2QkwlslDP0D0PutUorM3trZHt2vqSkKdpzoQxPa5fBtuUa+FQ3xtCZ8RoDJoZ1TEy3rGX6oUQh4vsrflFxhzuUKevKPMmf/ZQFvslytPN0vtHbHtPA9i4iaw0R6RuWyoc8QBLcHHyopul63KzweLlTBacSeC7oQ=='),DATE '1993-07-06'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (11,'First 11','Last 11',FROM_BASE64('OwMBMDWFt7Rni8cbwjWDeZ4BWluiA91JHDyh41zm2Vm36DuwwaLblF1kX2oGwJkICx2191DyfnFsJ7xejiPylZg170+iSwOeNkjj7s45JyihJVnCgEN2u5/D/7DFi0lmdqIGQzIJZ7VrhC/qEU8+4kx8uPfoQx8XndgOQJYibzw2YZM6LIMHhmJmd1nDvvda7Etdo5s9rYlGN6lvvBGifA=='),DATE '1895-09-15'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (12,'First 12','Last 12',FROM_BASE64('DNE+9WHnlmdsOLBBtVwEBotQmrHLw3JbKU6CzAGmV6yEtut+dmZU0OyDMK1jMY+vFH1fK0CSUJ4oM9jBkrI2lIhbL4UyxZghP3z6aWyywpOor/llA4xYoNdaT75xcQJUFYkrR1omHA5BqFG72qx+bjv2qV2izdttQYqq72+TYDLYCPLzhB6iP21zodySDD3HS0qc2/FeJHtm4Xe/HdOzlw=='),DATE '1922-01-03'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (13,'First 13','Last 13',FROM_BASE64('ltUFKoMUjmWlo0Vxwq4pd2kONfIX7mnNnmC2UmfF+M6w9X0U41iMVSVkVZBh4jpUNHx3AhZEJH4x7DnGgcuc8JaFbqRCT8GawwmFvrrJV8lBT3fPCV/QRDrP8Mx4DePxnBEcABfwPJlHMOF59WJX67eUyx1o5EnJx+KS8DTEPEh0yKWDreErIvMPft5T5JlHgGqOMrSNX3eKiEPI3sWjpw=='),DATE '1930-08-03'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (14,'First 14','Last 14',FROM_BASE64('SuJFYQf146OJUJCoOUOcN41X8M84E1lHVn/S0mHjrq7J8HPsUmfjAUNrwZ5RVJJ81vsm8I3xQkLtlQRC7lWkS5eCFSSo56B/NwtgtMugg+r7PSjoIC2HbIM0p89PA8QPW7jRMSx7fmSIm+PJBxavr5xJvv38IQboX/G4lK8wtMy0eNySrya0OE5fCKGKvke2fP9V5QpzhC0WnG9lhs/aRg=='),DATE '1940-05-12'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (15,'First 15','Last 15',FROM_BASE64('bUSUVJWZAEqNlHvePw03zNjtv6Bt45YXSnkduopD1wfJK8enFd9/9FwcWpEom6F8k7skYlTFMgsJCoxVXYXEbb9ZXYi0NoevQ3xG9uWT5NvFCKw++IeUwVztUjYIIHkH4zsYI3csH9Su3yHEqddKyg216ccUTgB0NZcosgKs1eTg1NC5BIzqCXa5Z+X38t/QismLAflh1gTbD2F7ihSDIA=='),DATE '1946-09-23'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (16,'First 16','Last 16',FROM_BASE64('lan0QanIaA/igo2HGkKzB82cKPgAZod4JMN/sV7kQSsMLqzMijItMQFKR1H6eYJosWKm2ajiYByBG8nxP5og5B3aut/Y2n58U86jgoHxoQR4LHOmhCnzjsBLfwZ4wE8BN8iznkWuMihQbZvsAQituLo3zygYKzSZ0V0O+nJBf4OesrS9UW1fwC312k1iB39ELDnZFTuWfca+8nqiv5kolg=='),DATE '1947-09-30'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (17,'First 17','Last 17',FROM_BASE64('NCks7+4E3+XdpeWrBg/0zz2t3KzNGh1hE3uZaXcQewMjBmiujYEP4teH6Sb2awoR55zII2eJHC6hyTcrCVLrTktBm8wqSkve+yxTvY1IIJt5eULLCerZeyl8dRDXpkpIJ3itPvXlsQUToBNhxW2gQqmz+segWsJwbtQSnnGZ+Frn8JiFSz51FCRcYP/eBlogljT9vxxuWkKrL8koRz3+ew=='),DATE '1948-02-04'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (18,'First 18','Last 18',FROM_BASE64('KZyY3e9J6d5G4uuBYa4mLVWaZv8SowusNx4KHrYx5VWF3xLsy/ZuOqRczNDeAitOyXC4lh2t1M8hclCsyxHIW2cUOR9xQnnqWtYA3WrYcFycqJn4hM+ghEAX5OXRVWEQ5lr9op7cSJio2JMawTcR5z3MrNucj0VTBtLTQKxHcW7VeuPARHCBkDCOicr0gQr/pODAUs5ipqv807ZhCV0n7Q=='),DATE '1962-11-10'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (19,'First 19','Last 19',FROM_BASE64('RymWYvEhWXx4AhUQaGoruxL/XgVUnz2vjMqa8yQtFEd8awR7Vzknzl1hpl/kKdCaKSzI9TV6RoD0HZu0U3UTazIh5WjMZYKwDT0ewsh4i5S1EIRzGohMg7l0vUVRtCzWVO5uALxm1mKYp3SczU0ETmQ0t+o1ke13Bz8I1/hyIsj6PnCIvxdOBZVycfKZ64dVxwwB9vYjVoRv5jnEw4K9Kg=='),DATE '1988-10-07'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (20,'First 20','Last 20',FROM_BASE64('+OgGCnKsVaMSILWEr/0wqkPajWcdSx79nDEOqmtCtQiIP7zqZETVKOjgfVYZg3pBzQQHQ9IExYlCvqX+//GxLhegBzKFfpJ6hp6NpKiJ2p6odLfeYVkvP7GdggU5sII5da3ApMebuQDkbYS1fWk8pXdqDIpkWbFG/PTGq+p1IdHRV0tkAEe9NFW2h5y8aO6Oy+zJprq0IX5CYln6zek/gQ=='),DATE '2000-02-29'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (21,'First 21','Last 21',FROM_BASE64('0BPlFBGYZ1w3Snpf3o6PswLXQeFgEE2ehluMDXYeqPjOO+dXN6s3CrS3JUVhejj5kARAoT510bRM4eAY7x5zRBtGQisDkeaeh0d1h/o+NESSX8MPZikMmeltT864xjxwnTd/5/m1oZTSVjVLVewzi6b1MuHcghcHrdgYMy/0f3ivz1DJMH6T4tIIFxg/y8Ueb0qKcFGvnvJlTWuNnMEpdA=='),DATE '1886-08-09'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (22,'First 22','Last 22',FROM_BASE64('K6GpZCoGGMJdF/55vnvqKCfpNyVrSJGMIpvDA8nxlwQFLBqemxUgCFrtAAZx7ERd0ndYXFJOpsRS8+You2lPcaXh/jfGWoZSy/AHLS7vpML7vRzrxKlyuocjaaDEm/wb351dEU3tT8VSOEhFkYk1VvhiFS47Hm5au5E2XXUpuQwHE/6f+FlkoD64wgmdyaOQWaJgJ0Nhg6UHWA0+MJ6AEA=='),DATE '1889-04-03'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (23,'First 23','Last 23',FROM_BASE64('etCS2Mi+5SgbO7VHnr1V+3PHp2ExR+NW0mF5mUhUxitXK4CtS1tbcUzvoSYoVEMhRlT0d1O2qlIyOPayxIB2GfEfhkJpajyPSjyBSEmh8frdKLx9qICQ+Ztwv8jK9JBOJC3VQxooS49ovUff/0W6akc0s9bNevQx8v8d3daklRCKFWYQCSIFcoYZv5+78zwZ8KZHErTXQl2ZW9/zH06Uew=='),DATE '1892-01-21'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (24,'First 24','Last 24',FROM_BASE64('RUq40F7M3XWGARLYX8ZW04hf4L+zW2wkKXf5zH4rqBxG2sacUMpZcK65mmQgj51C8XFcny+4E+ZuGfGVXIi3rsF700SnZVeFdKx1s2WMZJRKvJjbXKyHoaWytT9oUHIGqJw4qXpGh/CKUb9frNWCK5FiUk6iNsE3yMsEMVe+WnG5x+AeGXtWYwW5FtF0TnqUTnXw1lf3QzSdXg+DAvIZQA=='),DATE '1898-02-21'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (25,'First 25','Last 25',FROM_BASE64('HzmgCTWib9uD7oO0qPps+AvNx1o5b38RVsvRGXAMG9uxijG62pDK6gMVwCMt0PvUJNxEpcs0uKmPqx8eF66+V++VKjpKI8CerlxrEi7oOq344tAwRYK941HqXgBN9nQB1X33cwIufEwqq5nU85HGlGFm6O8EEGQb6+n5hXItCuMJAZWXkYiK1UW7H3zLDW4xJp+ijA35TfcHusirUaH8WQ=='),DATE '1911-12-15'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (26,'First 26','Last 26',FROM_BASE64('/j6wAEIFHAARYGDM5RDQYihb8QSfQGvZA7O2wDL2Tag1iY+twDM6DcFtvKt3PFmaFKYlB1mNkc129CWAW7PSHIIKDIVTDeI4PSHWy6DwCrYBDfn/ARmP7tRFqtM/RzFQKVQS3BvKPTAv3dNTjIWto9C0FFv7TyguTv0aPVkboxzQpJnR2FfjNG05/Uy2J67w+ngspZiUvj3aRQI/s/k8qQ=='),DATE '1912-07-01'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (27,'First 27','Last 27',FROM_BASE64('OTmvVaLjJI/8/xL6/W2dYhmAnhnB8SlzdnU1VxV/Z/FAmYp+4rALgjjq6KrQNpZ7oF2Iw+MF6bWbdQO2I3uqiH9nwCGflrq1Tjf8YkqwfZvYJ/RAorsd9WHHK74+5XpGYB3hgcPjeZ5vZg6cBeHnJbAlxEKTiBpnGvOoQqBm5bQQ1sLKsLanvBcMEsGyT98BlEZIHYeubPOELbLmhR/SWQ=='),DATE '1939-05-17'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (28,'First 28','Last 28',FROM_BASE64('OVlneKkb0DxkcCvpsKAVCE6hTutOrOBk+lF/iNCh/YMFQbIiVdZyBWNhpo8yfDKicgL50n3jjPNvEPX+I/RdKG82uM/bF8v/SWkrpzxXX9HMN4Ng9kErouVTK7s0Gf1eBHQcF4WrIbnCuN+SxWQxJhD6LCX02xw0JxXyqqRBUEmGYEbTmr/vfKZgGfj0UWYdvxbFX8bO+6vDq9NK9wTAKA=='),DATE '1946-10-18'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (29,'First 29','Last 29',FROM_BASE64('BUClPKVhaV2/DkWtL/JwWVIlqUjF1bOhCNQGM0xz/pbgxsE1jcLYNoMNVFbVPhwmEIyGiqAGOyUzfyyVVNHfPY0Hrbw2LlHXbm7VymFvxqlRNufrDnQrA6ZzsZECwkYHNtrOVcSp0rdSToNDzKdViSDPwIEzELtCKFWcycDYHF5AZzJDU1AV7gQQZHi8h8oJfncvCP9wLnXy/YpCjnDClQ=='),DATE '1956-12-23'); -INSERT INTO Singers (SingerId, FirstName, LastName, SingerInfo, BirthDate) VALUES (30,'First 30','Last 30',FROM_BASE64('1JJ36b41BmeXie2RZ8TykjUUzyJfWV0ZoRShMybsVYebCanPaTb6uUiTFT4MDP1ise6jjN2STpZ49aHL8fOj02vzq1TsAVOznAScd2cbLDdnfSjVeABZRFKKIslpBNUSEP+4sgkoRi7D+ojXsNYVl+D+hSEB1mPn0brbV6mMQUWeryiUFf9ock9hYqa3BbhDEGFjkH0WcnRrvDHZgGAIVw=='),DATE '1988-05-29'); -COMMIT; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 30 AS EXPECTED -FROM Singers; - -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (1,1,"Album 1 1",980045); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (2,2,"Album 2 2",667788); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (3,3,"Album 3 3",908791); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (4,4,"Album 4 4",690335); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (5,5,"Album 5 5",133041); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (6,6,"Album 6 6",505292); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (7,7,"Album 7 7",91969); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (8,8,"Album 8 8",289965); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (9,9,"Album 9 9",78176); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (10,10,"Album 10 10",485664); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (11,11,"Album 11 11",972680); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (12,12,"Album 12 12",893680); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (13,13,"Album 13 13",892138); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (14,14,"Album 14 14",449562); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (15,15,"Album 15 15",150968); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (16,16,"Album 16 16",580377); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (17,17,"Album 17 17",763081); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (18,18,"Album 18 18",203427); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (19,19,"Album 19 19",995368); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (20,20,"Album 20 20",29900); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (21,21,"Album 21 21",723728); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (22,22,"Album 22 22",540582); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (23,23,"Album 23 23",784245); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (24,24,"Album 24 24",614788); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (25,25,"Album 25 25",275649); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (26,26,"Album 26 26",970898); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (27,27,"Album 27 27",409289); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (28,28,"Album 28 28",766560); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (29,29,"Album 29 29",32414); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (30,30,"Album 30 30",457957); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (1,31,"Album 1 31",52546); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (2,32,"Album 2 32",412424); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (3,33,"Album 3 33",568496); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (4,34,"Album 4 34",353491); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (5,35,"Album 5 35",489951); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (6,36,"Album 6 36",75938); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (7,37,"Album 7 37",460461); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (8,38,"Album 8 38",642042); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (9,39,"Album 9 39",282872); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (10,40,"Album 10 40",521496); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (11,41,"Album 11 41",98126); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (12,42,"Album 12 42",535113); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (13,43,"Album 13 43",957625); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (14,44,"Album 14 44",667630); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (15,45,"Album 15 45",236968); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (16,46,"Album 16 46",445647); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (17,47,"Album 17 47",446396); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (18,48,"Album 18 48",852859); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (19,49,"Album 19 49",404105); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (20,50,"Album 20 50",384439); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (21,51,"Album 21 51",440468); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (22,52,"Album 22 52",455384); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (23,53,"Album 23 53",210756); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (24,54,"Album 24 54",849113); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (25,55,"Album 25 55",63969); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (26,56,"Album 26 56",277122); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (27,57,"Album 27 57",350063); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (28,58,"Album 28 58",359473); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (29,59,"Album 29 59",209825); -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle, MarketingBudget) VALUES (30,60,"Album 30 60",84543); - -COMMIT; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 60 AS EXPECTED -FROM Albums; - -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,42,1,"Song 12 42 1",387,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,12,2,"Song 12 12 2",202,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,59,3,"Song 29 59 3",160,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,4,"Song 23 23 4",255,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,54,5,"Song 24 54 5",436,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (28,58,6,"Song 28 58 6",121,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,7,"Song 27 27 7",319,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,24,8,"Song 24 24 8",213,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,49,9,"Song 19 49 9",280,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (17,47,10,"Song 17 47 10",253,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (6,6,11,"Song 6 6 11",321,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,42,12,"Song 12 42 12",124,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (25,25,13,"Song 25 25 13",449,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,24,14,"Song 24 24 14",438,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,5,15,"Song 5 5 15",378,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,39,16,"Song 9 39 16",202,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (20,50,17,"Song 20 50 17",452,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (7,37,18,"Song 7 37 18",420,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,8,19,"Song 8 8 19",318,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,35,20,"Song 5 35 20",347,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,3,21,"Song 3 3 21",377,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,15,22,"Song 15 15 22",314,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,49,23,"Song 19 49 23",199,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (20,20,24,"Song 20 20 24",266,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,45,25,"Song 15 45 25",433,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (14,44,26,"Song 14 44 26",482,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,19,27,"Song 19 19 27",345,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,43,28,"Song 13 43 28",159,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (18,48,29,"Song 18 48 29",350,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,13,30,"Song 13 13 30",131,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,9,31,"Song 9 9 31",183,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,13,32,"Song 13 13 32",193,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,24,33,"Song 24 24 33",378,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,60,34,"Song 30 60 34",270,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,43,35,"Song 13 43 35",375,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,36,"Song 27 27 36",219,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (20,50,37,"Song 20 50 37",314,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (18,48,38,"Song 18 48 38",416,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,51,39,"Song 21 51 39",330,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (1,31,40,"Song 1 31 40",376,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,5,41,"Song 5 5 41",398,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,45,42,"Song 15 45 42",466,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,24,43,"Song 24 24 43",384,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,19,44,"Song 19 19 44",472,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,45,45,"Song 15 45 45",246,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,33,46,"Song 3 33 46",412,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,47,"Song 23 23 47",159,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,60,48,"Song 30 60 48",290,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,19,49,"Song 19 19 49",446,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (16,16,50,"Song 16 16 50",485,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (4,4,51,"Song 4 4 51",185,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,38,52,"Song 8 38 52",349,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,54,53,"Song 24 54 53",301,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,35,54,"Song 5 35 54",206,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,30,55,"Song 30 30 55",250,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,42,56,"Song 12 42 56",146,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,30,57,"Song 30 30 57",416,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (26,56,58,"Song 26 56 58",244,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (20,50,59,"Song 20 50 59",356,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (7,7,60,"Song 7 7 60",234,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,19,61,"Song 19 19 61",412,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,43,62,"Song 13 43 62",161,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,5,63,"Song 5 5 63",300,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (1,31,64,"Song 1 31 64",307,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (4,4,65,"Song 4 4 65",197,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,54,66,"Song 24 54 66",180,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,3,67,"Song 3 3 67",156,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (14,44,68,"Song 14 44 68",184,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,51,69,"Song 21 51 69",486,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,49,70,"Song 19 49 70",212,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,39,71,"Song 9 39 71",452,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,53,72,"Song 23 53 72",425,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (11,41,73,"Song 11 41 73",316,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,8,74,"Song 8 8 74",395,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,9,75,"Song 9 9 75",189,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (2,2,76,"Song 2 2 76",354,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,53,77,"Song 23 53 77",137,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,15,78,"Song 15 15 78",176,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,60,79,"Song 30 60 79",224,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (14,44,80,"Song 14 44 80",305,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,81,"Song 27 27 81",432,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (18,18,82,"Song 18 18 82",357,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (10,10,83,"Song 10 10 83",187,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,42,84,"Song 12 42 84",461,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,8,85,"Song 8 8 85",434,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (1,31,86,"Song 1 31 86",436,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (11,41,87,"Song 11 41 87",469,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,13,88,"Song 13 13 88",452,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (4,34,89,"Song 4 34 89",309,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,21,90,"Song 21 21 90",226,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (6,36,91,"Song 6 36 91",257,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,92,"Song 27 27 92",251,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,39,93,"Song 9 39 93",325,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,30,94,"Song 30 30 94",122,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,59,95,"Song 29 59 95",207,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (1,1,96,"Song 1 1 96",318,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (4,4,97,"Song 4 4 97",353,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,98,"Song 23 23 98",450,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,12,99,"Song 12 12 99",323,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,24,100,"Song 24 24 100",397,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,101,"Song 27 27 101",296,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,59,102,"Song 29 59 102",349,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (17,47,103,"Song 17 47 103",438,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,5,104,"Song 5 5 104",388,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (26,56,105,"Song 26 56 105",425,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (22,52,106,"Song 22 52 106",154,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,107,"Song 23 23 107",213,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,38,108,"Song 8 38 108",276,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,39,109,"Song 9 39 109",417,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (9,9,110,"Song 9 9 110",299,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (22,52,111,"Song 22 52 111",476,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,21,112,"Song 21 21 112",225,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,113,"Song 23 23 113",303,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (7,7,114,"Song 7 7 114",291,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,38,115,"Song 8 38 115",276,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (14,44,116,"Song 14 44 116",238,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,57,117,"Song 27 57 117",188,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (28,28,118,"Song 28 28 118",372,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (15,15,119,"Song 15 15 119",258,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,21,120,"Song 21 21 120",308,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,59,121,"Song 29 59 121",319,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (28,58,122,"Song 28 58 122",453,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (7,7,123,"Song 7 7 123",198,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (4,4,124,"Song 4 4 124",435,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,27,125,"Song 27 27 125",475,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (30,30,126,"Song 30 30 126",395,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,51,127,"Song 21 51 127",454,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,29,128,"Song 29 29 128",376,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (27,57,129,"Song 27 57 129",396,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,53,130,"Song 23 53 130",458,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (6,36,131,"Song 6 36 131",289,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (29,29,132,"Song 29 29 132",207,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (25,55,133,"Song 25 55 133",280,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,3,134,"Song 3 3 134",432,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (5,35,135,"",304,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,3,136,"",392,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,12,137,"",393,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (13,13,138,"",382,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (18,48,139,"",447,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (17,17,140,"",182,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (23,23,141,"",266,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (21,51,142,"",383,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (3,3,143,"",439,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (25,25,144,"",454,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (12,12,145,"",179,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (19,19,146,"",422,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (24,54,147,"",478,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (8,38,148,"",233,'Unknown'); -INSERT INTO Songs (SingerId, AlbumId, TrackId, SongName, Duration, SongGenre) VALUES (6,6,149,"",245,'Unknown'); - -COMMIT; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 149 AS EXPECTED -FROM Songs; - -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (1,1,DATE '2003-06-19',TIMESTAMP '2003-06-19T12:30:05Z',TIMESTAMP '2003-06-19T18:57:15Z',[11,93,140,923]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (2,18,DATE '2004-01-25',TIMESTAMP '2004-01-25T14:58:28Z',TIMESTAMP '2004-01-26T01:10:52Z',[18,51,101,812]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (3,21,DATE '2005-03-15',TIMESTAMP '2005-03-15T18:14:50Z',TIMESTAMP '2005-03-16T02:21:28Z',[23,26,107,721]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (4,16,DATE '2009-05-09',TIMESTAMP '2009-05-09T05:22:34Z',TIMESTAMP '2009-05-09T15:28:28Z',[18,70,150,297]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (5,11,DATE '2001-01-07',TIMESTAMP '2001-01-07T18:37:33Z',TIMESTAMP '2001-01-07T21:22:17Z',[20,55,185,672]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (6,25,DATE '2015-11-19',TIMESTAMP '2015-11-19T22:47:42Z',TIMESTAMP '2015-11-20T02:54:01Z',[12,73,150,833]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (7,26,DATE '2012-10-06',TIMESTAMP '2012-10-06T10:58:43Z',TIMESTAMP '2012-10-06T15:35:40Z',[8,83,199,625]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (8,8,DATE '2001-09-26',TIMESTAMP '2001-09-26T06:41:20Z',TIMESTAMP '2001-09-26T16:38:35Z',[19,87,192,912]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (9,27,DATE '2016-11-24',TIMESTAMP '2016-11-24T20:00:48Z',TIMESTAMP '2016-11-24T23:03:07Z',[20,84,134,885]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (10,30,DATE '2017-05-05',TIMESTAMP '2017-05-05T12:44:05Z',TIMESTAMP '2017-05-05T23:06:55Z',[17,44,177,997]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (11,7,DATE '2018-06-07',TIMESTAMP '2018-06-07T07:03:11Z',TIMESTAMP '2018-06-07T08:21:41Z',[10,73,182,287]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (12,22,DATE '2009-01-07',TIMESTAMP '2009-01-07T23:22:11Z',TIMESTAMP '2009-01-08T08:34:18Z',[22,59,150,983]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (13,16,DATE '2013-06-28',TIMESTAMP '2013-06-28T14:59:25Z',TIMESTAMP '2013-06-28T22:32:11Z',[17,41,129,433]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (14,11,DATE '2005-08-19',TIMESTAMP '2005-08-19T01:11:28Z',TIMESTAMP '2005-08-19T01:30:30Z',[18,49,110,590]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (15,18,DATE '2001-11-26',TIMESTAMP '2001-11-26T15:55:31Z',TIMESTAMP '2001-11-26T20:52:13Z',[18,51,132,854]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (16,26,DATE '2009-01-04',TIMESTAMP '2009-01-04T03:09:11Z',TIMESTAMP '2009-01-04T12:02:14Z',[5,37,146,344]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (17,20,DATE '2012-09-28',TIMESTAMP '2012-09-28T00:45:00Z',TIMESTAMP '2012-09-28T02:10:39Z',[15,89,185,480]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (18,24,DATE '2004-09-06',TIMESTAMP '2004-09-06T09:55:40Z',TIMESTAMP '2004-09-06T18:10:32Z',[23,51,113,244]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (19,21,DATE '2010-11-18',TIMESTAMP '2010-11-18T09:59:17Z',TIMESTAMP '2010-11-18T17:13:12Z',[14,69,164,218]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (20,29,DATE '2010-12-24',TIMESTAMP '2010-12-24T04:21:25Z',TIMESTAMP '2010-12-24T06:10:08Z',[20,34,166,573]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (21,3,DATE '2000-05-14',TIMESTAMP '2000-05-14T13:49:08Z',TIMESTAMP '2000-05-14T14:39:25Z',[21,67,136,779]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (22,18,DATE '2000-05-14',TIMESTAMP '2000-05-14T00:23:23Z',TIMESTAMP '2000-05-14T01:20:04Z',[21,91,111,749]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (23,26,DATE '2015-05-04',TIMESTAMP '2015-05-04T10:39:46Z',TIMESTAMP '2015-05-04T19:21:45Z',[24,91,128,559]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (24,16,DATE '2012-08-18',TIMESTAMP '2012-08-18T08:47:12Z',TIMESTAMP '2012-08-18T09:35:03Z',[19,44,136,281]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (25,4,DATE '2000-03-16',TIMESTAMP '2000-03-16T10:15:15Z',TIMESTAMP '2000-03-16T12:29:53Z',[22,28,111,948]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (26,4,DATE '2002-11-20',TIMESTAMP '2002-11-20T16:28:19Z',TIMESTAMP '2002-11-20T17:56:10Z',[7,70,141,517]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (27,23,DATE '2000-08-09',TIMESTAMP '2000-08-09T04:30:51Z',TIMESTAMP '2000-08-09T15:27:15Z',[13,98,156,230]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (28,16,DATE '2000-10-15',TIMESTAMP '2000-10-15T04:12:39Z',TIMESTAMP '2000-10-15T14:07:05Z',[8,39,160,455]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (29,22,DATE '2003-03-25',TIMESTAMP '2003-03-25T17:21:56Z',TIMESTAMP '2003-03-25T19:18:25Z',[17,70,148,681]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (30,15,DATE '2008-11-11',TIMESTAMP '2008-11-11T22:56:07Z',TIMESTAMP '2008-11-12T09:33:48Z',[24,47,175,901]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (31,7,DATE '2018-05-22',TIMESTAMP '2018-05-22T20:54:59Z',TIMESTAMP '2018-05-23T02:52:28Z',[13,34,177,804]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (32,30,DATE '2000-04-03',TIMESTAMP '2000-04-03T13:54:10Z',TIMESTAMP '2000-04-03T15:57:02Z',[16,48,137,249]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (33,23,DATE '2003-12-24',TIMESTAMP '2003-12-24T22:22:00Z',TIMESTAMP '2003-12-25T06:09:40Z',[15,36,131,922]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (34,12,DATE '2012-06-23',TIMESTAMP '2012-06-23T18:15:30Z',TIMESTAMP '2012-06-24T03:46:17Z',[25,31,160,564]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (35,5,DATE '2017-12-15',TIMESTAMP '2017-12-15T09:43:38Z',TIMESTAMP '2017-12-15T17:18:28Z',[22,31,177,868]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (36,20,DATE '2012-12-21',TIMESTAMP '2012-12-21T08:28:14Z',TIMESTAMP '2012-12-21T11:34:59Z',[25,62,143,437]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (37,19,DATE '2014-07-07',TIMESTAMP '2014-07-07T22:01:35Z',TIMESTAMP '2014-07-08T04:39:37Z',[8,31,184,784]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (38,15,DATE '2012-07-26',TIMESTAMP '2012-07-26T09:45:35Z',TIMESTAMP '2012-07-26T13:03:53Z',[19,79,140,908]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (39,24,DATE '2014-03-19',TIMESTAMP '2014-03-19T07:52:25Z',TIMESTAMP '2014-03-19T11:47:01Z',[11,90,141,978]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (40,4,DATE '2015-08-26',TIMESTAMP '2015-08-26T20:51:25Z',TIMESTAMP '2015-08-27T07:06:46Z',[15,94,195,510]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (41,24,DATE '2016-04-11',TIMESTAMP '2016-04-11T08:59:07Z',TIMESTAMP '2016-04-11T13:23:30Z',[15,51,173,233]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (42,18,DATE '2005-03-19',TIMESTAMP '2005-03-19T15:45:04Z',TIMESTAMP '2005-03-19T16:28:42Z',[19,31,188,546]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (43,7,DATE '2001-01-04',TIMESTAMP '2001-01-04T11:02:16Z',TIMESTAMP '2001-01-04T11:32:21Z',[20,37,133,958]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (44,5,DATE '2015-12-24',TIMESTAMP '2015-12-24T06:49:48Z',TIMESTAMP '2015-12-24T14:46:46Z',[12,61,175,233]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (45,12,DATE '2011-08-24',TIMESTAMP '2011-08-24T03:45:46Z',TIMESTAMP '2011-08-24T06:13:10Z',[18,38,169,913]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (46,16,DATE '2017-03-04',TIMESTAMP '2017-03-04T04:01:04Z',TIMESTAMP '2017-03-04T13:44:38Z',[21,79,119,839]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (47,18,DATE '2009-05-19',TIMESTAMP '2009-05-19T23:10:52Z',TIMESTAMP '2009-05-20T04:02:01Z',[25,79,151,357]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (48,22,DATE '2003-10-03',TIMESTAMP '2003-10-03T14:10:24Z',TIMESTAMP '2003-10-03T17:35:09Z',[18,60,140,450]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (49,9,DATE '2003-03-07',TIMESTAMP '2003-03-07T22:09:59Z',TIMESTAMP '2003-03-08T08:28:29Z',[22,41,122,726]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (50,9,DATE '2015-07-12',TIMESTAMP '2015-07-12T07:43:51Z',TIMESTAMP '2015-07-12T12:45:20Z',[18,67,126,474]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (51,12,DATE '2014-11-05',TIMESTAMP '2014-11-05T19:03:00Z',TIMESTAMP '2014-11-06T05:27:07Z',[19,43,125,865]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (52,6,DATE '2016-07-25',TIMESTAMP '2016-07-25T14:39:28Z',TIMESTAMP '2016-07-26T00:36:03Z',[6,74,192,344]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (53,13,DATE '2005-08-02',TIMESTAMP '2005-08-02T16:06:47Z',TIMESTAMP '2005-08-02T17:13:41Z',[5,52,192,977]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (54,18,DATE '2010-01-25',TIMESTAMP '2010-01-25T07:34:54Z',TIMESTAMP '2010-01-25T16:29:11Z',[24,85,181,304]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (55,14,DATE '2012-05-20',TIMESTAMP '2012-05-20T13:15:12Z',TIMESTAMP '2012-05-20T17:40:09Z',[15,43,104,665]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (56,3,DATE '2013-09-08',TIMESTAMP '2013-09-08T19:53:42Z',TIMESTAMP '2013-09-08T22:32:52Z',[14,81,129,354]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (57,27,DATE '2003-07-18',TIMESTAMP '2003-07-18T23:11:24Z',TIMESTAMP '2003-07-19T03:29:46Z',[21,85,188,854]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (58,27,DATE '2001-04-10',TIMESTAMP '2001-04-10T08:36:49Z',TIMESTAMP '2001-04-10T16:17:57Z',[17,86,161,438]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (59,2,DATE '2002-07-02',TIMESTAMP '2002-07-02T17:32:20Z',TIMESTAMP '2002-07-03T01:59:33Z',[23,59,164,357]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (60,28,DATE '2000-11-24',TIMESTAMP '2000-11-24T12:53:25Z',TIMESTAMP '2000-11-24T22:37:53Z',[22,47,161,739]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (61,12,DATE '2017-07-04',TIMESTAMP '2017-07-04T21:02:01Z',TIMESTAMP '2017-07-05T03:57:29Z',[16,88,179,478]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (62,3,DATE '2015-10-07',TIMESTAMP '2015-10-07T17:58:42Z',TIMESTAMP '2015-10-07T21:04:38Z',[21,44,155,381]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (63,23,DATE '2005-05-03',TIMESTAMP '2005-05-03T15:08:10Z',TIMESTAMP '2005-05-03T20:58:30Z',[20,43,111,824]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (64,24,DATE '2012-12-09',TIMESTAMP '2012-12-09T02:52:09Z',TIMESTAMP '2012-12-09T08:01:11Z',[18,87,106,997]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (65,30,DATE '2004-03-01',TIMESTAMP '2004-03-01T07:09:06Z',TIMESTAMP '2004-03-01T07:49:32Z',[14,26,195,895]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (66,24,DATE '2007-05-19',TIMESTAMP '2007-05-19T10:20:57Z',TIMESTAMP '2007-05-19T15:21:09Z',[18,54,179,238]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (67,16,DATE '2016-01-06',TIMESTAMP '2016-01-06T21:32:20Z',TIMESTAMP '2016-01-07T02:31:32Z',[20,61,120,652]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (68,2,DATE '2007-10-26',TIMESTAMP '2007-10-26T03:37:22Z',TIMESTAMP '2007-10-26T10:02:36Z',[11,65,151,537]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (69,2,DATE '2018-08-11',TIMESTAMP '2018-08-11T01:33:38Z',TIMESTAMP '2018-08-11T07:39:21Z',[10,98,105,621]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (70,23,DATE '2012-07-06',TIMESTAMP '2012-07-06T01:02:23Z',TIMESTAMP '2012-07-06T05:04:16Z',[14,44,172,953]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (71,7,DATE '2006-01-24',TIMESTAMP '2006-01-24T15:32:10Z',TIMESTAMP '2006-01-24T17:40:43Z',[9,58,150,713]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (72,8,DATE '2002-11-06',TIMESTAMP '2002-11-06T05:58:03Z',TIMESTAMP '2002-11-06T07:43:24Z',[25,36,193,213]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (73,10,DATE '2003-11-24',TIMESTAMP '2003-11-24T17:39:10Z',TIMESTAMP '2003-11-25T03:17:36Z',[8,55,200,352]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (74,16,DATE '2007-11-03',TIMESTAMP '2007-11-03T05:49:12Z',TIMESTAMP '2007-11-03T16:34:16Z',[21,50,114,820]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (75,4,DATE '2009-05-06',TIMESTAMP '2009-05-06T18:52:07Z',TIMESTAMP '2009-05-06T21:10:02Z',[16,42,101,281]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (76,1,DATE '2012-12-03',TIMESTAMP '2012-12-03T06:01:05Z',TIMESTAMP '2012-12-03T06:45:00Z',[24,60,140,292]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (77,1,DATE '2016-11-26',TIMESTAMP '2016-11-26T01:19:27Z',TIMESTAMP '2016-11-26T07:20:17Z',[19,31,123,214]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (78,9,DATE '2018-05-21',TIMESTAMP '2018-05-21T00:14:43Z',TIMESTAMP '2018-05-21T08:43:35Z',[7,28,115,634]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (79,14,DATE '2013-11-20',TIMESTAMP '2013-11-20T08:54:47Z',TIMESTAMP '2013-11-20T10:44:54Z',[18,39,155,328]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (80,17,DATE '2015-10-11',TIMESTAMP '2015-10-11T23:41:17Z',TIMESTAMP '2015-10-12T02:42:48Z',[16,94,102,894]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (81,23,DATE '2011-08-07',TIMESTAMP '2011-08-07T19:33:01Z',TIMESTAMP '2011-08-07T21:51:53Z',[23,90,134,370]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (82,7,DATE '2010-04-10',TIMESTAMP '2010-04-10T13:22:08Z',TIMESTAMP '2010-04-10T17:59:08Z',[18,68,121,303]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (83,27,DATE '2001-07-08',TIMESTAMP '2001-07-08T20:19:54Z',TIMESTAMP '2001-07-08T22:46:15Z',[18,86,148,746]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (84,6,DATE '2017-09-02',TIMESTAMP '2017-09-02T10:29:03Z',TIMESTAMP '2017-09-02T13:06:41Z',[12,85,138,471]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (85,1,DATE '2013-11-02',TIMESTAMP '2013-11-02T04:01:03Z',TIMESTAMP '2013-11-02T14:08:47Z',[9,65,111,583]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (86,22,DATE '2004-04-03',TIMESTAMP '2004-04-03T19:13:48Z',TIMESTAMP '2004-04-04T05:59:31Z',[19,72,105,908]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (87,2,DATE '2012-02-26',TIMESTAMP '2012-02-26T22:52:21Z',TIMESTAMP '2012-02-27T02:55:24Z',[16,75,129,740]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (88,9,DATE '2017-09-17',TIMESTAMP '2017-09-17T11:28:49Z',TIMESTAMP '2017-09-17T12:13:03Z',[24,77,182,755]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (89,11,DATE '2011-03-28',TIMESTAMP '2011-03-28T13:05:23Z',TIMESTAMP '2011-03-28T16:32:29Z',[22,96,174,731]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (90,21,DATE '2006-12-12',TIMESTAMP '2006-12-12T20:44:10Z',TIMESTAMP '2006-12-12T22:10:34Z',[15,68,166,616]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (91,27,DATE '2010-08-18',TIMESTAMP '2010-08-18T05:49:35Z',TIMESTAMP '2010-08-18T12:58:36Z',[12,84,157,369]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (92,2,DATE '2003-02-03',TIMESTAMP '2003-02-03T11:19:43Z',TIMESTAMP '2003-02-03T22:10:42Z',[25,59,140,939]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (93,5,DATE '2016-01-04',TIMESTAMP '2016-01-04T08:10:26Z',TIMESTAMP '2016-01-04T13:08:30Z',[5,90,163,272]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (94,3,DATE '2018-04-20',TIMESTAMP '2018-04-20T07:19:52Z',TIMESTAMP '2018-04-20T17:41:01Z',[5,59,109,854]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (95,19,DATE '2016-10-09',TIMESTAMP '2016-10-09T17:02:59Z',TIMESTAMP '2016-10-09T17:37:27Z',[6,35,176,442]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (96,9,DATE '2007-06-12',TIMESTAMP '2007-06-12T16:50:12Z',TIMESTAMP '2007-06-12T19:27:30Z',[7,49,169,729]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (97,29,DATE '2012-11-25',TIMESTAMP '2012-11-25T20:40:30Z',TIMESTAMP '2012-11-25T21:29:50Z',[12,35,128,269]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (98,11,DATE '2013-10-22',TIMESTAMP '2013-10-22T03:26:36Z',TIMESTAMP '2013-10-22T06:42:42Z',[14,49,148,726]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (99,10,DATE '2006-05-10',TIMESTAMP '2006-05-10T05:49:43Z',TIMESTAMP '2006-05-10T07:12:18Z',[5,67,131,360]); -INSERT INTO Concerts (VenueId, SingerId, ConcertDate, BeginTime, EndTime, TicketPrices) VALUES (100,18,DATE '2015-02-15',TIMESTAMP '2015-02-15T01:18:05Z',TIMESTAMP '2015-02-15T04:19:27Z',[11,38,127,909]); - -COMMIT; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 100 AS EXPECTED -FROM Concerts; - -COMMIT; - -# Switch to read-only mode -SET READONLY = TRUE; - -# Do a query that should also generate a read timestamp -@EXPECT RESULT_SET 'NUMBER_OF_SINGERS',30 -SELECT COUNT(*) AS NUMBER_OF_SINGERS -FROM Singers; - -# Check that the read-timestamp is there -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- End the read-only transaction and try to get a commit timestamp. -COMMIT; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Try to do an update in read-only mode -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE Singers SET FirstName='FirstName' WHERE SingerId=1; - --- Verify that it was not changed -@EXPECT RESULT_SET 'FirstName','First 1' -SELECT FirstName -FROM Singers -WHERE SingerId=1; - -COMMIT; - --- Switch to autocommit and read/write mode -SET READONLY = FALSE; -SET AUTOCOMMIT = TRUE; - --- Try to insert a record that already exists -@EXPECT EXCEPTION ALREADY_EXISTS -INSERT INTO Singers (SingerId, FirstName, LastName) -SELECT SingerId, FirstName, LastName -FROM Singers -WHERE SingerId=1; - --- Ensure there was no commit timestamp -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Delete a record that will also cascade to other records --- First verify the actual number of records -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED -FROM Albums -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 4 AS EXPECTED -FROM Songs -WHERE SingerId=1; - --- Even though the delete cascades to several other records, the update count is returned as 1 -@EXPECT UPDATE_COUNT 1 -DELETE FROM Singers WHERE SingerId=1; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Albums -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Songs -WHERE SingerId=1; - --- Switch to transactional mode -SET AUTOCOMMIT = FALSE; - --- Delete a record that will also cascade to other records and then rollback --- First verify the actual number of records -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED -FROM Albums -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Songs -WHERE SingerId=2; - --- Even though the delete cascades to several other records, the update count is returned as 1 -@EXPECT UPDATE_COUNT 1 -DELETE FROM Singers WHERE SingerId=2; - --- Verify that the change is visible inside the transaction -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Albums -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Songs -WHERE SingerId=2; - --- Rollback and verify that no changes were persisted -ROLLBACK; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 2 AS EXPECTED -FROM Albums -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Songs -WHERE SingerId=2; - --- End transaction -COMMIT; - --- Switch to autocommit and partitioned_non_atomic mode and redo the delete -SET AUTOCOMMIT = TRUE; -SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; - -@EXPECT UPDATE_COUNT 1 -DELETE FROM Singers WHERE SingerId=2; - --- There should be no commit timestamp for PARTITIONED_NON_ATOMIC -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Albums -WHERE SingerId=2; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Songs -WHERE SingerId=2; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_CreateTables.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_CreateTables.sql deleted file mode 100644 index b72560b55f8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_CreateTables.sql +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Test script that creates a couple of test tables in one transaction. - */ - --- Turn off autocommit (and verify) -@EXPECT NO_RESULT -SET AUTOCOMMIT = FALSE; -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; - --- Turn off readonly (and verify) -@EXPECT NO_RESULT -SET READONLY = FALSE; -@EXPECT RESULT_SET 'READONLY',false -SHOW VARIABLE READONLY; - --- Start a DDL batch to execute a number of DDL statements as one operation. -@EXPECT NO_RESULT -START BATCH DDL; - --- Create a couple of test tables -@EXPECT NO_RESULT -CREATE TABLE Singers ( - SingerId INT64 NOT NULL, - FirstName STRING(1024), - LastName STRING(1024), - SingerInfo BYTES(MAX) -) PRIMARY KEY (SingerId); - -@EXPECT NO_RESULT -CREATE TABLE Albums ( - SingerId INT64 NOT NULL, - AlbumId INT64 NOT NULL, - AlbumTitle STRING(MAX) -) PRIMARY KEY (SingerId, AlbumId), --- interleave this table in the Singers table -INTERLEAVE IN PARENT Singers ON DELETE CASCADE; - --- Create a secondary index -@EXPECT NO_RESULT -CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle); - --- Run the DDL batch -RUN BATCH; - --- Reset the statement timeout -SET STATEMENT_TIMEOUT=null; - -/* - * Verify that the test tables have been created - */ -@EXPECT NO_RESULT -SET AUTOCOMMIT = TRUE; -@EXPECT NO_RESULT -SET READONLY = TRUE; - --- Check that the table has been created -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='Singers'; - --- Check for all columns -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 4 AS EXPECTED -FROM INFORMATION_SCHEMA.COLUMNS -WHERE TABLE_NAME='Singers' -/** - * List all expected column names - */ -AND COLUMN_NAME IN ( - 'SingerId', - 'FirstName', - 'LastName', - 'SingerInfo' -); - --- Check for index -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM INFORMATION_SCHEMA.INDEXES -WHERE TABLE_NAME='Albums' AND INDEX_NAME='AlbumsByAlbumTitle'; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_InsertTestData.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_InsertTestData.sql deleted file mode 100644 index e1434ce3595..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_InsertTestData.sql +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Insert test data into test tables - */ - -@EXPECT NO_RESULT -SET AUTOCOMMIT = FALSE; -@EXPECT NO_RESULT -SET READONLY = FALSE; - -@EXPECT UPDATE_COUNT 3 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES(1, 'First 1', 'Last 1'), - (2, 'First 2', 'Last 2'), - (3, 'First 3', 'Last 3'); - -@EXPECT UPDATE_COUNT 3 -INSERT INTO Singers (SingerId, FirstName, LastName) -SELECT 4, 'First 4', 'Last 4' -UNION ALL -SELECT 5, 'First 5', 'Last 5' -UNION ALL -SELECT 6, 'First 6', 'Last 6'; - -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (10, 'First 10', 'Last 10'); -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (11, 'First 11', 'Last 11'); - -@EXPECT UPDATE_COUNT 5 -INSERT INTO Albums (SingerId, AlbumId, AlbumTitle) -VALUES - (1, 1, 'Album 1 1'), - (1, 2, 'Album 1 2'), - (2, 1, 'Album 2 1'), - (2, 2, 'Album 2 2'), - (2, 3, 'Album 2 3'); - -@EXPECT NO_RESULT -COMMIT; - --- Try to insert a record that already exists -@EXPECT EXCEPTION ALREADY_EXISTS -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (10, 'First 10', 'Last 10'); - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE FirstName='First 10' AND LastName='Last 10'; - -@EXPECT NO_RESULT -ROLLBACK; - --- Verify the contents of the tables -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 5 AS EXPECTED -FROM Albums; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 8 AS EXPECTED -FROM Singers; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitDmlMode.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitDmlMode.sql deleted file mode 100644 index 355c356132e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitDmlMode.sql +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script that tests the different possible autocommit dml modes - */ - -SET AUTOCOMMIT = FALSE; -SET READONLY = FALSE; - --- First verify that the mode cannot be set when not in autocommit mode -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Cannot set autocommit DML mode while not in autocommit mode or while a transaction is active' -SET AUTOCOMMIT_DML_MODE = 'Transactional'; - --- Turn on autocommit and set mode to transactional -SET AUTOCOMMIT = TRUE; - -@EXPECT NO_RESULT -SET AUTOCOMMIT_DML_MODE = 'Transactional'; - -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; - --- Verify that executing an update statement is possible -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='Some Other Last Name' /* It used to be 'Last 1' */ -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Some Other Last Name' AS EXPECTED -FROM Singers -WHERE SingerId=1; - --- Reset to original value in partioned mode -@EXPECT NO_RESULT -SET AUTOCOMMIT_DML_MODE = 'partitioned_non_atomic'; - -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; - -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='Last 1' -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - --- Verify that trying to set the mode to an invalid value will throw an exception -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for AUTOCOMMIT_DML_MODE: 'None'' -SET AUTOCOMMIT_DML_MODE = 'None'; - --- Verify that setting the mode in read-only mode will throw an exception -SET READONLY = TRUE; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Cannot set autocommit DML mode for a read-only connection' -SET AUTOCOMMIT_DML_MODE = 'Transactional'; - --- Back to read-write mode -SET READONLY = FALSE; - --- Verify that turning off autocommit and on again will not reset the AUTOCOMMIT_DML_MODE value -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; -SET AUTOCOMMIT = FALSE; -SET AUTOCOMMIT = TRUE; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','PARTITIONED_NON_ATOMIC' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; - --- Reset to default value -SET AUTOCOMMIT_DML_MODE = 'Transactional'; -@EXPECT RESULT_SET 'AUTOCOMMIT_DML_MODE','TRANSACTIONAL' -SHOW VARIABLE AUTOCOMMIT_DML_MODE; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitReadOnly.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitReadOnly.sql deleted file mode 100644 index 1230c01fa8b..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestAutocommitReadOnly.sql +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script that tests a connection in read-only and autocommit mode - */ - -SET AUTOCOMMIT = TRUE; -SET READONLY = TRUE; - --- First verify that the autocommit dml mode cannot be set when in read-only mode -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Cannot set autocommit DML mode for a read-only connection' -SET AUTOCOMMIT_DML_MODE = 'PARTITIONED_NON_ATOMIC'; - --- Verify that executing an update statement fails -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed in read-only mode' -UPDATE Singers SET LastName='Some Other Last Name' /* It used to be 'Last 1' */ -WHERE SingerId=1; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - --- Verify the same for INSERT and DELETE statements -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed in read-only mode' -INSERT INTO Singers (SingerId, FirstName, LastName) VALUES (9999, 'First 9999', 'Last 9999'); - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed in read-only mode' -DELETE FROM Singers; - --- Verify that the same error message is given even if the update statements references a non-existent table -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed in read-only mode' -/* The referenced table does not exist */ -update Artists set LastName='Some Last Name' -where ArtistId=1; - --- Verify that DDL statements will also cause an exception -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL statements are not allowed in read-only mode' -CREATE TABLE FOO (ID INT64, NAME STRING(100)) PRIMARY KEY (ID); - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL statements are not allowed in read-only mode' -/* The statement is recognized even if it is preceeded - * by a multi-line comment */ --- And a single line comment, and some spaces - - DROP TABLE Singers; - --- And verify that alter table statements also fail -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL statements are not allowed in read-only mode' -alter table Singers add column test string(100); diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetCommitTimestamp.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetCommitTimestamp.sql deleted file mode 100644 index 2baa5974121..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetCommitTimestamp.sql +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Test SHOW VARIABLE COMMIT_TIMESTAMP in different modes - */ - --- Select query in autocommit and read-only mode should not yield a commit timestamp -@EXPECT NO_RESULT -SET AUTOCOMMIT = TRUE; -@EXPECT NO_RESULT -SET READONLY = TRUE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Select query in autocommit and read-write mode should not yield a commit timestamp -@EXPECT NO_RESULT -SET READONLY = FALSE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Select query in transactional and read-only mode should not yield a commit timestamp -@EXPECT NO_RESULT -SET AUTOCOMMIT = FALSE; -@EXPECT NO_RESULT -SET READONLY = TRUE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT NO_RESULT -COMMIT; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Select query in transactional and read-write mode should yield a commit timestamp -@EXPECT NO_RESULT -SET READONLY = FALSE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT NO_RESULT -COMMIT; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Update statement in transactional and read-write mode should yield a commit timestamp -@EXPECT NO_RESULT -SET AUTOCOMMIT = FALSE; - -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='New Last 1' -WHERE SingerId=1; - -@EXPECT NO_RESULT -COMMIT; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Reset the value to its original value -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='Last 1' -WHERE SingerId=1; - -@EXPECT NO_RESULT -COMMIT; - --- Select query in transactional and read-write mode that rollbacks should not yield a commit timestamp -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT NO_RESULT -ROLLBACK; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Update statement in transactional and read-write mode that rollbacks should not yield a commit timestamp -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='New Last 1' -WHERE SingerId=1; - -@EXPECT NO_RESULT -ROLLBACK; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP',null -SHOW VARIABLE COMMIT_TIMESTAMP; - --- Invalid select query in transactional and read-write mode should yield a commit timestamp --- The (invalid) query is sent to the server, initiating a transaction, that is committed afterwards -SET AUTOCOMMIT = FALSE; -SET READONLY = FALSE; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM NonExistentTable -WHERE SingerId=1; - -@EXPECT NO_RESULT -COMMIT; - -@EXPECT RESULT_SET 'COMMIT_TIMESTAMP' -SHOW VARIABLE COMMIT_TIMESTAMP; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetReadTimestamp.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetReadTimestamp.sql deleted file mode 100644 index c166d48ed88..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestGetReadTimestamp.sql +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Test SHOW VARIABLE READ_TIMESTAMP in different modes - */ - --- Select query in autocommit and read-only mode should yield a read timestamp -SET AUTOCOMMIT = TRUE; -SET READONLY = TRUE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Select query in autocommit and read-write mode should yield a read timestamp -SET READONLY = FALSE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Select query in transactional and read-only mode should yield a read timestamp -SET AUTOCOMMIT = FALSE; -SET READONLY = TRUE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - -COMMIT; - --- Select query in transactional and read-write mode should NOT yield a read timestamp -SET READONLY = FALSE; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - -COMMIT; - --- Update statement in transactional and read-write mode should NOT yield a read timestamp -SET AUTOCOMMIT = FALSE; - -@EXPECT UPDATE_COUNT 1 -UPDATE Singers SET LastName='New Last 1' -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - -ROLLBACK; - --- Verify that the rollback actually worked -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - -COMMIT; - --- Invalid select query in autocommit and read-only mode should not yield a read timestamp -SET AUTOCOMMIT = TRUE; -SET READONLY = TRUE; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM NonExistentTable -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - --- Invalid select query in autocommit and read-write mode should not yield a read timestamp -SET READONLY = FALSE; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM NonExistentTable -WHERE SingerId=1; - -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestInvalidStatements.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestInvalidStatements.sql deleted file mode 100644 index 551d5c07ce7..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestInvalidStatements.sql +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script for testing invalid/unrecognized statements - */ --- EXPLAIN statement -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement: EXPLAIN' -EXPLAIN SELECT * -FROM Singers; - --- EXPLAIN ANALYZE statement -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement: EXPLAIN ANALYZE' -EXPLAIN ANALYZE SELECT * -FROM Singers; - --- SET unknown property -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown statement: SET some_property' -SET some_property='value'; \ No newline at end of file diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestReadOnlyStaleness.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestReadOnlyStaleness.sql deleted file mode 100644 index 6feb7894bf7..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestReadOnlyStaleness.sql +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script that tests the different possible read-only staleness modes - */ - --- First test in autocommit mode. READONLY mode is not strictly necessary -SET AUTOCOMMIT = TRUE; -SET READONLY = FALSE; - ---------------------- STRONG ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set STRONG with a timestamp value -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'STRONG 2018-11-15T13:09:25Z'' -SET READ_ONLY_STALENESS='STRONG 2018-11-15T13:09:25Z'; - --- Try to set STRONG with a duration value -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'STRONG 10s'' -SET READ_ONLY_STALENESS='STRONG 10s'; - ---------------------- MIN_READ_TIMESTAMP ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-11-15T13:09:25Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-11-15T13:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Min_Read_Timestamp 2018-11-15T13:09:25-08:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-11-15T21:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-11-15T13:09:25+07:45'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-11-15T05:24:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set MIN_READ_TIMESTAMP without a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MIN_READ_TIMESTAMP'' -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP'; - --- Try to set MIN_READ_TIMESTAMP with a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MIN_READ_TIMESTAMP 10s'' -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 10s'; - ---------------------- READ_TIMESTAMP ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-11-15T13:09:25Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T13:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Read_Timestamp 2018-11-15T13:09:25-08:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T21:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='read_timestamp 2018-11-15T13:09:25+07:45'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T05:24:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set READ_TIMESTAMP without a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'READ_TIMESTAMP'' -SET READ_ONLY_STALENESS='READ_TIMESTAMP'; - --- Try to set READ_TIMESTAMP with a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'READ_TIMESTAMP 10s'' -SET READ_ONLY_STALENESS='READ_TIMESTAMP 10s'; - ---------------------- MAX_STALENESS ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 100ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Max_Staleness 1000ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='max_staleness 10001ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10001ns' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set MAX_STALENESS without a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MAX_STALENESS'' -SET READ_ONLY_STALENESS='MAX_STALENESS'; - --- Try to set MAX_STALENESS with a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MAX_STALENESS 2018-11-15T13:09:25+07:45'' -SET READ_ONLY_STALENESS='MAX_STALENESS 2018-11-15T13:09:25+07:45'; - ---------------------- EXACT_STALENESS ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='EXACT_STALENESS 1000ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Exact_Staleness 1001ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1001ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='exact_staleness 1000000000ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set EXACT_STALENESS without a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'EXACT_STALENESS'' -SET READ_ONLY_STALENESS='EXACT_STALENESS'; - --- Try to set EXACT_STALENESS with a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'EXACT_STALENESS 2018-11-15T13:09:25+07:45'' -SET READ_ONLY_STALENESS='EXACT_STALENESS 2018-11-15T13:09:25+07:45'; - - ------------------------------------------------------------------------------------------------------------------------------- - - --- Then test in transactional read-only mode. -SET AUTOCOMMIT = FALSE; -SET READONLY = TRUE; - ---------------------- STRONG ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set STRONG with a timestamp value -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'STRONG 2018-11-15T13:09:25Z'' -SET READ_ONLY_STALENESS='STRONG 2018-11-15T13:09:25Z'; - --- Try to set STRONG with a duration value -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'STRONG 10s'' -SET READ_ONLY_STALENESS='STRONG 10s'; - ---------------------- MIN_READ_TIMESTAMP ---------------------------- --- This is not allowed in transactional mode -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: MAX_STALENESS and MIN_READ_TIMESTAMP are only allowed in autocommit mode' -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-11-15T13:09:25Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - ---------------------- READ_TIMESTAMP ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-11-15T13:09:25Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T13:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Read_Timestamp 2018-11-15T13:09:25-08:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T21:09:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='read_timestamp 2018-11-15T13:09:25+07:45'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T05:24:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set READ_TIMESTAMP without a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'READ_TIMESTAMP'' -SET READ_ONLY_STALENESS='READ_TIMESTAMP'; - --- Try to set READ_TIMESTAMP with a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'READ_TIMESTAMP 10s'' -SET READ_ONLY_STALENESS='READ_TIMESTAMP 10s'; - ---------------------- MAX_STALENESS ---------------------------- --- only allowed in autocommit mode -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: MAX_STALENESS and MIN_READ_TIMESTAMP are only allowed in autocommit mode' -SET READ_ONLY_STALENESS='MAX_STALENESS 100ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-11-15T05:24:25Z' -SHOW VARIABLE READ_ONLY_STALENESS; - ---------------------- EXACT_STALENESS ---------------------------- -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='EXACT_STALENESS 1000ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='Exact_Staleness 1001ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1001ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='exact_staleness 1000000000ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Try to set EXACT_STALENESS without a duration -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'EXACT_STALENESS'' -SET READ_ONLY_STALENESS='EXACT_STALENESS'; - --- Try to set EXACT_STALENESS with a timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'EXACT_STALENESS 2018-11-15T13:09:25+07:45'' -SET READ_ONLY_STALENESS='EXACT_STALENESS 2018-11-15T13:09:25+07:45'; - - ----------------------------------------------------------------------------------------------------------------- - --- Then test in transactional read-write mode. This should also work, although it has no effect on the current transaction, unless the transaction mode is explicitly set to read only -SET AUTOCOMMIT = FALSE; -SET READONLY = FALSE; - -@EXPECT NO_RESULT -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Then test while in an active transaction. This should not be allowed. -SET TRANSACTION READ ONLY; -SELECT * -FROM Singers; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Cannot set read-only staleness when a transaction has been started' -SET READ_ONLY_STALENESS='EXACT_STALENESS 1000ms'; --- Check that the staleness mode is still 'STRONG' -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - -COMMIT; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestSetStatements.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestSetStatements.sql deleted file mode 100644 index 8502d9da136..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestSetStatements.sql +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script for testing setting invalid values for the different connection and transaction options - */ - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for AUTOCOMMIT: on' -set autocommit = on; -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READONLY: on' -set readonly = on; - -SET AUTOCOMMIT = TRUE; -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for AUTOCOMMIT_DML_MODE: 'non_atomic'' -set autocommit_dml_mode='non_atomic'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'weak'' -set read_only_staleness='weak'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'strong 2018-11-15T13:09:25Z'' -set read_only_staleness='strong 2018-11-15T13:09:25Z'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MIN_READ_TIMESTAMP'' -set read_only_staleness='MIN_READ_TIMESTAMP'; -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MIN_READ_TIMESTAMP 10s'' -set read_only_staleness='MIN_READ_TIMESTAMP 10s'; --- Missing timezone in timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MIN_READ_TIMESTAMP 2018-11-15T13:09:25'' -set read_only_staleness='MIN_READ_TIMESTAMP 2018-11-15T13:09:25'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MAX_STALENESS'' -set read_only_staleness='MAX_STALENESS'; -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MAX_STALENESS 2018-11-15T13:09:25Z'' -set read_only_staleness='MAX_STALENESS 2018-11-15T13:09:25Z'; --- Missing time unit -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for READ_ONLY_STALENESS: 'MAX_STALENESS 10'' -set read_only_staleness='MAX_STALENESS 10'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for STATEMENT_TIMEOUT: -1' -set statement_timeout=-1; -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for STATEMENT_TIMEOUT: '1'' -set statement_timeout='1'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for TRANSACTION: readonly' -set transaction readonly; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestStatementTimeout.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestStatementTimeout.sql deleted file mode 100644 index 9a9894fafa9..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestStatementTimeout.sql +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Test setting statement timeout and verify that statements actually do timeout - */ - --- Ensure we know what mode we are in -SET AUTOCOMMIT = TRUE; -SET AUTOCOMMIT_DML_MODE='Transactional'; -SET READONLY = FALSE; - --- Verify that setting a negative timeout value is not allowed -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for STATEMENT_TIMEOUT: '-1ms'' -SET STATEMENT_TIMEOUT='-1ms'; - -@EXPECT EXCEPTION INVALID_ARGUMENT 'INVALID_ARGUMENT: Unknown value for STATEMENT_TIMEOUT: '1'' -SET STATEMENT_TIMEOUT='1'; - --- First set the statement timeout to null, which means no timeout -SET STATEMENT_TIMEOUT=null; - -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Do a somewhat complex query that should not timeout -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM ( - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) RES -; - --- Set the statement timeout to 1 nanosecond that should cause basically any statement to timeout -SET STATEMENT_TIMEOUT='1ns'; - -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Do a somewhat complex query that should now timeout -@EXPECT EXCEPTION DEADLINE_EXCEEDED 'DEADLINE_EXCEEDED: Statement execution timeout occurred' -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM ( - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) RES -; - --- Try to execute an update that should also timeout -@EXPECT EXCEPTION DEADLINE_EXCEEDED 'DEADLINE_EXCEEDED: Statement execution timeout occurred' -UPDATE Singers SET LastName='Some Other Last Name' /* It used to be 'Last 1' */ -WHERE SingerId=1 -OR LastName IN ( - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) -; - --- Verify that the record was not updated -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; - - ------------------------------------------------------------------------------------------------------ - --- Repeat test in transactional mode -SET AUTOCOMMIT = FALSE; --- First set the statement timeout to null, which means no timeout -SET STATEMENT_TIMEOUT=null; - -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Do a somewhat complex query that should not timeout -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM ( - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) RES -; - --- Set the statement timeout to 1 nanosecond that should cause basically any statement to timeout -SET STATEMENT_TIMEOUT='1ns'; - -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Do a somewhat complex query that should now timeout -@EXPECT EXCEPTION DEADLINE_EXCEEDED 'DEADLINE_EXCEEDED: Statement execution timeout occurred' -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM ( - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT * - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) RES -; --- We need to rollback the transaction as it is no longer usable. -@EXPECT EXCEPTION DEADLINE_EXCEEDED 'DEADLINE_EXCEEDED: Statement execution timeout occurred' -ROLLBACK; - --- Try to execute an update that should also timeout -@EXPECT EXCEPTION DEADLINE_EXCEEDED 'DEADLINE_EXCEEDED: Statement execution timeout occurred' -UPDATE Singers SET LastName='Some Other Last Name' /* It used to be 'Last 1' */ -WHERE SingerId=1 -OR LastName IN ( - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - UNION ALL - SELECT LastName - FROM Singers - WHERE LastName IN (SELECT AlbumTitle FROM Albums) - OR LastName IN (SELECT CAST(SingerId AS STRING) FROM Singers) - OR FirstName IN (SELECT AlbumTitle FROM Albums) - OR FirstName IN (SELECT CAST(SingerId AS STRING) FROM Singers) -) -; - -/* As we are in a transaction, the statement *could* continue in the background and will not - * automatically be rollbacked by the connection. Whether the statement will continue to - * execute in the background depends on what the reason for the timeout was. If the timeout - * was caused because the statement took too long to execute on the server, the statement - * will continue to run server side. If the timeout was caused by a network problem that - * prevented the statement to be delivered to the server in a timely fashion, the statement - * has never reached the server and hence will not be executed in the background. - * - * It is the responsibility of the user to rollback the transaction. If the user does nothing, - * the transaction will automatically abort server side and the change will not be committed. - */ - --- Now rollback the transaction and verify that there was no permanent change -SET STATEMENT_TIMEOUT=null; -ROLLBACK; - -@EXPECT RESULT_SET -SELECT LastName AS ACTUAL, 'Last 1' AS EXPECTED -FROM Singers -WHERE SingerId=1; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTemporaryTransactions.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTemporaryTransactions.sql deleted file mode 100644 index 2a64a2a09f8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTemporaryTransactions.sql +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Test script for temporary transactions (i.e. autocommit mode with explicit BEGIN [TRANSACTION] statements) - */ - -SET AUTOCOMMIT = TRUE; -SET READONLY = FALSE; - --- Insert a new singer in a temporary transaction and commit -BEGIN; -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (9999, 'First 9999', 'Last 9999'); -COMMIT; - --- Verify that the record is there -@EXPECT RESULT_SET -SELECT FirstName AS ACTUAL, 'First 9999' AS EXPECTED -FROM Singers -WHERE SingerId=9999 -UNION ALL -SELECT LastName AS ACTUAL, 'Last 9999' AS EXPECTED -FROM Singers -WHERE SingerId=9999; - --- Insert another singer in a temporary transaction and rollback -BEGIN; -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (9998, 'First 9998', 'Last 9998'); -ROLLBACK; - --- Verify that the record is not there -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=9998; - --- Delete the initial test record in autocommit mode -@EXPECT UPDATE_COUNT 1 -DELETE FROM Singers -WHERE SingerId=9999; - --- Verify that a rollback is not possible, as we are in autocommit mode -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: This connection has no transaction' -ROLLBACK; - --- Verify that the record has been removed -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=9999; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode.sql deleted file mode 100644 index c89dab4f8d8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode.sql +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script that tests the different possible transaction modes in read-write mode - */ - -SET AUTOCOMMIT = FALSE; -SET READONLY = FALSE; - --- Insert a test record -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (9999, 'First 9999', 'Last 9999'); -COMMIT; - ----------------------------------------- Test read only transactions --------------------------------------------- -SET TRANSACTION READ ONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=9999; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed for read-only transactions' --- try to update a record in a read-only transaction -UPDATE Singers SET FirstName='New First Name' WHERE SingerId=9999; - --- We are in a read-only transaction that has returned a query, so there should be a read-timestamp -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Finish the transaction with a rollback. This removes the read timestamp -ROLLBACK; - --- Read timestamp from the previous transaction should no longer be available as it rolled back -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - --- Start a new read only transaction and SHOW VARIABLE the read timestamp after a commit -SET TRANSACTION READ ONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=9999; - -COMMIT; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Try to execute DDL in a read-only transaction -SET TRANSACTION READ ONLY; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL statements are not allowed for read-only transactions' -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); - -ROLLBACK; - ----------------------------------------- Test read/write transactions --------------------------------------------- -SET TRANSACTION READ WRITE; - -@EXPECT UPDATE_COUNT 1 -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (9998, 'First 9998', 'Last 9998'); - -COMMIT; - --- Verify the existence of the record -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=9998; - -COMMIT; - --- try to delete the record, then rollback the transaction -@EXPECT UPDATE_COUNT 1 -DELETE FROM Singers WHERE SingerId=9998; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 0 AS EXPECTED -FROM Singers -WHERE SingerId=9998; - -ROLLBACK; - --- Verify that the rollback succeeded -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=9998; - --- Try to execute DDL in a read/write transaction -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL-statements are not allowed inside a read/write transaction.' -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); - -ROLLBACK; - ----------------------------------------- Test DDL batches --------------------------------------------- -START BATCH DDL; - --- Verify that queries and updates fail -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Executing queries is not allowed for DDL batches.' -SELECT * -FROM Singers; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Executing updates is not allowed for DDL batches.' -UPDATE Singers SET LastName='Foo'; - --- Verify that DDL statements are allowed -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); -alter table FOO add column bar timestamp; -RUN BATCH; - --- Verify the existence of the table and the column -SET AUTOCOMMIT = TRUE; -@EXPECT RESULT_SET -SELECT TABLE_NAME AS ACTUAL, 'FOO' AS EXPECTED -FROM INFORMATION_SCHEMA.TABLES -WHERE TABLE_NAME='FOO'; - -@EXPECT RESULT_SET -SELECT COLUMN_NAME AS ACTUAL, 'bar' AS EXPECTED -FROM INFORMATION_SCHEMA.COLUMNS -WHERE TABLE_NAME='FOO' AND COLUMN_NAME='bar'; - -SET AUTOCOMMIT = FALSE; - --- Remove the table -START BATCH DDL; -DROP TABLE FOO; -RUN BATCH; - --- Remove the test records -@EXPECT UPDATE_COUNT 2 -DELETE FROM Singers WHERE SingerId IN (9999, 9998); -COMMIT; \ No newline at end of file diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode_ReadOnly.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode_ReadOnly.sql deleted file mode 100644 index edd213ff607..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITSqlScriptTest_TestTransactionMode_ReadOnly.sql +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -/* - * Script that tests the different possible transaction modes in read-only mode - */ - -SET AUTOCOMMIT = FALSE; -SET READONLY = TRUE; - --- Verify that trying to insert a test record will fail -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed for read-only transactions' -INSERT INTO Singers (SingerId, FirstName, LastName) -VALUES (9999, 'First 9999', 'Last 9999'); -COMMIT; - ----------------------------------------- Test read only transactions --------------------------------------------- -SET TRANSACTION READ ONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=1; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Update statements are not allowed for read-only transactions' --- try to update a record in a read-only transaction -UPDATE Singers SET FirstName='New First Name' WHERE SingerId=9999; - --- We are in a read-only transaction that has returned a query, so there should be a read-timestamp -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Finish the transaction with a rollback. This removes the read timestamp -ROLLBACK; - --- Read timestamp from the previous transaction should no longer be available as it rolled back -@EXPECT RESULT_SET 'READ_TIMESTAMP',null -SHOW VARIABLE READ_TIMESTAMP; - --- Start a new read only transaction and SHOW VARIABLE the read timestamp after a commit -SET TRANSACTION READ ONLY; - -@EXPECT RESULT_SET -SELECT COUNT(*) AS ACTUAL, 1 AS EXPECTED -FROM Singers -WHERE SingerId=1; - -COMMIT; - -@EXPECT RESULT_SET 'READ_TIMESTAMP' -SHOW VARIABLE READ_TIMESTAMP; - --- Try to execute DDL in a read-only transaction -SET TRANSACTION READ ONLY; - -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: DDL statements are not allowed for read-only transactions' -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100)) PRIMARY KEY (ID); - -ROLLBACK; - ----------------------------------------- Test read/write transactions --------------------------------------------- -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: The transaction mode can only be READ_ONLY when the connection is in read_only mode' -SET TRANSACTION READ WRITE; - ----------------------------------------- Test DDL batches --------------------------------------------- -@EXPECT EXCEPTION FAILED_PRECONDITION 'FAILED_PRECONDITION: Cannot start a DDL batch when the connection is in read-only mode' -START BATCH DDL; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITTransactionModeTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITTransactionModeTest.sql deleted file mode 100644 index 7bb0f80943a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/ITTransactionModeTest.sql +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -NEW_CONNECTION; - --- Test that DDL statements are allowed in DDL batches -START BATCH DDL; - --- Try to execute a DDL statement -@EXPECT NO_RESULT -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100) PRIMARY KEY (ID); --- Abort batch as creating a table takes quite some time -ABORT BATCH; - - -NEW_CONNECTION; - --- Test that DDL statements are not allowed in read/write transactions -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; -@EXPECT RESULT_SET 'READONLY',false -SHOW VARIABLE READONLY; - -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100) PRIMARY KEY (ID); - - -NEW_CONNECTION; - --- Test that DDL statements are not allowed in read-only transactions -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; - -@EXPECT EXCEPTION FAILED_PRECONDITION -CREATE TABLE FOO (ID INT64 NOT NULL, NAME STRING(100) PRIMARY KEY (ID); - - -NEW_CONNECTION; - --- Test that DML statements are allowed in read/write transactions -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; -@EXPECT RESULT_SET 'READONLY',false -SHOW VARIABLE READONLY; - -@EXPECT UPDATE_COUNT 1 -INSERT INTO TEST (ID, NAME) VALUES (1, 'TEST'); -@EXPECT UPDATE_COUNT 1 -UPDATE TEST SET NAME='TEST2' WHERE ID=1; -@EXPECT UPDATE_COUNT 1 -DELETE FROM TEST WHERE ID=1; -COMMIT; - - -NEW_CONNECTION; - --- Test that DML statements are not allowed in read-only transactions -SET TRANSACTION READ ONLY; -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; - -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE FOO SET BAR=1 WHERE ID=2; - - -NEW_CONNECTION; - --- Test that DML statements are not allowed in DDL batches -START BATCH DDL; - -@EXPECT EXCEPTION FAILED_PRECONDITION -UPDATE FOO SET BAR=1 WHERE ID=2; - - -NEW_CONNECTION; - --- Test that queries are allowed in read/write transactions -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; - -SELECT * FROM TEST; - - -NEW_CONNECTION; - --- Test that queries are allowed in read-only transactions -@EXPECT RESULT_SET 'AUTOCOMMIT',false -SHOW VARIABLE AUTOCOMMIT; -SET TRANSACTION READ ONLY; - -SELECT * FROM TEST; - - -NEW_CONNECTION; - --- Test that queries are not allowed in DDL batches -START BATCH DDL; - -@EXPECT EXCEPTION FAILED_PRECONDITION -SELECT * FROM TEST; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessTest.sql deleted file mode 100644 index e545753c34e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetReadOnlyStalenessTest.sql +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - --- Test valid values for strong -SET READ_ONLY_STALENESS='strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS='STRONG'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS='Strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS = 'strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS = 'strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS -= -'strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS='strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; -SET READ_ONLY_STALENESS='strong'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','STRONG' -SHOW VARIABLE READ_ONLY_STALENESS; - --- Test invalid values for strong -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='strongg'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='sstrong'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='strng'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' strong'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='strong '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' strong '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' strong'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='strong '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' strong '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=strong; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS="strong"; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=`strong`; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='''strong'''; - - --- Test valid values for min_read_timestamp -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='Min_Read_Timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2000-02-29T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2000-02-29T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2004-02-29T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2004-02-29T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+01:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T12:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01-01:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T14:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+06:30'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-07T07:06:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+24:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2018-12-06T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - - --- Test invalid values for min_read_timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestampp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='mmin_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_red_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min read timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min-read-timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min%read%timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' min_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' min_read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' min_read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' min_read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=min_read_timestamp 2018-12-07T13:36:00.01Z; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS="min_read_timestamp 2018-12-07T13:36:00.01Z"; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=`min_read_timestamp 2018-12-07T13:36:00.01Z`; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='''min_read_timestamp 2018-12-07T13:36:00.01Z'''; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07 13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T3:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.9999999999Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-7T13:36:00.01Z'; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+8'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+08'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+08:0'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.0108:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+08:00.0'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+08:000'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01+100:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01*08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01%08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01 08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='min_read_timestamp 2018-12-07T13:36:00.01Z+08:00'; - - - - --- Test valid values for read_timestamp -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='Read_Timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2000-02-29T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2000-02-29T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2004-02-29T13:36:00.01Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2004-02-29T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2019-01-01T00:00:00Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2019-01-01T00:00:00Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+01:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T12:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01-01:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T14:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+06:30'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-07T07:06:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+24:00'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2018-12-06T13:36:00.010000000Z' -SHOW VARIABLE READ_ONLY_STALENESS; - - --- Test invalid values for read_timestamp -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestampp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='mread_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='red_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read-timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read%timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' read_timestamp 2018-12-07T13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' read_timestamp 2018-12-07T13:36:00.01Z '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=read_timestamp 2018-12-07T13:36:00.01Z; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS="read_timestamp 2018-12-07T13:36:00.01Z"; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=`read_timestamp 2018-12-07T13:36:00.01Z`; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='''read_timestamp 2018-12-07T13:36:00.01Z'''; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07 13:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T3:36:00.01Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.9999999999Z'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-7T13:36:00.01Z'; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+8'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+08'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+08:0'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.0108:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+08:00.0'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+08:000'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01+100:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01*08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01%08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01 08:00'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='read_timestamp 2018-12-07T13:36:00.01Z+08:00'; - - --- Test valid values for exact_staleness -SET READ_ONLY_STALENESS='exact_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='Exact_Staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1ns' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 9999s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 9999s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1000ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1001ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1001ms' -SHOW VARIABLE READ_ONLY_STALENESS; - - -SET READ_ONLY_STALENESS='exact_staleness 1000us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1001us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1001us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1000ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='exact_staleness 1001ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','EXACT_STALENESS 1001ns' -SHOW VARIABLE READ_ONLY_STALENESS; - - --- Test invalid values for exact_staleness -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_stalenesss 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='eexact_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exct_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact-staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact%staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' exact_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' exact_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' exact_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' exact_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=exact_staleness 10s; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS="exact_staleness 10s"; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=`exact_staleness 10s`; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='''exact_staleness 10s'''; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness 10'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness 10mus'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness 999999999999s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness not_a_number'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='exact_staleness'; - - - --- Test valid values for max_staleness -SET READ_ONLY_STALENESS='max_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_Staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_STALENESS 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1ns' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 9999s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 9999s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 10s'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 10s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1000ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1s' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1001ms'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1001ms' -SHOW VARIABLE READ_ONLY_STALENESS; - - -SET READ_ONLY_STALENESS='max_staleness 1000us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1ms' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1001us'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1001us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1000ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1us' -SHOW VARIABLE READ_ONLY_STALENESS; - -SET READ_ONLY_STALENESS='max_staleness 1001ns'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MAX_STALENESS 1001ns' -SHOW VARIABLE READ_ONLY_STALENESS; - - --- Test invalid values for max_staleness -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_stalenesss 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='emax_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='mx_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max-staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max%staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' max_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' max_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' max_staleness 10s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=' max_staleness 10s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=max_staleness 10s; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS="max_staleness 10s"; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS=`max_staleness 10s`; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='''max_staleness 10s'''; - -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness 10'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness 10mus'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness 999999999999s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness not_a_number'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET READ_ONLY_STALENESS='max_staleness'; - diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetStatementTimeoutTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetStatementTimeoutTest.sql deleted file mode 100644 index d74be83acf4..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/SetStatementTimeoutTest.sql +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - --- Test valid values --- Null (no timeout) -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Seconds -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT = '2s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','2s' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1S'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Milliseconds -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1Ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1mS'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1MS'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Microseconds -SET STATEMENT_TIMEOUT='1us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1Us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1uS'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1US'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Nanoseconds -SET STATEMENT_TIMEOUT='1ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1Ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1nS'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1NS'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - --- Test flip to higher time unit -SET STATEMENT_TIMEOUT='1000ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1us' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1001ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1001ns' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1000us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1001us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1001us' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1000ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1001ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1001ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1000000ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1000000000ns'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; - -SET STATEMENT_TIMEOUT='1000000us'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; - - --- Invalid suffixes -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1m'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1mi'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1h'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1mus'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1n'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1u'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1'; - --- Invalid numbers -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='-1s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='a1s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0xas'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0x1s'; - --- Invalid because of spaces -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1 s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT=' 1s'; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1s '; -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='1m s'; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/TimeoutSqlScriptTest.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/TimeoutSqlScriptTest.sql deleted file mode 100644 index 06dc96fb869..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/TimeoutSqlScriptTest.sql +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - --- check that the default is null -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; --- set a new value -SET STATEMENT_TIMEOUT='1000ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; --- do a simple select and verify that the timeout does not change -SELECT 1 AS TEST; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; --- set a value that contains a fraction of a second -SET STATEMENT_TIMEOUT='1800ms'; --- check that the jdbc driver reports the value that is set, although under water the JDBC connection will round it to a whole second -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1800ms' -SHOW VARIABLE STATEMENT_TIMEOUT; --- set a value that is just above a whole second -SET STATEMENT_TIMEOUT='1ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1ms' -SHOW VARIABLE STATEMENT_TIMEOUT; --- set a value that contains a whole second -SET STATEMENT_TIMEOUT='3s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','3s' -SHOW VARIABLE STATEMENT_TIMEOUT; --- set a value to a higher value -SET STATEMENT_TIMEOUT='2999ms'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','2999ms' -SHOW VARIABLE STATEMENT_TIMEOUT; --- Check that setting the value to 0 is not allowed -@EXPECT EXCEPTION INVALID_ARGUMENT -SET STATEMENT_TIMEOUT='0s'; --- Set a timeout value and then reset it to null -SET STATEMENT_TIMEOUT='1s'; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT','1s' -SHOW VARIABLE STATEMENT_TIMEOUT; -SET STATEMENT_TIMEOUT=null; -@EXPECT RESULT_SET 'STATEMENT_TIMEOUT',null -SHOW VARIABLE STATEMENT_TIMEOUT; diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Albums.txt b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Albums.txt deleted file mode 100644 index 0cf7eafedf8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Albums.txt +++ /dev/null @@ -1,60 +0,0 @@ -(1,1,"Album 1",980045); -(2,2,"Album 2",667788); -(3,3,"Album 3",908791); -(4,4,"Album 4",690335); -(5,5,"Album 5",133041); -(6,6,"Album 6",505292); -(7,7,"Album 7",91969); -(8,8,"Album 8",289965); -(9,9,"Album 9",78176); -(10,10,"Album 10",485664); -(11,11,"Album 11",972680); -(12,12,"Album 12",893680); -(13,13,"Album 13",892138); -(14,14,"Album 14",449562); -(15,15,"Album 15",150968); -(16,16,"Album 16",580377); -(17,17,"Album 17",763081); -(18,18,"Album 18",203427); -(19,19,"Album 19",995368); -(20,20,"Album 20",29900); -(21,21,"Album 21",723728); -(22,22,"Album 22",540582); -(23,23,"Album 23",784245); -(24,24,"Album 24",614788); -(25,25,"Album 25",275649); -(26,26,"Album 26",970898); -(27,27,"Album 27",409289); -(28,28,"Album 28",766560); -(29,29,"Album 29",32414); -(30,30,"Album 30",457957); -(1,31,"Album 31",52546); -(2,32,"Album 32",412424); -(3,33,"Album 33",568496); -(4,34,"Album 34",353491); -(5,35,"Album 35",489951); -(6,36,"Album 36",75938); -(7,37,"Album 37",460461); -(8,38,"Album 38",642042); -(9,39,"Album 39",282872); -(10,40,"Album 40",521496); -(11,41,"Album 41",98126); -(12,42,"Album 42",535113); -(13,43,"Album 43",957625); -(14,44,"Album 44",667630); -(15,45,"Album 45",236968); -(16,46,"Album 46",445647); -(17,47,"Album 47",446396); -(18,48,"Album 48",852859); -(19,49,"Album 49",404105); -(20,50,"Album 50",384439); -(21,51,"Album 51",440468); -(22,52,"Album 52",455384); -(23,53,"Album 53",210756); -(24,54,"Album 54",849113); -(25,55,"Album 55",63969); -(26,56,"Album 56",277122); -(27,57,"Album 57",350063); -(28,58,"Album 58",359473); -(29,59,"Album 59",209825); -(30,60,"Album 60",84543); diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Concerts.txt b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Concerts.txt deleted file mode 100644 index 2e53d92ccaf..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Concerts.txt +++ /dev/null @@ -1,100 +0,0 @@ -(1,1,DATE '2003-06-19',TIMESTAMP '2003-06-19T12:30:05Z',TIMESTAMP '2003-06-19T18:57:15Z',[11,93,140,923]); -(2,18,DATE '2004-01-25',TIMESTAMP '2004-01-25T14:58:28Z',TIMESTAMP '2004-01-26T01:10:52Z',[18,51,101,812]); -(3,21,DATE '2005-03-15',TIMESTAMP '2005-03-15T18:14:50Z',TIMESTAMP '2005-03-16T02:21:28Z',[23,26,107,721]); -(4,16,DATE '2009-05-09',TIMESTAMP '2009-05-09T05:22:34Z',TIMESTAMP '2009-05-09T15:28:28Z',[18,70,150,297]); -(5,11,DATE '2001-01-07',TIMESTAMP '2001-01-07T18:37:33Z',TIMESTAMP '2001-01-07T21:22:17Z',[20,55,185,672]); -(6,25,DATE '2015-11-19',TIMESTAMP '2015-11-19T22:47:42Z',TIMESTAMP '2015-11-20T02:54:01Z',[12,73,150,833]); -(7,26,DATE '2012-10-06',TIMESTAMP '2012-10-06T10:58:43Z',TIMESTAMP '2012-10-06T15:35:40Z',[8,83,199,625]); -(8,8,DATE '2001-09-26',TIMESTAMP '2001-09-26T06:41:20Z',TIMESTAMP '2001-09-26T16:38:35Z',[19,87,192,912]); -(9,27,DATE '2016-11-24',TIMESTAMP '2016-11-24T20:00:48Z',TIMESTAMP '2016-11-24T23:03:07Z',[20,84,134,885]); -(10,30,DATE '2017-05-05',TIMESTAMP '2017-05-05T12:44:05Z',TIMESTAMP '2017-05-05T23:06:55Z',[17,44,177,997]); -(11,7,DATE '2018-06-07',TIMESTAMP '2018-06-07T07:03:11Z',TIMESTAMP '2018-06-07T08:21:41Z',[10,73,182,287]); -(12,22,DATE '2009-01-07',TIMESTAMP '2009-01-07T23:22:11Z',TIMESTAMP '2009-01-08T08:34:18Z',[22,59,150,983]); -(13,16,DATE '2013-06-28',TIMESTAMP '2013-06-28T14:59:25Z',TIMESTAMP '2013-06-28T22:32:11Z',[17,41,129,433]); -(14,11,DATE '2005-08-19',TIMESTAMP '2005-08-19T01:11:28Z',TIMESTAMP '2005-08-19T01:30:30Z',[18,49,110,590]); -(15,18,DATE '2001-11-26',TIMESTAMP '2001-11-26T15:55:31Z',TIMESTAMP '2001-11-26T20:52:13Z',[18,51,132,854]); -(16,26,DATE '2009-01-04',TIMESTAMP '2009-01-04T03:09:11Z',TIMESTAMP '2009-01-04T12:02:14Z',[5,37,146,344]); -(17,20,DATE '2012-09-28',TIMESTAMP '2012-09-28T00:45:00Z',TIMESTAMP '2012-09-28T02:10:39Z',[15,89,185,480]); -(18,24,DATE '2004-09-06',TIMESTAMP '2004-09-06T09:55:40Z',TIMESTAMP '2004-09-06T18:10:32Z',[23,51,113,244]); -(19,21,DATE '2010-11-18',TIMESTAMP '2010-11-18T09:59:17Z',TIMESTAMP '2010-11-18T17:13:12Z',[14,69,164,218]); -(20,29,DATE '2010-12-24',TIMESTAMP '2010-12-24T04:21:25Z',TIMESTAMP '2010-12-24T06:10:08Z',[20,34,166,573]); -(21,3,DATE '2000-05-14',TIMESTAMP '2000-05-14T13:49:08Z',TIMESTAMP '2000-05-14T14:39:25Z',[21,67,136,779]); -(22,18,DATE '2000-05-14',TIMESTAMP '2000-05-14T00:23:23Z',TIMESTAMP '2000-05-14T01:20:04Z',[21,91,111,749]); -(23,26,DATE '2015-05-04',TIMESTAMP '2015-05-04T10:39:46Z',TIMESTAMP '2015-05-04T19:21:45Z',[24,91,128,559]); -(24,16,DATE '2012-08-18',TIMESTAMP '2012-08-18T08:47:12Z',TIMESTAMP '2012-08-18T09:35:03Z',[19,44,136,281]); -(25,4,DATE '2000-03-16',TIMESTAMP '2000-03-16T10:15:15Z',TIMESTAMP '2000-03-16T12:29:53Z',[22,28,111,948]); -(26,4,DATE '2002-11-20',TIMESTAMP '2002-11-20T16:28:19Z',TIMESTAMP '2002-11-20T17:56:10Z',[7,70,141,517]); -(27,23,DATE '2000-08-09',TIMESTAMP '2000-08-09T04:30:51Z',TIMESTAMP '2000-08-09T15:27:15Z',[13,98,156,230]); -(28,16,DATE '2000-10-15',TIMESTAMP '2000-10-15T04:12:39Z',TIMESTAMP '2000-10-15T14:07:05Z',[8,39,160,455]); -(29,22,DATE '2003-03-25',TIMESTAMP '2003-03-25T17:21:56Z',TIMESTAMP '2003-03-25T19:18:25Z',[17,70,148,681]); -(30,15,DATE '2008-11-11',TIMESTAMP '2008-11-11T22:56:07Z',TIMESTAMP '2008-11-12T09:33:48Z',[24,47,175,901]); -(31,7,DATE '2018-05-22',TIMESTAMP '2018-05-22T20:54:59Z',TIMESTAMP '2018-05-23T02:52:28Z',[13,34,177,804]); -(32,30,DATE '2000-04-03',TIMESTAMP '2000-04-03T13:54:10Z',TIMESTAMP '2000-04-03T15:57:02Z',[16,48,137,249]); -(33,23,DATE '2003-12-24',TIMESTAMP '2003-12-24T22:22:00Z',TIMESTAMP '2003-12-25T06:09:40Z',[15,36,131,922]); -(34,12,DATE '2012-06-23',TIMESTAMP '2012-06-23T18:15:30Z',TIMESTAMP '2012-06-24T03:46:17Z',[25,31,160,564]); -(35,5,DATE '2017-12-15',TIMESTAMP '2017-12-15T09:43:38Z',TIMESTAMP '2017-12-15T17:18:28Z',[22,31,177,868]); -(36,20,DATE '2012-12-21',TIMESTAMP '2012-12-21T08:28:14Z',TIMESTAMP '2012-12-21T11:34:59Z',[25,62,143,437]); -(37,19,DATE '2014-07-07',TIMESTAMP '2014-07-07T22:01:35Z',TIMESTAMP '2014-07-08T04:39:37Z',[8,31,184,784]); -(38,15,DATE '2012-07-26',TIMESTAMP '2012-07-26T09:45:35Z',TIMESTAMP '2012-07-26T13:03:53Z',[19,79,140,908]); -(39,24,DATE '2014-03-19',TIMESTAMP '2014-03-19T07:52:25Z',TIMESTAMP '2014-03-19T11:47:01Z',[11,90,141,978]); -(40,4,DATE '2015-08-26',TIMESTAMP '2015-08-26T20:51:25Z',TIMESTAMP '2015-08-27T07:06:46Z',[15,94,195,510]); -(41,24,DATE '2016-04-11',TIMESTAMP '2016-04-11T08:59:07Z',TIMESTAMP '2016-04-11T13:23:30Z',[15,51,173,233]); -(42,18,DATE '2005-03-19',TIMESTAMP '2005-03-19T15:45:04Z',TIMESTAMP '2005-03-19T16:28:42Z',[19,31,188,546]); -(43,7,DATE '2001-01-04',TIMESTAMP '2001-01-04T11:02:16Z',TIMESTAMP '2001-01-04T11:32:21Z',[20,37,133,958]); -(44,5,DATE '2015-12-24',TIMESTAMP '2015-12-24T06:49:48Z',TIMESTAMP '2015-12-24T14:46:46Z',[12,61,175,233]); -(45,12,DATE '2011-08-24',TIMESTAMP '2011-08-24T03:45:46Z',TIMESTAMP '2011-08-24T06:13:10Z',[18,38,169,913]); -(46,16,DATE '2017-03-04',TIMESTAMP '2017-03-04T04:01:04Z',TIMESTAMP '2017-03-04T13:44:38Z',[21,79,119,839]); -(47,18,DATE '2009-05-19',TIMESTAMP '2009-05-19T23:10:52Z',TIMESTAMP '2009-05-20T04:02:01Z',[25,79,151,357]); -(48,22,DATE '2003-10-03',TIMESTAMP '2003-10-03T14:10:24Z',TIMESTAMP '2003-10-03T17:35:09Z',[18,60,140,450]); -(49,9,DATE '2003-03-07',TIMESTAMP '2003-03-07T22:09:59Z',TIMESTAMP '2003-03-08T08:28:29Z',[22,41,122,726]); -(50,9,DATE '2015-07-12',TIMESTAMP '2015-07-12T07:43:51Z',TIMESTAMP '2015-07-12T12:45:20Z',[18,67,126,474]); -(51,12,DATE '2014-11-05',TIMESTAMP '2014-11-05T19:03:00Z',TIMESTAMP '2014-11-06T05:27:07Z',[19,43,125,865]); -(52,6,DATE '2016-07-25',TIMESTAMP '2016-07-25T14:39:28Z',TIMESTAMP '2016-07-26T00:36:03Z',[6,74,192,344]); -(53,13,DATE '2005-08-02',TIMESTAMP '2005-08-02T16:06:47Z',TIMESTAMP '2005-08-02T17:13:41Z',[5,52,192,977]); -(54,18,DATE '2010-01-25',TIMESTAMP '2010-01-25T07:34:54Z',TIMESTAMP '2010-01-25T16:29:11Z',[24,85,181,304]); -(55,14,DATE '2012-05-20',TIMESTAMP '2012-05-20T13:15:12Z',TIMESTAMP '2012-05-20T17:40:09Z',[15,43,104,665]); -(56,3,DATE '2013-09-08',TIMESTAMP '2013-09-08T19:53:42Z',TIMESTAMP '2013-09-08T22:32:52Z',[14,81,129,354]); -(57,27,DATE '2003-07-18',TIMESTAMP '2003-07-18T23:11:24Z',TIMESTAMP '2003-07-19T03:29:46Z',[21,85,188,854]); -(58,27,DATE '2001-04-10',TIMESTAMP '2001-04-10T08:36:49Z',TIMESTAMP '2001-04-10T16:17:57Z',[17,86,161,438]); -(59,2,DATE '2002-07-02',TIMESTAMP '2002-07-02T17:32:20Z',TIMESTAMP '2002-07-03T01:59:33Z',[23,59,164,357]); -(60,28,DATE '2000-11-24',TIMESTAMP '2000-11-24T12:53:25Z',TIMESTAMP '2000-11-24T22:37:53Z',[22,47,161,739]); -(61,12,DATE '2017-07-04',TIMESTAMP '2017-07-04T21:02:01Z',TIMESTAMP '2017-07-05T03:57:29Z',[16,88,179,478]); -(62,3,DATE '2015-10-07',TIMESTAMP '2015-10-07T17:58:42Z',TIMESTAMP '2015-10-07T21:04:38Z',[21,44,155,381]); -(63,23,DATE '2005-05-03',TIMESTAMP '2005-05-03T15:08:10Z',TIMESTAMP '2005-05-03T20:58:30Z',[20,43,111,824]); -(64,24,DATE '2012-12-09',TIMESTAMP '2012-12-09T02:52:09Z',TIMESTAMP '2012-12-09T08:01:11Z',[18,87,106,997]); -(65,30,DATE '2004-03-01',TIMESTAMP '2004-03-01T07:09:06Z',TIMESTAMP '2004-03-01T07:49:32Z',[14,26,195,895]); -(66,24,DATE '2007-05-19',TIMESTAMP '2007-05-19T10:20:57Z',TIMESTAMP '2007-05-19T15:21:09Z',[18,54,179,238]); -(67,16,DATE '2016-01-06',TIMESTAMP '2016-01-06T21:32:20Z',TIMESTAMP '2016-01-07T02:31:32Z',[20,61,120,652]); -(68,2,DATE '2007-10-26',TIMESTAMP '2007-10-26T03:37:22Z',TIMESTAMP '2007-10-26T10:02:36Z',[11,65,151,537]); -(69,2,DATE '2018-08-11',TIMESTAMP '2018-08-11T01:33:38Z',TIMESTAMP '2018-08-11T07:39:21Z',[10,98,105,621]); -(70,23,DATE '2012-07-06',TIMESTAMP '2012-07-06T01:02:23Z',TIMESTAMP '2012-07-06T05:04:16Z',[14,44,172,953]); -(71,7,DATE '2006-01-24',TIMESTAMP '2006-01-24T15:32:10Z',TIMESTAMP '2006-01-24T17:40:43Z',[9,58,150,713]); -(72,8,DATE '2002-11-06',TIMESTAMP '2002-11-06T05:58:03Z',TIMESTAMP '2002-11-06T07:43:24Z',[25,36,193,213]); -(73,10,DATE '2003-11-24',TIMESTAMP '2003-11-24T17:39:10Z',TIMESTAMP '2003-11-25T03:17:36Z',[8,55,200,352]); -(74,16,DATE '2007-11-03',TIMESTAMP '2007-11-03T05:49:12Z',TIMESTAMP '2007-11-03T16:34:16Z',[21,50,114,820]); -(75,4,DATE '2009-05-06',TIMESTAMP '2009-05-06T18:52:07Z',TIMESTAMP '2009-05-06T21:10:02Z',[16,42,101,281]); -(76,1,DATE '2012-12-03',TIMESTAMP '2012-12-03T06:01:05Z',TIMESTAMP '2012-12-03T06:45:00Z',[24,60,140,292]); -(77,1,DATE '2016-11-26',TIMESTAMP '2016-11-26T01:19:27Z',TIMESTAMP '2016-11-26T07:20:17Z',[19,31,123,214]); -(78,9,DATE '2018-05-21',TIMESTAMP '2018-05-21T00:14:43Z',TIMESTAMP '2018-05-21T08:43:35Z',[7,28,115,634]); -(79,14,DATE '2013-11-20',TIMESTAMP '2013-11-20T08:54:47Z',TIMESTAMP '2013-11-20T10:44:54Z',[18,39,155,328]); -(80,17,DATE '2015-10-11',TIMESTAMP '2015-10-11T23:41:17Z',TIMESTAMP '2015-10-12T02:42:48Z',[16,94,102,894]); -(81,23,DATE '2011-08-07',TIMESTAMP '2011-08-07T19:33:01Z',TIMESTAMP '2011-08-07T21:51:53Z',[23,90,134,370]); -(82,7,DATE '2010-04-10',TIMESTAMP '2010-04-10T13:22:08Z',TIMESTAMP '2010-04-10T17:59:08Z',[18,68,121,303]); -(83,27,DATE '2001-07-08',TIMESTAMP '2001-07-08T20:19:54Z',TIMESTAMP '2001-07-08T22:46:15Z',[18,86,148,746]); -(84,6,DATE '2017-09-02',TIMESTAMP '2017-09-02T10:29:03Z',TIMESTAMP '2017-09-02T13:06:41Z',[12,85,138,471]); -(85,1,DATE '2013-11-02',TIMESTAMP '2013-11-02T04:01:03Z',TIMESTAMP '2013-11-02T14:08:47Z',[9,65,111,583]); -(86,22,DATE '2004-04-03',TIMESTAMP '2004-04-03T19:13:48Z',TIMESTAMP '2004-04-04T05:59:31Z',[19,72,105,908]); -(87,2,DATE '2012-02-26',TIMESTAMP '2012-02-26T22:52:21Z',TIMESTAMP '2012-02-27T02:55:24Z',[16,75,129,740]); -(88,9,DATE '2017-09-17',TIMESTAMP '2017-09-17T11:28:49Z',TIMESTAMP '2017-09-17T12:13:03Z',[24,77,182,755]); -(89,11,DATE '2011-03-28',TIMESTAMP '2011-03-28T13:05:23Z',TIMESTAMP '2011-03-28T16:32:29Z',[22,96,174,731]); -(90,21,DATE '2006-12-12',TIMESTAMP '2006-12-12T20:44:10Z',TIMESTAMP '2006-12-12T22:10:34Z',[15,68,166,616]); -(91,27,DATE '2010-08-18',TIMESTAMP '2010-08-18T05:49:35Z',TIMESTAMP '2010-08-18T12:58:36Z',[12,84,157,369]); -(92,2,DATE '2003-02-03',TIMESTAMP '2003-02-03T11:19:43Z',TIMESTAMP '2003-02-03T22:10:42Z',[25,59,140,939]); -(93,5,DATE '2016-01-04',TIMESTAMP '2016-01-04T08:10:26Z',TIMESTAMP '2016-01-04T13:08:30Z',[5,90,163,272]); -(94,3,DATE '2018-04-20',TIMESTAMP '2018-04-20T07:19:52Z',TIMESTAMP '2018-04-20T17:41:01Z',[5,59,109,854]); -(95,19,DATE '2016-10-09',TIMESTAMP '2016-10-09T17:02:59Z',TIMESTAMP '2016-10-09T17:37:27Z',[6,35,176,442]); -(96,9,DATE '2007-06-12',TIMESTAMP '2007-06-12T16:50:12Z',TIMESTAMP '2007-06-12T19:27:30Z',[7,49,169,729]); -(97,29,DATE '2012-11-25',TIMESTAMP '2012-11-25T20:40:30Z',TIMESTAMP '2012-11-25T21:29:50Z',[12,35,128,269]); -(98,11,DATE '2013-10-22',TIMESTAMP '2013-10-22T03:26:36Z',TIMESTAMP '2013-10-22T06:42:42Z',[14,49,148,726]); -(99,10,DATE '2006-05-10',TIMESTAMP '2006-05-10T05:49:43Z',TIMESTAMP '2006-05-10T07:12:18Z',[5,67,131,360]); -(100,18,DATE '2015-02-15',TIMESTAMP '2015-02-15T01:18:05Z',TIMESTAMP '2015-02-15T04:19:27Z',[11,38,127,909]); diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/CreateMusicTables.sql b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/CreateMusicTables.sql deleted file mode 100644 index 896b8b9cbf2..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/CreateMusicTables.sql +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 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 - * - * http://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. - */ - -START BATCH DDL; - -CREATE TABLE Singers ( - SingerId INT64 NOT NULL, - FirstName STRING(1024), - LastName STRING(1024), - SingerInfo BYTES(MAX), - BirthDate DATE -) PRIMARY KEY(SingerId); - -CREATE INDEX SingersByFirstLastName ON Singers(FirstName, LastName); - -CREATE TABLE Albums ( - SingerId INT64 NOT NULL, - AlbumId INT64 NOT NULL, - AlbumTitle STRING(MAX), - MarketingBudget INT64 -) PRIMARY KEY(SingerId, AlbumId), - INTERLEAVE IN PARENT Singers ON DELETE CASCADE; - -CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle); - -CREATE INDEX AlbumsByAlbumTitle2 ON Albums(AlbumTitle) STORING (MarketingBudget); - -CREATE TABLE Songs ( - SingerId INT64 NOT NULL, - AlbumId INT64 NOT NULL, - TrackId INT64 NOT NULL, - SongName STRING(MAX), - Duration INT64, - SongGenre STRING(25) -) PRIMARY KEY(SingerId, AlbumId, TrackId), - INTERLEAVE IN PARENT Albums ON DELETE CASCADE; - -CREATE UNIQUE INDEX SongsBySingerAlbumSongNameDesc ON Songs(SingerId, AlbumId, SongName DESC), INTERLEAVE IN Albums; - -CREATE INDEX SongsBySongName ON Songs(SongName); - -CREATE TABLE Concerts ( - VenueId INT64 NOT NULL, - SingerId INT64 NOT NULL, - ConcertDate DATE NOT NULL, - BeginTime TIMESTAMP, - EndTime TIMESTAMP, - TicketPrices ARRAY -) PRIMARY KEY(VenueId, SingerId, ConcertDate); - -CREATE TABLE TableWithAllColumnTypes ( - ColInt64 INT64 NOT NULL, - ColFloat64 FLOAT64 NOT NULL, - ColBool BOOL NOT NULL, - ColString STRING(100) NOT NULL, - ColStringMax STRING(MAX) NOT NULL, - ColBytes BYTES(100) NOT NULL, - ColBytesMax BYTES(MAX) NOT NULL, - ColDate DATE NOT NULL, - ColTimestamp TIMESTAMP NOT NULL, - ColCommitTS TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true), - - ColInt64Array ARRAY, - ColFloat64Array ARRAY, - ColBoolArray ARRAY, - ColStringArray ARRAY, - ColStringMaxArray ARRAY, - ColBytesArray ARRAY, - ColBytesMaxArray ARRAY, - ColDateArray ARRAY, - ColTimestampArray ARRAY -) PRIMARY KEY (ColInt64) -; - -RUN BATCH; \ No newline at end of file diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Singers.txt b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Singers.txt deleted file mode 100644 index 939873de17e..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Singers.txt +++ /dev/null @@ -1,30 +0,0 @@ -(1,'First 1','A Last 1',FROM_BASE64('5KckBUgBLuj+nlmI0WXBEA0TCSeOK8x/B35kzIIHC01YrF8CNTjRT8hVQ4T0NkVGZjz96bF68aBu4QQ9VlZ/EhX22++vPADslt5YdqFzJjdxhlbGCufKIbrCVn1Po5u+j46SaV1TAHffIGfsAY0lhHJNmRS2P4p2/CGWJas4bzEo/Fn/JxuKF/et1LXgmlShOiE+LbnysvjbDt7GcbL7mA=='),DATE '1906-04-28'); -(2,'First 2','ALast 2',FROM_BASE64('1uLrsGLZS2BUfLGU0CLO9lgDau+TfX/XYK0RyEKvwgWdm3f0mbt4vbLziTn7iY/fM5OeGoeNZneQFWJoAY1XimD4aFDcQlIkkUxaXHFbOik4KNc/OiQMNaLghXtyaTP+UEaHX7o3w7iCp/wjzljEsnaYZxYTKY8Nm6JfKSwXvP1xHXi0KpaCdLf/V/8Vg102CNqqR4fgFwLy3/5QLxbGAg=='),DATE '1922-11-17'); -(3,'First 3','A Last 3',FROM_BASE64('Mc3i5IYbAWfrpZbCa8R2IXsK2DM0zW8mCx58tMClAPvIKktEIOh/HEl3l6qnJ8FPqp17E+PYZsplE9Hxu0LV9N1inR4TO+my3h9Vq72BA6hoSHmo2mxhRSF+iUL3TrC+MalcKPZuKnmI48RRfKoIrwP0Am1iqXWhhpOMo+zHDVL40FsbDIDW7zezTjyxPmwryF9I5vF+t1j8B5NKPA8Gnw=='),DATE '1935-11-08'); -(4,'First 4','A Last 4',FROM_BASE64('FyMiT7GA1pQzfrf/SnGN4iWMizOf+M59fVauKUqP84oGBSkI4F746K+grXinm3txsfPGu23J4OYtZt9FUxQssbaVykkhGBX9+nuiV+RYESLRj6uHT6mZH5g2BOR9L6cWRclks6GBFzIwjFu7JqeofmiJt/R1BwJMFH+07rDRPgi/9oS/DK6/ipC77dpomAuW48d9IbUNofd9/tc89mJbEg=='),DATE '1945-03-23'); -(5,'First 5','A Last 5',FROM_BASE64('BfpuifEdiau23UcEnnaONRxA9V0UH2uMhv3gZG/o0tnh6IR306luK4UL12RSbDVzGgpmDa7tLNC2pZzAlDMJmO4h5F73GzvSa8mVFrJrnqeNy9ECLM1sTIH1HYaF9jZXAYcSo14PK4+xygz1tsENs3jfKfWNuNBEi463x+fL8RcVxVMclSyOEBQaTnLD0pnzji99NkwMBQiwIHN5bl6XLA=='),DATE '1953-06-03'); -(6,'First 6','A Last 6',FROM_BASE64('Hdcj53Vc1yNAuCAP7H8YGadmbdOFGg1nfSpfVuiWWgx2OGR8KQIzTTHny8FsYnmyEBmJQZQMv1m1HU0EFmq5b4id0TmBUMfPzgWF5LFAJPgziAnbprYiKhwDaiRxrmL4Q0kVozeT1vniS3T6HioC20pjzmN8aF1vxzrLBr3IC9e8zHt9+Vla52lNoG/8atlWaSPx1agj5CyPncO7QTdPuw=='),DATE '1956-02-07'); -(7,'First 7','B Last 7',FROM_BASE64('FqOl3vAVSMU6NGINNZjVbYQRgmb95stb6CHfMYEec32ngI8XCS2687kGHfZ16innPuGau5Z/JSchkE8JYMaSITQ/7+B5eh40vZI1CKuLyXKfZ4BR8VkBVqxXyAsAShboxlt+kMHZEvWMY0iXcl9jCB3V+GNbPMHlCxz46CAnjp9ArnwwojRZgUDK9PonTr9N4GBEmO04DLip30LyvCpW/g=='),DATE '1969-05-26'); -(8,'First 8','B Last 8',FROM_BASE64('PQLBMSGGZXeSI7FLot4EcX3JfPTafiu5yeisMBQvuQmDW7kQC/mU9Oh+UhAbovDIx0dZGJ5dIhoAXZEzZPxGgBMWvbPNFmTB7+Q5Hd3/1uxL81XDZs6FlVCpGCKB0KER4WxtKbVqeQgltCeEvhYsTeLRNJdka33uq06lSZFyJXKX9bQyRLCZlGQRy2VHG1+sqjAX0FfcLf6RNEG64sDwOA=='),DATE '1978-11-08'); -(9,'First 9','B Last 9',FROM_BASE64('Nk2ZqJZSCFKKY+NMSq0WGVnNDS/BDHDEyb/bbJFxC/TqRPi+8DQ1csNlqvULW0pDEE6IygIRQR2lv5kT43E4tal4PKXx/z5LTeL9xiJ+qOHwLqAJrZK3V4aQFCNXT6t95lsxZLcjaP6fzNWlGwuN++iR7hpYJLI3WQSlaPL2GuHI9dLGS9ZUPR9KhDor72IURkOHU9Dt1eWfYouPsuVnrA=='),DATE '1987-07-04'); -(10,'First 10','B Last 10',FROM_BASE64('E0rzdg+IDhd1N9S/Nh11Yr6Za+xZlfCOQr0TrsxjFzRvO1ZnXjHGQPdWvT/LIJV+f7TXu0rYtk75fx7uPylxANNEYnLfD7v6UHB5Yful0TCweTFs9qH35BEd0jJl0ATb1ggUmsxXF0xZQpsRRnfycPbMY59w2APSX3hvgF2Xk7lvhHQaSbjnHOh4s78cqa2Atrjeds8KI/I4v+aVQIX9+Q=='),DATE '1993-07-06'); -(11,'First 11','C Last 11',FROM_BASE64('rO6MoGIcZJ+6zIPyMCt2td9ytNkSAn/LxWkrBKUGQs+Fk+Se43Ml7YsuRYhdcIeawAtySL35vZzb6Avl7bH/MyXrg4E0jdvjpEsi7KHiN4f0ky85purgyEg8tRASTi2zVsIM8c27DZenHOqRFl4KUaGRdQATOEoEIH3aHLVoACb0Y1m9JDTIDBcKST8nvTDzayQx1Ur4CO+ZqqG8ye99ww=='),DATE '1895-09-15'); -(12,'First 12','C Last 12',FROM_BASE64('ki4b0vB6EHp9qdm9lFrxplFPTnFCq9/BWwBLK1Jzz39K2q1rESpVXFIe2L2WzOKrunXo8e+p7+xlzBBKCwVIW6hQy0A+7kp7SwdZgWr2pXJqtSuo43fwfhf/A63zFaUYg3AkuNJNAtV/F3mOVudPeJ2xvfRfJ06uKY4MzsDhXAFW5Wsf1ypWMCke58U1VncvpuNOwzSb0El+hOreiQRX8g=='),DATE '1922-01-03'); -(13,'First 13','C Last 13',FROM_BASE64('KEx72v8CBibM16yet2U0Nsbt8KypF1ih18jLso5Q4AmFYUK7961GTYWj0YprWHxIxL/3qAXkm8jjtcRqEUmIXxW7kR0xC7sOcMYJsOSsy2m59YnDTlzDLlR1gynzNJVUhj+aKkUPMQfYV6Dw3UEx2Kik4NKDlGJQc9A0w3rfXjzRln8Ou3F+KYMuuoi/4jP4GEu1Pgyqy8jhQKiN0e9cjA=='),DATE '1930-08-03'); -(14,'First 14','C Last 14',FROM_BASE64('SdOTrssLh3vCqjtPNSqUvX5xrHs6/tpdlqgbp1jp9FseXhhJm+sq6FhgSMX+jm/grBUkUbGCNcWYthv3hdRMIapyZANENn/8CN0BxoVnvECGA9moThVIVghiSAiUNB+SyZg9XlmFRBaQcXpSWoZ1tIRTIuFRKpKaC2GYiOHVPLSQEUOBGc+sN4J0eCvM5aytanUGzn0o98yL73hbRXjwUw=='),DATE '1940-05-12'); -(15,'First 15','C Last 15',FROM_BASE64('NFgZNOzxoDSrAOPXtDIyUtetwm6eUN11YdjB7rIFfylx2SSTbhWZMuJoToE8xQz458BNaUJ8xPB+fJR2AQJL75eZdwJgSA7nnSiFcQgJxU7CEShlBT1ANNJvPujQ7cowRAo4joPfxoBSODuZcEc9WeXhJpEnlQtiGq7k+kzQ0oPgGaj0gLNwiC2zZwL5XCiet5qsRk4LSkUcX3OugpgeCg=='),DATE '1946-09-23'); -(16,'First 16','D Last 16',FROM_BASE64('mmXbRxEVEhiWeMGeuYOv6xGovovbq/qfevmWdMcGiqmCU1yzUrWKLvDhwzYZMbdscj7Tr5e4YyaXpIgpdMro3SApCyfhX5o/dsBlBNVmwLqg8DYbzAeApkaXeiStpAtKdQ8kZ1jezAFlhR/PioNsZjj1iAU4paFLG5F1i01spp3OOeJaD1mUTCSEO85rOAbQ8+B1N3vzz1Yc3E3mTQtxHg=='),DATE '1947-09-30'); -(17,'First 17','D Last 17',FROM_BASE64('zXIaISyrpPC/s0Yowmfdcbcavm6bGs95oBnWOHeTlXXk2n61Ug/GdG4gn5KxcXTfkqZAyzCBEnoaVcrwcp3HzEPUQeumXQn0dt2/oc5s0qfmGDo1+eOVy3tWMTdXv3vKmc4xXQ9bTMQE+MTtZDUknVCJ73zGUAMunFgzVnERLGBfOVaoLxcwC4HBrRtvtLlMboaCHirA1U5fF8xx81dK/g=='),DATE '1948-02-04'); -(18,'First 18','D Last 18',FROM_BASE64('mYZ5eW8+N/PFaDAmnIU77XX1jOZszdOXxblHbB0gKoJ6XOLYKcsmJKG8mjmUCQDYiG1b12xRQga6wprvLsciiyIwTCca6i4JL4RoVz+GqyDLmNSxHruz4xIB7XFIQ0q5SIeL7nob7llp7n+4+T9VYeoMDlFkG903WfjZNqsMRzpFYTT1C4ef+IlHOQSD5K3f/H/uWQ61PUebhSYe9hYQNg=='),DATE '1962-11-10'); -(19,'First 19','D Last 19',FROM_BASE64('/FqFHFjzF6yL/d3bKfSS9ZS1j8xkDlmF6gLpFf/MlC8idAt9ceLvr6oNEAKIdu0xqfLN9fKh9B7wQjAGUBKFLFlVzPIC2BBt7cCiiVVqgYwH3PIKiWL1LndLi1VRcNpy+gWLdgaFn+u4FxNotLDhdx9jUJOsDDPy9aBDSYmYOBajVUgN6jyfvG6egGnIhj+RNGxRkKfZ0isLOByT82v73w=='),DATE '1988-10-07'); -(20,'First 20','D Last 20',FROM_BASE64('3YII52xQjwk1RwhDPlbEKYWje92/04jIYhSJWa7LsLEt6qDxaFt1/1viQKAJWreCzgD0iC08CSJOQDLEmpuDPW5HZmWSnA0AuO46TGaYWtdQDFeJhgVzcldsAC7dMRid+SO1+sjvr/VfGCJP0XT3kWdE8mWNTdI74KrVm0CChj6XF7fLtjekbjZETrg7ySo8pmawVbTKrrZ5FIuNlkxI/Q=='),DATE '2000-02-29'); -(21,'First 21','D Last 21',FROM_BASE64('sKVHb3YTv4OPAB+77pjXln3omYqFy20LkBT/uP7PMSWlYaH+UpRdzOO52pDUh6BrMDjS3qgXU7irLoNA2NEma1QFzvVrLaa6yArnpZCyAEOw3OzpIQf2lJ7YqN8ZjwWEn8SztpMZBiJVXeZoYyYWnhkn9a+crIBOWMYI9ZfPUWk1xtvMX7I1QgHdSqPsLpT8iSnO42tjraGd5ulqkWrIRg=='),DATE '1886-08-09'); -(22,'First 22','E Last 22',FROM_BASE64('07GVEGBPEhQC8lELkxIGFhrQNspbl2NEGIrND5VXnUJFnuFctZaSpPovPHlYKtORcpGFsHTv3rSM6UUxTYFHzIUrxQJxNJ84KXjEXrlAN4tWkQOifh4icFc9FezQzQfsjf0KDjRatIFy8Q2jcSUfnhHbeZ1gpbsLIp8Ajioc7ptZG7Lnl1JyPmqKjQwQ+9WyE4uB0BGJTHI3xwzXQLm45A=='),DATE '1889-04-03'); -(23,'First 23','E Last 23',FROM_BASE64('tyGduCzcRQhWJXhDm5c9a8Mfpyyc1sKKk/OxSJFJ2numyNWuurKglMuDZSgdC9sH122eZdJU1uid7umiWYwhYYUC0JuYaYLNpYCnRuOL2FWVSN9jrJYX6AsNNpUDUfcKlJobFL/XJ+ulAr18Z/qtoWXDr4lx5TZAk05TTlFHJwRjIrybzrFYohhZZ20O4WtL3dryRKTgTgvVSElX0SZ8Tw=='),DATE '1892-01-21'); -(24,'First 24','E Last 24',FROM_BASE64('bXe6LecQB+BcWwzcE3b+JrH/20zrVIUXsH9AcBMduKoVIpCnrloUziiWbE1b2Te3/mD7ShKfD4RXSahJ7KgACA3CxS70yAa945NaqoX/aND7kGfFE6PEiS4pUrkJ10A1mRY2fP0J/Qn2tEyegtTF4b2BZuACQJy0qU8QyYrykaVK/+ExVI+MrvHA2LD062EDWPJrPgApCpPRMmtAV3KnTA=='),DATE '1898-02-21'); -(25,'First 25','Last 25',FROM_BASE64('82g7Ytc6/RBp/3vFxUG7JfAz9al82TRPlqBybWKBj/1pA26Pgv1UTxdDloQ24ovTmRZ3agPmaFEc/0ry820ozm8NmR340IwHRmO+jb2LQY4FGEMKFg7zDxAZpJXqITMZsFL1zO/EJ6VMnvZ90Udk2mywsnvv857PRCXJgx6vu4gn+oqUaRAQnSHq3pveu4/88FogqWoOotSzraD2RkW39Q=='),DATE '1911-12-15'); -(26,'First 26','Last 26',FROM_BASE64('KwbjBuHNQvzeWR2Ucf3v5dHAIO/b3/A0AlKxWI2qARDKuaXNuBooTCtdhIv5ZczOH5BbEKlaYkK3mr3GA5GClmwxsafbv3eE0LkV88T7KjfrKSkfatyTtcIWLIrw60B5hlMS5uxmj4X9nZfivj9boB4g3rqEdg/vgOsO9xdk/BKw6FMCuDO3PgDGEn89dOZmaB0PgadYNN3vqz8ZLgXWtg=='),DATE '1912-07-01'); -(27,'First 27','Last 27',FROM_BASE64('O3T43r6OjBwCWu925WlVnd6NLufFAken2Jk/QQBJOGQWsqc4dQsFhs/RSAC8iMZg32lfpfjMQPltRjmwqV7JleYRxL9e6co5WDj9cQk7AcL6wedgR5O/voPZIJ0aqkh5bZvijuxNIerbYhmYZEPOuzhgz9ayE7LgPkvO6WWNfhYuhnulnuDa3e2RsBNC7J1zuuf3DKHnL8SpaD0SMcZRuw=='),DATE '1939-05-17'); -(28,'First 28','Last 28',FROM_BASE64('xC71kYOpe6iZJd4DZnb11wBapa37lquOSW0JzuS15kW1xSG/Jxu0FXUIbFaBJ84hvFYQ3OSxr5HRxI0SBaFyUQhglUT3KTv/m8fEN/W+apBu4aUtlLcZPOTr1amaz30fu89J6pEoQOgmswSIr/0CtiaQ/ZHnuU2rZUXh7hTzBdygF30bAIq6yBGPpfb/MV66yagZtQO/q69sRmar70H/hg=='),DATE '1946-10-18'); -(29,'First 29','Last 29',FROM_BASE64('koHC6ZTUt89ksDORKlw5ep/zJCO0/LNo5A6yC5E8HEKOZpzX7xllDsIQuDmMQDn1HCHkpouKFmoTM24kWvfAs9B6yE7JccSFJbUU5s4Z/iLtYnnfKDzMEDDd/TyL6FxxS0McscfZ/TIc6ZFCArlJCbviqTSafPamrlD7tOJNxkCZae+dFIgnTCiTcwcjvkQeM5Ul6jDNoqIy5lrZdR6wJg=='),DATE '1956-12-23'); -(30,'First 30','Last 30',FROM_BASE64('WjdDzKHsiWCc0kXraf7NbebOU2TIv9KicHO6Og18iZpsxKH0am6wN7f1FwB1VSvZkvfJQgFkqjoqYEJ8qmgKB/YC9mbQAP14BjoJTq6fwDehF5leqSYT7NJarlhV7BX+hn4cCOBZ/gdGPCdK2aXZy8KJrnxh6RBGe0+84L3mEOaSZmZRvmXMcRjRozu17qV3xm6mo7BTq+/7tES3CAovMw=='),DATE '1988-05-29'); diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Songs.txt b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Songs.txt deleted file mode 100644 index bda929b0fe5..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/it/Songs.txt +++ /dev/null @@ -1,149 +0,0 @@ -(12,42,1,"Song 12 42 1",387,'Unknown'); -(12,12,2,"Song 12 12 2",202,'Unknown'); -(29,59,3,"Song 29 59 3",160,'Unknown'); -(23,23,4,"Song 23 23 4",255,'Unknown'); -(24,54,5,"Song 24 54 5",436,'Unknown'); -(28,58,6,"Song 28 58 6",121,'Unknown'); -(27,27,7,"Song 27 27 7",319,'Unknown'); -(24,24,8,"Song 24 24 8",213,'Unknown'); -(19,49,9,"Song 19 49 9",280,'Unknown'); -(17,47,10,"Song 17 47 10",253,'Unknown'); -(6,6,11,"Song 6 6 11",321,'Unknown'); -(12,42,12,"Song 12 42 12 12 42 12",124,'Unknown'); -(25,25,13,"Song 25 25 13",449,'Unknown'); -(24,24,14,"Song 24 24 14",438,'Unknown'); -(5,5,15,"Song 5 5 15",378,'Unknown'); -(9,39,16,"Song 9 39 16",202,'Unknown'); -(20,50,17,"Song 20 50 17",452,'Unknown'); -(7,37,18,"Song 7 37 18",420,'Unknown'); -(8,8,19,"Song 8 8 19",318,'Unknown'); -(5,35,20,"Song 5 35 20",347,'Unknown'); -(3,3,21,"Song 3 3 21",377,'Unknown'); -(15,15,22,"Song 15 15 22",314,'Unknown'); -(19,49,23,"Song 19 49 23",199,'Unknown'); -(20,20,24,"Song 20 20 24",266,'Unknown'); -(15,45,25,"Song 15 45 25",433,'Unknown'); -(14,44,26,"Song 14 44 26",482,'Unknown'); -(19,19,27,"Song 19 19 27",345,'Unknown'); -(13,43,28,"Song 13 43 28",159,'Unknown'); -(18,48,29,"Song 18 48 29",350,'Unknown'); -(13,13,30,"Song 13 13 30",131,'Unknown'); -(9,9,31,"Song 9 9 31",183,'Unknown'); -(13,13,32,"Song 13 13 32",193,'Unknown'); -(24,24,33,"Song 24 24 33",378,'Unknown'); -(30,60,34,"Song 30 60 34",270,'Unknown'); -(13,43,35,"Song 13 43 35",375,'Unknown'); -(27,27,36,"Song 27 27 36",219,'Unknown'); -(20,50,37,"Song 20 50 37",314,'Unknown'); -(18,48,38,"Song 18 48 38",416,'Unknown'); -(21,51,39,"Song 21 51 39",330,'Unknown'); -(1,31,40,"Song 1 31 40",376,'Unknown'); -(5,5,41,"Song 5 5 41",398,'Unknown'); -(15,45,42,"Song 15 45 42",466,'Unknown'); -(24,24,43,"v 24 24 43",384,'Unknown'); -(19,19,44,"Song 19 19 44",472,'Unknown'); -(15,45,45,"Song 15 45 45",246,'Unknown'); -(3,33,46,"Song 3 33 46",412,'Unknown'); -(23,23,47,"Song 23 23 47",159,'Unknown'); -(30,60,48,"Song 30 60 48",290,'Unknown'); -(19,19,49,"Song 19 19 49",446,'Unknown'); -(16,16,50,"Song 16 16 50",485,'Unknown'); -(4,4,51,"Song 4 4 51",185,'Unknown'); -(8,38,52,"Song 8 38 52",349,'Unknown'); -(24,54,53,"Song 24 54 53",301,'Unknown'); -(5,35,54,"Song 5 35 54",206,'Unknown'); -(30,30,55,"Song 30 30 55",250,'Unknown'); -(12,42,56,"Song 12 42 56",146,'Unknown'); -(30,30,57,"Song 30 30 57",416,'Unknown'); -(26,56,58,"Song 26 56 58",244,'Unknown'); -(20,50,59,"Song 20 50 59",356,'Unknown'); -(7,7,60,"Song 7 7 60",234,'Unknown'); -(19,19,61,"Song 19 19 61",412,'Unknown'); -(13,43,62,"Song 13 43 62",161,'Unknown'); -(5,5,63,"Song 5 5 63",300,'Unknown'); -(1,31,64,"Song 1 31 64",307,'Unknown'); -(4,4,65,"Song 4 4 65",197,'Unknown'); -(24,54,66,"Song 24 54 66",180,'Unknown'); -(3,3,67,"Song 3 3 67",156,'Unknown'); -(14,44,68,"Song 14 44 68",184,'Unknown'); -(21,51,69,"Song 21 51 69",486,'Unknown'); -(19,49,70,"Song 19 49 70",212,'Unknown'); -(9,39,71,"Song 9 39 71",452,'Unknown'); -(23,53,72,"Song 23 53 72",425,'Unknown'); -(11,41,73,"Song 11 41 73",316,'Unknown'); -(8,8,74,"Song 8 8 74",395,'Unknown'); -(9,9,75,"Song 9 9 75",189,'Unknown'); -(2,2,76,"Song 2 2 76",354,'Unknown'); -(23,53,77,"Song 23 53 77",137,'Unknown'); -(15,15,78,"TSong 15 15 78",176,'Unknown'); -(30,60,79,"Song 30 60 79",224,'Unknown'); -(14,44,80,"Song 14 44 80",305,'Unknown'); -(27,27,81,"Song 27 27 81",432,'Unknown'); -(18,18,82,"Song 18 18 82",357,'Unknown'); -(10,10,83,"Song 10 10 83",187,'Unknown'); -(12,42,84,"Song 12 42 84",461,'Unknown'); -(8,8,85,"Song 8 8 85",434,'Unknown'); -(1,31,86,"Song 1 31 86",436,'Unknown'); -(11,41,87,"Song 11 41 87",469,'Unknown'); -(13,13,88,"Song 13 13 88",452,'Unknown'); -(4,34,89,"Song 4 34 89",309,'Unknown'); -(21,21,90,"Song 21 21 90",226,'Unknown'); -(6,36,91,"Song 6 36 91",257,'Unknown'); -(27,27,92,"Song 27 27 92",251,'Unknown'); -(9,39,93,"Song 9 39 93",325,'Unknown'); -(30,30,94,"Song 30 30 94",122,'Unknown'); -(29,59,95,"Song 29 59 95",207,'Unknown'); -(1,1,96,"Song 1 1 96",318,'Unknown'); -(4,4,97,"Song 4 4 97",353,'Unknown'); -(23,23,98,"Song 23 23 98",450,'Unknown'); -(12,12,99,"Song 12 12 99",323,'Unknown'); -(24,24,100,"Song 24 24 100",397,'Unknown'); -(27,27,101,"Song 27 27 101",296,'Unknown'); -(29,59,102,"Song 29 59 102",349,'Unknown'); -(17,47,103,"Song 17 47 103",438,'Unknown'); -(5,5,104,"Song 5 5 104",388,'Unknown'); -(26,56,105,"Song 26 56 105",425,'Unknown'); -(22,52,106,"Song 22 52 106",154,'Unknown'); -(23,23,107,"Song 23 23 107",213,'Unknown'); -(8,38,108,"Song 8 38 108",276,'Unknown'); -(9,39,109,"Song 9 39 109",417,'Unknown'); -(9,9,110,"Song 9 9 110",299,'Unknown'); -(22,52,111,"Song 22 52 111",476,'Unknown'); -(21,21,112,"Song 21 21 112",225,'Unknown'); -(23,23,113,"Song 23 23 113",303,'Unknown'); -(7,7,114,"Song 7 7 114",291,'Unknown'); -(8,38,115,"Song 8 38 115",276,'Unknown'); -(14,44,116,"Song 14 44 116",238,'Unknown'); -(27,57,117,"Song 27 57 117",188,'Unknown'); -(28,28,118,"Song 28 28 118",372,'Unknown'); -(15,15,119,"Song 15 15 119",258,'Unknown'); -(21,21,120,"Song 21 21 120",308,'Unknown'); -(29,59,121,"Song 29 59 121",319,'Unknown'); -(28,58,122,"Song 28 58 122",453,'Unknown'); -(7,7,123,"Song 7 7 123",198,'Unknown'); -(4,4,124,"Song 4 4 124",435,'Unknown'); -(27,27,125,"Song 27 27 125",475,'Unknown'); -(30,30,126,"Song 30 30 126",395,'Unknown'); -(21,51,127,"Song 21 51 127",454,'Unknown'); -(29,29,128,"Song 29 29 128",376,'Unknown'); -(27,57,129,"Song 27 57 129",396,'Unknown'); -(23,53,130,"Song 23 53 130",458,'Unknown'); -(6,36,131,"Song 6 36 131",289,'Unknown'); -(29,29,132,"Song 29 29 132",207,'Unknown'); -(25,55,133,"Song 25 55 133",280,'Unknown'); -(3,3,134,"Song 3 3 134",432,'Unknown'); -(5,35,135,"1 5 35 135",304,'Unknown'); -(3,3,136,"2 3 3 136",392,'Unknown'); -(12,12,137,"3 12 12 137",393,'Unknown'); -(13,13,138,"4 13 13 138",382,'Unknown'); -(18,48,139,"5 18 48 139",447,'Unknown'); -(17,17,140,"6 17 17 140",182,'Unknown'); -(23,23,141,"7 23 23 141",266,'Unknown'); -(21,51,142,"8 21 51 142",383,'Unknown'); -(3,3,143,"9 3 3 143",439,'Unknown'); -(25,25,144,"10 25 25 144",454,'Unknown'); -(12,12,145,"11 12 12 145",179,'Unknown'); -(19,19,146,"12 19 19 146",422,'Unknown'); -(24,54,147,"13 24 54 147",478,'Unknown'); -(8,38,148,"14 8 38 148",233,'Unknown'); -(6,6,149,"15 6 6 149",245,'Unknown'); diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-app-default.json b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-app-default.json deleted file mode 100644 index 3e849240609..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-app-default.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "app-default-test-project", - "private_key_id": "some-key-id", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgFkCu/z3Sn8Py\nIHcUSSyCOjZ17AB/0F5IvhuGtTZTIJ33ltxeYmb69qK0m4QSk75HH5eX1OgF7/6E\nraqDaKlgi8ecSot1XrMRKyIY+LlTLMWeNtG54vymwjeH9wrMWQWfHJUCVUgUE8hL\nxQMEbU2Hn8t6P1JaGkfsm8cLiD0ve25iw/P2OPDdJukBlE2+47OL8RndyziVnLkW\n1y1kfujd83Cnf0sJp78fBKI7IRBWyXTS1C6/reZlkPq+D9ImCvn4YHpI6J1rsSDD\nitDbA0v/8l7KLyJoOK9vsFym4yhs4Q+Nzathv/ozvdHhob8I6JVizb5+D4QJ0GZ4\n9bMIzpV3AgMBAAECggEANbrCQvnP2h1dOqrCzMAyfBLlrHZlRIC+5FNKEdBIR2Yv\nHqY3mEYWoiydN1jq3wFPX7euvXrr1PJTzlwrWqeKEalYeZBbdi0ulJiRfSgdq1jf\nitaDVYxll+KfmLbFnQhT5q9FI99Trcll9GhPNvEokFiFhqYyEaO4eCVgjPJQ9tpC\njnKl9eLeHkhYK1pOKxJVBqzPcZI3F9jNvXWYTO1F7lFMom9I89W+NtBRAeYZnVao\nfH52GDJProB5A9BtRXkuLDzmFFjGjr8oT4E32wLuiu2UvNHgIZe7Hz+fMGGHsDHS\nc5jogukVwgt7QrfKVtoRTk8h2jyIrpRy4AQLfJZ4QQKBgQDT0X3+mp+tbEncLFBW\nXLT1k/1VWumi1TipiVsMpUcAZjWTGO8/WJF83IcNBAFqBJGyTAwplXIyUeI8CGg0\nOkBPY1Cy/dtTyiav05vRPZPkT44mhBua2tyhaE12DVo1/6ezF88yTPQkO9EjlvLs\nW32XlhqGQ8O587xjNaB/rqsjXwKBgQDBenKlO3eDBSfVb/te/xwqeVnKBgEYIAOJ\nN+FE49aH05n8DYQij1m8+Ck6sFBZywWliIQdS6d6J4NE69Ok7bfowwVqoumX8LWD\ntstMkOE2FmPCF4nbxkAFYbcuep1iItA2LVSwh3ChAA6aexA/fV6bMauhJPJTSnwX\nItnKvPMc6QKBgBrwZtTNt4cn4ZDl9eW17rHY+3wyjspN0eIF/RVzo78SQLgPkMX+\nrqoxpd9q5f8ky57gex+CyT5LGbnG2/HggrNWDzpkfNOAP0FXaVbIPRnpYEvXu2cL\ndMn2aPudoR6DAEIPwiNElDxTezrKhOS4khWIWqE+1xK8Q/ZeKKZ0gYGDAoGAcc3p\no6FgAfRFYvl0fYNHeQBaPUfc2ujxy4PQAKqXpNtlhuoYYA+79DhwX/IXwUl3L9Am\nDelTQLn/L8oberbNZ59XD0t2ZYYT7r7VxFqv7hWrZh5cW6a4P7IjgrZi3reli0iM\nuS1hpYIYFOvwObgvrs+/qZDG7REx/pXkT6lmwwkCgYEAub91mMF6YR76ETPAdFLs\nfTAP+Q06Ate+gw1Ob6Cf+biF6TXe/B3Ql1R4FzPF9xG1rS/BfI+bUi3W68/jDill\nHnDPvFxX9Q82/KNCY9LlzbuQLWjziyQk6BgXtcKWT1K1zy4tsZZy5WVvXEXdF+XV\n3MMUkEaBHE5iddCl7Kkbvfg=\n-----END PRIVATE KEY-----\n", - "client_email": "test@app-default-test-project.iam.gserviceaccount.com", - "client_id": "1234567890", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://accounts.google.com/o/oauth2/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test%40app-default-test-project.iam.gserviceaccount.com" -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-cloud-storage.json b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-cloud-storage.json deleted file mode 100644 index cf2157696a8..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key-cloud-storage.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "gs-test-project", - "private_key_id": "cloud-storage-key-id", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgFkCu/z3Sn8Py\nIHcUSSyCOjZ17AB/0F5IvhuGtTZTIJ33ltxeYmb69qK0m4QSk75HH5eX1OgF7/6E\nraqDaKlgi8ecSot1XrMRKyIY+LlTLMWeNtG54vymwjeH9wrMWQWfHJUCVUgUE8hL\nxQMEbU2Hn8t6P1JaGkfsm8cLiD0ve25iw/P2OPDdJukBlE2+47OL8RndyziVnLkW\n1y1kfujd83Cnf0sJp78fBKI7IRBWyXTS1C6/reZlkPq+D9ImCvn4YHpI6J1rsSDD\nitDbA0v/8l7KLyJoOK9vsFym4yhs4Q+Nzathv/ozvdHhob8I6JVizb5+D4QJ0GZ4\n9bMIzpV3AgMBAAECggEANbrCQvnP2h1dOqrCzMAyfBLlrHZlRIC+5FNKEdBIR2Yv\nHqY3mEYWoiydN1jq3wFPX7euvXrr1PJTzlwrWqeKEalYeZBbdi0ulJiRfSgdq1jf\nitaDVYxll+KfmLbFnQhT5q9FI99Trcll9GhPNvEokFiFhqYyEaO4eCVgjPJQ9tpC\njnKl9eLeHkhYK1pOKxJVBqzPcZI3F9jNvXWYTO1F7lFMom9I89W+NtBRAeYZnVao\nfH52GDJProB5A9BtRXkuLDzmFFjGjr8oT4E32wLuiu2UvNHgIZe7Hz+fMGGHsDHS\nc5jogukVwgt7QrfKVtoRTk8h2jyIrpRy4AQLfJZ4QQKBgQDT0X3+mp+tbEncLFBW\nXLT1k/1VWumi1TipiVsMpUcAZjWTGO8/WJF83IcNBAFqBJGyTAwplXIyUeI8CGg0\nOkBPY1Cy/dtTyiav05vRPZPkT44mhBua2tyhaE12DVo1/6ezF88yTPQkO9EjlvLs\nW32XlhqGQ8O587xjNaB/rqsjXwKBgQDBenKlO3eDBSfVb/te/xwqeVnKBgEYIAOJ\nN+FE49aH05n8DYQij1m8+Ck6sFBZywWliIQdS6d6J4NE69Ok7bfowwVqoumX8LWD\ntstMkOE2FmPCF4nbxkAFYbcuep1iItA2LVSwh3ChAA6aexA/fV6bMauhJPJTSnwX\nItnKvPMc6QKBgBrwZtTNt4cn4ZDl9eW17rHY+3wyjspN0eIF/RVzo78SQLgPkMX+\nrqoxpd9q5f8ky57gex+CyT5LGbnG2/HggrNWDzpkfNOAP0FXaVbIPRnpYEvXu2cL\ndMn2aPudoR6DAEIPwiNElDxTezrKhOS4khWIWqE+1xK8Q/ZeKKZ0gYGDAoGAcc3p\no6FgAfRFYvl0fYNHeQBaPUfc2ujxy4PQAKqXpNtlhuoYYA+79DhwX/IXwUl3L9Am\nDelTQLn/L8oberbNZ59XD0t2ZYYT7r7VxFqv7hWrZh5cW6a4P7IjgrZi3reli0iM\nuS1hpYIYFOvwObgvrs+/qZDG7REx/pXkT6lmwwkCgYEAub91mMF6YR76ETPAdFLs\nfTAP+Q06Ate+gw1Ob6Cf+biF6TXe/B3Ql1R4FzPF9xG1rS/BfI+bUi3W68/jDill\nHnDPvFxX9Q82/KNCY9LlzbuQLWjziyQk6BgXtcKWT1K1zy4tsZZy5WVvXEXdF+XV\n3MMUkEaBHE5iddCl7Kkbvfg=\n-----END PRIVATE KEY-----\n", - "client_email": "cloud-storage@gs-test-project.iam.gserviceaccount.com", - "client_id": "1234567890", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://accounts.google.com/o/oauth2/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/cloud-storage%40gs-test-project.iam.gserviceaccount.com" -} diff --git a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key.json b/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key.json deleted file mode 100644 index b7f5351350a..00000000000 --- a/google-cloud-contrib/google-cloud-spanner-jdbc/src/test/resources/com/google/cloud/spanner/jdbc/test-key.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "test-project", - "private_key_id": "some-key-id", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgFkCu/z3Sn8Py\nIHcUSSyCOjZ17AB/0F5IvhuGtTZTIJ33ltxeYmb69qK0m4QSk75HH5eX1OgF7/6E\nraqDaKlgi8ecSot1XrMRKyIY+LlTLMWeNtG54vymwjeH9wrMWQWfHJUCVUgUE8hL\nxQMEbU2Hn8t6P1JaGkfsm8cLiD0ve25iw/P2OPDdJukBlE2+47OL8RndyziVnLkW\n1y1kfujd83Cnf0sJp78fBKI7IRBWyXTS1C6/reZlkPq+D9ImCvn4YHpI6J1rsSDD\nitDbA0v/8l7KLyJoOK9vsFym4yhs4Q+Nzathv/ozvdHhob8I6JVizb5+D4QJ0GZ4\n9bMIzpV3AgMBAAECggEANbrCQvnP2h1dOqrCzMAyfBLlrHZlRIC+5FNKEdBIR2Yv\nHqY3mEYWoiydN1jq3wFPX7euvXrr1PJTzlwrWqeKEalYeZBbdi0ulJiRfSgdq1jf\nitaDVYxll+KfmLbFnQhT5q9FI99Trcll9GhPNvEokFiFhqYyEaO4eCVgjPJQ9tpC\njnKl9eLeHkhYK1pOKxJVBqzPcZI3F9jNvXWYTO1F7lFMom9I89W+NtBRAeYZnVao\nfH52GDJProB5A9BtRXkuLDzmFFjGjr8oT4E32wLuiu2UvNHgIZe7Hz+fMGGHsDHS\nc5jogukVwgt7QrfKVtoRTk8h2jyIrpRy4AQLfJZ4QQKBgQDT0X3+mp+tbEncLFBW\nXLT1k/1VWumi1TipiVsMpUcAZjWTGO8/WJF83IcNBAFqBJGyTAwplXIyUeI8CGg0\nOkBPY1Cy/dtTyiav05vRPZPkT44mhBua2tyhaE12DVo1/6ezF88yTPQkO9EjlvLs\nW32XlhqGQ8O587xjNaB/rqsjXwKBgQDBenKlO3eDBSfVb/te/xwqeVnKBgEYIAOJ\nN+FE49aH05n8DYQij1m8+Ck6sFBZywWliIQdS6d6J4NE69Ok7bfowwVqoumX8LWD\ntstMkOE2FmPCF4nbxkAFYbcuep1iItA2LVSwh3ChAA6aexA/fV6bMauhJPJTSnwX\nItnKvPMc6QKBgBrwZtTNt4cn4ZDl9eW17rHY+3wyjspN0eIF/RVzo78SQLgPkMX+\nrqoxpd9q5f8ky57gex+CyT5LGbnG2/HggrNWDzpkfNOAP0FXaVbIPRnpYEvXu2cL\ndMn2aPudoR6DAEIPwiNElDxTezrKhOS4khWIWqE+1xK8Q/ZeKKZ0gYGDAoGAcc3p\no6FgAfRFYvl0fYNHeQBaPUfc2ujxy4PQAKqXpNtlhuoYYA+79DhwX/IXwUl3L9Am\nDelTQLn/L8oberbNZ59XD0t2ZYYT7r7VxFqv7hWrZh5cW6a4P7IjgrZi3reli0iM\nuS1hpYIYFOvwObgvrs+/qZDG7REx/pXkT6lmwwkCgYEAub91mMF6YR76ETPAdFLs\nfTAP+Q06Ate+gw1Ob6Cf+biF6TXe/B3Ql1R4FzPF9xG1rS/BfI+bUi3W68/jDill\nHnDPvFxX9Q82/KNCY9LlzbuQLWjziyQk6BgXtcKWT1K1zy4tsZZy5WVvXEXdF+XV\n3MMUkEaBHE5iddCl7Kkbvfg=\n-----END PRIVATE KEY-----\n", - "client_email": "test@test-project.iam.gserviceaccount.com", - "client_id": "1234567890", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://accounts.google.com/o/oauth2/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test%40test-project.iam.gserviceaccount.com" -} diff --git a/google-cloud-spanner-bom/pom.xml b/google-cloud-spanner-bom/pom.xml new file mode 100644 index 00000000000..2fa066d26d2 --- /dev/null +++ b/google-cloud-spanner-bom/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + com.google.cloud + google-cloud-spanner-bom + 1.47.1-SNAPSHOT + pom + + com.google.cloud + google-cloud-shared-config + 0.3.1 + + + Google Cloud Spanner BOM + https://github.com/googleapis/java-spanner + + BOM for Google Cloud Spanner + + + + Google LLC + + + + + chingor13 + Jeff Ching + chingor@google.com + Google LLC + + Developer + + + + + + scm:git:https://github.com/googleapis/java-spanner.git + scm:git:git@github.com:googleapis/java-spanner.git + https://github.com/googleapis/java-spanner + + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + + + com.google.api.grpc + proto-google-cloud-spanner-admin-instance-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-admin-database-v1 + 1.47.1-SNAPSHOT + + + com.google.cloud + google-cloud-spanner + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-admin-instance-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-admin-database-v1 + 1.47.1-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + \ No newline at end of file diff --git a/google-cloud-spanner/pom.xml b/google-cloud-spanner/pom.xml index e9c9724db9a..43d3d764362 100644 --- a/google-cloud-spanner/pom.xml +++ b/google-cloud-spanner/pom.xml @@ -1,25 +1,22 @@ - + + 4.0.0 + com.google.cloud google-cloud-spanner 1.47.1-SNAPSHOT jar Google Cloud Spanner - https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-spanner - - Java idiomatic client for Google Cloud Spanner. - + https://github.com/googleapis/java-spanner + Java idiomatic client for Google Cloud Spanner. com.google.cloud - google-cloud-clients - 0.120.1-alpha-SNAPSHOT + google-cloud-spanner-parent + 1.47.1-SNAPSHOT google-cloud-spanner - true + @@ -41,113 +38,170 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M4 - - com.google.cloud.spanner.IntegrationTest - sponge_log - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.0.0-M4 - - - com.google.cloud.spanner.GceTestEnvConfig - projects/gcloud-devel/instances/spanner-testing - - com.google.cloud.spanner.IntegrationTest - com.google.cloud.spanner.FlakyTest - 2400 - - - - org.apache.maven.surefire - surefire-junit47 - 3.0.0-M4 - - - - - - integration-test - - - - + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + com.google.cloud.spanner.IntegrationTest + sponge_log + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M4 + + + com.google.cloud.spanner.GceTestEnvConfig + projects/gcloud-devel/instances/spanner-testing + + com.google.cloud.spanner.IntegrationTest + com.google.cloud.spanner.FlakyTest + 2400 + + + + org.apache.maven.plugins + maven-dependency-plugin + + io.grpc:grpc-protobuf-lite,org.hamcrest:hamcrest,org.hamcrest:hamcrest-core + + + + - com.google.cloud - google-cloud-core-grpc + io.grpc + grpc-api - com.google.api.grpc - proto-google-cloud-spanner-v1 - 1.47.1-SNAPSHOT + io.grpc + grpc-context + + + io.grpc + grpc-core + + + io.grpc + grpc-netty-shaded + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.protobuf + protobuf-java-util com.google.api.grpc - proto-google-cloud-spanner-admin-database-v1 - 1.47.1-SNAPSHOT + proto-google-common-protos com.google.api.grpc - proto-google-cloud-spanner-admin-instance-v1 - 1.47.1-SNAPSHOT + grpc-google-common-protos com.google.api.grpc - grpc-google-cloud-spanner-v1 - 1.47.1-SNAPSHOT + proto-google-iam-v1 + + + com.google.cloud + google-cloud-core + + + com.google.cloud + google-cloud-core-grpc + + + io.opencensus + opencensus-api + + + io.opencensus + opencensus-contrib-grpc-util + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.http-client + google-http-client com.google.api.grpc - grpc-google-cloud-spanner-admin-database-v1 - 1.47.1-SNAPSHOT + proto-google-cloud-spanner-admin-instance-v1 com.google.api.grpc - grpc-google-cloud-spanner-admin-instance-v1 - 1.47.1-SNAPSHOT + proto-google-cloud-spanner-v1 com.google.api.grpc - grpc-google-common-protos - 1.17.0 + proto-google-cloud-spanner-admin-database-v1 + + + com.google.guava + guava + + + com.google.api + gax - + + com.google.api + gax-grpc + + + org.threeten + threetenbp + + + com.google.code.findbugs + jsr305 + 3.0.2 + + junit junit test + - com.google.truth - truth + com.google.api.grpc + grpc-google-cloud-spanner-v1 test - org.mockito - mockito-all - 1.10.19 + com.google.api.grpc + grpc-google-cloud-spanner-admin-instance-v1 test - - - org.objenesis - objenesis - - - com.google.guava - guava-testlib + com.google.api.grpc + grpc-google-cloud-spanner-admin-database-v1 test @@ -158,8 +212,19 @@ test - io.opencensus - opencensus-contrib-grpc-util + com.google.truth + truth + test + + org.mockito + mockito-all + 1.10.19 + + + org.objenesis + objenesis + + org.json @@ -167,47 +232,31 @@ 20190722 test + + com.google.guava + guava-testlib + test + + + org.hamcrest + hamcrest + 2.2 + test + - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - protected - true - none - true - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/proto-google-cloud-spanner-admin-database-v1/target/site/apidocs/ - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/grpc-google-cloud-spanner-admin-database-v1/target/site/apidocs/ - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/proto-google-cloud-spanner-admin-instance-v1/target/site/apidocs/ - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/grpc-google-cloud-spanner-admin-instance-v1/target/site/apidocs/ - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/proto-google-cloud-spanner-v1/target/site/apidocs/ - - - ${project.javadoc.protobufBaseURL} - ../../../../../google-api-grpc/grpc-google-cloud-spanner-v1/target/site/apidocs/ - - - - - - - + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/google-cloud-spanner/synth.metadata b/google-cloud-spanner/synth.metadata deleted file mode 100644 index 7c923481a58..00000000000 --- a/google-cloud-spanner/synth.metadata +++ /dev/null @@ -1,52 +0,0 @@ -{ - "updateTime": "2019-11-19T08:38:07.665315Z", - "sources": [ - { - "generator": { - "name": "artman", - "version": "0.42.1", - "dockerImage": "googleapis/artman@sha256:c773192618c608a7a0415dd95282f841f8e6bcdef7dd760a988c93b77a64bd57" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d8dd7fe8d5304f7bd1c52207703d7f27d5328c5a", - "internalRef": "281088257" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "spanner", - "apiVersion": "v1", - "language": "java", - "generator": "gapic", - "config": "google/spanner/artman_spanner.yaml" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "spanner", - "apiVersion": "v1", - "language": "java", - "generator": "gapic", - "config": "google/spanner/admin/database/artman_spanner_admin_database.yaml" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "spanner", - "apiVersion": "v1", - "language": "java", - "generator": "gapic", - "config": "google/spanner/admin/instance/artman_spanner_admin_instance.yaml" - } - } - ] -} \ No newline at end of file diff --git a/google-cloud-spanner/synth.py b/google-cloud-spanner/synth.py deleted file mode 100644 index fe8266addbf..00000000000 --- a/google-cloud-spanner/synth.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2018 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 -# -# http://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. - -"""This script is used to synthesize generated parts of this library.""" - -import synthtool as s -import synthtool.gcp as gcp -import synthtool.languages.java as java - -gapic = gcp.GAPICGenerator() - -library = gapic.java_library( - service='spanner', - version='v1', - config_path='/google/spanner/artman_spanner.yaml', - artman_output_name='') - -s.copy(library / 'gapic-google-cloud-spanner-v1/src', 'src') -s.copy(library / 'grpc-google-cloud-spanner-v1/src', '../../google-api-grpc/grpc-google-cloud-spanner-v1/src') -s.copy(library / 'proto-google-cloud-spanner-v1/src', '../../google-api-grpc/proto-google-cloud-spanner-v1/src') - -library = gapic.java_library( - service='spanner', - version='v1', - config_path='/google/spanner/admin/database/artman_spanner_admin_database.yaml', - artman_output_name='') - -s.copy(library / 'gapic-google-cloud-spanner-admin-database-v1/src', 'src') -s.copy(library / 'grpc-google-cloud-spanner-admin-database-v1/src', '../../google-api-grpc/grpc-google-cloud-spanner-admin-database-v1/src') -s.copy(library / 'proto-google-cloud-spanner-admin-database-v1/src', '../../google-api-grpc/proto-google-cloud-spanner-admin-database-v1/src') - -library = gapic.java_library( - service='spanner', - version='v1', - config_path='/google/spanner/admin/instance/artman_spanner_admin_instance.yaml', - artman_output_name='') - -s.copy(library / 'gapic-google-cloud-spanner-admin-instance-v1/src', 'src') -s.copy(library / 'grpc-google-cloud-spanner-admin-instance-v1/src', '../../google-api-grpc/grpc-google-cloud-spanner-admin-instance-v1/src') -s.copy(library / 'proto-google-cloud-spanner-admin-instance-v1/src', '../../google-api-grpc/proto-google-cloud-spanner-admin-instance-v1/src') - -java.format_code('./src') -java.format_code(f'../../google-api-grpc/grpc-google-cloud-spanner-v1/src') -java.format_code(f'../../google-api-grpc/proto-google-cloud-spanner-v1/src') -java.format_code(f'../../google-api-grpc/grpc-google-cloud-spanner-admin-database-v1/src') -java.format_code(f'../../google-api-grpc/proto-google-cloud-spanner-admin-database-v1/src') -java.format_code(f'../../google-api-grpc/grpc-google-cloud-spanner-admin-instance-v1/src') -java.format_code(f'../../google-api-grpc/proto-google-cloud-spanner-admin-instance-v1/src') diff --git a/grpc-google-cloud-spanner-admin-database-v1/pom.xml b/grpc-google-cloud-spanner-admin-database-v1/pom.xml index d1bb92d743e..ad83da2ae88 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-database-v1/pom.xml @@ -2,51 +2,63 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 1.47.1-SNAPSHOT grpc-google-cloud-spanner-admin-database-v1 GRPC library for grpc-google-cloud-spanner-admin-database-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT + + io.grpc + grpc-api + io.grpc grpc-stub - compile io.grpc grpc-protobuf - compile + + + com.google.protobuf + protobuf-java com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - compile + + + com.google.guava + guava + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api.grpc + proto-google-common-protos - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - protected - true - none - true - - - ${project.javadoc.protobufBaseURL} - ../../../../proto-google-cloud-spanner-admin-database-v1/target/site/apidocs/ - - - - - - - + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java index 5c3d1470a70..7686748677d 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java +++ b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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. + */ package com.google.spanner.admin.database.v1; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml index e5e28961ff9..233773df8d9 100644 --- a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml @@ -2,51 +2,63 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 1.47.1-SNAPSHOT grpc-google-cloud-spanner-admin-instance-v1 GRPC library for grpc-google-cloud-spanner-admin-instance-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT + + io.grpc + grpc-api + io.grpc grpc-stub - compile io.grpc grpc-protobuf - compile + + + com.google.protobuf + protobuf-java com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - compile + + + com.google.guava + guava + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api.grpc + proto-google-common-protos - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - protected - true - none - true - - - ${project.javadoc.protobufBaseURL} - ../../../../proto-google-cloud-spanner-admin-instance-v1/target/site/apidocs/ - - - - - - - + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/grpc-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceAdminGrpc.java b/grpc-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceAdminGrpc.java index 896479cf988..cf2e97017bf 100644 --- a/grpc-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceAdminGrpc.java +++ b/grpc-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceAdminGrpc.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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. + */ package com.google.spanner.admin.instance.v1; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/grpc-google-cloud-spanner-v1/pom.xml b/grpc-google-cloud-spanner-v1/pom.xml index d038a8d1d3e..31d4271edd2 100644 --- a/grpc-google-cloud-spanner-v1/pom.xml +++ b/grpc-google-cloud-spanner-v1/pom.xml @@ -2,51 +2,55 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc grpc-google-cloud-spanner-v1 1.47.1-SNAPSHOT grpc-google-cloud-spanner-v1 GRPC library for grpc-google-cloud-spanner-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT + + io.grpc + grpc-api + io.grpc grpc-stub - compile io.grpc grpc-protobuf - compile + + + com.google.protobuf + protobuf-java com.google.api.grpc proto-google-cloud-spanner-v1 - compile + + + com.google.guava + guava - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.1.1 - - protected - true - none - true - - - ${project.javadoc.protobufBaseURL} - ../../../../proto-google-cloud-spanner-v1/target/site/apidocs/ - - - - - - - + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + \ No newline at end of file diff --git a/grpc-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerGrpc.java b/grpc-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerGrpc.java index 4392de49c0c..e2548eb32fa 100644 --- a/grpc-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerGrpc.java +++ b/grpc-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerGrpc.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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. + */ package com.google.spanner.v1; import static io.grpc.MethodDescriptor.generateFullMethodName; diff --git a/java.header b/java.header new file mode 100644 index 00000000000..3a9b503aa24 --- /dev/null +++ b/java.header @@ -0,0 +1,15 @@ +^/\*$ +^ \* Copyright \d\d\d\d,? Google (Inc\.|LLC)( All [rR]ights [rR]eserved\.)?$ +^ \*$ +^ \* 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\.$ +^ \*/$ diff --git a/license-checks.xml b/license-checks.xml new file mode 100644 index 00000000000..6597fced808 --- /dev/null +++ b/license-checks.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000000..3f29c2bc26b --- /dev/null +++ b/pom.xml @@ -0,0 +1,316 @@ + + + 4.0.0 + com.google.cloud + google-cloud-spanner-parent + pom + 1.47.1-SNAPSHOT + Google Cloud Spanner Parent + https://github.com/googleapis/java-spanner + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-shared-config + 0.3.1 + + + + + chingor + Jeff Ching + chingor@google.com + Google + + Developer + + + + + Google LLC + + + scm:git:git@github.com:googleapis/java-spanner.git + scm:git:git@github.com:googleapis/java-spanner.git + https://github.com/googleapis/java-spanner + HEAD + + + https://github.com/googleapis/java-spanner/issues + GitHub Issues + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + UTF-8 + UTF-8 + github + google-cloud-spanner-parent + 1.92.0 + 1.8.1 + 1.17.0 + 1.52.0 + 1.26.0 + 3.11.1 + 4.12 + 28.1-android + 1.4.0 + 1.3.2 + 1.18 + 0.24.0 + + + + + + com.google.api.grpc + proto-google-cloud-spanner-admin-instance-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-spanner-admin-database-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-admin-instance-v1 + 1.47.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-spanner-admin-database-v1 + 1.47.1-SNAPSHOT + + + com.google.cloud + google-cloud-spanner + 1.47.1-SNAPSHOT + + + + io.grpc + grpc-bom + ${grpc.version} + pom + import + + + com.google.api + gax-bom + ${gax.version} + pom + import + + + com.google.guava + guava-bom + ${guava.version} + pom + import + + + com.google.cloud + google-cloud-core-bom + ${google.core.version} + pom + import + + + com.google.auth + google-auth-library-bom + 0.19.0 + pom + import + + + com.google.protobuf + protobuf-bom + ${protobuf.version} + pom + import + + + com.google.http-client + google-http-client-bom + 1.34.0 + pom + import + + + + com.google.api + api-common + ${google.api-common.version} + + + com.google.api.grpc + proto-google-common-protos + ${google.common-protos.version} + + + com.google.api.grpc + grpc-google-common-protos + ${google.common-protos.version} + + + com.google.api.grpc + proto-google-iam-v1 + 0.13.0 + + + org.threeten + threetenbp + ${threeten.version} + + + javax.annotation + javax.annotation-api + ${javax.annotations.version} + + + org.codehaus.mojo + animal-sniffer-annotations + ${animal-sniffer.version} + + + io.opencensus + opencensus-api + ${opencensus.version} + + + io.opencensus + opencensus-contrib-grpc-util + ${opencensus.version} + + + + junit + junit + ${junit.version} + test + + + com.google.api + gax-grpc + ${gax.version} + testlib + test + + + com.google.truth + truth + 1.0 + test + + + + + + proto-google-cloud-spanner-admin-instance-v1 + proto-google-cloud-spanner-v1 + proto-google-cloud-spanner-admin-database-v1 + grpc-google-cloud-spanner-v1 + grpc-google-cloud-spanner-admin-instance-v1 + grpc-google-cloud-spanner-admin-database-v1 + google-cloud-spanner + google-cloud-spanner-bom + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + index + dependency-info + team + ci-management + issue-management + licenses + scm + dependency-management + distribution-management + summary + modules + + + + + true + ${site.installationModule} + jar + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + + html + + aggregate + javadoc + + + + + none + protected + true + ${project.build.directory}/javadoc + + + Test helpers packages + com.google.cloud.testing + + + SPI packages + com.google.cloud.spi* + + + + + https://grpc.io/grpc-java/javadoc/ + https://developers.google.com/protocol-buffers/docs/reference/java/ + https://googleapis.dev/java/google-auth-library/latest/ + https://googleapis.dev/java/gax/latest/ + https://googleapis.github.io/api-common-java/${google.api-common.version}/apidocs/ + + + + + + \ No newline at end of file diff --git a/proto-google-cloud-spanner-admin-database-v1/pom.xml b/proto-google-cloud-spanner-admin-database-v1/pom.xml index 59ec2d53720..b8c15f9cedc 100644 --- a/proto-google-cloud-spanner-admin-database-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-database-v1/pom.xml @@ -2,35 +2,36 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 1.47.1-SNAPSHOT proto-google-cloud-spanner-admin-database-v1 PROTO library for proto-google-cloud-spanner-admin-database-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT com.google.protobuf protobuf-java - compile + + + com.google.api.grpc + proto-google-common-protos com.google.api api-common - compile - com.google.api.grpc - proto-google-common-protos - compile + com.google.guava + guava com.google.api.grpc proto-google-iam-v1 - compile \ No newline at end of file diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadata.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadata.java index 6b1552cce98..38a5d3893af 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadata.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private CreateDatabaseMetadata() { database_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateDatabaseMetadata(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private CreateDatabaseMetadata( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -102,6 +122,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -122,6 +144,8 @@ public java.lang.String getDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -464,6 +488,8 @@ public Builder mergeFrom( * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -484,6 +510,8 @@ public java.lang.String getDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -504,6 +532,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -522,6 +553,8 @@ public Builder setDatabase(java.lang.String value) { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -537,6 +570,9 @@ public Builder clearDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadataOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadataOrBuilder.java index 6830fbb50fc..54efb57f228 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadataOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadataOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -16,6 +31,8 @@ public interface CreateDatabaseMetadataOrBuilder * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -26,6 +43,8 @@ public interface CreateDatabaseMetadataOrBuilder * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequest.java index 97338932196..bb659cb2469 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -29,6 +44,12 @@ private CreateDatabaseRequest() { extraStatements_ = com.google.protobuf.LazyStringArrayList.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateDatabaseRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -70,9 +91,9 @@ private CreateDatabaseRequest( case 26: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { extraStatements_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000001; } extraStatements_.add(s); break; @@ -91,7 +112,7 @@ private CreateDatabaseRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { extraStatements_ = extraStatements_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); @@ -114,7 +135,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.database.v1.CreateDatabaseRequest.Builder.class); } - private int bitField0_; public static final int PARENT_FIELD_NUMBER = 1; private volatile java.lang.Object parent_; /** @@ -128,6 +148,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -151,6 +173,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -178,6 +202,8 @@ public com.google.protobuf.ByteString getParentBytes() { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The createStatement. */ public java.lang.String getCreateStatement() { java.lang.Object ref = createStatement_; @@ -202,6 +228,8 @@ public java.lang.String getCreateStatement() { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for createStatement. */ public com.google.protobuf.ByteString getCreateStatementBytes() { java.lang.Object ref = createStatement_; @@ -228,6 +256,8 @@ public com.google.protobuf.ByteString getCreateStatementBytes() { * * * repeated string extra_statements = 3; + * + * @return A list containing the extraStatements. */ public com.google.protobuf.ProtocolStringList getExtraStatementsList() { return extraStatements_; @@ -243,6 +273,8 @@ public com.google.protobuf.ProtocolStringList getExtraStatementsList() { * * * repeated string extra_statements = 3; + * + * @return The count of extraStatements. */ public int getExtraStatementsCount() { return extraStatements_.size(); @@ -258,6 +290,9 @@ public int getExtraStatementsCount() { * * * repeated string extra_statements = 3; + * + * @param index The index of the element to return. + * @return The extraStatements at the given index. */ public java.lang.String getExtraStatements(int index) { return extraStatements_.get(index); @@ -273,6 +308,9 @@ public java.lang.String getExtraStatements(int index) { * * * repeated string extra_statements = 3; + * + * @param index The index of the value to return. + * @return The bytes of the extraStatements at the given index. */ public com.google.protobuf.ByteString getExtraStatementsBytes(int index) { return extraStatements_.getByteString(index); @@ -514,7 +552,7 @@ public Builder clear() { createStatement_ = ""; extraStatements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -543,15 +581,13 @@ public com.google.spanner.admin.database.v1.CreateDatabaseRequest buildPartial() com.google.spanner.admin.database.v1.CreateDatabaseRequest result = new com.google.spanner.admin.database.v1.CreateDatabaseRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.parent_ = parent_; result.createStatement_ = createStatement_; - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { extraStatements_ = extraStatements_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } result.extraStatements_ = extraStatements_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -613,7 +649,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.CreateDatabaseRequ if (!other.extraStatements_.isEmpty()) { if (extraStatements_.isEmpty()) { extraStatements_ = other.extraStatements_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureExtraStatementsIsMutable(); extraStatements_.addAll(other.extraStatements_); @@ -664,6 +700,8 @@ public Builder mergeFrom( * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -687,6 +725,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -710,6 +750,9 @@ public com.google.protobuf.ByteString getParentBytes() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The parent to set. + * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { @@ -731,6 +774,8 @@ public Builder setParent(java.lang.String value) { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearParent() { @@ -749,6 +794,9 @@ public Builder clearParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -774,6 +822,8 @@ public Builder setParentBytes(com.google.protobuf.ByteString value) { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The createStatement. */ public java.lang.String getCreateStatement() { java.lang.Object ref = createStatement_; @@ -798,6 +848,8 @@ public java.lang.String getCreateStatement() { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for createStatement. */ public com.google.protobuf.ByteString getCreateStatementBytes() { java.lang.Object ref = createStatement_; @@ -822,6 +874,9 @@ public com.google.protobuf.ByteString getCreateStatementBytes() { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The createStatement to set. + * @return This builder for chaining. */ public Builder setCreateStatement(java.lang.String value) { if (value == null) { @@ -844,6 +899,8 @@ public Builder setCreateStatement(java.lang.String value) { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearCreateStatement() { @@ -863,6 +920,9 @@ public Builder clearCreateStatement() { * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for createStatement to set. + * @return This builder for chaining. */ public Builder setCreateStatementBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -879,9 +939,9 @@ public Builder setCreateStatementBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureExtraStatementsIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { extraStatements_ = new com.google.protobuf.LazyStringArrayList(extraStatements_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000001; } } /** @@ -895,6 +955,8 @@ private void ensureExtraStatementsIsMutable() { * * * repeated string extra_statements = 3; + * + * @return A list containing the extraStatements. */ public com.google.protobuf.ProtocolStringList getExtraStatementsList() { return extraStatements_.getUnmodifiableView(); @@ -910,6 +972,8 @@ public com.google.protobuf.ProtocolStringList getExtraStatementsList() { * * * repeated string extra_statements = 3; + * + * @return The count of extraStatements. */ public int getExtraStatementsCount() { return extraStatements_.size(); @@ -925,6 +989,9 @@ public int getExtraStatementsCount() { * * * repeated string extra_statements = 3; + * + * @param index The index of the element to return. + * @return The extraStatements at the given index. */ public java.lang.String getExtraStatements(int index) { return extraStatements_.get(index); @@ -940,6 +1007,9 @@ public java.lang.String getExtraStatements(int index) { * * * repeated string extra_statements = 3; + * + * @param index The index of the value to return. + * @return The bytes of the extraStatements at the given index. */ public com.google.protobuf.ByteString getExtraStatementsBytes(int index) { return extraStatements_.getByteString(index); @@ -955,6 +1025,10 @@ public com.google.protobuf.ByteString getExtraStatementsBytes(int index) { * * * repeated string extra_statements = 3; + * + * @param index The index to set the value at. + * @param value The extraStatements to set. + * @return This builder for chaining. */ public Builder setExtraStatements(int index, java.lang.String value) { if (value == null) { @@ -976,6 +1050,9 @@ public Builder setExtraStatements(int index, java.lang.String value) { * * * repeated string extra_statements = 3; + * + * @param value The extraStatements to add. + * @return This builder for chaining. */ public Builder addExtraStatements(java.lang.String value) { if (value == null) { @@ -997,6 +1074,9 @@ public Builder addExtraStatements(java.lang.String value) { * * * repeated string extra_statements = 3; + * + * @param values The extraStatements to add. + * @return This builder for chaining. */ public Builder addAllExtraStatements(java.lang.Iterable values) { ensureExtraStatementsIsMutable(); @@ -1015,10 +1095,12 @@ public Builder addAllExtraStatements(java.lang.Iterable values * * * repeated string extra_statements = 3; + * + * @return This builder for chaining. */ public Builder clearExtraStatements() { extraStatements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -1033,6 +1115,9 @@ public Builder clearExtraStatements() { * * * repeated string extra_statements = 3; + * + * @param value The bytes of the extraStatements to add. + * @return This builder for chaining. */ public Builder addExtraStatementsBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequestOrBuilder.java index 56a8f3715b2..e4fe1708c81 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -19,6 +34,8 @@ public interface CreateDatabaseRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ java.lang.String getParent(); /** @@ -32,6 +49,8 @@ public interface CreateDatabaseRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ com.google.protobuf.ByteString getParentBytes(); @@ -47,6 +66,8 @@ public interface CreateDatabaseRequestOrBuilder * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The createStatement. */ java.lang.String getCreateStatement(); /** @@ -61,6 +82,8 @@ public interface CreateDatabaseRequestOrBuilder * * * string create_statement = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for createStatement. */ com.google.protobuf.ByteString getCreateStatementBytes(); @@ -75,6 +98,8 @@ public interface CreateDatabaseRequestOrBuilder * * * repeated string extra_statements = 3; + * + * @return A list containing the extraStatements. */ java.util.List getExtraStatementsList(); /** @@ -88,6 +113,8 @@ public interface CreateDatabaseRequestOrBuilder * * * repeated string extra_statements = 3; + * + * @return The count of extraStatements. */ int getExtraStatementsCount(); /** @@ -101,6 +128,9 @@ public interface CreateDatabaseRequestOrBuilder * * * repeated string extra_statements = 3; + * + * @param index The index of the element to return. + * @return The extraStatements at the given index. */ java.lang.String getExtraStatements(int index); /** @@ -114,6 +144,9 @@ public interface CreateDatabaseRequestOrBuilder * * * repeated string extra_statements = 3; + * + * @param index The index of the value to return. + * @return The bytes of the extraStatements at the given index. */ com.google.protobuf.ByteString getExtraStatementsBytes(int index); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Database.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Database.java index fd81b3833b4..2994d88cad0 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Database.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Database.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private Database() { state_ = 0; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Database(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private Database( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -183,12 +203,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static State valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static State forNumber(int value) { switch (value) { case 0: @@ -260,6 +288,8 @@ private State(int value) { * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -284,6 +314,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -307,6 +339,8 @@ public com.google.protobuf.ByteString getNameBytes() { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The enum numeric value on the wire for state. */ public int getStateValue() { return state_; @@ -319,6 +353,8 @@ public int getStateValue() { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The state. */ public com.google.spanner.admin.database.v1.Database.State getState() { @SuppressWarnings("deprecation") @@ -675,6 +711,8 @@ public Builder mergeFrom( * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -699,6 +737,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -723,6 +763,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -745,6 +788,8 @@ public Builder setName(java.lang.String value) { * * * string name = 1; + * + * @return This builder for chaining. */ public Builder clearName() { @@ -764,6 +809,9 @@ public Builder clearName() { * * * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -785,6 +833,8 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The enum numeric value on the wire for state. */ public int getStateValue() { return state_; @@ -797,6 +847,9 @@ public int getStateValue() { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. */ public Builder setStateValue(int value) { state_ = value; @@ -811,6 +864,8 @@ public Builder setStateValue(int value) { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The state. */ public com.google.spanner.admin.database.v1.Database.State getState() { @SuppressWarnings("deprecation") @@ -828,6 +883,9 @@ public com.google.spanner.admin.database.v1.Database.State getState() { * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @param value The state to set. + * @return This builder for chaining. */ public Builder setState(com.google.spanner.admin.database.v1.Database.State value) { if (value == null) { @@ -846,6 +904,8 @@ public Builder setState(com.google.spanner.admin.database.v1.Database.State valu * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return This builder for chaining. */ public Builder clearState() { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseName.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseName.java index 6b5a5d482f2..86d875bea6d 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseName.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.admin.database.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class DatabaseName implements ResourceName { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseOrBuilder.java index 13cbd9757f8..1d1074d1b03 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -20,6 +35,8 @@ public interface DatabaseOrBuilder * * * string name = 1; + * + * @return The name. */ java.lang.String getName(); /** @@ -34,6 +51,8 @@ public interface DatabaseOrBuilder * * * string name = 1; + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -45,6 +64,8 @@ public interface DatabaseOrBuilder * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The enum numeric value on the wire for state. */ int getStateValue(); /** @@ -55,6 +76,8 @@ public interface DatabaseOrBuilder * * * .google.spanner.admin.database.v1.Database.State state = 2; + * + * @return The state. */ com.google.spanner.admin.database.v1.Database.State getState(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequest.java index 93a7239af12..66be7b4fe2f 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private DropDatabaseRequest() { database_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DropDatabaseRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private DropDatabaseRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -104,6 +124,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -126,6 +148,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -470,6 +494,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -492,6 +518,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -514,6 +542,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -534,6 +565,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -551,6 +584,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequestOrBuilder.java index cb8ef2c3982..aa88c7d714e 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -18,6 +33,8 @@ public interface DropDatabaseRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface DropDatabaseRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequest.java index 4311944637a..6470b940c08 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private GetDatabaseDdlRequest() { database_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetDatabaseDdlRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private GetDatabaseDdlRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -104,6 +124,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -126,6 +148,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -470,6 +494,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -492,6 +518,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -514,6 +542,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -534,6 +565,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -551,6 +584,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequestOrBuilder.java index d74076b7ff5..d5e0a579592 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -18,6 +33,8 @@ public interface GetDatabaseDdlRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface GetDatabaseDdlRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponse.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponse.java index cfd704a1d9d..c8b7b517e93 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponse.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private GetDatabaseDdlResponse() { statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetDatabaseDdlResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -109,6 +130,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * repeated string statements = 1; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_; @@ -122,6 +145,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 1; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -135,6 +160,9 @@ public int getStatementsCount() { * * * repeated string statements = 1; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -148,6 +176,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 1; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -511,6 +542,8 @@ private void ensureStatementsIsMutable() { * * * repeated string statements = 1; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_.getUnmodifiableView(); @@ -524,6 +557,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 1; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -537,6 +572,9 @@ public int getStatementsCount() { * * * repeated string statements = 1; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -550,6 +588,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 1; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -563,6 +604,10 @@ public com.google.protobuf.ByteString getStatementsBytes(int index) { * * * repeated string statements = 1; + * + * @param index The index to set the value at. + * @param value The statements to set. + * @return This builder for chaining. */ public Builder setStatements(int index, java.lang.String value) { if (value == null) { @@ -582,6 +627,9 @@ public Builder setStatements(int index, java.lang.String value) { * * * repeated string statements = 1; + * + * @param value The statements to add. + * @return This builder for chaining. */ public Builder addStatements(java.lang.String value) { if (value == null) { @@ -601,6 +649,9 @@ public Builder addStatements(java.lang.String value) { * * * repeated string statements = 1; + * + * @param values The statements to add. + * @return This builder for chaining. */ public Builder addAllStatements(java.lang.Iterable values) { ensureStatementsIsMutable(); @@ -617,6 +668,8 @@ public Builder addAllStatements(java.lang.Iterable values) { * * * repeated string statements = 1; + * + * @return This builder for chaining. */ public Builder clearStatements() { statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; @@ -633,6 +686,9 @@ public Builder clearStatements() { * * * repeated string statements = 1; + * + * @param value The bytes of the statements to add. + * @return This builder for chaining. */ public Builder addStatementsBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponseOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponseOrBuilder.java index 3588da7a90b..c8e86f5f8db 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponseOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -17,6 +32,8 @@ public interface GetDatabaseDdlResponseOrBuilder * * * repeated string statements = 1; + * + * @return A list containing the statements. */ java.util.List getStatementsList(); /** @@ -28,6 +45,8 @@ public interface GetDatabaseDdlResponseOrBuilder * * * repeated string statements = 1; + * + * @return The count of statements. */ int getStatementsCount(); /** @@ -39,6 +58,9 @@ public interface GetDatabaseDdlResponseOrBuilder * * * repeated string statements = 1; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ java.lang.String getStatements(int index); /** @@ -50,6 +72,9 @@ public interface GetDatabaseDdlResponseOrBuilder * * * repeated string statements = 1; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ com.google.protobuf.ByteString getStatementsBytes(int index); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequest.java index 706caa96bd2..a293a6d505b 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +42,12 @@ private GetDatabaseRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetDatabaseRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private GetDatabaseRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -105,6 +125,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -128,6 +150,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -473,6 +497,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -496,6 +522,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -519,6 +547,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -540,6 +571,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -558,6 +591,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequestOrBuilder.java index 41e07a84f69..c64b857a9a8 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -19,6 +34,8 @@ public interface GetDatabaseRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -32,6 +49,8 @@ public interface GetDatabaseRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/InstanceName.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/InstanceName.java index 4b9be8cf906..5d06419da5d 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/InstanceName.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/InstanceName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.admin.database.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class InstanceName implements ResourceName { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequest.java index 10087481172..ab2cb243760 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -28,6 +43,12 @@ private ListDatabasesRequest() { pageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListDatabasesRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -41,7 +62,6 @@ private ListDatabasesRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -118,6 +138,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -141,6 +163,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -165,6 +189,8 @@ public com.google.protobuf.ByteString getParentBytes() { * * * int32 page_size = 3; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -183,6 +209,8 @@ public int getPageSize() { * * * string page_token = 4; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -206,6 +234,8 @@ public java.lang.String getPageToken() { * * * string page_token = 4; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -582,6 +612,8 @@ public Builder mergeFrom( * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -605,6 +637,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -628,6 +662,9 @@ public com.google.protobuf.ByteString getParentBytes() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The parent to set. + * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { @@ -649,6 +686,8 @@ public Builder setParent(java.lang.String value) { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearParent() { @@ -667,6 +706,9 @@ public Builder clearParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -689,6 +731,8 @@ public Builder setParentBytes(com.google.protobuf.ByteString value) { * * * int32 page_size = 3; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -702,6 +746,9 @@ public int getPageSize() { * * * int32 page_size = 3; + * + * @param value The pageSize to set. + * @return This builder for chaining. */ public Builder setPageSize(int value) { @@ -718,6 +765,8 @@ public Builder setPageSize(int value) { * * * int32 page_size = 3; + * + * @return This builder for chaining. */ public Builder clearPageSize() { @@ -738,6 +787,8 @@ public Builder clearPageSize() { * * * string page_token = 4; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -761,6 +812,8 @@ public java.lang.String getPageToken() { * * * string page_token = 4; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -784,6 +837,9 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string page_token = 4; + * + * @param value The pageToken to set. + * @return This builder for chaining. */ public Builder setPageToken(java.lang.String value) { if (value == null) { @@ -805,6 +861,8 @@ public Builder setPageToken(java.lang.String value) { * * * string page_token = 4; + * + * @return This builder for chaining. */ public Builder clearPageToken() { @@ -823,6 +881,9 @@ public Builder clearPageToken() { * * * string page_token = 4; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. */ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequestOrBuilder.java index cf48f05b099..67d817ac9d1 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -19,6 +34,8 @@ public interface ListDatabasesRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ java.lang.String getParent(); /** @@ -32,6 +49,8 @@ public interface ListDatabasesRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ com.google.protobuf.ByteString getParentBytes(); @@ -44,6 +63,8 @@ public interface ListDatabasesRequestOrBuilder * * * int32 page_size = 3; + * + * @return The pageSize. */ int getPageSize(); @@ -58,6 +79,8 @@ public interface ListDatabasesRequestOrBuilder * * * string page_token = 4; + * + * @return The pageToken. */ java.lang.String getPageToken(); /** @@ -71,6 +94,8 @@ public interface ListDatabasesRequestOrBuilder * * * string page_token = 4; + * + * @return The bytes for pageToken. */ com.google.protobuf.ByteString getPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponse.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponse.java index beeb0decddd..7b6b79afd06 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponse.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -28,6 +43,12 @@ private ListDatabasesResponse() { nextPageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListDatabasesResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -108,7 +129,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.database.v1.ListDatabasesResponse.Builder.class); } - private int bitField0_; public static final int DATABASES_FIELD_NUMBER = 1; private java.util.List databases_; /** @@ -185,6 +205,8 @@ public com.google.spanner.admin.database.v1.DatabaseOrBuilder getDatabasesOrBuil * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -207,6 +229,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -475,7 +499,6 @@ public com.google.spanner.admin.database.v1.ListDatabasesResponse buildPartial() com.google.spanner.admin.database.v1.ListDatabasesResponse result = new com.google.spanner.admin.database.v1.ListDatabasesResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (databasesBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { databases_ = java.util.Collections.unmodifiableList(databases_); @@ -486,7 +509,6 @@ public com.google.spanner.admin.database.v1.ListDatabasesResponse buildPartial() result.databases_ = databasesBuilder_.build(); } result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -962,6 +984,8 @@ public com.google.spanner.admin.database.v1.Database.Builder addDatabasesBuilder * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -984,6 +1008,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -1006,6 +1032,9 @@ public com.google.protobuf.ByteString getNextPageTokenBytes() { * * * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageToken(java.lang.String value) { if (value == null) { @@ -1026,6 +1055,8 @@ public Builder setNextPageToken(java.lang.String value) { * * * string next_page_token = 2; + * + * @return This builder for chaining. */ public Builder clearNextPageToken() { @@ -1043,6 +1074,9 @@ public Builder clearNextPageToken() { * * * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponseOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponseOrBuilder.java index ca8f7b972d4..2ebc92e0b86 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponseOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -70,6 +85,8 @@ public interface ListDatabasesResponseOrBuilder * * * string next_page_token = 2; + * + * @return The nextPageToken. */ java.lang.String getNextPageToken(); /** @@ -82,6 +99,8 @@ public interface ListDatabasesResponseOrBuilder * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ com.google.protobuf.ByteString getNextPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java index 9a98b291bfb..08c7e6c9440 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -171,28 +186,20 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "er.googleapis.com/Instance\022\'projects/{pr" + "oject}/instances/{instance}b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.api.ClientProto.getDescriptor(), - com.google.api.FieldBehaviorProto.getDescriptor(), - com.google.api.ResourceProto.getDescriptor(), - com.google.iam.v1.IamPolicyProto.getDescriptor(), - com.google.iam.v1.PolicyProto.getDescriptor(), - com.google.longrunning.OperationsProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.iam.v1.IamPolicyProto.getDescriptor(), + com.google.iam.v1.PolicyProto.getDescriptor(), + com.google.longrunning.OperationsProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); internal_static_google_spanner_admin_database_v1_Database_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_admin_database_v1_Database_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadata.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadata.java index 0f504c937e6..5fff2a55eb7 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadata.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -29,6 +44,12 @@ private UpdateDatabaseDdlMetadata() { commitTimestamps_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateDatabaseDdlMetadata(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -63,18 +84,18 @@ private UpdateDatabaseDdlMetadata( case 18: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } statements_.add(s); break; } case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { commitTimestamps_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000002; } commitTimestamps_.add( input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry)); @@ -94,10 +115,10 @@ private UpdateDatabaseDdlMetadata( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = statements_.getUnmodifiableView(); } - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000002) != 0)) { commitTimestamps_ = java.util.Collections.unmodifiableList(commitTimestamps_); } this.unknownFields = unknownFields.build(); @@ -120,7 +141,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata.Builder.class); } - private int bitField0_; public static final int DATABASE_FIELD_NUMBER = 1; private volatile java.lang.Object database_; /** @@ -131,6 +151,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -151,6 +173,8 @@ public java.lang.String getDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -175,6 +199,8 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * repeated string statements = 2; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_; @@ -188,6 +214,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 2; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -201,6 +229,9 @@ public int getStatementsCount() { * * * repeated string statements = 2; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -214,6 +245,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 2; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -531,10 +565,10 @@ public Builder clear() { database_ = ""; statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); if (commitTimestampsBuilder_ == null) { commitTimestamps_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { commitTimestampsBuilder_.clear(); } @@ -567,23 +601,21 @@ public com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata buildParti com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata result = new com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.database_ = database_; - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { statements_ = statements_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.statements_ = statements_; if (commitTimestampsBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { commitTimestamps_ = java.util.Collections.unmodifiableList(commitTimestamps_); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } result.commitTimestamps_ = commitTimestamps_; } else { result.commitTimestamps_ = commitTimestampsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -642,7 +674,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.UpdateDatabaseDdlM if (!other.statements_.isEmpty()) { if (statements_.isEmpty()) { statements_ = other.statements_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureStatementsIsMutable(); statements_.addAll(other.statements_); @@ -653,7 +685,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.UpdateDatabaseDdlM if (!other.commitTimestamps_.isEmpty()) { if (commitTimestamps_.isEmpty()) { commitTimestamps_ = other.commitTimestamps_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { ensureCommitTimestampsIsMutable(); commitTimestamps_.addAll(other.commitTimestamps_); @@ -666,7 +698,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.UpdateDatabaseDdlM commitTimestampsBuilder_.dispose(); commitTimestampsBuilder_ = null; commitTimestamps_ = other.commitTimestamps_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); commitTimestampsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getCommitTimestampsFieldBuilder() @@ -718,6 +750,8 @@ public Builder mergeFrom( * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -738,6 +772,8 @@ public java.lang.String getDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -758,6 +794,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -776,6 +815,8 @@ public Builder setDatabase(java.lang.String value) { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -791,6 +832,9 @@ public Builder clearDatabase() { * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -807,9 +851,9 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureStatementsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { statements_ = new com.google.protobuf.LazyStringArrayList(statements_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } /** @@ -821,6 +865,8 @@ private void ensureStatementsIsMutable() { * * * repeated string statements = 2; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_.getUnmodifiableView(); @@ -834,6 +880,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 2; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -847,6 +895,9 @@ public int getStatementsCount() { * * * repeated string statements = 2; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -860,6 +911,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 2; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -873,6 +927,10 @@ public com.google.protobuf.ByteString getStatementsBytes(int index) { * * * repeated string statements = 2; + * + * @param index The index to set the value at. + * @param value The statements to set. + * @return This builder for chaining. */ public Builder setStatements(int index, java.lang.String value) { if (value == null) { @@ -892,6 +950,9 @@ public Builder setStatements(int index, java.lang.String value) { * * * repeated string statements = 2; + * + * @param value The statements to add. + * @return This builder for chaining. */ public Builder addStatements(java.lang.String value) { if (value == null) { @@ -911,6 +972,9 @@ public Builder addStatements(java.lang.String value) { * * * repeated string statements = 2; + * + * @param values The statements to add. + * @return This builder for chaining. */ public Builder addAllStatements(java.lang.Iterable values) { ensureStatementsIsMutable(); @@ -927,10 +991,12 @@ public Builder addAllStatements(java.lang.Iterable values) { * * * repeated string statements = 2; + * + * @return This builder for chaining. */ public Builder clearStatements() { statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -943,6 +1009,9 @@ public Builder clearStatements() { * * * repeated string statements = 2; + * + * @param value The bytes of the statements to add. + * @return This builder for chaining. */ public Builder addStatementsBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -959,10 +1028,10 @@ public Builder addStatementsBytes(com.google.protobuf.ByteString value) { java.util.Collections.emptyList(); private void ensureCommitTimestampsIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000002) != 0)) { commitTimestamps_ = new java.util.ArrayList(commitTimestamps_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000002; } } @@ -1199,7 +1268,7 @@ public Builder addAllCommitTimestamps( public Builder clearCommitTimestamps() { if (commitTimestampsBuilder_ == null) { commitTimestamps_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); } else { commitTimestampsBuilder_.clear(); @@ -1335,7 +1404,7 @@ public java.util.List getCommitTimestamps com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>( commitTimestamps_, - ((bitField0_ & 0x00000004) != 0), + ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); commitTimestamps_ = null; diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadataOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadataOrBuilder.java index ab533ff8884..57dedd59836 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadataOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadataOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -16,6 +31,8 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -26,6 +43,8 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * string database = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); @@ -38,6 +57,8 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * repeated string statements = 2; + * + * @return A list containing the statements. */ java.util.List getStatementsList(); /** @@ -49,6 +70,8 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * repeated string statements = 2; + * + * @return The count of statements. */ int getStatementsCount(); /** @@ -60,6 +83,9 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * repeated string statements = 2; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ java.lang.String getStatements(int index); /** @@ -71,6 +97,9 @@ public interface UpdateDatabaseDdlMetadataOrBuilder * * * repeated string statements = 2; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ com.google.protobuf.ByteString getStatementsBytes(int index); diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequest.java index 7972f052291..9fe843e22f6 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequest.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -42,6 +57,12 @@ private UpdateDatabaseDdlRequest() { operationId_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateDatabaseDdlRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -76,9 +97,9 @@ private UpdateDatabaseDdlRequest( case 18: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } statements_.add(s); break; @@ -104,7 +125,7 @@ private UpdateDatabaseDdlRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = statements_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); @@ -127,7 +148,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.Builder.class); } - private int bitField0_; public static final int DATABASE_FIELD_NUMBER = 1; private volatile java.lang.Object database_; /** @@ -140,6 +160,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -162,6 +184,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -185,6 +209,8 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_; @@ -197,6 +223,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -209,6 +237,9 @@ public int getStatementsCount() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -221,6 +252,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -254,6 +288,8 @@ public com.google.protobuf.ByteString getStatementsBytes(int index) { * * * string operation_id = 3; + * + * @return The operationId. */ public java.lang.String getOperationId() { java.lang.Object ref = operationId_; @@ -292,6 +328,8 @@ public java.lang.String getOperationId() { * * * string operation_id = 3; + * + * @return The bytes for operationId. */ public com.google.protobuf.ByteString getOperationIdBytes() { java.lang.Object ref = operationId_; @@ -552,7 +590,7 @@ public Builder clear() { database_ = ""; statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); operationId_ = ""; return this; @@ -584,15 +622,13 @@ public com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest buildPartia com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest result = new com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.database_ = database_; - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { statements_ = statements_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.statements_ = statements_; result.operationId_ = operationId_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -651,7 +687,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.UpdateDatabaseDdlR if (!other.statements_.isEmpty()) { if (statements_.isEmpty()) { statements_ = other.statements_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureStatementsIsMutable(); statements_.addAll(other.statements_); @@ -706,6 +742,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -728,6 +766,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -750,6 +790,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -770,6 +813,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -787,6 +832,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -803,9 +851,9 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureStatementsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { statements_ = new com.google.protobuf.LazyStringArrayList(statements_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } /** @@ -816,6 +864,8 @@ private void ensureStatementsIsMutable() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the statements. */ public com.google.protobuf.ProtocolStringList getStatementsList() { return statements_.getUnmodifiableView(); @@ -828,6 +878,8 @@ public com.google.protobuf.ProtocolStringList getStatementsList() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of statements. */ public int getStatementsCount() { return statements_.size(); @@ -840,6 +892,9 @@ public int getStatementsCount() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ public java.lang.String getStatements(int index) { return statements_.get(index); @@ -852,6 +907,9 @@ public java.lang.String getStatements(int index) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ public com.google.protobuf.ByteString getStatementsBytes(int index) { return statements_.getByteString(index); @@ -864,6 +922,10 @@ public com.google.protobuf.ByteString getStatementsBytes(int index) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index to set the value at. + * @param value The statements to set. + * @return This builder for chaining. */ public Builder setStatements(int index, java.lang.String value) { if (value == null) { @@ -882,6 +944,9 @@ public Builder setStatements(int index, java.lang.String value) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The statements to add. + * @return This builder for chaining. */ public Builder addStatements(java.lang.String value) { if (value == null) { @@ -900,6 +965,9 @@ public Builder addStatements(java.lang.String value) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param values The statements to add. + * @return This builder for chaining. */ public Builder addAllStatements(java.lang.Iterable values) { ensureStatementsIsMutable(); @@ -915,10 +983,12 @@ public Builder addAllStatements(java.lang.Iterable values) { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearStatements() { statements_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -930,6 +1000,9 @@ public Builder clearStatements() { * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes of the statements to add. + * @return This builder for chaining. */ public Builder addStatementsBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -969,6 +1042,8 @@ public Builder addStatementsBytes(com.google.protobuf.ByteString value) { * * * string operation_id = 3; + * + * @return The operationId. */ public java.lang.String getOperationId() { java.lang.Object ref = operationId_; @@ -1007,6 +1082,8 @@ public java.lang.String getOperationId() { * * * string operation_id = 3; + * + * @return The bytes for operationId. */ public com.google.protobuf.ByteString getOperationIdBytes() { java.lang.Object ref = operationId_; @@ -1045,6 +1122,9 @@ public com.google.protobuf.ByteString getOperationIdBytes() { * * * string operation_id = 3; + * + * @param value The operationId to set. + * @return This builder for chaining. */ public Builder setOperationId(java.lang.String value) { if (value == null) { @@ -1081,6 +1161,8 @@ public Builder setOperationId(java.lang.String value) { * * * string operation_id = 3; + * + * @return This builder for chaining. */ public Builder clearOperationId() { @@ -1114,6 +1196,9 @@ public Builder clearOperationId() { * * * string operation_id = 3; + * + * @param value The bytes for operationId to set. + * @return This builder for chaining. */ public Builder setOperationIdBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequestOrBuilder.java index 7a48ee2792d..b5c654b880b 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/database/v1/spanner_database_admin.proto @@ -18,6 +33,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); @@ -41,6 +60,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the statements. */ java.util.List getStatementsList(); /** @@ -51,6 +72,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of statements. */ int getStatementsCount(); /** @@ -61,6 +84,9 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The statements at the given index. */ java.lang.String getStatements(int index); /** @@ -71,6 +97,9 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * repeated string statements = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the statements at the given index. */ com.google.protobuf.ByteString getStatementsBytes(int index); @@ -100,6 +129,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * string operation_id = 3; + * + * @return The operationId. */ java.lang.String getOperationId(); /** @@ -128,6 +159,8 @@ public interface UpdateDatabaseDdlRequestOrBuilder * * * string operation_id = 3; + * + * @return The bytes for operationId. */ com.google.protobuf.ByteString getOperationIdBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/pom.xml b/proto-google-cloud-spanner-admin-instance-v1/pom.xml index 77dbec0d07e..d0fbd36b345 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-instance-v1/pom.xml @@ -2,35 +2,36 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 1.47.1-SNAPSHOT proto-google-cloud-spanner-admin-instance-v1 PROTO library for proto-google-cloud-spanner-admin-instance-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT com.google.protobuf protobuf-java - compile + + + com.google.api.grpc + proto-google-common-protos com.google.api api-common - compile - com.google.api.grpc - proto-google-common-protos - compile + com.google.guava + guava com.google.api.grpc proto-google-iam-v1 - compile \ No newline at end of file diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadata.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadata.java index 4f4478b4918..aafd144c954 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadata.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -25,6 +40,12 @@ private CreateInstanceMetadata(com.google.protobuf.GeneratedMessageV3.Builder private CreateInstanceMetadata() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateInstanceMetadata(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -38,7 +59,6 @@ private CreateInstanceMetadata( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -154,6 +174,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instance_ != null; @@ -166,6 +188,8 @@ public boolean hasInstance() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { return instance_ == null @@ -197,6 +221,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ public boolean hasStartTime() { return startTime_ != null; @@ -211,6 +237,8 @@ public boolean hasStartTime() { * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ public com.google.protobuf.Timestamp getStartTime() { return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; @@ -242,6 +270,8 @@ public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ public boolean hasCancelTime() { return cancelTime_ != null; @@ -256,6 +286,8 @@ public boolean hasCancelTime() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ public com.google.protobuf.Timestamp getCancelTime() { return cancelTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : cancelTime_; @@ -285,6 +317,8 @@ public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ public boolean hasEndTime() { return endTime_ != null; @@ -297,6 +331,8 @@ public boolean hasEndTime() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ public com.google.protobuf.Timestamp getEndTime() { return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; @@ -744,6 +780,8 @@ public Builder mergeFrom( * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instanceBuilder_ != null || instance_ != null; @@ -756,6 +794,8 @@ public boolean hasInstance() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { if (instanceBuilder_ == null) { @@ -928,6 +968,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ public boolean hasStartTime() { return startTimeBuilder_ != null || startTime_ != null; @@ -942,6 +984,8 @@ public boolean hasStartTime() { * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ public com.google.protobuf.Timestamp getStartTime() { if (startTimeBuilder_ == null) { @@ -1121,6 +1165,8 @@ public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ public boolean hasCancelTime() { return cancelTimeBuilder_ != null || cancelTime_ != null; @@ -1135,6 +1181,8 @@ public boolean hasCancelTime() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ public com.google.protobuf.Timestamp getCancelTime() { if (cancelTimeBuilder_ == null) { @@ -1316,6 +1364,8 @@ public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ public boolean hasEndTime() { return endTimeBuilder_ != null || endTime_ != null; @@ -1328,6 +1378,8 @@ public boolean hasEndTime() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ public com.google.protobuf.Timestamp getEndTime() { if (endTimeBuilder_ == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadataOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadataOrBuilder.java index 5148378400f..2c6e1407ea0 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadataOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadataOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -16,6 +31,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ boolean hasInstance(); /** @@ -26,6 +43,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ com.google.spanner.admin.instance.v1.Instance getInstance(); /** @@ -49,6 +68,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ boolean hasStartTime(); /** @@ -61,6 +82,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ com.google.protobuf.Timestamp getStartTime(); /** @@ -86,6 +109,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ boolean hasCancelTime(); /** @@ -98,6 +123,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ com.google.protobuf.Timestamp getCancelTime(); /** @@ -121,6 +148,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ boolean hasEndTime(); /** @@ -131,6 +160,8 @@ public interface CreateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ com.google.protobuf.Timestamp getEndTime(); /** diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequest.java index 109c2d640c9..b0612b233ce 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -27,6 +42,12 @@ private CreateInstanceRequest() { instanceId_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateInstanceRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private CreateInstanceRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -128,6 +148,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -151,6 +173,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -176,6 +200,8 @@ public com.google.protobuf.ByteString getParentBytes() { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The instanceId. */ public java.lang.String getInstanceId() { java.lang.Object ref = instanceId_; @@ -198,6 +224,8 @@ public java.lang.String getInstanceId() { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for instanceId. */ public com.google.protobuf.ByteString getInstanceIdBytes() { java.lang.Object ref = instanceId_; @@ -224,6 +252,8 @@ public com.google.protobuf.ByteString getInstanceIdBytes() { * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instance_ != null; @@ -239,6 +269,8 @@ public boolean hasInstance() { * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { return instance_ == null @@ -636,6 +668,8 @@ public Builder mergeFrom( * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -659,6 +693,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -682,6 +718,9 @@ public com.google.protobuf.ByteString getParentBytes() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The parent to set. + * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { @@ -703,6 +742,8 @@ public Builder setParent(java.lang.String value) { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearParent() { @@ -721,6 +762,9 @@ public Builder clearParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -744,6 +788,8 @@ public Builder setParentBytes(com.google.protobuf.ByteString value) { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The instanceId. */ public java.lang.String getInstanceId() { java.lang.Object ref = instanceId_; @@ -766,6 +812,8 @@ public java.lang.String getInstanceId() { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for instanceId. */ public com.google.protobuf.ByteString getInstanceIdBytes() { java.lang.Object ref = instanceId_; @@ -788,6 +836,9 @@ public com.google.protobuf.ByteString getInstanceIdBytes() { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The instanceId to set. + * @return This builder for chaining. */ public Builder setInstanceId(java.lang.String value) { if (value == null) { @@ -808,6 +859,8 @@ public Builder setInstanceId(java.lang.String value) { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearInstanceId() { @@ -825,6 +878,9 @@ public Builder clearInstanceId() { * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for instanceId to set. + * @return This builder for chaining. */ public Builder setInstanceIdBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -854,6 +910,8 @@ public Builder setInstanceIdBytes(com.google.protobuf.ByteString value) { * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instanceBuilder_ != null || instance_ != null; @@ -869,6 +927,8 @@ public boolean hasInstance() { * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { if (instanceBuilder_ == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequestOrBuilder.java index f99b87bd6d9..603aab0467c 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface CreateInstanceRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ java.lang.String getParent(); /** @@ -32,6 +49,8 @@ public interface CreateInstanceRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ com.google.protobuf.ByteString getParentBytes(); @@ -45,6 +64,8 @@ public interface CreateInstanceRequestOrBuilder * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The instanceId. */ java.lang.String getInstanceId(); /** @@ -57,6 +78,8 @@ public interface CreateInstanceRequestOrBuilder * * * string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for instanceId. */ com.google.protobuf.ByteString getInstanceIdBytes(); @@ -71,6 +94,8 @@ public interface CreateInstanceRequestOrBuilder * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ boolean hasInstance(); /** @@ -84,6 +109,8 @@ public interface CreateInstanceRequestOrBuilder * * .google.spanner.admin.instance.v1.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ com.google.spanner.admin.instance.v1.Instance getInstance(); /** diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequest.java index b32786d357f..2d11b64b3c1 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -26,6 +41,12 @@ private DeleteInstanceRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteInstanceRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private DeleteInstanceRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -104,6 +124,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -127,6 +149,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -471,6 +495,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -494,6 +520,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -517,6 +545,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -538,6 +569,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -556,6 +589,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequestOrBuilder.java index 2036c7ec50a..4a1c3234072 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface DeleteInstanceRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -32,6 +49,8 @@ public interface DeleteInstanceRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequest.java index 208d8918f7f..cf971aa7825 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -27,6 +42,12 @@ private GetInstanceConfigRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetInstanceConfigRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private GetInstanceConfigRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -105,6 +125,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -128,6 +150,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -476,6 +500,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -499,6 +525,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -522,6 +550,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -543,6 +574,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -561,6 +594,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequestOrBuilder.java index baf5f881b76..318a79bb237 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface GetInstanceConfigRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -32,6 +49,8 @@ public interface GetInstanceConfigRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequest.java index f8ddc2338c5..4cbeb750aa4 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -26,6 +41,12 @@ private GetInstanceRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetInstanceRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private GetInstanceRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -119,6 +139,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -142,6 +164,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -167,6 +191,8 @@ public com.google.protobuf.ByteString getNameBytes() { * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return Whether the fieldMask field is set. */ public boolean hasFieldMask() { return fieldMask_ != null; @@ -181,6 +207,8 @@ public boolean hasFieldMask() { * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return The fieldMask. */ public com.google.protobuf.FieldMask getFieldMask() { return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; @@ -559,6 +587,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -582,6 +612,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -605,6 +637,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -626,6 +661,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -644,6 +681,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -672,6 +712,8 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return Whether the fieldMask field is set. */ public boolean hasFieldMask() { return fieldMaskBuilder_ != null || fieldMask_ != null; @@ -686,6 +728,8 @@ public boolean hasFieldMask() { * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return The fieldMask. */ public com.google.protobuf.FieldMask getFieldMask() { if (fieldMaskBuilder_ == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequestOrBuilder.java index 15a7ccb827a..76f9db5955e 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface GetInstanceRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -32,6 +49,8 @@ public interface GetInstanceRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -45,6 +64,8 @@ public interface GetInstanceRequestOrBuilder * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return Whether the fieldMask field is set. */ boolean hasFieldMask(); /** @@ -57,6 +78,8 @@ public interface GetInstanceRequestOrBuilder * * * .google.protobuf.FieldMask field_mask = 2; + * + * @return The fieldMask. */ com.google.protobuf.FieldMask getFieldMask(); /** diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java index a6fd7baab07..c0c2279bdb8 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -30,6 +45,12 @@ private Instance() { endpointUris_ = com.google.protobuf.LazyStringArrayList.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Instance(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -89,10 +110,10 @@ private Instance( } case 58: { - if (!((mutable_bitField0_ & 0x00000020) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { labels_ = com.google.protobuf.MapField.newMapField(LabelsDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000020; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry labels__ = input.readMessage( @@ -103,9 +124,9 @@ private Instance( case 66: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000040) != 0)) { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { endpointUris_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000040; + mutable_bitField0_ |= 0x00000002; } endpointUris_.add(s); break; @@ -124,7 +145,7 @@ private Instance( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000040) != 0)) { + if (((mutable_bitField0_ & 0x00000002) != 0)) { endpointUris_ = endpointUris_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); @@ -246,12 +267,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static State valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static State forNumber(int value) { switch (value) { case 0: @@ -309,7 +338,6 @@ private State(int value) { // @@protoc_insertion_point(enum_scope:google.spanner.admin.instance.v1.Instance.State) } - private int bitField0_; public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; /** @@ -323,6 +351,8 @@ private State(int value) { * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -346,6 +376,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -372,6 +404,8 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The config. */ public java.lang.String getConfig() { java.lang.Object ref = config_; @@ -395,6 +429,8 @@ public java.lang.String getConfig() { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for config. */ public com.google.protobuf.ByteString getConfigBytes() { java.lang.Object ref = config_; @@ -419,6 +455,8 @@ public com.google.protobuf.ByteString getConfigBytes() { * * * string display_name = 3; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -440,6 +478,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 3; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -467,6 +507,8 @@ public com.google.protobuf.ByteString getDisplayNameBytes() { * * * int32 node_count = 5; + * + * @return The nodeCount. */ public int getNodeCount() { return nodeCount_; @@ -486,6 +528,8 @@ public int getNodeCount() { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The enum numeric value on the wire for state. */ public int getStateValue() { return state_; @@ -502,6 +546,8 @@ public int getStateValue() { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The state. */ public com.google.spanner.admin.instance.v1.Instance.State getState() { @SuppressWarnings("deprecation") @@ -690,6 +736,8 @@ public java.lang.String getLabelsOrThrow(java.lang.String key) { * * * repeated string endpoint_uris = 8; + * + * @return A list containing the endpointUris. */ public com.google.protobuf.ProtocolStringList getEndpointUrisList() { return endpointUris_; @@ -709,6 +757,8 @@ public com.google.protobuf.ProtocolStringList getEndpointUrisList() { * * * repeated string endpoint_uris = 8; + * + * @return The count of endpointUris. */ public int getEndpointUrisCount() { return endpointUris_.size(); @@ -728,6 +778,9 @@ public int getEndpointUrisCount() { * * * repeated string endpoint_uris = 8; + * + * @param index The index of the element to return. + * @return The endpointUris at the given index. */ public java.lang.String getEndpointUris(int index) { return endpointUris_.get(index); @@ -747,6 +800,9 @@ public java.lang.String getEndpointUris(int index) { * * * repeated string endpoint_uris = 8; + * + * @param index The index of the value to return. + * @return The bytes of the endpointUris at the given index. */ public com.google.protobuf.ByteString getEndpointUrisBytes(int index) { return endpointUris_.getByteString(index); @@ -1059,7 +1115,7 @@ public Builder clear() { internalGetMutableLabels().clear(); endpointUris_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -1088,7 +1144,6 @@ public com.google.spanner.admin.instance.v1.Instance buildPartial() { com.google.spanner.admin.instance.v1.Instance result = new com.google.spanner.admin.instance.v1.Instance(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.name_ = name_; result.config_ = config_; result.displayName_ = displayName_; @@ -1096,12 +1151,11 @@ public com.google.spanner.admin.instance.v1.Instance buildPartial() { result.state_ = state_; result.labels_ = internalGetLabels(); result.labels_.makeImmutable(); - if (((bitField0_ & 0x00000040) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { endpointUris_ = endpointUris_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000002); } result.endpointUris_ = endpointUris_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1173,7 +1227,7 @@ public Builder mergeFrom(com.google.spanner.admin.instance.v1.Instance other) { if (!other.endpointUris_.isEmpty()) { if (endpointUris_.isEmpty()) { endpointUris_ = other.endpointUris_; - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000002); } else { ensureEndpointUrisIsMutable(); endpointUris_.addAll(other.endpointUris_); @@ -1223,6 +1277,8 @@ public Builder mergeFrom( * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -1246,6 +1302,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -1269,6 +1327,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -1290,6 +1351,8 @@ public Builder setName(java.lang.String value) { * * * string name = 1; + * + * @return This builder for chaining. */ public Builder clearName() { @@ -1308,6 +1371,9 @@ public Builder clearName() { * * * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1332,6 +1398,8 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The config. */ public java.lang.String getConfig() { java.lang.Object ref = config_; @@ -1355,6 +1423,8 @@ public java.lang.String getConfig() { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for config. */ public com.google.protobuf.ByteString getConfigBytes() { java.lang.Object ref = config_; @@ -1378,6 +1448,9 @@ public com.google.protobuf.ByteString getConfigBytes() { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @param value The config to set. + * @return This builder for chaining. */ public Builder setConfig(java.lang.String value) { if (value == null) { @@ -1399,6 +1472,8 @@ public Builder setConfig(java.lang.String value) { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. */ public Builder clearConfig() { @@ -1417,6 +1492,9 @@ public Builder clearConfig() { * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for config to set. + * @return This builder for chaining. */ public Builder setConfigBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1439,6 +1517,8 @@ public Builder setConfigBytes(com.google.protobuf.ByteString value) { * * * string display_name = 3; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -1460,6 +1540,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 3; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -1481,6 +1563,9 @@ public com.google.protobuf.ByteString getDisplayNameBytes() { * * * string display_name = 3; + * + * @param value The displayName to set. + * @return This builder for chaining. */ public Builder setDisplayName(java.lang.String value) { if (value == null) { @@ -1500,6 +1585,8 @@ public Builder setDisplayName(java.lang.String value) { * * * string display_name = 3; + * + * @return This builder for chaining. */ public Builder clearDisplayName() { @@ -1516,6 +1603,9 @@ public Builder clearDisplayName() { * * * string display_name = 3; + * + * @param value The bytes for displayName to set. + * @return This builder for chaining. */ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1541,6 +1631,8 @@ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { * * * int32 node_count = 5; + * + * @return The nodeCount. */ public int getNodeCount() { return nodeCount_; @@ -1557,6 +1649,9 @@ public int getNodeCount() { * * * int32 node_count = 5; + * + * @param value The nodeCount to set. + * @return This builder for chaining. */ public Builder setNodeCount(int value) { @@ -1576,6 +1671,8 @@ public Builder setNodeCount(int value) { * * * int32 node_count = 5; + * + * @return This builder for chaining. */ public Builder clearNodeCount() { @@ -1597,6 +1694,8 @@ public Builder clearNodeCount() { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The enum numeric value on the wire for state. */ public int getStateValue() { return state_; @@ -1613,6 +1712,9 @@ public int getStateValue() { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. */ public Builder setStateValue(int value) { state_ = value; @@ -1631,6 +1733,8 @@ public Builder setStateValue(int value) { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The state. */ public com.google.spanner.admin.instance.v1.Instance.State getState() { @SuppressWarnings("deprecation") @@ -1652,6 +1756,9 @@ public com.google.spanner.admin.instance.v1.Instance.State getState() { * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @param value The state to set. + * @return This builder for chaining. */ public Builder setState(com.google.spanner.admin.instance.v1.Instance.State value) { if (value == null) { @@ -1674,6 +1781,8 @@ public Builder setState(com.google.spanner.admin.instance.v1.Instance.State valu * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return This builder for chaining. */ public Builder clearState() { @@ -1957,9 +2066,9 @@ public Builder putAllLabels(java.util.Map va com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureEndpointUrisIsMutable() { - if (!((bitField0_ & 0x00000040) != 0)) { + if (!((bitField0_ & 0x00000002) != 0)) { endpointUris_ = new com.google.protobuf.LazyStringArrayList(endpointUris_); - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000002; } } /** @@ -1977,6 +2086,8 @@ private void ensureEndpointUrisIsMutable() { * * * repeated string endpoint_uris = 8; + * + * @return A list containing the endpointUris. */ public com.google.protobuf.ProtocolStringList getEndpointUrisList() { return endpointUris_.getUnmodifiableView(); @@ -1996,6 +2107,8 @@ public com.google.protobuf.ProtocolStringList getEndpointUrisList() { * * * repeated string endpoint_uris = 8; + * + * @return The count of endpointUris. */ public int getEndpointUrisCount() { return endpointUris_.size(); @@ -2015,6 +2128,9 @@ public int getEndpointUrisCount() { * * * repeated string endpoint_uris = 8; + * + * @param index The index of the element to return. + * @return The endpointUris at the given index. */ public java.lang.String getEndpointUris(int index) { return endpointUris_.get(index); @@ -2034,6 +2150,9 @@ public java.lang.String getEndpointUris(int index) { * * * repeated string endpoint_uris = 8; + * + * @param index The index of the value to return. + * @return The bytes of the endpointUris at the given index. */ public com.google.protobuf.ByteString getEndpointUrisBytes(int index) { return endpointUris_.getByteString(index); @@ -2053,6 +2172,10 @@ public com.google.protobuf.ByteString getEndpointUrisBytes(int index) { * * * repeated string endpoint_uris = 8; + * + * @param index The index to set the value at. + * @param value The endpointUris to set. + * @return This builder for chaining. */ public Builder setEndpointUris(int index, java.lang.String value) { if (value == null) { @@ -2078,6 +2201,9 @@ public Builder setEndpointUris(int index, java.lang.String value) { * * * repeated string endpoint_uris = 8; + * + * @param value The endpointUris to add. + * @return This builder for chaining. */ public Builder addEndpointUris(java.lang.String value) { if (value == null) { @@ -2103,6 +2229,9 @@ public Builder addEndpointUris(java.lang.String value) { * * * repeated string endpoint_uris = 8; + * + * @param values The endpointUris to add. + * @return This builder for chaining. */ public Builder addAllEndpointUris(java.lang.Iterable values) { ensureEndpointUrisIsMutable(); @@ -2125,10 +2254,12 @@ public Builder addAllEndpointUris(java.lang.Iterable values) { * * * repeated string endpoint_uris = 8; + * + * @return This builder for chaining. */ public Builder clearEndpointUris() { endpointUris_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); return this; } @@ -2147,6 +2278,9 @@ public Builder clearEndpointUris() { * * * repeated string endpoint_uris = 8; + * + * @param value The bytes of the endpointUris to add. + * @return This builder for chaining. */ public Builder addEndpointUrisBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfig.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfig.java index 1c04ced88f8..fd339a8e53c 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfig.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -29,6 +44,12 @@ private InstanceConfig() { replicas_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new InstanceConfig(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -69,10 +90,10 @@ private InstanceConfig( } case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { replicas_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000001; } replicas_.add( input.readMessage( @@ -94,7 +115,7 @@ private InstanceConfig( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { replicas_ = java.util.Collections.unmodifiableList(replicas_); } this.unknownFields = unknownFields.build(); @@ -117,7 +138,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.instance.v1.InstanceConfig.Builder.class); } - private int bitField0_; public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; /** @@ -130,6 +150,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -152,6 +174,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -175,6 +199,8 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string display_name = 2; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -195,6 +221,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 2; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -510,7 +538,7 @@ public Builder clear() { if (replicasBuilder_ == null) { replicas_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } else { replicasBuilder_.clear(); } @@ -542,19 +570,17 @@ public com.google.spanner.admin.instance.v1.InstanceConfig buildPartial() { com.google.spanner.admin.instance.v1.InstanceConfig result = new com.google.spanner.admin.instance.v1.InstanceConfig(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.name_ = name_; result.displayName_ = displayName_; if (replicasBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { replicas_ = java.util.Collections.unmodifiableList(replicas_); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } result.replicas_ = replicas_; } else { result.replicas_ = replicasBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -617,7 +643,7 @@ public Builder mergeFrom(com.google.spanner.admin.instance.v1.InstanceConfig oth if (!other.replicas_.isEmpty()) { if (replicas_.isEmpty()) { replicas_ = other.replicas_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureReplicasIsMutable(); replicas_.addAll(other.replicas_); @@ -630,7 +656,7 @@ public Builder mergeFrom(com.google.spanner.admin.instance.v1.InstanceConfig oth replicasBuilder_.dispose(); replicasBuilder_ = null; replicas_ = other.replicas_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); replicasBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getReplicasFieldBuilder() @@ -683,6 +709,8 @@ public Builder mergeFrom( * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -705,6 +733,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -727,6 +757,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -747,6 +780,8 @@ public Builder setName(java.lang.String value) { * * * string name = 1; + * + * @return This builder for chaining. */ public Builder clearName() { @@ -764,6 +799,9 @@ public Builder clearName() { * * * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -785,6 +823,8 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * * string display_name = 2; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -805,6 +845,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 2; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -825,6 +867,9 @@ public com.google.protobuf.ByteString getDisplayNameBytes() { * * * string display_name = 2; + * + * @param value The displayName to set. + * @return This builder for chaining. */ public Builder setDisplayName(java.lang.String value) { if (value == null) { @@ -843,6 +888,8 @@ public Builder setDisplayName(java.lang.String value) { * * * string display_name = 2; + * + * @return This builder for chaining. */ public Builder clearDisplayName() { @@ -858,6 +905,9 @@ public Builder clearDisplayName() { * * * string display_name = 2; + * + * @param value The bytes for displayName to set. + * @return This builder for chaining. */ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -874,10 +924,10 @@ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { java.util.Collections.emptyList(); private void ensureReplicasIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { replicas_ = new java.util.ArrayList(replicas_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000001; } } @@ -1104,7 +1154,7 @@ public Builder addAllReplicas( public Builder clearReplicas() { if (replicasBuilder_ == null) { replicas_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { replicasBuilder_.clear(); @@ -1234,7 +1284,7 @@ public com.google.spanner.admin.instance.v1.ReplicaInfo.Builder addReplicasBuild com.google.spanner.admin.instance.v1.ReplicaInfo, com.google.spanner.admin.instance.v1.ReplicaInfo.Builder, com.google.spanner.admin.instance.v1.ReplicaInfoOrBuilder>( - replicas_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + replicas_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); replicas_ = null; } return replicasBuilder_; diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigName.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigName.java index 40cc0c3c09c..60c4170bcf7 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigName.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.admin.instance.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class InstanceConfigName implements ResourceName { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigOrBuilder.java index 17af7098b39..b4caa9d211e 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -18,6 +33,8 @@ public interface InstanceConfigOrBuilder * * * string name = 1; + * + * @return The name. */ java.lang.String getName(); /** @@ -30,6 +47,8 @@ public interface InstanceConfigOrBuilder * * * string name = 1; + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -41,6 +60,8 @@ public interface InstanceConfigOrBuilder * * * string display_name = 2; + * + * @return The displayName. */ java.lang.String getDisplayName(); /** @@ -51,6 +72,8 @@ public interface InstanceConfigOrBuilder * * * string display_name = 2; + * + * @return The bytes for displayName. */ com.google.protobuf.ByteString getDisplayNameBytes(); diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceName.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceName.java index 6bf5b58b6bf..072dc6c0ac8 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceName.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.admin.instance.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class InstanceName implements ResourceName { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java index 752930f3b7c..c1c027e0aae 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface InstanceOrBuilder * * * string name = 1; + * + * @return The name. */ java.lang.String getName(); /** @@ -32,6 +49,8 @@ public interface InstanceOrBuilder * * * string name = 1; + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -46,6 +65,8 @@ public interface InstanceOrBuilder * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The config. */ java.lang.String getConfig(); /** @@ -59,6 +80,8 @@ public interface InstanceOrBuilder * * * string config = 2 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for config. */ com.google.protobuf.ByteString getConfigBytes(); @@ -71,6 +94,8 @@ public interface InstanceOrBuilder * * * string display_name = 3; + * + * @return The displayName. */ java.lang.String getDisplayName(); /** @@ -82,6 +107,8 @@ public interface InstanceOrBuilder * * * string display_name = 3; + * + * @return The bytes for displayName. */ com.google.protobuf.ByteString getDisplayNameBytes(); @@ -97,6 +124,8 @@ public interface InstanceOrBuilder * * * int32 node_count = 5; + * + * @return The nodeCount. */ int getNodeCount(); @@ -112,6 +141,8 @@ public interface InstanceOrBuilder * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The enum numeric value on the wire for state. */ int getStateValue(); /** @@ -126,6 +157,8 @@ public interface InstanceOrBuilder * * * .google.spanner.admin.instance.v1.Instance.State state = 6; + * + * @return The state. */ com.google.spanner.admin.instance.v1.Instance.State getState(); @@ -283,6 +316,8 @@ public interface InstanceOrBuilder * * * repeated string endpoint_uris = 8; + * + * @return A list containing the endpointUris. */ java.util.List getEndpointUrisList(); /** @@ -300,6 +335,8 @@ public interface InstanceOrBuilder * * * repeated string endpoint_uris = 8; + * + * @return The count of endpointUris. */ int getEndpointUrisCount(); /** @@ -317,6 +354,9 @@ public interface InstanceOrBuilder * * * repeated string endpoint_uris = 8; + * + * @param index The index of the element to return. + * @return The endpointUris at the given index. */ java.lang.String getEndpointUris(int index); /** @@ -334,6 +374,9 @@ public interface InstanceOrBuilder * * * repeated string endpoint_uris = 8; + * + * @param index The index of the value to return. + * @return The bytes of the endpointUris at the given index. */ com.google.protobuf.ByteString getEndpointUrisBytes(int index); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequest.java index 19bad823a25..1a15fe43109 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -27,6 +42,12 @@ private ListInstanceConfigsRequest() { pageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListInstanceConfigsRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private ListInstanceConfigsRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -118,6 +138,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -142,6 +164,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -166,6 +190,8 @@ public com.google.protobuf.ByteString getParentBytes() { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -183,6 +209,8 @@ public int getPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -205,6 +233,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -585,6 +615,8 @@ public Builder mergeFrom( * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -609,6 +641,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -633,6 +667,9 @@ public com.google.protobuf.ByteString getParentBytes() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The parent to set. + * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { @@ -655,6 +692,8 @@ public Builder setParent(java.lang.String value) { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearParent() { @@ -674,6 +713,9 @@ public Builder clearParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -696,6 +738,8 @@ public Builder setParentBytes(com.google.protobuf.ByteString value) { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -709,6 +753,9 @@ public int getPageSize() { * * * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. */ public Builder setPageSize(int value) { @@ -725,6 +772,8 @@ public Builder setPageSize(int value) { * * * int32 page_size = 2; + * + * @return This builder for chaining. */ public Builder clearPageSize() { @@ -744,6 +793,8 @@ public Builder clearPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -766,6 +817,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -788,6 +841,9 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. */ public Builder setPageToken(java.lang.String value) { if (value == null) { @@ -808,6 +864,8 @@ public Builder setPageToken(java.lang.String value) { * * * string page_token = 3; + * + * @return This builder for chaining. */ public Builder clearPageToken() { @@ -825,6 +883,9 @@ public Builder clearPageToken() { * * * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. */ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequestOrBuilder.java index 09f2624ebdb..459976ee143 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -20,6 +35,8 @@ public interface ListInstanceConfigsRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ java.lang.String getParent(); /** @@ -34,6 +51,8 @@ public interface ListInstanceConfigsRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ com.google.protobuf.ByteString getParentBytes(); @@ -46,6 +65,8 @@ public interface ListInstanceConfigsRequestOrBuilder * * * int32 page_size = 2; + * + * @return The pageSize. */ int getPageSize(); @@ -59,6 +80,8 @@ public interface ListInstanceConfigsRequestOrBuilder * * * string page_token = 3; + * + * @return The pageToken. */ java.lang.String getPageToken(); /** @@ -71,6 +94,8 @@ public interface ListInstanceConfigsRequestOrBuilder * * * string page_token = 3; + * + * @return The bytes for pageToken. */ com.google.protobuf.ByteString getPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponse.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponse.java index 4a59edfafd1..c730416b660 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponse.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -27,6 +42,12 @@ private ListInstanceConfigsResponse() { nextPageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListInstanceConfigsResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -108,7 +129,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse.Builder.class); } - private int bitField0_; public static final int INSTANCE_CONFIGS_FIELD_NUMBER = 1; private java.util.List instanceConfigs_; /** @@ -187,6 +207,8 @@ public com.google.spanner.admin.instance.v1.InstanceConfigOrBuilder getInstanceC * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -209,6 +231,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -477,7 +501,6 @@ public com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse buildPar com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse result = new com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (instanceConfigsBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { instanceConfigs_ = java.util.Collections.unmodifiableList(instanceConfigs_); @@ -488,7 +511,6 @@ public com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse buildPar result.instanceConfigs_ = instanceConfigsBuilder_.build(); } result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -978,6 +1000,8 @@ public com.google.spanner.admin.instance.v1.InstanceConfig.Builder addInstanceCo * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -1000,6 +1024,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -1022,6 +1048,9 @@ public com.google.protobuf.ByteString getNextPageTokenBytes() { * * * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageToken(java.lang.String value) { if (value == null) { @@ -1042,6 +1071,8 @@ public Builder setNextPageToken(java.lang.String value) { * * * string next_page_token = 2; + * + * @return This builder for chaining. */ public Builder clearNextPageToken() { @@ -1059,6 +1090,9 @@ public Builder clearNextPageToken() { * * * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponseOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponseOrBuilder.java index 08afe8af2ff..be1df406dfd 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponseOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -71,6 +86,8 @@ com.google.spanner.admin.instance.v1.InstanceConfigOrBuilder getInstanceConfigsO * * * string next_page_token = 2; + * + * @return The nextPageToken. */ java.lang.String getNextPageToken(); /** @@ -83,6 +100,8 @@ com.google.spanner.admin.instance.v1.InstanceConfigOrBuilder getInstanceConfigsO * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ com.google.protobuf.ByteString getNextPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequest.java index def70213d54..9a634cd6295 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -28,6 +43,12 @@ private ListInstancesRequest() { filter_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListInstancesRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -41,7 +62,6 @@ private ListInstancesRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -125,6 +145,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -148,6 +170,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -172,6 +196,8 @@ public com.google.protobuf.ByteString getParentBytes() { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -189,6 +215,8 @@ public int getPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -211,6 +239,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -249,6 +279,8 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string filter = 4; + * + * @return The filter. */ public java.lang.String getFilter() { java.lang.Object ref = filter_; @@ -284,6 +316,8 @@ public java.lang.String getFilter() { * * * string filter = 4; + * + * @return The bytes for filter. */ public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; @@ -675,6 +709,8 @@ public Builder mergeFrom( * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ public java.lang.String getParent() { java.lang.Object ref = parent_; @@ -698,6 +734,8 @@ public java.lang.String getParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ public com.google.protobuf.ByteString getParentBytes() { java.lang.Object ref = parent_; @@ -721,6 +759,9 @@ public com.google.protobuf.ByteString getParentBytes() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The parent to set. + * @return This builder for chaining. */ public Builder setParent(java.lang.String value) { if (value == null) { @@ -742,6 +783,8 @@ public Builder setParent(java.lang.String value) { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearParent() { @@ -760,6 +803,9 @@ public Builder clearParent() { * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. */ public Builder setParentBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -782,6 +828,8 @@ public Builder setParentBytes(com.google.protobuf.ByteString value) { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -795,6 +843,9 @@ public int getPageSize() { * * * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. */ public Builder setPageSize(int value) { @@ -811,6 +862,8 @@ public Builder setPageSize(int value) { * * * int32 page_size = 2; + * + * @return This builder for chaining. */ public Builder clearPageSize() { @@ -830,6 +883,8 @@ public Builder clearPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -852,6 +907,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -874,6 +931,9 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. */ public Builder setPageToken(java.lang.String value) { if (value == null) { @@ -894,6 +954,8 @@ public Builder setPageToken(java.lang.String value) { * * * string page_token = 3; + * + * @return This builder for chaining. */ public Builder clearPageToken() { @@ -911,6 +973,9 @@ public Builder clearPageToken() { * * * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. */ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -947,6 +1012,8 @@ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { * * * string filter = 4; + * + * @return The filter. */ public java.lang.String getFilter() { java.lang.Object ref = filter_; @@ -982,6 +1049,8 @@ public java.lang.String getFilter() { * * * string filter = 4; + * + * @return The bytes for filter. */ public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; @@ -1017,6 +1086,9 @@ public com.google.protobuf.ByteString getFilterBytes() { * * * string filter = 4; + * + * @param value The filter to set. + * @return This builder for chaining. */ public Builder setFilter(java.lang.String value) { if (value == null) { @@ -1050,6 +1122,8 @@ public Builder setFilter(java.lang.String value) { * * * string filter = 4; + * + * @return This builder for chaining. */ public Builder clearFilter() { @@ -1080,6 +1154,9 @@ public Builder clearFilter() { * * * string filter = 4; + * + * @param value The bytes for filter to set. + * @return This builder for chaining. */ public Builder setFilterBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequestOrBuilder.java index 8f2123b9fa1..990d31126f4 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface ListInstancesRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The parent. */ java.lang.String getParent(); /** @@ -32,6 +49,8 @@ public interface ListInstancesRequestOrBuilder * * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for parent. */ com.google.protobuf.ByteString getParentBytes(); @@ -44,6 +63,8 @@ public interface ListInstancesRequestOrBuilder * * * int32 page_size = 2; + * + * @return The pageSize. */ int getPageSize(); @@ -57,6 +78,8 @@ public interface ListInstancesRequestOrBuilder * * * string page_token = 3; + * + * @return The pageToken. */ java.lang.String getPageToken(); /** @@ -69,6 +92,8 @@ public interface ListInstancesRequestOrBuilder * * * string page_token = 3; + * + * @return The bytes for pageToken. */ com.google.protobuf.ByteString getPageTokenBytes(); @@ -95,6 +120,8 @@ public interface ListInstancesRequestOrBuilder * * * string filter = 4; + * + * @return The filter. */ java.lang.String getFilter(); /** @@ -120,6 +147,8 @@ public interface ListInstancesRequestOrBuilder * * * string filter = 4; + * + * @return The bytes for filter. */ com.google.protobuf.ByteString getFilterBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponse.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponse.java index dc7c63b36a7..78b600aef47 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponse.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -27,6 +42,12 @@ private ListInstancesResponse() { nextPageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListInstancesResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -107,7 +128,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.admin.instance.v1.ListInstancesResponse.Builder.class); } - private int bitField0_; public static final int INSTANCES_FIELD_NUMBER = 1; private java.util.List instances_; /** @@ -184,6 +204,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstancesOrBuil * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -206,6 +228,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -473,7 +497,6 @@ public com.google.spanner.admin.instance.v1.ListInstancesResponse buildPartial() com.google.spanner.admin.instance.v1.ListInstancesResponse result = new com.google.spanner.admin.instance.v1.ListInstancesResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (instancesBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { instances_ = java.util.Collections.unmodifiableList(instances_); @@ -484,7 +507,6 @@ public com.google.spanner.admin.instance.v1.ListInstancesResponse buildPartial() result.instances_ = instancesBuilder_.build(); } result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -960,6 +982,8 @@ public com.google.spanner.admin.instance.v1.Instance.Builder addInstancesBuilder * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -982,6 +1006,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -1004,6 +1030,9 @@ public com.google.protobuf.ByteString getNextPageTokenBytes() { * * * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageToken(java.lang.String value) { if (value == null) { @@ -1024,6 +1053,8 @@ public Builder setNextPageToken(java.lang.String value) { * * * string next_page_token = 2; + * + * @return This builder for chaining. */ public Builder clearNextPageToken() { @@ -1041,6 +1072,9 @@ public Builder clearNextPageToken() { * * * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponseOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponseOrBuilder.java index d23f2bc416d..2aebd055c5c 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponseOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -70,6 +85,8 @@ public interface ListInstancesResponseOrBuilder * * * string next_page_token = 2; + * + * @return The nextPageToken. */ java.lang.String getNextPageToken(); /** @@ -82,6 +99,8 @@ public interface ListInstancesResponseOrBuilder * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ com.google.protobuf.ByteString getNextPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ProjectName.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ProjectName.java index ee632bde2a2..8887e23824f 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ProjectName.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ProjectName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.admin.instance.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class ProjectName implements ResourceName { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfo.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfo.java index 95465c2e8f7..b649abd7134 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfo.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfo.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,12 @@ private ReplicaInfo() { type_ = 0; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReplicaInfo(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -32,7 +53,6 @@ private ReplicaInfo( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -228,12 +248,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static ReplicaType valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static ReplicaType forNumber(int value) { switch (value) { case 0: @@ -303,6 +331,8 @@ private ReplicaType(int value) { * * * string location = 1; + * + * @return The location. */ public java.lang.String getLocation() { java.lang.Object ref = location_; @@ -323,6 +353,8 @@ public java.lang.String getLocation() { * * * string location = 1; + * + * @return The bytes for location. */ public com.google.protobuf.ByteString getLocationBytes() { java.lang.Object ref = location_; @@ -346,6 +378,8 @@ public com.google.protobuf.ByteString getLocationBytes() { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The enum numeric value on the wire for type. */ public int getTypeValue() { return type_; @@ -358,6 +392,8 @@ public int getTypeValue() { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The type. */ public com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType getType() { @SuppressWarnings("deprecation") @@ -381,6 +417,8 @@ public com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType getType() { * * * bool default_leader_location = 3; + * + * @return The defaultLeaderLocation. */ public boolean getDefaultLeaderLocation() { return defaultLeaderLocation_; @@ -738,6 +776,8 @@ public Builder mergeFrom( * * * string location = 1; + * + * @return The location. */ public java.lang.String getLocation() { java.lang.Object ref = location_; @@ -758,6 +798,8 @@ public java.lang.String getLocation() { * * * string location = 1; + * + * @return The bytes for location. */ public com.google.protobuf.ByteString getLocationBytes() { java.lang.Object ref = location_; @@ -778,6 +820,9 @@ public com.google.protobuf.ByteString getLocationBytes() { * * * string location = 1; + * + * @param value The location to set. + * @return This builder for chaining. */ public Builder setLocation(java.lang.String value) { if (value == null) { @@ -796,6 +841,8 @@ public Builder setLocation(java.lang.String value) { * * * string location = 1; + * + * @return This builder for chaining. */ public Builder clearLocation() { @@ -811,6 +858,9 @@ public Builder clearLocation() { * * * string location = 1; + * + * @param value The bytes for location to set. + * @return This builder for chaining. */ public Builder setLocationBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -832,6 +882,8 @@ public Builder setLocationBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The enum numeric value on the wire for type. */ public int getTypeValue() { return type_; @@ -844,6 +896,9 @@ public int getTypeValue() { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. */ public Builder setTypeValue(int value) { type_ = value; @@ -858,6 +913,8 @@ public Builder setTypeValue(int value) { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The type. */ public com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType getType() { @SuppressWarnings("deprecation") @@ -875,6 +932,9 @@ public com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType getType() { * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @param value The type to set. + * @return This builder for chaining. */ public Builder setType(com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType value) { if (value == null) { @@ -893,6 +953,8 @@ public Builder setType(com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaT * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return This builder for chaining. */ public Builder clearType() { @@ -913,6 +975,8 @@ public Builder clearType() { * * * bool default_leader_location = 3; + * + * @return The defaultLeaderLocation. */ public boolean getDefaultLeaderLocation() { return defaultLeaderLocation_; @@ -928,6 +992,9 @@ public boolean getDefaultLeaderLocation() { * * * bool default_leader_location = 3; + * + * @param value The defaultLeaderLocation to set. + * @return This builder for chaining. */ public Builder setDefaultLeaderLocation(boolean value) { @@ -946,6 +1013,8 @@ public Builder setDefaultLeaderLocation(boolean value) { * * * bool default_leader_location = 3; + * + * @return This builder for chaining. */ public Builder clearDefaultLeaderLocation() { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfoOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfoOrBuilder.java index 9bcc4d2ee03..65206fff830 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfoOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfoOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -16,6 +31,8 @@ public interface ReplicaInfoOrBuilder * * * string location = 1; + * + * @return The location. */ java.lang.String getLocation(); /** @@ -26,6 +43,8 @@ public interface ReplicaInfoOrBuilder * * * string location = 1; + * + * @return The bytes for location. */ com.google.protobuf.ByteString getLocationBytes(); @@ -37,6 +56,8 @@ public interface ReplicaInfoOrBuilder * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The enum numeric value on the wire for type. */ int getTypeValue(); /** @@ -47,6 +68,8 @@ public interface ReplicaInfoOrBuilder * * * .google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType type = 2; + * + * @return The type. */ com.google.spanner.admin.instance.v1.ReplicaInfo.ReplicaType getType(); @@ -61,6 +84,8 @@ public interface ReplicaInfoOrBuilder * * * bool default_leader_location = 3; + * + * @return The defaultLeaderLocation. */ boolean getDefaultLeaderLocation(); } diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java index 1cbd1d99d33..32f9848e60d 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -215,29 +230,21 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "1\312\002&Google\\Cloud\\Spanner\\Admin\\Instance\\" + "V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.api.ClientProto.getDescriptor(), - com.google.api.FieldBehaviorProto.getDescriptor(), - com.google.api.ResourceProto.getDescriptor(), - com.google.iam.v1.IamPolicyProto.getDescriptor(), - com.google.iam.v1.PolicyProto.getDescriptor(), - com.google.longrunning.OperationsProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - com.google.protobuf.FieldMaskProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.iam.v1.IamPolicyProto.getDescriptor(), + com.google.iam.v1.PolicyProto.getDescriptor(), + com.google.longrunning.OperationsProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.protobuf.FieldMaskProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); internal_static_google_spanner_admin_instance_v1_ReplicaInfo_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_admin_instance_v1_ReplicaInfo_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadata.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadata.java index 17112e5f93e..ff477001675 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadata.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -25,6 +40,12 @@ private UpdateInstanceMetadata(com.google.protobuf.GeneratedMessageV3.Builder private UpdateInstanceMetadata() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateInstanceMetadata(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -38,7 +59,6 @@ private UpdateInstanceMetadata( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -154,6 +174,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instance_ != null; @@ -166,6 +188,8 @@ public boolean hasInstance() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { return instance_ == null @@ -196,6 +220,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ public boolean hasStartTime() { return startTime_ != null; @@ -209,6 +235,8 @@ public boolean hasStartTime() { * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ public com.google.protobuf.Timestamp getStartTime() { return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; @@ -239,6 +267,8 @@ public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ public boolean hasCancelTime() { return cancelTime_ != null; @@ -253,6 +283,8 @@ public boolean hasCancelTime() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ public com.google.protobuf.Timestamp getCancelTime() { return cancelTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : cancelTime_; @@ -282,6 +314,8 @@ public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ public boolean hasEndTime() { return endTime_ != null; @@ -294,6 +328,8 @@ public boolean hasEndTime() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ public com.google.protobuf.Timestamp getEndTime() { return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; @@ -741,6 +777,8 @@ public Builder mergeFrom( * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instanceBuilder_ != null || instance_ != null; @@ -753,6 +791,8 @@ public boolean hasInstance() { * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { if (instanceBuilder_ == null) { @@ -924,6 +964,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ public boolean hasStartTime() { return startTimeBuilder_ != null || startTime_ != null; @@ -937,6 +979,8 @@ public boolean hasStartTime() { * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ public com.google.protobuf.Timestamp getStartTime() { if (startTimeBuilder_ == null) { @@ -1109,6 +1153,8 @@ public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ public boolean hasCancelTime() { return cancelTimeBuilder_ != null || cancelTime_ != null; @@ -1123,6 +1169,8 @@ public boolean hasCancelTime() { * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ public com.google.protobuf.Timestamp getCancelTime() { if (cancelTimeBuilder_ == null) { @@ -1304,6 +1352,8 @@ public com.google.protobuf.TimestampOrBuilder getCancelTimeOrBuilder() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ public boolean hasEndTime() { return endTimeBuilder_ != null || endTime_ != null; @@ -1316,6 +1366,8 @@ public boolean hasEndTime() { * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ public com.google.protobuf.Timestamp getEndTime() { if (endTimeBuilder_ == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadataOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadataOrBuilder.java index 4f79ef6216d..b866f7dd109 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadataOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadataOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -16,6 +31,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return Whether the instance field is set. */ boolean hasInstance(); /** @@ -26,6 +43,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.spanner.admin.instance.v1.Instance instance = 1; + * + * @return The instance. */ com.google.spanner.admin.instance.v1.Instance getInstance(); /** @@ -48,6 +67,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp start_time = 2; + * + * @return Whether the startTime field is set. */ boolean hasStartTime(); /** @@ -59,6 +80,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp start_time = 2; + * + * @return The startTime. */ com.google.protobuf.Timestamp getStartTime(); /** @@ -83,6 +106,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return Whether the cancelTime field is set. */ boolean hasCancelTime(); /** @@ -95,6 +120,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp cancel_time = 3; + * + * @return The cancelTime. */ com.google.protobuf.Timestamp getCancelTime(); /** @@ -118,6 +145,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp end_time = 4; + * + * @return Whether the endTime field is set. */ boolean hasEndTime(); /** @@ -128,6 +157,8 @@ public interface UpdateInstanceMetadataOrBuilder * * * .google.protobuf.Timestamp end_time = 4; + * + * @return The endTime. */ com.google.protobuf.Timestamp getEndTime(); /** diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequest.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequest.java index 0695115e1f3..d9105b4ab45 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequest.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -24,6 +39,12 @@ private UpdateInstanceRequest(com.google.protobuf.GeneratedMessageV3.Builder private UpdateInstanceRequest() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateInstanceRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -37,7 +58,6 @@ private UpdateInstanceRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -126,6 +146,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instance_ != null; @@ -141,6 +163,8 @@ public boolean hasInstance() { * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { return instance_ == null @@ -177,6 +201,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the fieldMask field is set. */ public boolean hasFieldMask() { return fieldMask_ != null; @@ -193,6 +219,8 @@ public boolean hasFieldMask() { * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The fieldMask. */ public com.google.protobuf.FieldMask getFieldMask() { return fieldMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : fieldMask_; @@ -590,6 +618,8 @@ public Builder mergeFrom( * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ public boolean hasInstance() { return instanceBuilder_ != null || instance_ != null; @@ -605,6 +635,8 @@ public boolean hasInstance() { * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ public com.google.spanner.admin.instance.v1.Instance getInstance() { if (instanceBuilder_ == null) { @@ -800,6 +832,8 @@ public com.google.spanner.admin.instance.v1.InstanceOrBuilder getInstanceOrBuild * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the fieldMask field is set. */ public boolean hasFieldMask() { return fieldMaskBuilder_ != null || fieldMask_ != null; @@ -816,6 +850,8 @@ public boolean hasFieldMask() { * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The fieldMask. */ public com.google.protobuf.FieldMask getFieldMask() { if (fieldMaskBuilder_ == null) { diff --git a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequestOrBuilder.java b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequestOrBuilder.java index b4fedf419d5..a0c799f3264 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequestOrBuilder.java +++ b/proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto @@ -19,6 +34,8 @@ public interface UpdateInstanceRequestOrBuilder * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the instance field is set. */ boolean hasInstance(); /** @@ -32,6 +49,8 @@ public interface UpdateInstanceRequestOrBuilder * * .google.spanner.admin.instance.v1.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The instance. */ com.google.spanner.admin.instance.v1.Instance getInstance(); /** @@ -60,6 +79,8 @@ public interface UpdateInstanceRequestOrBuilder * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the fieldMask field is set. */ boolean hasFieldMask(); /** @@ -74,6 +95,8 @@ public interface UpdateInstanceRequestOrBuilder * * .google.protobuf.FieldMask field_mask = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The fieldMask. */ com.google.protobuf.FieldMask getFieldMask(); /** diff --git a/proto-google-cloud-spanner-v1/pom.xml b/proto-google-cloud-spanner-v1/pom.xml index 539e33e704e..2fcae0b0d5e 100644 --- a/proto-google-cloud-spanner-v1/pom.xml +++ b/proto-google-cloud-spanner-v1/pom.xml @@ -2,30 +2,32 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.api.grpc proto-google-cloud-spanner-v1 1.47.1-SNAPSHOT proto-google-cloud-spanner-v1 PROTO library for proto-google-cloud-spanner-v1 - com.google.api.grpc - google-api-grpc - 0.85.1-SNAPSHOT + com.google.cloud + google-cloud-spanner-parent + 1.47.1-SNAPSHOT com.google.protobuf protobuf-java - compile + + + com.google.api.grpc + proto-google-common-protos com.google.api api-common - compile - com.google.api.grpc - proto-google-common-protos - compile + com.google.guava + guava \ No newline at end of file diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequest.java index d2562fc6981..943a4100dd6 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private BatchCreateSessionsRequest() { database_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BatchCreateSessionsRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private BatchCreateSessionsRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -124,6 +144,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -146,6 +168,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -169,6 +193,8 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * .google.spanner.v1.Session session_template = 2; + * + * @return Whether the sessionTemplate field is set. */ public boolean hasSessionTemplate() { return sessionTemplate_ != null; @@ -181,6 +207,8 @@ public boolean hasSessionTemplate() { * * * .google.spanner.v1.Session session_template = 2; + * + * @return The sessionTemplate. */ public com.google.spanner.v1.Session getSessionTemplate() { return sessionTemplate_ == null @@ -215,6 +243,8 @@ public com.google.spanner.v1.SessionOrBuilder getSessionTemplateOrBuilder() { * * * int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sessionCount. */ public int getSessionCount() { return sessionCount_; @@ -592,6 +622,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -614,6 +646,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -636,6 +670,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -656,6 +693,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -673,6 +712,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -699,6 +741,8 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.Session session_template = 2; + * + * @return Whether the sessionTemplate field is set. */ public boolean hasSessionTemplate() { return sessionTemplateBuilder_ != null || sessionTemplate_ != null; @@ -711,6 +755,8 @@ public boolean hasSessionTemplate() { * * * .google.spanner.v1.Session session_template = 2; + * + * @return The sessionTemplate. */ public com.google.spanner.v1.Session getSessionTemplate() { if (sessionTemplateBuilder_ == null) { @@ -880,6 +926,8 @@ public com.google.spanner.v1.SessionOrBuilder getSessionTemplateOrBuilder() { * * * int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sessionCount. */ public int getSessionCount() { return sessionCount_; @@ -897,6 +945,9 @@ public int getSessionCount() { * * * int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The sessionCount to set. + * @return This builder for chaining. */ public Builder setSessionCount(int value) { @@ -917,6 +968,8 @@ public Builder setSessionCount(int value) { * * * int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearSessionCount() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequestOrBuilder.java index 392184738fd..107b140d5fd 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface BatchCreateSessionsRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface BatchCreateSessionsRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); @@ -41,6 +60,8 @@ public interface BatchCreateSessionsRequestOrBuilder * * * .google.spanner.v1.Session session_template = 2; + * + * @return Whether the sessionTemplate field is set. */ boolean hasSessionTemplate(); /** @@ -51,6 +72,8 @@ public interface BatchCreateSessionsRequestOrBuilder * * * .google.spanner.v1.Session session_template = 2; + * + * @return The sessionTemplate. */ com.google.spanner.v1.Session getSessionTemplate(); /** @@ -77,6 +100,8 @@ public interface BatchCreateSessionsRequestOrBuilder * * * int32 session_count = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sessionCount. */ int getSessionCount(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponse.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponse.java index acb48fdc617..59a4176e33a 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponse.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private BatchCreateSessionsResponse() { session_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BatchCreateSessionsResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponseOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponseOrBuilder.java index 24207b8e17a..4b2c98d851e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponseOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequest.java index 9f386367a54..907cc26b74d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private BeginTransactionRequest() { session_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BeginTransactionRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private BeginTransactionRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -120,6 +140,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -142,6 +164,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -167,6 +191,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the options field is set. */ public boolean hasOptions() { return options_ != null; @@ -181,6 +207,8 @@ public boolean hasOptions() { * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The options. */ public com.google.spanner.v1.TransactionOptions getOptions() { return options_ == null @@ -558,6 +586,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -580,6 +610,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -602,6 +634,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -622,6 +657,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -639,6 +676,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -667,6 +707,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the options field is set. */ public boolean hasOptions() { return optionsBuilder_ != null || options_ != null; @@ -681,6 +723,8 @@ public boolean hasOptions() { * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The options. */ public com.google.spanner.v1.TransactionOptions getOptions() { if (optionsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequestOrBuilder.java index 2c430972948..332d23801ab 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface BeginTransactionRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface BeginTransactionRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -43,6 +62,8 @@ public interface BeginTransactionRequestOrBuilder * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the options field is set. */ boolean hasOptions(); /** @@ -55,6 +76,8 @@ public interface BeginTransactionRequestOrBuilder * * .google.spanner.v1.TransactionOptions options = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The options. */ com.google.spanner.v1.TransactionOptions getOptions(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequest.java index 720afc1fb14..0aaf9e0926d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private CommitRequest() { mutations_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CommitRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -82,9 +103,9 @@ private CommitRequest( } case 34: { - if (!((mutable_bitField0_ & 0x00000008) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { mutations_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; + mutable_bitField0_ |= 0x00000001; } mutations_.add( input.readMessage(com.google.spanner.v1.Mutation.parser(), extensionRegistry)); @@ -104,7 +125,7 @@ private CommitRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000008) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { mutations_ = java.util.Collections.unmodifiableList(mutations_); } this.unknownFields = unknownFields.build(); @@ -127,11 +148,13 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.CommitRequest.Builder.class); } - private int bitField0_; private int transactionCase_ = 0; private java.lang.Object transaction_; - public enum TransactionCase implements com.google.protobuf.Internal.EnumLite { + public enum TransactionCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { TRANSACTION_ID(2), SINGLE_USE_TRANSACTION(3), TRANSACTION_NOT_SET(0); @@ -140,7 +163,11 @@ public enum TransactionCase implements com.google.protobuf.Internal.EnumLite { private TransactionCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static TransactionCase valueOf(int value) { return forNumber(value); @@ -180,6 +207,8 @@ public TransactionCase getTransactionCase() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -202,6 +231,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -224,6 +255,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * bytes transaction_id = 2; + * + * @return The transactionId. */ public com.google.protobuf.ByteString getTransactionId() { if (transactionCase_ == 2) { @@ -249,6 +282,8 @@ public com.google.protobuf.ByteString getTransactionId() { * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return Whether the singleUseTransaction field is set. */ public boolean hasSingleUseTransaction() { return transactionCase_ == 3; @@ -269,6 +304,8 @@ public boolean hasSingleUseTransaction() { * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return The singleUseTransaction. */ public com.google.spanner.v1.TransactionOptions getSingleUseTransaction() { if (transactionCase_ == 3) { @@ -632,7 +669,7 @@ public Builder clear() { if (mutationsBuilder_ == null) { mutations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } else { mutationsBuilder_.clear(); } @@ -665,7 +702,6 @@ public com.google.spanner.v1.CommitRequest build() { public com.google.spanner.v1.CommitRequest buildPartial() { com.google.spanner.v1.CommitRequest result = new com.google.spanner.v1.CommitRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionCase_ == 2) { result.transaction_ = transaction_; @@ -678,15 +714,14 @@ public com.google.spanner.v1.CommitRequest buildPartial() { } } if (mutationsBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { mutations_ = java.util.Collections.unmodifiableList(mutations_); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } result.mutations_ = mutations_; } else { result.mutations_ = mutationsBuilder_.build(); } - result.bitField0_ = to_bitField0_; result.transactionCase_ = transactionCase_; onBuilt(); return result; @@ -745,7 +780,7 @@ public Builder mergeFrom(com.google.spanner.v1.CommitRequest other) { if (!other.mutations_.isEmpty()) { if (mutations_.isEmpty()) { mutations_ = other.mutations_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureMutationsIsMutable(); mutations_.addAll(other.mutations_); @@ -758,7 +793,7 @@ public Builder mergeFrom(com.google.spanner.v1.CommitRequest other) { mutationsBuilder_.dispose(); mutationsBuilder_ = null; mutations_ = other.mutations_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); mutationsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getMutationsFieldBuilder() @@ -840,6 +875,8 @@ public Builder clearTransaction() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -862,6 +899,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -884,6 +923,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -904,6 +946,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -921,6 +965,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -941,6 +988,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * bytes transaction_id = 2; + * + * @return The transactionId. */ public com.google.protobuf.ByteString getTransactionId() { if (transactionCase_ == 2) { @@ -956,6 +1005,9 @@ public com.google.protobuf.ByteString getTransactionId() { * * * bytes transaction_id = 2; + * + * @param value The transactionId to set. + * @return This builder for chaining. */ public Builder setTransactionId(com.google.protobuf.ByteString value) { if (value == null) { @@ -974,6 +1026,8 @@ public Builder setTransactionId(com.google.protobuf.ByteString value) { * * * bytes transaction_id = 2; + * + * @return This builder for chaining. */ public Builder clearTransactionId() { if (transactionCase_ == 2) { @@ -1005,6 +1059,8 @@ public Builder clearTransactionId() { * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return Whether the singleUseTransaction field is set. */ public boolean hasSingleUseTransaction() { return transactionCase_ == 3; @@ -1025,6 +1081,8 @@ public boolean hasSingleUseTransaction() { * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return The singleUseTransaction. */ public com.google.spanner.v1.TransactionOptions getSingleUseTransaction() { if (singleUseTransactionBuilder_ == null) { @@ -1262,9 +1320,9 @@ public com.google.spanner.v1.TransactionOptionsOrBuilder getSingleUseTransaction java.util.Collections.emptyList(); private void ensureMutationsIsMutable() { - if (!((bitField0_ & 0x00000008) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { mutations_ = new java.util.ArrayList(mutations_); - bitField0_ |= 0x00000008; + bitField0_ |= 0x00000001; } } @@ -1499,7 +1557,7 @@ public Builder addAllMutations( public Builder clearMutations() { if (mutationsBuilder_ == null) { mutations_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { mutationsBuilder_.clear(); @@ -1634,7 +1692,7 @@ public java.util.List getMutationsBuilde com.google.spanner.v1.Mutation, com.google.spanner.v1.Mutation.Builder, com.google.spanner.v1.MutationOrBuilder>( - mutations_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + mutations_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); mutations_ = null; } return mutationsBuilder_; diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequestOrBuilder.java index a5f094451bb..a0b457f2d5b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface CommitRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface CommitRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -41,6 +60,8 @@ public interface CommitRequestOrBuilder * * * bytes transaction_id = 2; + * + * @return The transactionId. */ com.google.protobuf.ByteString getTransactionId(); @@ -60,6 +81,8 @@ public interface CommitRequestOrBuilder * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return Whether the singleUseTransaction field is set. */ boolean hasSingleUseTransaction(); /** @@ -78,6 +101,8 @@ public interface CommitRequestOrBuilder * * * .google.spanner.v1.TransactionOptions single_use_transaction = 3; + * + * @return The singleUseTransaction. */ com.google.spanner.v1.TransactionOptions getSingleUseTransaction(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponse.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponse.java index 5335d7d6e1b..0aecb393608 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponse.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -24,6 +39,12 @@ private CommitResponse(com.google.protobuf.GeneratedMessageV3.Builder builder private CommitResponse() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CommitResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -37,7 +58,6 @@ private CommitResponse( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -107,6 +127,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return Whether the commitTimestamp field is set. */ public boolean hasCommitTimestamp() { return commitTimestamp_ != null; @@ -119,6 +141,8 @@ public boolean hasCommitTimestamp() { * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return The commitTimestamp. */ public com.google.protobuf.Timestamp getCommitTimestamp() { return commitTimestamp_ == null @@ -477,6 +501,8 @@ public Builder mergeFrom( * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return Whether the commitTimestamp field is set. */ public boolean hasCommitTimestamp() { return commitTimestampBuilder_ != null || commitTimestamp_ != null; @@ -489,6 +515,8 @@ public boolean hasCommitTimestamp() { * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return The commitTimestamp. */ public com.google.protobuf.Timestamp getCommitTimestamp() { if (commitTimestampBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponseOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponseOrBuilder.java index 27962c9e698..296ab5c2348 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponseOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -16,6 +31,8 @@ public interface CommitResponseOrBuilder * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return Whether the commitTimestamp field is set. */ boolean hasCommitTimestamp(); /** @@ -26,6 +43,8 @@ public interface CommitResponseOrBuilder * * * .google.protobuf.Timestamp commit_timestamp = 1; + * + * @return The commitTimestamp. */ com.google.protobuf.Timestamp getCommitTimestamp(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java index ae6bf936aba..7201539d85d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -26,6 +41,12 @@ private CreateSessionRequest() { database_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateSessionRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private CreateSessionRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -118,6 +138,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -140,6 +162,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -163,6 +187,8 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * .google.spanner.v1.Session session = 2; + * + * @return Whether the session field is set. */ public boolean hasSession() { return session_ != null; @@ -175,6 +201,8 @@ public boolean hasSession() { * * * .google.spanner.v1.Session session = 2; + * + * @return The session. */ public com.google.spanner.v1.Session getSession() { return session_ == null ? com.google.spanner.v1.Session.getDefaultInstance() : session_; @@ -547,6 +575,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -569,6 +599,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -591,6 +623,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -611,6 +646,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -628,6 +665,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -654,6 +694,8 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.Session session = 2; + * + * @return Whether the session field is set. */ public boolean hasSession() { return sessionBuilder_ != null || session_ != null; @@ -666,6 +708,8 @@ public boolean hasSession() { * * * .google.spanner.v1.Session session = 2; + * + * @return The session. */ public com.google.spanner.v1.Session getSession() { if (sessionBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java index d2eb00c159b..a138ef5035c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface CreateSessionRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface CreateSessionRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); @@ -41,6 +60,8 @@ public interface CreateSessionRequestOrBuilder * * * .google.spanner.v1.Session session = 2; + * + * @return Whether the session field is set. */ boolean hasSession(); /** @@ -51,6 +72,8 @@ public interface CreateSessionRequestOrBuilder * * * .google.spanner.v1.Session session = 2; + * + * @return The session. */ com.google.spanner.v1.Session getSession(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DatabaseName.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DatabaseName.java index 5882855aba2..feff5b1fc3e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DatabaseName.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DatabaseName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class DatabaseName implements ResourceName { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequest.java index 63db1455732..253ae2d41c3 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -26,6 +41,12 @@ private DeleteSessionRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteSessionRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private DeleteSessionRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -103,6 +123,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -125,6 +147,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -465,6 +489,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -487,6 +513,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -509,6 +537,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -529,6 +560,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -546,6 +579,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequestOrBuilder.java index 2917bda2e91..bc6b0c5429c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface DeleteSessionRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -30,6 +47,8 @@ public interface DeleteSessionRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java index 643145e3929..93a28a71239 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private ExecuteBatchDmlRequest() { statements_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecuteBatchDmlRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -76,11 +97,11 @@ private ExecuteBatchDmlRequest( } case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = new java.util.ArrayList< com.google.spanner.v1.ExecuteBatchDmlRequest.Statement>(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000001; } statements_.add( input.readMessage( @@ -107,7 +128,7 @@ private ExecuteBatchDmlRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { statements_ = java.util.Collections.unmodifiableList(statements_); } this.unknownFields = unknownFields.build(); @@ -143,6 +164,8 @@ public interface StatementOrBuilder * * * string sql = 1; + * + * @return The sql. */ java.lang.String getSql(); /** @@ -153,6 +176,8 @@ public interface StatementOrBuilder * * * string sql = 1; + * + * @return The bytes for sql. */ com.google.protobuf.ByteString getSqlBytes(); @@ -171,6 +196,8 @@ public interface StatementOrBuilder * * * .google.protobuf.Struct params = 2; + * + * @return Whether the params field is set. */ boolean hasParams(); /** @@ -188,6 +215,8 @@ public interface StatementOrBuilder * * * .google.protobuf.Struct params = 2; + * + * @return The params. */ com.google.protobuf.Struct getParams(); /** @@ -326,6 +355,12 @@ private Statement() { sql_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Statement(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -373,11 +408,11 @@ private Statement( } case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { paramTypes_ = com.google.protobuf.MapField.newMapField( ParamTypesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry paramTypes__ = @@ -432,7 +467,6 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { com.google.spanner.v1.ExecuteBatchDmlRequest.Statement.Builder.class); } - private int bitField0_; public static final int SQL_FIELD_NUMBER = 1; private volatile java.lang.Object sql_; /** @@ -443,6 +477,8 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { * * * string sql = 1; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -463,6 +499,8 @@ public java.lang.String getSql() { * * * string sql = 1; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -493,6 +531,8 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * .google.protobuf.Struct params = 2; + * + * @return Whether the params field is set. */ public boolean hasParams() { return params_ != null; @@ -512,6 +552,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 2; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { return params_ == null ? com.google.protobuf.Struct.getDefaultInstance() : params_; @@ -963,7 +1005,6 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement buildPartial() { com.google.spanner.v1.ExecuteBatchDmlRequest.Statement result = new com.google.spanner.v1.ExecuteBatchDmlRequest.Statement(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.sql_ = sql_; if (paramsBuilder_ == null) { result.params_ = params_; @@ -972,7 +1013,6 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement buildPartial() { } result.paramTypes_ = internalGetParamTypes(); result.paramTypes_.makeImmutable(); - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1074,6 +1114,8 @@ public Builder mergeFrom( * * * string sql = 1; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -1094,6 +1136,8 @@ public java.lang.String getSql() { * * * string sql = 1; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -1114,6 +1158,9 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * string sql = 1; + * + * @param value The sql to set. + * @return This builder for chaining. */ public Builder setSql(java.lang.String value) { if (value == null) { @@ -1132,6 +1179,8 @@ public Builder setSql(java.lang.String value) { * * * string sql = 1; + * + * @return This builder for chaining. */ public Builder clearSql() { @@ -1147,6 +1196,9 @@ public Builder clearSql() { * * * string sql = 1; + * + * @param value The bytes for sql to set. + * @return This builder for chaining. */ public Builder setSqlBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1180,6 +1232,8 @@ public Builder setSqlBytes(com.google.protobuf.ByteString value) { * * * .google.protobuf.Struct params = 2; + * + * @return Whether the params field is set. */ public boolean hasParams() { return paramsBuilder_ != null || params_ != null; @@ -1199,6 +1253,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 2; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { if (paramsBuilder_ == null) { @@ -1664,7 +1720,6 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement getDefaultInstance } } - private int bitField0_; public static final int SESSION_FIELD_NUMBER = 1; private volatile java.lang.Object session_; /** @@ -1677,6 +1732,8 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement getDefaultInstance * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -1699,6 +1756,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -1727,6 +1786,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -1744,6 +1805,8 @@ public boolean hasTransaction() { * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { return transaction_ == null @@ -1880,6 +1943,8 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.StatementOrBuilder getStatem * * * int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The seqno. */ public long getSeqno() { return seqno_; @@ -2135,7 +2200,7 @@ public Builder clear() { } if (statementsBuilder_ == null) { statements_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } else { statementsBuilder_.clear(); } @@ -2169,7 +2234,6 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest buildPartial() { com.google.spanner.v1.ExecuteBatchDmlRequest result = new com.google.spanner.v1.ExecuteBatchDmlRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionBuilder_ == null) { result.transaction_ = transaction_; @@ -2177,16 +2241,15 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest buildPartial() { result.transaction_ = transactionBuilder_.build(); } if (statementsBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { statements_ = java.util.Collections.unmodifiableList(statements_); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } result.statements_ = statements_; } else { result.statements_ = statementsBuilder_.build(); } result.seqno_ = seqno_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -2247,7 +2310,7 @@ public Builder mergeFrom(com.google.spanner.v1.ExecuteBatchDmlRequest other) { if (!other.statements_.isEmpty()) { if (statements_.isEmpty()) { statements_ = other.statements_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureStatementsIsMutable(); statements_.addAll(other.statements_); @@ -2260,7 +2323,7 @@ public Builder mergeFrom(com.google.spanner.v1.ExecuteBatchDmlRequest other) { statementsBuilder_.dispose(); statementsBuilder_ = null; statements_ = other.statements_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); statementsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getStatementsFieldBuilder() @@ -2315,6 +2378,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -2337,6 +2402,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -2359,6 +2426,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -2379,6 +2449,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -2396,6 +2468,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -2427,6 +2502,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -2444,6 +2521,8 @@ public boolean hasTransaction() { * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { if (transactionBuilder_ == null) { @@ -2639,11 +2718,11 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde java.util.Collections.emptyList(); private void ensureStatementsIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { statements_ = new java.util.ArrayList( statements_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000001; } } @@ -2929,7 +3008,7 @@ public Builder addAllStatements( public Builder clearStatements() { if (statementsBuilder_ == null) { statements_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { statementsBuilder_.clear(); @@ -3097,7 +3176,7 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement.Builder addStateme com.google.spanner.v1.ExecuteBatchDmlRequest.Statement, com.google.spanner.v1.ExecuteBatchDmlRequest.Statement.Builder, com.google.spanner.v1.ExecuteBatchDmlRequest.StatementOrBuilder>( - statements_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + statements_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); statements_ = null; } return statementsBuilder_; @@ -3118,6 +3197,8 @@ public com.google.spanner.v1.ExecuteBatchDmlRequest.Statement.Builder addStateme * * * int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The seqno. */ public long getSeqno() { return seqno_; @@ -3136,6 +3217,9 @@ public long getSeqno() { * * * int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The seqno to set. + * @return This builder for chaining. */ public Builder setSeqno(long value) { @@ -3157,6 +3241,8 @@ public Builder setSeqno(long value) { * * * int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearSeqno() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequestOrBuilder.java index a10a8d45fa9..1c129c96ef6 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface ExecuteBatchDmlRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface ExecuteBatchDmlRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -46,6 +65,8 @@ public interface ExecuteBatchDmlRequestOrBuilder * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -61,6 +82,8 @@ public interface ExecuteBatchDmlRequestOrBuilder * * .google.spanner.v1.TransactionSelector transaction = 2 [(.google.api.field_behavior) = REQUIRED]; * + * + * @return The transaction. */ com.google.spanner.v1.TransactionSelector getTransaction(); /** @@ -175,6 +198,8 @@ public interface ExecuteBatchDmlRequestOrBuilder * * * int64 seqno = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The seqno. */ long getSeqno(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponse.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponse.java index dcf124408f5..a5df81b2068 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponse.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -50,6 +65,12 @@ private ExecuteBatchDmlResponse() { resultSets_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecuteBatchDmlResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -135,7 +156,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.ExecuteBatchDmlResponse.Builder.class); } - private int bitField0_; public static final int RESULT_SETS_FIELD_NUMBER = 1; private java.util.List resultSets_; /** @@ -246,6 +266,8 @@ public com.google.spanner.v1.ResultSetOrBuilder getResultSetsOrBuilder(int index * * * .google.rpc.Status status = 2; + * + * @return Whether the status field is set. */ public boolean hasStatus() { return status_ != null; @@ -259,6 +281,8 @@ public boolean hasStatus() { * * * .google.rpc.Status status = 2; + * + * @return The status. */ public com.google.rpc.Status getStatus() { return status_ == null ? com.google.rpc.Status.getDefaultInstance() : status_; @@ -563,7 +587,6 @@ public com.google.spanner.v1.ExecuteBatchDmlResponse buildPartial() { com.google.spanner.v1.ExecuteBatchDmlResponse result = new com.google.spanner.v1.ExecuteBatchDmlResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (resultSetsBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { resultSets_ = java.util.Collections.unmodifiableList(resultSets_); @@ -578,7 +601,6 @@ public com.google.spanner.v1.ExecuteBatchDmlResponse buildPartial() { } else { result.status_ = statusBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1176,6 +1198,8 @@ public java.util.List getResultSetsBuil * * * .google.rpc.Status status = 2; + * + * @return Whether the status field is set. */ public boolean hasStatus() { return statusBuilder_ != null || status_ != null; @@ -1189,6 +1213,8 @@ public boolean hasStatus() { * * * .google.rpc.Status status = 2; + * + * @return The status. */ public com.google.rpc.Status getStatus() { if (statusBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponseOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponseOrBuilder.java index 3fb4fc40e45..77449f76ed7 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponseOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -103,6 +118,8 @@ public interface ExecuteBatchDmlResponseOrBuilder * * * .google.rpc.Status status = 2; + * + * @return Whether the status field is set. */ boolean hasStatus(); /** @@ -114,6 +131,8 @@ public interface ExecuteBatchDmlResponseOrBuilder * * * .google.rpc.Status status = 2; + * + * @return The status. */ com.google.rpc.Status getStatus(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequest.java index 8f79be328cc..30a0e5c7677 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -31,6 +46,12 @@ private ExecuteSqlRequest() { partitionToken_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecuteSqlRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -101,11 +122,11 @@ private ExecuteSqlRequest( } case 42: { - if (!((mutable_bitField0_ & 0x00000010) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { paramTypes_ = com.google.protobuf.MapField.newMapField( ParamTypesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000010; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry paramTypes__ = @@ -268,12 +289,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static QueryMode valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static QueryMode forNumber(int value) { switch (value) { case 0: @@ -331,7 +360,6 @@ private QueryMode(int value) { // @@protoc_insertion_point(enum_scope:google.spanner.v1.ExecuteSqlRequest.QueryMode) } - private int bitField0_; public static final int SESSION_FIELD_NUMBER = 1; private volatile java.lang.Object session_; /** @@ -344,6 +372,8 @@ private QueryMode(int value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -366,6 +396,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -395,6 +427,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -413,6 +447,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { return transaction_ == null @@ -448,6 +484,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -468,6 +506,8 @@ public java.lang.String getSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -498,6 +538,8 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ public boolean hasParams() { return params_ != null; @@ -517,6 +559,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { return params_ == null ? com.google.protobuf.Struct.getDefaultInstance() : params_; @@ -683,6 +727,8 @@ public com.google.spanner.v1.Type getParamTypesOrThrow(java.lang.String key) { * * * bytes resume_token = 6; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -703,6 +749,8 @@ public com.google.protobuf.ByteString getResumeToken() { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The enum numeric value on the wire for queryMode. */ public int getQueryModeValue() { return queryMode_; @@ -720,6 +768,8 @@ public int getQueryModeValue() { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The queryMode. */ public com.google.spanner.v1.ExecuteSqlRequest.QueryMode getQueryMode() { @SuppressWarnings("deprecation") @@ -741,6 +791,8 @@ public com.google.spanner.v1.ExecuteSqlRequest.QueryMode getQueryMode() { * * * bytes partition_token = 8; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -763,6 +815,8 @@ public com.google.protobuf.ByteString getPartitionToken() { * * * int64 seqno = 9; + * + * @return The seqno. */ public long getSeqno() { return seqno_; @@ -1135,7 +1189,6 @@ public com.google.spanner.v1.ExecuteSqlRequest buildPartial() { com.google.spanner.v1.ExecuteSqlRequest result = new com.google.spanner.v1.ExecuteSqlRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionBuilder_ == null) { result.transaction_ = transaction_; @@ -1154,7 +1207,6 @@ public com.google.spanner.v1.ExecuteSqlRequest buildPartial() { result.queryMode_ = queryMode_; result.partitionToken_ = partitionToken_; result.seqno_ = seqno_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1273,6 +1325,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -1295,6 +1349,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -1317,6 +1373,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -1337,6 +1396,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -1354,6 +1415,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1386,6 +1450,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -1404,6 +1470,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { if (transactionBuilder_ == null) { @@ -1611,6 +1679,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -1631,6 +1701,8 @@ public java.lang.String getSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -1651,6 +1723,9 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The sql to set. + * @return This builder for chaining. */ public Builder setSql(java.lang.String value) { if (value == null) { @@ -1669,6 +1744,8 @@ public Builder setSql(java.lang.String value) { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearSql() { @@ -1684,6 +1761,9 @@ public Builder clearSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for sql to set. + * @return This builder for chaining. */ public Builder setSqlBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1717,6 +1797,8 @@ public Builder setSqlBytes(com.google.protobuf.ByteString value) { * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ public boolean hasParams() { return paramsBuilder_ != null || params_ != null; @@ -1736,6 +1818,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { if (paramsBuilder_ == null) { @@ -2154,6 +2238,8 @@ public Builder putAllParamTypes( * * * bytes resume_token = 6; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -2171,6 +2257,9 @@ public com.google.protobuf.ByteString getResumeToken() { * * * bytes resume_token = 6; + * + * @param value The resumeToken to set. + * @return This builder for chaining. */ public Builder setResumeToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -2194,6 +2283,8 @@ public Builder setResumeToken(com.google.protobuf.ByteString value) { * * * bytes resume_token = 6; + * + * @return This builder for chaining. */ public Builder clearResumeToken() { @@ -2216,6 +2307,8 @@ public Builder clearResumeToken() { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The enum numeric value on the wire for queryMode. */ public int getQueryModeValue() { return queryMode_; @@ -2233,6 +2326,9 @@ public int getQueryModeValue() { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @param value The enum numeric value on the wire for queryMode to set. + * @return This builder for chaining. */ public Builder setQueryModeValue(int value) { queryMode_ = value; @@ -2252,6 +2348,8 @@ public Builder setQueryModeValue(int value) { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The queryMode. */ public com.google.spanner.v1.ExecuteSqlRequest.QueryMode getQueryMode() { @SuppressWarnings("deprecation") @@ -2274,6 +2372,9 @@ public com.google.spanner.v1.ExecuteSqlRequest.QueryMode getQueryMode() { * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @param value The queryMode to set. + * @return This builder for chaining. */ public Builder setQueryMode(com.google.spanner.v1.ExecuteSqlRequest.QueryMode value) { if (value == null) { @@ -2297,6 +2398,8 @@ public Builder setQueryMode(com.google.spanner.v1.ExecuteSqlRequest.QueryMode va * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return This builder for chaining. */ public Builder clearQueryMode() { @@ -2317,6 +2420,8 @@ public Builder clearQueryMode() { * * * bytes partition_token = 8; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -2332,6 +2437,9 @@ public com.google.protobuf.ByteString getPartitionToken() { * * * bytes partition_token = 8; + * + * @param value The partitionToken to set. + * @return This builder for chaining. */ public Builder setPartitionToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -2353,6 +2461,8 @@ public Builder setPartitionToken(com.google.protobuf.ByteString value) { * * * bytes partition_token = 8; + * + * @return This builder for chaining. */ public Builder clearPartitionToken() { @@ -2377,6 +2487,8 @@ public Builder clearPartitionToken() { * * * int64 seqno = 9; + * + * @return The seqno. */ public long getSeqno() { return seqno_; @@ -2396,6 +2508,9 @@ public long getSeqno() { * * * int64 seqno = 9; + * + * @param value The seqno to set. + * @return This builder for chaining. */ public Builder setSeqno(long value) { @@ -2418,6 +2533,8 @@ public Builder setSeqno(long value) { * * * int64 seqno = 9; + * + * @return This builder for chaining. */ public Builder clearSeqno() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequestOrBuilder.java index 833d08b76ba..b7a19093221 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface ExecuteSqlRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface ExecuteSqlRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -47,6 +66,8 @@ public interface ExecuteSqlRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -63,6 +84,8 @@ public interface ExecuteSqlRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.TransactionSelector getTransaction(); /** @@ -90,6 +113,8 @@ public interface ExecuteSqlRequestOrBuilder * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ java.lang.String getSql(); /** @@ -100,6 +125,8 @@ public interface ExecuteSqlRequestOrBuilder * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ com.google.protobuf.ByteString getSqlBytes(); @@ -118,6 +145,8 @@ public interface ExecuteSqlRequestOrBuilder * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ boolean hasParams(); /** @@ -135,6 +164,8 @@ public interface ExecuteSqlRequestOrBuilder * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ com.google.protobuf.Struct getParams(); /** @@ -258,6 +289,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * bytes resume_token = 6; + * + * @return The resumeToken. */ com.google.protobuf.ByteString getResumeToken(); @@ -274,6 +307,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The enum numeric value on the wire for queryMode. */ int getQueryModeValue(); /** @@ -289,6 +324,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * .google.spanner.v1.ExecuteSqlRequest.QueryMode query_mode = 7; + * + * @return The queryMode. */ com.google.spanner.v1.ExecuteSqlRequest.QueryMode getQueryMode(); @@ -303,6 +340,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * bytes partition_token = 8; + * + * @return The partitionToken. */ com.google.protobuf.ByteString getPartitionToken(); @@ -321,6 +360,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * int64 seqno = 9; + * + * @return The seqno. */ long getSeqno(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequest.java index 7335071a1f7..8f001c499a8 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -26,6 +41,12 @@ private GetSessionRequest() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetSessionRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private GetSessionRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -103,6 +123,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -125,6 +147,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -464,6 +488,8 @@ public Builder mergeFrom( * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -486,6 +512,8 @@ public java.lang.String getName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -508,6 +536,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -528,6 +559,8 @@ public Builder setName(java.lang.String value) { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearName() { @@ -545,6 +578,9 @@ public Builder clearName() { * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequestOrBuilder.java index 4a4cc03f50c..a97de2cffae 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface GetSessionRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The name. */ java.lang.String getName(); /** @@ -30,6 +47,8 @@ public interface GetSessionRequestOrBuilder * * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRange.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRange.java index e539f54a4b7..7d390f0cf25 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRange.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRange.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/keys.proto @@ -84,6 +99,12 @@ private KeyRange(com.google.protobuf.GeneratedMessageV3.Builder builder) { private KeyRange() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new KeyRange(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -97,7 +118,6 @@ private KeyRange( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -203,7 +223,10 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { private int startKeyTypeCase_ = 0; private java.lang.Object startKeyType_; - public enum StartKeyTypeCase implements com.google.protobuf.Internal.EnumLite { + public enum StartKeyTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { START_CLOSED(1), START_OPEN(2), STARTKEYTYPE_NOT_SET(0); @@ -212,7 +235,11 @@ public enum StartKeyTypeCase implements com.google.protobuf.Internal.EnumLite { private StartKeyTypeCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static StartKeyTypeCase valueOf(int value) { return forNumber(value); @@ -243,7 +270,10 @@ public StartKeyTypeCase getStartKeyTypeCase() { private int endKeyTypeCase_ = 0; private java.lang.Object endKeyType_; - public enum EndKeyTypeCase implements com.google.protobuf.Internal.EnumLite { + public enum EndKeyTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { END_CLOSED(3), END_OPEN(4), ENDKEYTYPE_NOT_SET(0); @@ -252,7 +282,11 @@ public enum EndKeyTypeCase implements com.google.protobuf.Internal.EnumLite { private EndKeyTypeCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static EndKeyTypeCase valueOf(int value) { return forNumber(value); @@ -290,6 +324,8 @@ public EndKeyTypeCase getEndKeyTypeCase() { * * * .google.protobuf.ListValue start_closed = 1; + * + * @return Whether the startClosed field is set. */ public boolean hasStartClosed() { return startKeyTypeCase_ == 1; @@ -303,6 +339,8 @@ public boolean hasStartClosed() { * * * .google.protobuf.ListValue start_closed = 1; + * + * @return The startClosed. */ public com.google.protobuf.ListValue getStartClosed() { if (startKeyTypeCase_ == 1) { @@ -337,6 +375,8 @@ public com.google.protobuf.ListValueOrBuilder getStartClosedOrBuilder() { * * * .google.protobuf.ListValue start_open = 2; + * + * @return Whether the startOpen field is set. */ public boolean hasStartOpen() { return startKeyTypeCase_ == 2; @@ -350,6 +390,8 @@ public boolean hasStartOpen() { * * * .google.protobuf.ListValue start_open = 2; + * + * @return The startOpen. */ public com.google.protobuf.ListValue getStartOpen() { if (startKeyTypeCase_ == 2) { @@ -384,6 +426,8 @@ public com.google.protobuf.ListValueOrBuilder getStartOpenOrBuilder() { * * * .google.protobuf.ListValue end_closed = 3; + * + * @return Whether the endClosed field is set. */ public boolean hasEndClosed() { return endKeyTypeCase_ == 3; @@ -397,6 +441,8 @@ public boolean hasEndClosed() { * * * .google.protobuf.ListValue end_closed = 3; + * + * @return The endClosed. */ public com.google.protobuf.ListValue getEndClosed() { if (endKeyTypeCase_ == 3) { @@ -431,6 +477,8 @@ public com.google.protobuf.ListValueOrBuilder getEndClosedOrBuilder() { * * * .google.protobuf.ListValue end_open = 4; + * + * @return Whether the endOpen field is set. */ public boolean hasEndOpen() { return endKeyTypeCase_ == 4; @@ -444,6 +492,8 @@ public boolean hasEndOpen() { * * * .google.protobuf.ListValue end_open = 4; + * + * @return The endOpen. */ public com.google.protobuf.ListValue getEndOpen() { if (endKeyTypeCase_ == 4) { @@ -1008,6 +1058,8 @@ public Builder clearEndKeyType() { * * * .google.protobuf.ListValue start_closed = 1; + * + * @return Whether the startClosed field is set. */ public boolean hasStartClosed() { return startKeyTypeCase_ == 1; @@ -1021,6 +1073,8 @@ public boolean hasStartClosed() { * * * .google.protobuf.ListValue start_closed = 1; + * + * @return The startClosed. */ public com.google.protobuf.ListValue getStartClosed() { if (startClosedBuilder_ == null) { @@ -1216,6 +1270,8 @@ public com.google.protobuf.ListValueOrBuilder getStartClosedOrBuilder() { * * * .google.protobuf.ListValue start_open = 2; + * + * @return Whether the startOpen field is set. */ public boolean hasStartOpen() { return startKeyTypeCase_ == 2; @@ -1229,6 +1285,8 @@ public boolean hasStartOpen() { * * * .google.protobuf.ListValue start_open = 2; + * + * @return The startOpen. */ public com.google.protobuf.ListValue getStartOpen() { if (startOpenBuilder_ == null) { @@ -1424,6 +1482,8 @@ public com.google.protobuf.ListValueOrBuilder getStartOpenOrBuilder() { * * * .google.protobuf.ListValue end_closed = 3; + * + * @return Whether the endClosed field is set. */ public boolean hasEndClosed() { return endKeyTypeCase_ == 3; @@ -1437,6 +1497,8 @@ public boolean hasEndClosed() { * * * .google.protobuf.ListValue end_closed = 3; + * + * @return The endClosed. */ public com.google.protobuf.ListValue getEndClosed() { if (endClosedBuilder_ == null) { @@ -1631,6 +1693,8 @@ public com.google.protobuf.ListValueOrBuilder getEndClosedOrBuilder() { * * * .google.protobuf.ListValue end_open = 4; + * + * @return Whether the endOpen field is set. */ public boolean hasEndOpen() { return endKeyTypeCase_ == 4; @@ -1644,6 +1708,8 @@ public boolean hasEndOpen() { * * * .google.protobuf.ListValue end_open = 4; + * + * @return The endOpen. */ public com.google.protobuf.ListValue getEndOpen() { if (endOpenBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRangeOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRangeOrBuilder.java index 03ede7f5753..80c8e940d40 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRangeOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRangeOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/keys.proto @@ -17,6 +32,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue start_closed = 1; + * + * @return Whether the startClosed field is set. */ boolean hasStartClosed(); /** @@ -28,6 +45,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue start_closed = 1; + * + * @return The startClosed. */ com.google.protobuf.ListValue getStartClosed(); /** @@ -51,6 +70,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue start_open = 2; + * + * @return Whether the startOpen field is set. */ boolean hasStartOpen(); /** @@ -62,6 +83,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue start_open = 2; + * + * @return The startOpen. */ com.google.protobuf.ListValue getStartOpen(); /** @@ -85,6 +108,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue end_closed = 3; + * + * @return Whether the endClosed field is set. */ boolean hasEndClosed(); /** @@ -96,6 +121,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue end_closed = 3; + * + * @return The endClosed. */ com.google.protobuf.ListValue getEndClosed(); /** @@ -119,6 +146,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue end_open = 4; + * + * @return Whether the endOpen field is set. */ boolean hasEndOpen(); /** @@ -130,6 +159,8 @@ public interface KeyRangeOrBuilder * * * .google.protobuf.ListValue end_open = 4; + * + * @return The endOpen. */ com.google.protobuf.ListValue getEndOpen(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySet.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySet.java index e5ec02be514..5f43fd2dc53 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySet.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySet.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/keys.proto @@ -32,6 +47,12 @@ private KeySet() { ranges_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new KeySet(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -119,7 +140,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.KeySet.class, com.google.spanner.v1.KeySet.Builder.class); } - private int bitField0_; public static final int KEYS_FIELD_NUMBER = 1; private java.util.List keys_; /** @@ -279,6 +299,8 @@ public com.google.spanner.v1.KeyRangeOrBuilder getRangesOrBuilder(int index) { * * * bool all = 3; + * + * @return The all. */ public boolean getAll() { return all_; @@ -554,7 +576,6 @@ public com.google.spanner.v1.KeySet build() { public com.google.spanner.v1.KeySet buildPartial() { com.google.spanner.v1.KeySet result = new com.google.spanner.v1.KeySet(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (keysBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { keys_ = java.util.Collections.unmodifiableList(keys_); @@ -574,7 +595,6 @@ public com.google.spanner.v1.KeySet buildPartial() { result.ranges_ = rangesBuilder_.build(); } result.all_ = all_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1483,6 +1503,8 @@ public java.util.List getRangesBuilderLi * * * bool all = 3; + * + * @return The all. */ public boolean getAll() { return all_; @@ -1497,6 +1519,9 @@ public boolean getAll() { * * * bool all = 3; + * + * @param value The all to set. + * @return This builder for chaining. */ public Builder setAll(boolean value) { @@ -1514,6 +1539,8 @@ public Builder setAll(boolean value) { * * * bool all = 3; + * + * @return This builder for chaining. */ public Builder clearAll() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySetOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySetOrBuilder.java index 10a87a134da..cf23c2b3f50 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySetOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySetOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/keys.proto @@ -140,6 +155,8 @@ public interface KeySetOrBuilder * * * bool all = 3; + * + * @return The all. */ boolean getAll(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java index 827b3658326..fbb284538a3 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/keys.proto @@ -46,21 +61,13 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\C" + "loud\\Spanner\\V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.StructProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.StructProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_KeyRange_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_KeyRange_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequest.java index 0211aeb72ff..12e2669ad71 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -28,6 +43,12 @@ private ListSessionsRequest() { filter_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListSessionsRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -41,7 +62,6 @@ private ListSessionsRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -124,6 +144,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -146,6 +168,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -170,6 +194,8 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -188,6 +214,8 @@ public int getPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -211,6 +239,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -240,6 +270,8 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string filter = 4; + * + * @return The filter. */ public java.lang.String getFilter() { java.lang.Object ref = filter_; @@ -266,6 +298,8 @@ public java.lang.String getFilter() { * * * string filter = 4; + * + * @return The bytes for filter. */ public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; @@ -653,6 +687,8 @@ public Builder mergeFrom( * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ public java.lang.String getDatabase() { java.lang.Object ref = database_; @@ -675,6 +711,8 @@ public java.lang.String getDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ public com.google.protobuf.ByteString getDatabaseBytes() { java.lang.Object ref = database_; @@ -697,6 +735,9 @@ public com.google.protobuf.ByteString getDatabaseBytes() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The database to set. + * @return This builder for chaining. */ public Builder setDatabase(java.lang.String value) { if (value == null) { @@ -717,6 +758,8 @@ public Builder setDatabase(java.lang.String value) { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearDatabase() { @@ -734,6 +777,9 @@ public Builder clearDatabase() { * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for database to set. + * @return This builder for chaining. */ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -756,6 +802,8 @@ public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { * * * int32 page_size = 2; + * + * @return The pageSize. */ public int getPageSize() { return pageSize_; @@ -769,6 +817,9 @@ public int getPageSize() { * * * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. */ public Builder setPageSize(int value) { @@ -785,6 +836,8 @@ public Builder setPageSize(int value) { * * * int32 page_size = 2; + * + * @return This builder for chaining. */ public Builder clearPageSize() { @@ -805,6 +858,8 @@ public Builder clearPageSize() { * * * string page_token = 3; + * + * @return The pageToken. */ public java.lang.String getPageToken() { java.lang.Object ref = pageToken_; @@ -828,6 +883,8 @@ public java.lang.String getPageToken() { * * * string page_token = 3; + * + * @return The bytes for pageToken. */ public com.google.protobuf.ByteString getPageTokenBytes() { java.lang.Object ref = pageToken_; @@ -851,6 +908,9 @@ public com.google.protobuf.ByteString getPageTokenBytes() { * * * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. */ public Builder setPageToken(java.lang.String value) { if (value == null) { @@ -872,6 +932,8 @@ public Builder setPageToken(java.lang.String value) { * * * string page_token = 3; + * + * @return This builder for chaining. */ public Builder clearPageToken() { @@ -890,6 +952,9 @@ public Builder clearPageToken() { * * * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. */ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -917,6 +982,8 @@ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { * * * string filter = 4; + * + * @return The filter. */ public java.lang.String getFilter() { java.lang.Object ref = filter_; @@ -943,6 +1010,8 @@ public java.lang.String getFilter() { * * * string filter = 4; + * + * @return The bytes for filter. */ public com.google.protobuf.ByteString getFilterBytes() { java.lang.Object ref = filter_; @@ -969,6 +1038,9 @@ public com.google.protobuf.ByteString getFilterBytes() { * * * string filter = 4; + * + * @param value The filter to set. + * @return This builder for chaining. */ public Builder setFilter(java.lang.String value) { if (value == null) { @@ -993,6 +1065,8 @@ public Builder setFilter(java.lang.String value) { * * * string filter = 4; + * + * @return This builder for chaining. */ public Builder clearFilter() { @@ -1014,6 +1088,9 @@ public Builder clearFilter() { * * * string filter = 4; + * + * @param value The bytes for filter to set. + * @return This builder for chaining. */ public Builder setFilterBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequestOrBuilder.java index 75b3fc278f4..bff0c6889e2 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface ListSessionsRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The database. */ java.lang.String getDatabase(); /** @@ -30,6 +47,8 @@ public interface ListSessionsRequestOrBuilder * * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for database. */ com.google.protobuf.ByteString getDatabaseBytes(); @@ -42,6 +61,8 @@ public interface ListSessionsRequestOrBuilder * * * int32 page_size = 2; + * + * @return The pageSize. */ int getPageSize(); @@ -56,6 +77,8 @@ public interface ListSessionsRequestOrBuilder * * * string page_token = 3; + * + * @return The pageToken. */ java.lang.String getPageToken(); /** @@ -69,6 +92,8 @@ public interface ListSessionsRequestOrBuilder * * * string page_token = 3; + * + * @return The bytes for pageToken. */ com.google.protobuf.ByteString getPageTokenBytes(); @@ -86,6 +111,8 @@ public interface ListSessionsRequestOrBuilder * * * string filter = 4; + * + * @return The filter. */ java.lang.String getFilter(); /** @@ -102,6 +129,8 @@ public interface ListSessionsRequestOrBuilder * * * string filter = 4; + * + * @return The bytes for filter. */ com.google.protobuf.ByteString getFilterBytes(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponse.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponse.java index 9ae9f7ee318..c404c92267b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponse.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private ListSessionsResponse() { nextPageToken_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListSessionsResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -105,7 +126,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.ListSessionsResponse.Builder.class); } - private int bitField0_; public static final int SESSIONS_FIELD_NUMBER = 1; private java.util.List sessions_; /** @@ -182,6 +202,8 @@ public com.google.spanner.v1.SessionOrBuilder getSessionsOrBuilder(int index) { * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -204,6 +226,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -470,7 +494,6 @@ public com.google.spanner.v1.ListSessionsResponse buildPartial() { com.google.spanner.v1.ListSessionsResponse result = new com.google.spanner.v1.ListSessionsResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (sessionsBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { sessions_ = java.util.Collections.unmodifiableList(sessions_); @@ -481,7 +504,6 @@ public com.google.spanner.v1.ListSessionsResponse buildPartial() { result.sessions_ = sessionsBuilder_.build(); } result.nextPageToken_ = nextPageToken_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -950,6 +972,8 @@ public java.util.List getSessionsBuilderL * * * string next_page_token = 2; + * + * @return The nextPageToken. */ public java.lang.String getNextPageToken() { java.lang.Object ref = nextPageToken_; @@ -972,6 +996,8 @@ public java.lang.String getNextPageToken() { * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ public com.google.protobuf.ByteString getNextPageTokenBytes() { java.lang.Object ref = nextPageToken_; @@ -994,6 +1020,9 @@ public com.google.protobuf.ByteString getNextPageTokenBytes() { * * * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageToken(java.lang.String value) { if (value == null) { @@ -1014,6 +1043,8 @@ public Builder setNextPageToken(java.lang.String value) { * * * string next_page_token = 2; + * + * @return This builder for chaining. */ public Builder clearNextPageToken() { @@ -1031,6 +1062,9 @@ public Builder clearNextPageToken() { * * * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. */ public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { if (value == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponseOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponseOrBuilder.java index 78fb4f0dbb9..6cb68614bcd 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponseOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -69,6 +84,8 @@ public interface ListSessionsResponseOrBuilder * * * string next_page_token = 2; + * + * @return The nextPageToken. */ java.lang.String getNextPageToken(); /** @@ -81,6 +98,8 @@ public interface ListSessionsResponseOrBuilder * * * string next_page_token = 2; + * + * @return The bytes for nextPageToken. */ com.google.protobuf.ByteString getNextPageTokenBytes(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java index 7e58f471cf0..e9359ab6ff4 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/mutation.proto @@ -26,6 +41,12 @@ private Mutation(com.google.protobuf.GeneratedMessageV3.Builder builder) { private Mutation() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Mutation(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private Mutation( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -176,6 +196,8 @@ public interface WriteOrBuilder * * * string table = 1; + * + * @return The table. */ java.lang.String getTable(); /** @@ -186,6 +208,8 @@ public interface WriteOrBuilder * * * string table = 1; + * + * @return The bytes for table. */ com.google.protobuf.ByteString getTableBytes(); @@ -200,6 +224,8 @@ public interface WriteOrBuilder * * * repeated string columns = 2; + * + * @return A list containing the columns. */ java.util.List getColumnsList(); /** @@ -213,6 +239,8 @@ public interface WriteOrBuilder * * * repeated string columns = 2; + * + * @return The count of columns. */ int getColumnsCount(); /** @@ -226,6 +254,9 @@ public interface WriteOrBuilder * * * repeated string columns = 2; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ java.lang.String getColumns(int index); /** @@ -239,6 +270,9 @@ public interface WriteOrBuilder * * * repeated string columns = 2; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ com.google.protobuf.ByteString getColumnsBytes(int index); @@ -354,6 +388,12 @@ private Write() { values_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Write(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -388,18 +428,18 @@ private Write( case 18: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } columns_.add(s); break; } case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { values_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; + mutable_bitField0_ |= 0x00000002; } values_.add( input.readMessage(com.google.protobuf.ListValue.parser(), extensionRegistry)); @@ -419,10 +459,10 @@ private Write( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); } - if (((mutable_bitField0_ & 0x00000004) != 0)) { + if (((mutable_bitField0_ & 0x00000002) != 0)) { values_ = java.util.Collections.unmodifiableList(values_); } this.unknownFields = unknownFields.build(); @@ -445,7 +485,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.Mutation.Write.Builder.class); } - private int bitField0_; public static final int TABLE_FIELD_NUMBER = 1; private volatile java.lang.Object table_; /** @@ -456,6 +495,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string table = 1; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -476,6 +517,8 @@ public java.lang.String getTable() { * * * string table = 1; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -502,6 +545,8 @@ public com.google.protobuf.ByteString getTableBytes() { * * * repeated string columns = 2; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_; @@ -517,6 +562,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 2; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -532,6 +579,9 @@ public int getColumnsCount() { * * * repeated string columns = 2; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -547,6 +597,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 2; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -889,10 +942,10 @@ public Builder clear() { table_ = ""; columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); if (valuesBuilder_ == null) { values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { valuesBuilder_.clear(); } @@ -924,23 +977,21 @@ public com.google.spanner.v1.Mutation.Write buildPartial() { com.google.spanner.v1.Mutation.Write result = new com.google.spanner.v1.Mutation.Write(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.table_ = table_; - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.columns_ = columns_; if (valuesBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0)) { + if (((bitField0_ & 0x00000002) != 0)) { values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } result.values_ = values_; } else { result.values_ = valuesBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -999,7 +1050,7 @@ public Builder mergeFrom(com.google.spanner.v1.Mutation.Write other) { if (!other.columns_.isEmpty()) { if (columns_.isEmpty()) { columns_ = other.columns_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureColumnsIsMutable(); columns_.addAll(other.columns_); @@ -1010,7 +1061,7 @@ public Builder mergeFrom(com.google.spanner.v1.Mutation.Write other) { if (!other.values_.isEmpty()) { if (values_.isEmpty()) { values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); } else { ensureValuesIsMutable(); values_.addAll(other.values_); @@ -1023,7 +1074,7 @@ public Builder mergeFrom(com.google.spanner.v1.Mutation.Write other) { valuesBuilder_.dispose(); valuesBuilder_ = null; values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); valuesBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getValuesFieldBuilder() @@ -1073,6 +1124,8 @@ public Builder mergeFrom( * * * string table = 1; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -1093,6 +1146,8 @@ public java.lang.String getTable() { * * * string table = 1; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -1113,6 +1168,9 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string table = 1; + * + * @param value The table to set. + * @return This builder for chaining. */ public Builder setTable(java.lang.String value) { if (value == null) { @@ -1131,6 +1189,8 @@ public Builder setTable(java.lang.String value) { * * * string table = 1; + * + * @return This builder for chaining. */ public Builder clearTable() { @@ -1146,6 +1206,9 @@ public Builder clearTable() { * * * string table = 1; + * + * @param value The bytes for table to set. + * @return This builder for chaining. */ public Builder setTableBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1162,9 +1225,9 @@ public Builder setTableBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureColumnsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(columns_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } /** @@ -1178,6 +1241,8 @@ private void ensureColumnsIsMutable() { * * * repeated string columns = 2; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_.getUnmodifiableView(); @@ -1193,6 +1258,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 2; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -1208,6 +1275,9 @@ public int getColumnsCount() { * * * repeated string columns = 2; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -1223,6 +1293,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 2; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -1238,6 +1311,10 @@ public com.google.protobuf.ByteString getColumnsBytes(int index) { * * * repeated string columns = 2; + * + * @param index The index to set the value at. + * @param value The columns to set. + * @return This builder for chaining. */ public Builder setColumns(int index, java.lang.String value) { if (value == null) { @@ -1259,6 +1336,9 @@ public Builder setColumns(int index, java.lang.String value) { * * * repeated string columns = 2; + * + * @param value The columns to add. + * @return This builder for chaining. */ public Builder addColumns(java.lang.String value) { if (value == null) { @@ -1280,6 +1360,9 @@ public Builder addColumns(java.lang.String value) { * * * repeated string columns = 2; + * + * @param values The columns to add. + * @return This builder for chaining. */ public Builder addAllColumns(java.lang.Iterable values) { ensureColumnsIsMutable(); @@ -1298,10 +1381,12 @@ public Builder addAllColumns(java.lang.Iterable values) { * * * repeated string columns = 2; + * + * @return This builder for chaining. */ public Builder clearColumns() { columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -1316,6 +1401,9 @@ public Builder clearColumns() { * * * repeated string columns = 2; + * + * @param value The bytes of the columns to add. + * @return This builder for chaining. */ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1332,9 +1420,9 @@ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { java.util.Collections.emptyList(); private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000004) != 0)) { + if (!((bitField0_ & 0x00000002) != 0)) { values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000004; + bitField0_ |= 0x00000002; } } @@ -1624,7 +1712,7 @@ public Builder addAllValues( public Builder clearValues() { if (valuesBuilder_ == null) { values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); } else { valuesBuilder_.clear(); @@ -1794,7 +1882,7 @@ public java.util.List getValuesBuilderLis com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder>( - values_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + values_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); values_ = null; } return valuesBuilder_; @@ -1865,6 +1953,8 @@ public interface DeleteOrBuilder * * * string table = 1; + * + * @return The table. */ java.lang.String getTable(); /** @@ -1875,6 +1965,8 @@ public interface DeleteOrBuilder * * * string table = 1; + * + * @return The bytes for table. */ com.google.protobuf.ByteString getTableBytes(); @@ -1888,6 +1980,8 @@ public interface DeleteOrBuilder * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return Whether the keySet field is set. */ boolean hasKeySet(); /** @@ -1900,6 +1994,8 @@ public interface DeleteOrBuilder * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return The keySet. */ com.google.spanner.v1.KeySet getKeySet(); /** @@ -1938,6 +2034,12 @@ private Delete() { table_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Delete(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -1951,7 +2053,6 @@ private Delete( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -2028,6 +2129,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string table = 1; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -2048,6 +2151,8 @@ public java.lang.String getTable() { * * * string table = 1; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -2073,6 +2178,8 @@ public com.google.protobuf.ByteString getTableBytes() { * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySet_ != null; @@ -2087,6 +2194,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { return keySet_ == null ? com.google.spanner.v1.KeySet.getDefaultInstance() : keySet_; @@ -2462,6 +2571,8 @@ public Builder mergeFrom( * * * string table = 1; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -2482,6 +2593,8 @@ public java.lang.String getTable() { * * * string table = 1; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -2502,6 +2615,9 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string table = 1; + * + * @param value The table to set. + * @return This builder for chaining. */ public Builder setTable(java.lang.String value) { if (value == null) { @@ -2520,6 +2636,8 @@ public Builder setTable(java.lang.String value) { * * * string table = 1; + * + * @return This builder for chaining. */ public Builder clearTable() { @@ -2535,6 +2653,9 @@ public Builder clearTable() { * * * string table = 1; + * + * @param value The bytes for table to set. + * @return This builder for chaining. */ public Builder setTableBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -2563,6 +2684,8 @@ public Builder setTableBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySetBuilder_ != null || keySet_ != null; @@ -2577,6 +2700,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 2; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { if (keySetBuilder_ == null) { @@ -2795,7 +2920,10 @@ public com.google.spanner.v1.Mutation.Delete getDefaultInstanceForType() { private int operationCase_ = 0; private java.lang.Object operation_; - public enum OperationCase implements com.google.protobuf.Internal.EnumLite { + public enum OperationCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { INSERT(1), UPDATE(2), INSERT_OR_UPDATE(3), @@ -2807,7 +2935,11 @@ public enum OperationCase implements com.google.protobuf.Internal.EnumLite { private OperationCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static OperationCase valueOf(int value) { return forNumber(value); @@ -2851,6 +2983,8 @@ public OperationCase getOperationCase() { * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return Whether the insert field is set. */ public boolean hasInsert() { return operationCase_ == 1; @@ -2864,6 +2998,8 @@ public boolean hasInsert() { * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return The insert. */ public com.google.spanner.v1.Mutation.Write getInsert() { if (operationCase_ == 1) { @@ -2898,6 +3034,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getInsertOrBuilder() { * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return Whether the update field is set. */ public boolean hasUpdate() { return operationCase_ == 2; @@ -2911,6 +3049,8 @@ public boolean hasUpdate() { * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return The update. */ public com.google.spanner.v1.Mutation.Write getUpdate() { if (operationCase_ == 2) { @@ -2946,6 +3086,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getUpdateOrBuilder() { * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return Whether the insertOrUpdate field is set. */ public boolean hasInsertOrUpdate() { return operationCase_ == 3; @@ -2960,6 +3102,8 @@ public boolean hasInsertOrUpdate() { * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return The insertOrUpdate. */ public com.google.spanner.v1.Mutation.Write getInsertOrUpdate() { if (operationCase_ == 3) { @@ -3001,6 +3145,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getInsertOrUpdateOrBuilder( * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return Whether the replace field is set. */ public boolean hasReplace() { return operationCase_ == 4; @@ -3020,6 +3166,8 @@ public boolean hasReplace() { * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return The replace. */ public com.google.spanner.v1.Mutation.Write getReplace() { if (operationCase_ == 4) { @@ -3060,6 +3208,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getReplaceOrBuilder() { * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return Whether the delete field is set. */ public boolean hasDelete() { return operationCase_ == 5; @@ -3073,6 +3223,8 @@ public boolean hasDelete() { * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return The delete. */ public com.google.spanner.v1.Mutation.Delete getDelete() { if (operationCase_ == 5) { @@ -3576,6 +3728,8 @@ public Builder clearOperation() { * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return Whether the insert field is set. */ public boolean hasInsert() { return operationCase_ == 1; @@ -3589,6 +3743,8 @@ public boolean hasInsert() { * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return The insert. */ public com.google.spanner.v1.Mutation.Write getInsert() { if (insertBuilder_ == null) { @@ -3786,6 +3942,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getInsertOrBuilder() { * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return Whether the update field is set. */ public boolean hasUpdate() { return operationCase_ == 2; @@ -3799,6 +3957,8 @@ public boolean hasUpdate() { * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return The update. */ public com.google.spanner.v1.Mutation.Write getUpdate() { if (updateBuilder_ == null) { @@ -3997,6 +4157,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getUpdateOrBuilder() { * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return Whether the insertOrUpdate field is set. */ public boolean hasInsertOrUpdate() { return operationCase_ == 3; @@ -4011,6 +4173,8 @@ public boolean hasInsertOrUpdate() { * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return The insertOrUpdate. */ public com.google.spanner.v1.Mutation.Write getInsertOrUpdate() { if (insertOrUpdateBuilder_ == null) { @@ -4221,6 +4385,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getInsertOrUpdateOrBuilder( * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return Whether the replace field is set. */ public boolean hasReplace() { return operationCase_ == 4; @@ -4240,6 +4406,8 @@ public boolean hasReplace() { * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return The replace. */ public com.google.spanner.v1.Mutation.Write getReplace() { if (replaceBuilder_ == null) { @@ -4479,6 +4647,8 @@ public com.google.spanner.v1.Mutation.WriteOrBuilder getReplaceOrBuilder() { * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return Whether the delete field is set. */ public boolean hasDelete() { return operationCase_ == 5; @@ -4492,6 +4662,8 @@ public boolean hasDelete() { * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return The delete. */ public com.google.spanner.v1.Mutation.Delete getDelete() { if (deleteBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationOrBuilder.java index 0076dfc3d49..80374ce9e52 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/mutation.proto @@ -17,6 +32,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return Whether the insert field is set. */ boolean hasInsert(); /** @@ -28,6 +45,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write insert = 1; + * + * @return The insert. */ com.google.spanner.v1.Mutation.Write getInsert(); /** @@ -51,6 +70,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return Whether the update field is set. */ boolean hasUpdate(); /** @@ -62,6 +83,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write update = 2; + * + * @return The update. */ com.google.spanner.v1.Mutation.Write getUpdate(); /** @@ -86,6 +109,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return Whether the insertOrUpdate field is set. */ boolean hasInsertOrUpdate(); /** @@ -98,6 +123,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write insert_or_update = 3; + * + * @return The insertOrUpdate. */ com.google.spanner.v1.Mutation.Write getInsertOrUpdate(); /** @@ -128,6 +155,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return Whether the replace field is set. */ boolean hasReplace(); /** @@ -145,6 +174,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Write replace = 4; + * + * @return The replace. */ com.google.spanner.v1.Mutation.Write getReplace(); /** @@ -174,6 +205,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return Whether the delete field is set. */ boolean hasDelete(); /** @@ -185,6 +218,8 @@ public interface MutationOrBuilder * * * .google.spanner.v1.Mutation.Delete delete = 5; + * + * @return The delete. */ com.google.spanner.v1.Mutation.Delete getDelete(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java index ce654badd92..de56b1b412d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/mutation.proto @@ -54,22 +69,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "nner.V1\312\002\027Google\\Cloud\\Spanner\\V1b\006proto" + "3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.StructProto.getDescriptor(), - com.google.spanner.v1.KeysProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.StructProto.getDescriptor(), + com.google.spanner.v1.KeysProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_Mutation_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_Mutation_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSet.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSet.java index b04b9b568e0..c41431b66ae 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSet.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSet.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -29,6 +44,12 @@ private PartialResultSet() { resumeToken_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartialResultSet(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -71,9 +92,9 @@ private PartialResultSet( } case 18: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { values_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } values_.add(input.readMessage(com.google.protobuf.Value.parser(), extensionRegistry)); break; @@ -118,7 +139,7 @@ private PartialResultSet( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { values_ = java.util.Collections.unmodifiableList(values_); } this.unknownFields = unknownFields.build(); @@ -141,7 +162,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.PartialResultSet.Builder.class); } - private int bitField0_; public static final int METADATA_FIELD_NUMBER = 1; private com.google.spanner.v1.ResultSetMetadata metadata_; /** @@ -153,6 +173,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadata_ != null; @@ -166,6 +188,8 @@ public boolean hasMetadata() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ public com.google.spanner.v1.ResultSetMetadata getMetadata() { return metadata_ == null @@ -551,6 +575,8 @@ public com.google.protobuf.ValueOrBuilder getValuesOrBuilder(int index) { * * * bool chunked_value = 3; + * + * @return The chunkedValue. */ public boolean getChunkedValue() { return chunkedValue_; @@ -570,6 +596,8 @@ public boolean getChunkedValue() { * * * bytes resume_token = 4; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -590,6 +618,8 @@ public com.google.protobuf.ByteString getResumeToken() { * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return Whether the stats field is set. */ public boolean hasStats() { return stats_ != null; @@ -607,6 +637,8 @@ public boolean hasStats() { * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return The stats. */ public com.google.spanner.v1.ResultSetStats getStats() { return stats_ == null ? com.google.spanner.v1.ResultSetStats.getDefaultInstance() : stats_; @@ -892,7 +924,7 @@ public Builder clear() { } if (valuesBuilder_ == null) { values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { valuesBuilder_.clear(); } @@ -934,16 +966,15 @@ public com.google.spanner.v1.PartialResultSet buildPartial() { com.google.spanner.v1.PartialResultSet result = new com.google.spanner.v1.PartialResultSet(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (metadataBuilder_ == null) { result.metadata_ = metadata_; } else { result.metadata_ = metadataBuilder_.build(); } if (valuesBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.values_ = values_; } else { @@ -956,7 +987,6 @@ public com.google.spanner.v1.PartialResultSet buildPartial() { } else { result.stats_ = statsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1013,7 +1043,7 @@ public Builder mergeFrom(com.google.spanner.v1.PartialResultSet other) { if (!other.values_.isEmpty()) { if (values_.isEmpty()) { values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureValuesIsMutable(); values_.addAll(other.values_); @@ -1026,7 +1056,7 @@ public Builder mergeFrom(com.google.spanner.v1.PartialResultSet other) { valuesBuilder_.dispose(); valuesBuilder_ = null; values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); valuesBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getValuesFieldBuilder() @@ -1091,6 +1121,8 @@ public Builder mergeFrom( * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadataBuilder_ != null || metadata_ != null; @@ -1104,6 +1136,8 @@ public boolean hasMetadata() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ public com.google.spanner.v1.ResultSetMetadata getMetadata() { if (metadataBuilder_ == null) { @@ -1269,9 +1303,9 @@ public com.google.spanner.v1.ResultSetMetadataOrBuilder getMetadataOrBuilder() { private java.util.List values_ = java.util.Collections.emptyList(); private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } @@ -2121,7 +2155,7 @@ public Builder addAllValues(java.lang.Iterable getValuesBuilderList() com.google.protobuf.Value, com.google.protobuf.Value.Builder, com.google.protobuf.ValueOrBuilder>( - values_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + values_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); values_ = null; } return valuesBuilder_; @@ -2663,6 +2697,8 @@ public java.util.List getValuesBuilderList() * * * bool chunked_value = 3; + * + * @return The chunkedValue. */ public boolean getChunkedValue() { return chunkedValue_; @@ -2677,6 +2713,9 @@ public boolean getChunkedValue() { * * * bool chunked_value = 3; + * + * @param value The chunkedValue to set. + * @return This builder for chaining. */ public Builder setChunkedValue(boolean value) { @@ -2694,6 +2733,8 @@ public Builder setChunkedValue(boolean value) { * * * bool chunked_value = 3; + * + * @return This builder for chaining. */ public Builder clearChunkedValue() { @@ -2715,6 +2756,8 @@ public Builder clearChunkedValue() { * * * bytes resume_token = 4; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -2731,6 +2774,9 @@ public com.google.protobuf.ByteString getResumeToken() { * * * bytes resume_token = 4; + * + * @param value The resumeToken to set. + * @return This builder for chaining. */ public Builder setResumeToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -2753,6 +2799,8 @@ public Builder setResumeToken(com.google.protobuf.ByteString value) { * * * bytes resume_token = 4; + * + * @return This builder for chaining. */ public Builder clearResumeToken() { @@ -2780,6 +2828,8 @@ public Builder clearResumeToken() { * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return Whether the stats field is set. */ public boolean hasStats() { return statsBuilder_ != null || stats_ != null; @@ -2797,6 +2847,8 @@ public boolean hasStats() { * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return The stats. */ public com.google.spanner.v1.ResultSetStats getStats() { if (statsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSetOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSetOrBuilder.java index bfd2a8136dd..74c9adea4b8 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSetOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSetOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -17,6 +32,8 @@ public interface PartialResultSetOrBuilder * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ boolean hasMetadata(); /** @@ -28,6 +45,8 @@ public interface PartialResultSetOrBuilder * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ com.google.spanner.v1.ResultSetMetadata getMetadata(); /** @@ -393,6 +412,8 @@ public interface PartialResultSetOrBuilder * * * bool chunked_value = 3; + * + * @return The chunkedValue. */ boolean getChunkedValue(); @@ -408,6 +429,8 @@ public interface PartialResultSetOrBuilder * * * bytes resume_token = 4; + * + * @return The resumeToken. */ com.google.protobuf.ByteString getResumeToken(); @@ -424,6 +447,8 @@ public interface PartialResultSetOrBuilder * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return Whether the stats field is set. */ boolean hasStats(); /** @@ -439,6 +464,8 @@ public interface PartialResultSetOrBuilder * * * .google.spanner.v1.ResultSetStats stats = 5; + * + * @return The stats. */ com.google.spanner.v1.ResultSetStats getStats(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Partition.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Partition.java index bceca12a2da..175b7d5da6c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Partition.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Partition.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private Partition() { partitionToken_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Partition(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private Partition( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -101,6 +121,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * bytes partition_token = 1; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -429,6 +451,8 @@ public Builder mergeFrom( * * * bytes partition_token = 1; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -443,6 +467,9 @@ public com.google.protobuf.ByteString getPartitionToken() { * * * bytes partition_token = 1; + * + * @param value The partitionToken to set. + * @return This builder for chaining. */ public Builder setPartitionToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -463,6 +490,8 @@ public Builder setPartitionToken(com.google.protobuf.ByteString value) { * * * bytes partition_token = 1; + * + * @return This builder for chaining. */ public Builder clearPartitionToken() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptions.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptions.java index 01ed1f8a2c3..bf0288ca558 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptions.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptions.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -25,6 +40,12 @@ private PartitionOptions(com.google.protobuf.GeneratedMessageV3.Builder build private PartitionOptions() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionOptions(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -38,7 +59,6 @@ private PartitionOptions( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -107,6 +127,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * int64 partition_size_bytes = 1; + * + * @return The partitionSizeBytes. */ public long getPartitionSizeBytes() { return partitionSizeBytes_; @@ -128,6 +150,8 @@ public long getPartitionSizeBytes() { * * * int64 max_partitions = 2; + * + * @return The maxPartitions. */ public long getMaxPartitions() { return maxPartitions_; @@ -476,6 +500,8 @@ public Builder mergeFrom( * * * int64 partition_size_bytes = 1; + * + * @return The partitionSizeBytes. */ public long getPartitionSizeBytes() { return partitionSizeBytes_; @@ -492,6 +518,9 @@ public long getPartitionSizeBytes() { * * * int64 partition_size_bytes = 1; + * + * @param value The partitionSizeBytes to set. + * @return This builder for chaining. */ public Builder setPartitionSizeBytes(long value) { @@ -511,6 +540,8 @@ public Builder setPartitionSizeBytes(long value) { * * * int64 partition_size_bytes = 1; + * + * @return This builder for chaining. */ public Builder clearPartitionSizeBytes() { @@ -534,6 +565,8 @@ public Builder clearPartitionSizeBytes() { * * * int64 max_partitions = 2; + * + * @return The maxPartitions. */ public long getMaxPartitions() { return maxPartitions_; @@ -552,6 +585,9 @@ public long getMaxPartitions() { * * * int64 max_partitions = 2; + * + * @param value The maxPartitions to set. + * @return This builder for chaining. */ public Builder setMaxPartitions(long value) { @@ -573,6 +609,8 @@ public Builder setMaxPartitions(long value) { * * * int64 max_partitions = 2; + * + * @return This builder for chaining. */ public Builder clearMaxPartitions() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptionsOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptionsOrBuilder.java index bc4cd079f68..39a96d6b7f9 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptionsOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptionsOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -20,6 +35,8 @@ public interface PartitionOptionsOrBuilder * * * int64 partition_size_bytes = 1; + * + * @return The partitionSizeBytes. */ long getPartitionSizeBytes(); @@ -37,6 +54,8 @@ public interface PartitionOptionsOrBuilder * * * int64 max_partitions = 2; + * + * @return The maxPartitions. */ long getMaxPartitions(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOrBuilder.java index 07547b61a5e..bcdbf023214 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface PartitionOrBuilder * * * bytes partition_token = 1; + * + * @return The partitionToken. */ com.google.protobuf.ByteString getPartitionToken(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequest.java index bea643f7c38..0ae6e8dfbe5 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private PartitionQueryRequest() { sql_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionQueryRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -97,11 +118,11 @@ private PartitionQueryRequest( } case 42: { - if (!((mutable_bitField0_ & 0x00000010) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { paramTypes_ = com.google.protobuf.MapField.newMapField( ParamTypesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000010; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry paramTypes__ = @@ -172,7 +193,6 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { com.google.spanner.v1.PartitionQueryRequest.Builder.class); } - private int bitField0_; public static final int SESSION_FIELD_NUMBER = 1; private volatile java.lang.Object session_; /** @@ -185,6 +205,8 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -207,6 +229,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -231,6 +255,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -244,6 +270,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { return transaction_ == null @@ -283,6 +311,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -312,6 +342,8 @@ public java.lang.String getSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -342,6 +374,8 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ public boolean hasParams() { return params_ != null; @@ -361,6 +395,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { return params_ == null ? com.google.protobuf.Struct.getDefaultInstance() : params_; @@ -522,6 +558,8 @@ public com.google.spanner.v1.Type getParamTypesOrThrow(java.lang.String key) { * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return Whether the partitionOptions field is set. */ public boolean hasPartitionOptions() { return partitionOptions_ != null; @@ -534,6 +572,8 @@ public boolean hasPartitionOptions() { * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return The partitionOptions. */ public com.google.spanner.v1.PartitionOptions getPartitionOptions() { return partitionOptions_ == null @@ -896,7 +936,6 @@ public com.google.spanner.v1.PartitionQueryRequest buildPartial() { com.google.spanner.v1.PartitionQueryRequest result = new com.google.spanner.v1.PartitionQueryRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionBuilder_ == null) { result.transaction_ = transaction_; @@ -916,7 +955,6 @@ public com.google.spanner.v1.PartitionQueryRequest buildPartial() { } else { result.partitionOptions_ = partitionOptionsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -1026,6 +1064,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -1048,6 +1088,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -1070,6 +1112,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -1090,6 +1135,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -1107,6 +1154,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1134,6 +1184,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -1147,6 +1199,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { if (transactionBuilder_ == null) { @@ -1328,6 +1382,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ public java.lang.String getSql() { java.lang.Object ref = sql_; @@ -1357,6 +1413,8 @@ public java.lang.String getSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ public com.google.protobuf.ByteString getSqlBytes() { java.lang.Object ref = sql_; @@ -1386,6 +1444,9 @@ public com.google.protobuf.ByteString getSqlBytes() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The sql to set. + * @return This builder for chaining. */ public Builder setSql(java.lang.String value) { if (value == null) { @@ -1413,6 +1474,8 @@ public Builder setSql(java.lang.String value) { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearSql() { @@ -1437,6 +1500,9 @@ public Builder clearSql() { * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for sql to set. + * @return This builder for chaining. */ public Builder setSqlBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1470,6 +1536,8 @@ public Builder setSqlBytes(com.google.protobuf.ByteString value) { * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ public boolean hasParams() { return paramsBuilder_ != null || params_ != null; @@ -1489,6 +1557,8 @@ public boolean hasParams() { * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ public com.google.protobuf.Struct getParams() { if (paramsBuilder_ == null) { @@ -1907,6 +1977,8 @@ public Builder putAllParamTypes( * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return Whether the partitionOptions field is set. */ public boolean hasPartitionOptions() { return partitionOptionsBuilder_ != null || partitionOptions_ != null; @@ -1919,6 +1991,8 @@ public boolean hasPartitionOptions() { * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return The partitionOptions. */ public com.google.spanner.v1.PartitionOptions getPartitionOptions() { if (partitionOptionsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequestOrBuilder.java index 2f8acbdb225..47fe789bea7 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface PartitionQueryRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface PartitionQueryRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -42,6 +61,8 @@ public interface PartitionQueryRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -53,6 +74,8 @@ public interface PartitionQueryRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.TransactionSelector getTransaction(); /** @@ -84,6 +107,8 @@ public interface PartitionQueryRequestOrBuilder * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The sql. */ java.lang.String getSql(); /** @@ -103,6 +128,8 @@ public interface PartitionQueryRequestOrBuilder * * * string sql = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for sql. */ com.google.protobuf.ByteString getSqlBytes(); @@ -121,6 +148,8 @@ public interface PartitionQueryRequestOrBuilder * * * .google.protobuf.Struct params = 4; + * + * @return Whether the params field is set. */ boolean hasParams(); /** @@ -138,6 +167,8 @@ public interface PartitionQueryRequestOrBuilder * * * .google.protobuf.Struct params = 4; + * + * @return The params. */ com.google.protobuf.Struct getParams(); /** @@ -256,6 +287,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return Whether the partitionOptions field is set. */ boolean hasPartitionOptions(); /** @@ -266,6 +299,8 @@ com.google.spanner.v1.Type getParamTypesOrDefault( * * * .google.spanner.v1.PartitionOptions partition_options = 6; + * + * @return The partitionOptions. */ com.google.spanner.v1.PartitionOptions getPartitionOptions(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequest.java index 66a5a43da3e..6396851ed5b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -29,6 +44,12 @@ private PartitionReadRequest() { columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionReadRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -93,9 +114,9 @@ private PartitionReadRequest( case 42: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000010) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000010; + mutable_bitField0_ |= 0x00000001; } columns_.add(s); break; @@ -144,7 +165,7 @@ private PartitionReadRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000010) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); @@ -167,7 +188,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.PartitionReadRequest.Builder.class); } - private int bitField0_; public static final int SESSION_FIELD_NUMBER = 1; private volatile java.lang.Object session_; /** @@ -180,6 +200,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -202,6 +224,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -226,6 +250,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -239,6 +265,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { return transaction_ == null @@ -269,6 +297,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -289,6 +319,8 @@ public java.lang.String getTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -317,6 +349,8 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string index = 4; + * + * @return The index. */ public java.lang.String getIndex() { java.lang.Object ref = index_; @@ -342,6 +376,8 @@ public java.lang.String getIndex() { * * * string index = 4; + * + * @return The bytes for index. */ public com.google.protobuf.ByteString getIndexBytes() { java.lang.Object ref = index_; @@ -366,6 +402,8 @@ public com.google.protobuf.ByteString getIndexBytes() { * * * repeated string columns = 5; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_; @@ -379,6 +417,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 5; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -392,6 +432,9 @@ public int getColumnsCount() { * * * repeated string columns = 5; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -405,6 +448,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 5; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -428,6 +474,8 @@ public com.google.protobuf.ByteString getColumnsBytes(int index) { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySet_ != null; @@ -448,6 +496,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { return keySet_ == null ? com.google.spanner.v1.KeySet.getDefaultInstance() : keySet_; @@ -483,6 +533,8 @@ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return Whether the partitionOptions field is set. */ public boolean hasPartitionOptions() { return partitionOptions_ != null; @@ -495,6 +547,8 @@ public boolean hasPartitionOptions() { * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return The partitionOptions. */ public com.google.spanner.v1.PartitionOptions getPartitionOptions() { return partitionOptions_ == null @@ -807,7 +861,7 @@ public Builder clear() { index_ = ""; columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); if (keySetBuilder_ == null) { keySet_ = null; } else { @@ -848,7 +902,6 @@ public com.google.spanner.v1.PartitionReadRequest buildPartial() { com.google.spanner.v1.PartitionReadRequest result = new com.google.spanner.v1.PartitionReadRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionBuilder_ == null) { result.transaction_ = transaction_; @@ -857,9 +910,9 @@ public com.google.spanner.v1.PartitionReadRequest buildPartial() { } result.table_ = table_; result.index_ = index_; - if (((bitField0_ & 0x00000010) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); } result.columns_ = columns_; if (keySetBuilder_ == null) { @@ -872,7 +925,6 @@ public com.google.spanner.v1.PartitionReadRequest buildPartial() { } else { result.partitionOptions_ = partitionOptionsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -940,7 +992,7 @@ public Builder mergeFrom(com.google.spanner.v1.PartitionReadRequest other) { if (!other.columns_.isEmpty()) { if (columns_.isEmpty()) { columns_ = other.columns_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureColumnsIsMutable(); columns_.addAll(other.columns_); @@ -995,6 +1047,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -1017,6 +1071,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -1039,6 +1095,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -1059,6 +1118,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -1076,6 +1137,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1103,6 +1167,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -1116,6 +1182,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { if (transactionBuilder_ == null) { @@ -1288,6 +1356,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -1308,6 +1378,8 @@ public java.lang.String getTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -1328,6 +1400,9 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The table to set. + * @return This builder for chaining. */ public Builder setTable(java.lang.String value) { if (value == null) { @@ -1346,6 +1421,8 @@ public Builder setTable(java.lang.String value) { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearTable() { @@ -1361,6 +1438,9 @@ public Builder clearTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for table to set. + * @return This builder for chaining. */ public Builder setTableBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1387,6 +1467,8 @@ public Builder setTableBytes(com.google.protobuf.ByteString value) { * * * string index = 4; + * + * @return The index. */ public java.lang.String getIndex() { java.lang.Object ref = index_; @@ -1412,6 +1494,8 @@ public java.lang.String getIndex() { * * * string index = 4; + * + * @return The bytes for index. */ public com.google.protobuf.ByteString getIndexBytes() { java.lang.Object ref = index_; @@ -1437,6 +1521,9 @@ public com.google.protobuf.ByteString getIndexBytes() { * * * string index = 4; + * + * @param value The index to set. + * @return This builder for chaining. */ public Builder setIndex(java.lang.String value) { if (value == null) { @@ -1460,6 +1547,8 @@ public Builder setIndex(java.lang.String value) { * * * string index = 4; + * + * @return This builder for chaining. */ public Builder clearIndex() { @@ -1480,6 +1569,9 @@ public Builder clearIndex() { * * * string index = 4; + * + * @param value The bytes for index to set. + * @return This builder for chaining. */ public Builder setIndexBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1496,9 +1588,9 @@ public Builder setIndexBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureColumnsIsMutable() { - if (!((bitField0_ & 0x00000010) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(columns_); - bitField0_ |= 0x00000010; + bitField0_ |= 0x00000001; } } /** @@ -1510,6 +1602,8 @@ private void ensureColumnsIsMutable() { * * * repeated string columns = 5; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_.getUnmodifiableView(); @@ -1523,6 +1617,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 5; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -1536,6 +1632,9 @@ public int getColumnsCount() { * * * repeated string columns = 5; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -1549,6 +1648,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 5; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -1562,6 +1664,10 @@ public com.google.protobuf.ByteString getColumnsBytes(int index) { * * * repeated string columns = 5; + * + * @param index The index to set the value at. + * @param value The columns to set. + * @return This builder for chaining. */ public Builder setColumns(int index, java.lang.String value) { if (value == null) { @@ -1581,6 +1687,9 @@ public Builder setColumns(int index, java.lang.String value) { * * * repeated string columns = 5; + * + * @param value The columns to add. + * @return This builder for chaining. */ public Builder addColumns(java.lang.String value) { if (value == null) { @@ -1600,6 +1709,9 @@ public Builder addColumns(java.lang.String value) { * * * repeated string columns = 5; + * + * @param values The columns to add. + * @return This builder for chaining. */ public Builder addAllColumns(java.lang.Iterable values) { ensureColumnsIsMutable(); @@ -1616,10 +1728,12 @@ public Builder addAllColumns(java.lang.Iterable values) { * * * repeated string columns = 5; + * + * @return This builder for chaining. */ public Builder clearColumns() { columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -1632,6 +1746,9 @@ public Builder clearColumns() { * * * repeated string columns = 5; + * + * @param value The bytes of the columns to add. + * @return This builder for chaining. */ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1666,6 +1783,8 @@ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySetBuilder_ != null || keySet_ != null; @@ -1686,6 +1805,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { if (keySetBuilder_ == null) { @@ -1905,6 +2026,8 @@ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return Whether the partitionOptions field is set. */ public boolean hasPartitionOptions() { return partitionOptionsBuilder_ != null || partitionOptions_ != null; @@ -1917,6 +2040,8 @@ public boolean hasPartitionOptions() { * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return The partitionOptions. */ public com.google.spanner.v1.PartitionOptions getPartitionOptions() { if (partitionOptionsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequestOrBuilder.java index 1de002f85bd..c9a45175367 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface PartitionReadRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface PartitionReadRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -42,6 +61,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -53,6 +74,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.TransactionSelector getTransaction(); /** @@ -75,6 +98,8 @@ public interface PartitionReadRequestOrBuilder * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ java.lang.String getTable(); /** @@ -85,6 +110,8 @@ public interface PartitionReadRequestOrBuilder * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ com.google.protobuf.ByteString getTableBytes(); @@ -101,6 +128,8 @@ public interface PartitionReadRequestOrBuilder * * * string index = 4; + * + * @return The index. */ java.lang.String getIndex(); /** @@ -116,6 +145,8 @@ public interface PartitionReadRequestOrBuilder * * * string index = 4; + * + * @return The bytes for index. */ com.google.protobuf.ByteString getIndexBytes(); @@ -128,6 +159,8 @@ public interface PartitionReadRequestOrBuilder * * * repeated string columns = 5; + * + * @return A list containing the columns. */ java.util.List getColumnsList(); /** @@ -139,6 +172,8 @@ public interface PartitionReadRequestOrBuilder * * * repeated string columns = 5; + * + * @return The count of columns. */ int getColumnsCount(); /** @@ -150,6 +185,9 @@ public interface PartitionReadRequestOrBuilder * * * repeated string columns = 5; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ java.lang.String getColumns(int index); /** @@ -161,6 +199,9 @@ public interface PartitionReadRequestOrBuilder * * * repeated string columns = 5; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ com.google.protobuf.ByteString getColumnsBytes(int index); @@ -180,6 +221,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ boolean hasKeySet(); /** @@ -198,6 +241,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ com.google.spanner.v1.KeySet getKeySet(); /** @@ -227,6 +272,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return Whether the partitionOptions field is set. */ boolean hasPartitionOptions(); /** @@ -237,6 +284,8 @@ public interface PartitionReadRequestOrBuilder * * * .google.spanner.v1.PartitionOptions partition_options = 9; + * + * @return The partitionOptions. */ com.google.spanner.v1.PartitionOptions getPartitionOptions(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponse.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponse.java index fdea4ca390b..62f0c19122e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponse.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponse.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private PartitionResponse() { partitions_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionResponse(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -113,7 +134,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.PartitionResponse.Builder.class); } - private int bitField0_; public static final int PARTITIONS_FIELD_NUMBER = 1; private java.util.List partitions_; /** @@ -188,6 +208,8 @@ public com.google.spanner.v1.PartitionOrBuilder getPartitionsOrBuilder(int index * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -200,6 +222,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.Transaction getTransaction() { return transaction_ == null @@ -481,7 +505,6 @@ public com.google.spanner.v1.PartitionResponse buildPartial() { com.google.spanner.v1.PartitionResponse result = new com.google.spanner.v1.PartitionResponse(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (partitionsBuilder_ == null) { if (((bitField0_ & 0x00000001) != 0)) { partitions_ = java.util.Collections.unmodifiableList(partitions_); @@ -496,7 +519,6 @@ public com.google.spanner.v1.PartitionResponse buildPartial() { } else { result.transaction_ = transactionBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -969,6 +991,8 @@ public java.util.List getPartitionsBuil * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -981,6 +1005,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.Transaction getTransaction() { if (transactionBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponseOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponseOrBuilder.java index c307d4ec630..a895defa441 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponseOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponseOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -67,6 +82,8 @@ public interface PartitionResponseOrBuilder * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -77,6 +94,8 @@ public interface PartitionResponseOrBuilder * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.Transaction getTransaction(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNode.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNode.java index d5af9d075ce..4d44d62159f 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNode.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNode.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/query_plan.proto @@ -28,6 +43,12 @@ private PlanNode() { childLinks_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PlanNode(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -73,9 +94,9 @@ private PlanNode( } case 34: { - if (!((mutable_bitField0_ & 0x00000008) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { childLinks_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; + mutable_bitField0_ |= 0x00000001; } childLinks_.add( input.readMessage( @@ -142,7 +163,7 @@ private PlanNode( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000008) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { childLinks_ = java.util.Collections.unmodifiableList(childLinks_); } this.unknownFields = unknownFields.build(); @@ -257,12 +278,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static Kind valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static Kind forNumber(int value) { switch (value) { case 0: @@ -333,6 +362,8 @@ public interface ChildLinkOrBuilder * * * int32 child_index = 1; + * + * @return The childIndex. */ int getChildIndex(); @@ -347,6 +378,8 @@ public interface ChildLinkOrBuilder * * * string type = 2; + * + * @return The type. */ java.lang.String getType(); /** @@ -360,6 +393,8 @@ public interface ChildLinkOrBuilder * * * string type = 2; + * + * @return The bytes for type. */ com.google.protobuf.ByteString getTypeBytes(); @@ -378,6 +413,8 @@ public interface ChildLinkOrBuilder * * * string variable = 3; + * + * @return The variable. */ java.lang.String getVariable(); /** @@ -395,6 +432,8 @@ public interface ChildLinkOrBuilder * * * string variable = 3; + * + * @return The bytes for variable. */ com.google.protobuf.ByteString getVariableBytes(); } @@ -423,6 +462,12 @@ private ChildLink() { variable_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ChildLink(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -436,7 +481,6 @@ private ChildLink( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -510,6 +554,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * int32 child_index = 1; + * + * @return The childIndex. */ public int getChildIndex() { return childIndex_; @@ -528,6 +574,8 @@ public int getChildIndex() { * * * string type = 2; + * + * @return The type. */ public java.lang.String getType() { java.lang.Object ref = type_; @@ -551,6 +599,8 @@ public java.lang.String getType() { * * * string type = 2; + * + * @return The bytes for type. */ public com.google.protobuf.ByteString getTypeBytes() { java.lang.Object ref = type_; @@ -581,6 +631,8 @@ public com.google.protobuf.ByteString getTypeBytes() { * * * string variable = 3; + * + * @return The variable. */ public java.lang.String getVariable() { java.lang.Object ref = variable_; @@ -608,6 +660,8 @@ public java.lang.String getVariable() { * * * string variable = 3; + * + * @return The bytes for variable. */ public com.google.protobuf.ByteString getVariableBytes() { java.lang.Object ref = variable_; @@ -982,6 +1036,8 @@ public Builder mergeFrom( * * * int32 child_index = 1; + * + * @return The childIndex. */ public int getChildIndex() { return childIndex_; @@ -994,6 +1050,9 @@ public int getChildIndex() { * * * int32 child_index = 1; + * + * @param value The childIndex to set. + * @return This builder for chaining. */ public Builder setChildIndex(int value) { @@ -1009,6 +1068,8 @@ public Builder setChildIndex(int value) { * * * int32 child_index = 1; + * + * @return This builder for chaining. */ public Builder clearChildIndex() { @@ -1029,6 +1090,8 @@ public Builder clearChildIndex() { * * * string type = 2; + * + * @return The type. */ public java.lang.String getType() { java.lang.Object ref = type_; @@ -1052,6 +1115,8 @@ public java.lang.String getType() { * * * string type = 2; + * + * @return The bytes for type. */ public com.google.protobuf.ByteString getTypeBytes() { java.lang.Object ref = type_; @@ -1075,6 +1140,9 @@ public com.google.protobuf.ByteString getTypeBytes() { * * * string type = 2; + * + * @param value The type to set. + * @return This builder for chaining. */ public Builder setType(java.lang.String value) { if (value == null) { @@ -1096,6 +1164,8 @@ public Builder setType(java.lang.String value) { * * * string type = 2; + * + * @return This builder for chaining. */ public Builder clearType() { @@ -1114,6 +1184,9 @@ public Builder clearType() { * * * string type = 2; + * + * @param value The bytes for type to set. + * @return This builder for chaining. */ public Builder setTypeBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1142,6 +1215,8 @@ public Builder setTypeBytes(com.google.protobuf.ByteString value) { * * * string variable = 3; + * + * @return The variable. */ public java.lang.String getVariable() { java.lang.Object ref = variable_; @@ -1169,6 +1244,8 @@ public java.lang.String getVariable() { * * * string variable = 3; + * + * @return The bytes for variable. */ public com.google.protobuf.ByteString getVariableBytes() { java.lang.Object ref = variable_; @@ -1196,6 +1273,9 @@ public com.google.protobuf.ByteString getVariableBytes() { * * * string variable = 3; + * + * @param value The variable to set. + * @return This builder for chaining. */ public Builder setVariable(java.lang.String value) { if (value == null) { @@ -1221,6 +1301,8 @@ public Builder setVariable(java.lang.String value) { * * * string variable = 3; + * + * @return This builder for chaining. */ public Builder clearVariable() { @@ -1243,6 +1325,9 @@ public Builder clearVariable() { * * * string variable = 3; + * + * @param value The bytes for variable to set. + * @return This builder for chaining. */ public Builder setVariableBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1320,6 +1405,8 @@ public interface ShortRepresentationOrBuilder * * * string description = 1; + * + * @return The description. */ java.lang.String getDescription(); /** @@ -1330,6 +1417,8 @@ public interface ShortRepresentationOrBuilder * * * string description = 1; + * + * @return The bytes for description. */ com.google.protobuf.ByteString getDescriptionBytes(); @@ -1431,6 +1520,12 @@ private ShortRepresentation() { description_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ShortRepresentation(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -1464,11 +1559,11 @@ private ShortRepresentation( } case 18: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { subqueries_ = com.google.protobuf.MapField.newMapField( SubqueriesDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry subqueries__ = input.readMessage( @@ -1522,7 +1617,6 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { com.google.spanner.v1.PlanNode.ShortRepresentation.Builder.class); } - private int bitField0_; public static final int DESCRIPTION_FIELD_NUMBER = 1; private volatile java.lang.Object description_; /** @@ -1533,6 +1627,8 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { * * * string description = 1; + * + * @return The description. */ public java.lang.String getDescription() { java.lang.Object ref = description_; @@ -1553,6 +1649,8 @@ public java.lang.String getDescription() { * * * string description = 1; + * + * @return The bytes for description. */ public com.google.protobuf.ByteString getDescriptionBytes() { java.lang.Object ref = description_; @@ -1952,11 +2050,9 @@ public com.google.spanner.v1.PlanNode.ShortRepresentation buildPartial() { com.google.spanner.v1.PlanNode.ShortRepresentation result = new com.google.spanner.v1.PlanNode.ShortRepresentation(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.description_ = description_; result.subqueries_ = internalGetSubqueries(); result.subqueries_.makeImmutable(); - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -2055,6 +2151,8 @@ public Builder mergeFrom( * * * string description = 1; + * + * @return The description. */ public java.lang.String getDescription() { java.lang.Object ref = description_; @@ -2075,6 +2173,8 @@ public java.lang.String getDescription() { * * * string description = 1; + * + * @return The bytes for description. */ public com.google.protobuf.ByteString getDescriptionBytes() { java.lang.Object ref = description_; @@ -2095,6 +2195,9 @@ public com.google.protobuf.ByteString getDescriptionBytes() { * * * string description = 1; + * + * @param value The description to set. + * @return This builder for chaining. */ public Builder setDescription(java.lang.String value) { if (value == null) { @@ -2113,6 +2216,8 @@ public Builder setDescription(java.lang.String value) { * * * string description = 1; + * + * @return This builder for chaining. */ public Builder clearDescription() { @@ -2128,6 +2233,9 @@ public Builder clearDescription() { * * * string description = 1; + * + * @param value The bytes for description to set. + * @return This builder for chaining. */ public Builder setDescriptionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -2372,7 +2480,6 @@ public com.google.spanner.v1.PlanNode.ShortRepresentation getDefaultInstanceForT } } - private int bitField0_; public static final int INDEX_FIELD_NUMBER = 1; private int index_; /** @@ -2383,6 +2490,8 @@ public com.google.spanner.v1.PlanNode.ShortRepresentation getDefaultInstanceForT * * * int32 index = 1; + * + * @return The index. */ public int getIndex() { return index_; @@ -2402,6 +2511,8 @@ public int getIndex() { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The enum numeric value on the wire for kind. */ public int getKindValue() { return kind_; @@ -2418,6 +2529,8 @@ public int getKindValue() { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The kind. */ public com.google.spanner.v1.PlanNode.Kind getKind() { @SuppressWarnings("deprecation") @@ -2435,6 +2548,8 @@ public com.google.spanner.v1.PlanNode.Kind getKind() { * * * string display_name = 3; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -2455,6 +2570,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 3; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -2542,6 +2659,8 @@ public com.google.spanner.v1.PlanNode.ChildLinkOrBuilder getChildLinksOrBuilder( * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return Whether the shortRepresentation field is set. */ public boolean hasShortRepresentation() { return shortRepresentation_ != null; @@ -2554,6 +2673,8 @@ public boolean hasShortRepresentation() { * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return The shortRepresentation. */ public com.google.spanner.v1.PlanNode.ShortRepresentation getShortRepresentation() { return shortRepresentation_ == null @@ -2590,6 +2711,8 @@ public com.google.spanner.v1.PlanNode.ShortRepresentation getShortRepresentation * * * .google.protobuf.Struct metadata = 6; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadata_ != null; @@ -2608,6 +2731,8 @@ public boolean hasMetadata() { * * * .google.protobuf.Struct metadata = 6; + * + * @return The metadata. */ public com.google.protobuf.Struct getMetadata() { return metadata_ == null ? com.google.protobuf.Struct.getDefaultInstance() : metadata_; @@ -2644,6 +2769,8 @@ public com.google.protobuf.StructOrBuilder getMetadataOrBuilder() { * * * .google.protobuf.Struct execution_stats = 7; + * + * @return Whether the executionStats field is set. */ public boolean hasExecutionStats() { return executionStats_ != null; @@ -2659,6 +2786,8 @@ public boolean hasExecutionStats() { * * * .google.protobuf.Struct execution_stats = 7; + * + * @return The executionStats. */ public com.google.protobuf.Struct getExecutionStats() { return executionStats_ == null @@ -2963,7 +3092,7 @@ public Builder clear() { if (childLinksBuilder_ == null) { childLinks_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } else { childLinksBuilder_.clear(); } @@ -3012,14 +3141,13 @@ public com.google.spanner.v1.PlanNode build() { public com.google.spanner.v1.PlanNode buildPartial() { com.google.spanner.v1.PlanNode result = new com.google.spanner.v1.PlanNode(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.index_ = index_; result.kind_ = kind_; result.displayName_ = displayName_; if (childLinksBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { childLinks_ = java.util.Collections.unmodifiableList(childLinks_); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } result.childLinks_ = childLinks_; } else { @@ -3040,7 +3168,6 @@ public com.google.spanner.v1.PlanNode buildPartial() { } else { result.executionStats_ = executionStatsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -3104,7 +3231,7 @@ public Builder mergeFrom(com.google.spanner.v1.PlanNode other) { if (!other.childLinks_.isEmpty()) { if (childLinks_.isEmpty()) { childLinks_ = other.childLinks_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureChildLinksIsMutable(); childLinks_.addAll(other.childLinks_); @@ -3117,7 +3244,7 @@ public Builder mergeFrom(com.google.spanner.v1.PlanNode other) { childLinksBuilder_.dispose(); childLinksBuilder_ = null; childLinks_ = other.childLinks_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); childLinksBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getChildLinksFieldBuilder() @@ -3176,6 +3303,8 @@ public Builder mergeFrom( * * * int32 index = 1; + * + * @return The index. */ public int getIndex() { return index_; @@ -3188,6 +3317,9 @@ public int getIndex() { * * * int32 index = 1; + * + * @param value The index to set. + * @return This builder for chaining. */ public Builder setIndex(int value) { @@ -3203,6 +3335,8 @@ public Builder setIndex(int value) { * * * int32 index = 1; + * + * @return This builder for chaining. */ public Builder clearIndex() { @@ -3224,6 +3358,8 @@ public Builder clearIndex() { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The enum numeric value on the wire for kind. */ public int getKindValue() { return kind_; @@ -3240,6 +3376,9 @@ public int getKindValue() { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @param value The enum numeric value on the wire for kind to set. + * @return This builder for chaining. */ public Builder setKindValue(int value) { kind_ = value; @@ -3258,6 +3397,8 @@ public Builder setKindValue(int value) { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The kind. */ public com.google.spanner.v1.PlanNode.Kind getKind() { @SuppressWarnings("deprecation") @@ -3277,6 +3418,9 @@ public com.google.spanner.v1.PlanNode.Kind getKind() { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @param value The kind to set. + * @return This builder for chaining. */ public Builder setKind(com.google.spanner.v1.PlanNode.Kind value) { if (value == null) { @@ -3299,6 +3443,8 @@ public Builder setKind(com.google.spanner.v1.PlanNode.Kind value) { * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return This builder for chaining. */ public Builder clearKind() { @@ -3316,6 +3462,8 @@ public Builder clearKind() { * * * string display_name = 3; + * + * @return The displayName. */ public java.lang.String getDisplayName() { java.lang.Object ref = displayName_; @@ -3336,6 +3484,8 @@ public java.lang.String getDisplayName() { * * * string display_name = 3; + * + * @return The bytes for displayName. */ public com.google.protobuf.ByteString getDisplayNameBytes() { java.lang.Object ref = displayName_; @@ -3356,6 +3506,9 @@ public com.google.protobuf.ByteString getDisplayNameBytes() { * * * string display_name = 3; + * + * @param value The displayName to set. + * @return This builder for chaining. */ public Builder setDisplayName(java.lang.String value) { if (value == null) { @@ -3374,6 +3527,8 @@ public Builder setDisplayName(java.lang.String value) { * * * string display_name = 3; + * + * @return This builder for chaining. */ public Builder clearDisplayName() { @@ -3389,6 +3544,9 @@ public Builder clearDisplayName() { * * * string display_name = 3; + * + * @param value The bytes for displayName to set. + * @return This builder for chaining. */ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -3405,10 +3563,10 @@ public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { java.util.Collections.emptyList(); private void ensureChildLinksIsMutable() { - if (!((bitField0_ & 0x00000008) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { childLinks_ = new java.util.ArrayList(childLinks_); - bitField0_ |= 0x00000008; + bitField0_ |= 0x00000001; } } @@ -3623,7 +3781,7 @@ public Builder addAllChildLinks( public Builder clearChildLinks() { if (childLinksBuilder_ == null) { childLinks_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); } else { childLinksBuilder_.clear(); @@ -3745,7 +3903,7 @@ public com.google.spanner.v1.PlanNode.ChildLink.Builder addChildLinksBuilder(int com.google.spanner.v1.PlanNode.ChildLink, com.google.spanner.v1.PlanNode.ChildLink.Builder, com.google.spanner.v1.PlanNode.ChildLinkOrBuilder>( - childLinks_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + childLinks_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); childLinks_ = null; } return childLinksBuilder_; @@ -3765,6 +3923,8 @@ public com.google.spanner.v1.PlanNode.ChildLink.Builder addChildLinksBuilder(int * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return Whether the shortRepresentation field is set. */ public boolean hasShortRepresentation() { return shortRepresentationBuilder_ != null || shortRepresentation_ != null; @@ -3777,6 +3937,8 @@ public boolean hasShortRepresentation() { * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return The shortRepresentation. */ public com.google.spanner.v1.PlanNode.ShortRepresentation getShortRepresentation() { if (shortRepresentationBuilder_ == null) { @@ -3957,6 +4119,8 @@ public Builder clearShortRepresentation() { * * * .google.protobuf.Struct metadata = 6; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadataBuilder_ != null || metadata_ != null; @@ -3975,6 +4139,8 @@ public boolean hasMetadata() { * * * .google.protobuf.Struct metadata = 6; + * + * @return The metadata. */ public com.google.protobuf.Struct getMetadata() { if (metadataBuilder_ == null) { @@ -4183,6 +4349,8 @@ public com.google.protobuf.StructOrBuilder getMetadataOrBuilder() { * * * .google.protobuf.Struct execution_stats = 7; + * + * @return Whether the executionStats field is set. */ public boolean hasExecutionStats() { return executionStatsBuilder_ != null || executionStats_ != null; @@ -4198,6 +4366,8 @@ public boolean hasExecutionStats() { * * * .google.protobuf.Struct execution_stats = 7; + * + * @return The executionStats. */ public com.google.protobuf.Struct getExecutionStats() { if (executionStatsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNodeOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNodeOrBuilder.java index 5b9479517f6..96e8e6dfe08 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNodeOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNodeOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/query_plan.proto @@ -16,6 +31,8 @@ public interface PlanNodeOrBuilder * * * int32 index = 1; + * + * @return The index. */ int getIndex(); @@ -31,6 +48,8 @@ public interface PlanNodeOrBuilder * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The enum numeric value on the wire for kind. */ int getKindValue(); /** @@ -45,6 +64,8 @@ public interface PlanNodeOrBuilder * * * .google.spanner.v1.PlanNode.Kind kind = 2; + * + * @return The kind. */ com.google.spanner.v1.PlanNode.Kind getKind(); @@ -56,6 +77,8 @@ public interface PlanNodeOrBuilder * * * string display_name = 3; + * + * @return The displayName. */ java.lang.String getDisplayName(); /** @@ -66,6 +89,8 @@ public interface PlanNodeOrBuilder * * * string display_name = 3; + * + * @return The bytes for displayName. */ com.google.protobuf.ByteString getDisplayNameBytes(); @@ -129,6 +154,8 @@ public interface PlanNodeOrBuilder * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return Whether the shortRepresentation field is set. */ boolean hasShortRepresentation(); /** @@ -139,6 +166,8 @@ public interface PlanNodeOrBuilder * * * .google.spanner.v1.PlanNode.ShortRepresentation short_representation = 5; + * + * @return The shortRepresentation. */ com.google.spanner.v1.PlanNode.ShortRepresentation getShortRepresentation(); /** @@ -166,6 +195,8 @@ public interface PlanNodeOrBuilder * * * .google.protobuf.Struct metadata = 6; + * + * @return Whether the metadata field is set. */ boolean hasMetadata(); /** @@ -182,6 +213,8 @@ public interface PlanNodeOrBuilder * * * .google.protobuf.Struct metadata = 6; + * + * @return The metadata. */ com.google.protobuf.Struct getMetadata(); /** @@ -212,6 +245,8 @@ public interface PlanNodeOrBuilder * * * .google.protobuf.Struct execution_stats = 7; + * + * @return Whether the executionStats field is set. */ boolean hasExecutionStats(); /** @@ -225,6 +260,8 @@ public interface PlanNodeOrBuilder * * * .google.protobuf.Struct execution_stats = 7; + * + * @return The executionStats. */ com.google.protobuf.Struct getExecutionStats(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlan.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlan.java index 60f8979e375..49ee837d7fc 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlan.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlan.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/query_plan.proto @@ -26,6 +41,12 @@ private QueryPlan() { planNodes_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new QueryPlan(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanOrBuilder.java index 3594a6a9725..1ab98b7635d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/query_plan.proto diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java index 039d5ac57fb..a428ca64a70 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/query_plan.proto @@ -67,21 +82,13 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "gle.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Span" + "ner\\V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.StructProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.StructProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_PlanNode_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_PlanNode_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequest.java index dcb32faae95..ab4b4c2fd76 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -32,6 +47,12 @@ private ReadRequest() { partitionToken_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -96,9 +117,9 @@ private ReadRequest( case 42: { java.lang.String s = input.readStringRequireUtf8(); - if (!((mutable_bitField0_ & 0x00000010) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000010; + mutable_bitField0_ |= 0x00000001; } columns_.add(s); break; @@ -146,7 +167,7 @@ private ReadRequest( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000010) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); @@ -169,7 +190,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.ReadRequest.Builder.class); } - private int bitField0_; public static final int SESSION_FIELD_NUMBER = 1; private volatile java.lang.Object session_; /** @@ -182,6 +202,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -204,6 +226,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -228,6 +252,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -241,6 +267,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { return transaction_ == null @@ -271,6 +299,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -291,6 +321,8 @@ public java.lang.String getTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -319,6 +351,8 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string index = 4; + * + * @return The index. */ public java.lang.String getIndex() { java.lang.Object ref = index_; @@ -344,6 +378,8 @@ public java.lang.String getIndex() { * * * string index = 4; + * + * @return The bytes for index. */ public com.google.protobuf.ByteString getIndexBytes() { java.lang.Object ref = index_; @@ -368,6 +404,8 @@ public com.google.protobuf.ByteString getIndexBytes() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_; @@ -381,6 +419,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -394,6 +434,9 @@ public int getColumnsCount() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -407,6 +450,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -435,6 +481,8 @@ public com.google.protobuf.ByteString getColumnsBytes(int index) { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySet_ != null; @@ -460,6 +508,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { return keySet_ == null ? com.google.spanner.v1.KeySet.getDefaultInstance() : keySet_; @@ -502,6 +552,8 @@ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { * * * int64 limit = 8; + * + * @return The limit. */ public long getLimit() { return limit_; @@ -522,6 +574,8 @@ public long getLimit() { * * * bytes resume_token = 9; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -540,6 +594,8 @@ public com.google.protobuf.ByteString getResumeToken() { * * * bytes partition_token = 10; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -850,7 +906,7 @@ public Builder clear() { index_ = ""; columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); if (keySetBuilder_ == null) { keySet_ = null; } else { @@ -890,7 +946,6 @@ public com.google.spanner.v1.ReadRequest build() { public com.google.spanner.v1.ReadRequest buildPartial() { com.google.spanner.v1.ReadRequest result = new com.google.spanner.v1.ReadRequest(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.session_ = session_; if (transactionBuilder_ == null) { result.transaction_ = transaction_; @@ -899,9 +954,9 @@ public com.google.spanner.v1.ReadRequest buildPartial() { } result.table_ = table_; result.index_ = index_; - if (((bitField0_ & 0x00000010) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { columns_ = columns_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); } result.columns_ = columns_; if (keySetBuilder_ == null) { @@ -912,7 +967,6 @@ public com.google.spanner.v1.ReadRequest buildPartial() { result.limit_ = limit_; result.resumeToken_ = resumeToken_; result.partitionToken_ = partitionToken_; - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -980,7 +1034,7 @@ public Builder mergeFrom(com.google.spanner.v1.ReadRequest other) { if (!other.columns_.isEmpty()) { if (columns_.isEmpty()) { columns_ = other.columns_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureColumnsIsMutable(); columns_.addAll(other.columns_); @@ -1041,6 +1095,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -1063,6 +1119,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -1085,6 +1143,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -1105,6 +1166,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -1122,6 +1185,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1149,6 +1215,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -1162,6 +1230,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.TransactionSelector getTransaction() { if (transactionBuilder_ == null) { @@ -1334,6 +1404,8 @@ public com.google.spanner.v1.TransactionSelectorOrBuilder getTransactionOrBuilde * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ public java.lang.String getTable() { java.lang.Object ref = table_; @@ -1354,6 +1426,8 @@ public java.lang.String getTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ public com.google.protobuf.ByteString getTableBytes() { java.lang.Object ref = table_; @@ -1374,6 +1448,9 @@ public com.google.protobuf.ByteString getTableBytes() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The table to set. + * @return This builder for chaining. */ public Builder setTable(java.lang.String value) { if (value == null) { @@ -1392,6 +1469,8 @@ public Builder setTable(java.lang.String value) { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearTable() { @@ -1407,6 +1486,9 @@ public Builder clearTable() { * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for table to set. + * @return This builder for chaining. */ public Builder setTableBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1433,6 +1515,8 @@ public Builder setTableBytes(com.google.protobuf.ByteString value) { * * * string index = 4; + * + * @return The index. */ public java.lang.String getIndex() { java.lang.Object ref = index_; @@ -1458,6 +1542,8 @@ public java.lang.String getIndex() { * * * string index = 4; + * + * @return The bytes for index. */ public com.google.protobuf.ByteString getIndexBytes() { java.lang.Object ref = index_; @@ -1483,6 +1569,9 @@ public com.google.protobuf.ByteString getIndexBytes() { * * * string index = 4; + * + * @param value The index to set. + * @return This builder for chaining. */ public Builder setIndex(java.lang.String value) { if (value == null) { @@ -1506,6 +1595,8 @@ public Builder setIndex(java.lang.String value) { * * * string index = 4; + * + * @return This builder for chaining. */ public Builder clearIndex() { @@ -1526,6 +1617,9 @@ public Builder clearIndex() { * * * string index = 4; + * + * @param value The bytes for index to set. + * @return This builder for chaining. */ public Builder setIndexBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1542,9 +1636,9 @@ public Builder setIndexBytes(com.google.protobuf.ByteString value) { com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureColumnsIsMutable() { - if (!((bitField0_ & 0x00000010) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { columns_ = new com.google.protobuf.LazyStringArrayList(columns_); - bitField0_ |= 0x00000010; + bitField0_ |= 0x00000001; } } /** @@ -1556,6 +1650,8 @@ private void ensureColumnsIsMutable() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the columns. */ public com.google.protobuf.ProtocolStringList getColumnsList() { return columns_.getUnmodifiableView(); @@ -1569,6 +1665,8 @@ public com.google.protobuf.ProtocolStringList getColumnsList() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of columns. */ public int getColumnsCount() { return columns_.size(); @@ -1582,6 +1680,9 @@ public int getColumnsCount() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ public java.lang.String getColumns(int index) { return columns_.get(index); @@ -1595,6 +1696,9 @@ public java.lang.String getColumns(int index) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ public com.google.protobuf.ByteString getColumnsBytes(int index) { return columns_.getByteString(index); @@ -1608,6 +1712,10 @@ public com.google.protobuf.ByteString getColumnsBytes(int index) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index to set the value at. + * @param value The columns to set. + * @return This builder for chaining. */ public Builder setColumns(int index, java.lang.String value) { if (value == null) { @@ -1627,6 +1735,9 @@ public Builder setColumns(int index, java.lang.String value) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The columns to add. + * @return This builder for chaining. */ public Builder addColumns(java.lang.String value) { if (value == null) { @@ -1646,6 +1757,9 @@ public Builder addColumns(java.lang.String value) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param values The columns to add. + * @return This builder for chaining. */ public Builder addAllColumns(java.lang.Iterable values) { ensureColumnsIsMutable(); @@ -1662,10 +1776,12 @@ public Builder addAllColumns(java.lang.Iterable values) { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearColumns() { columns_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000001); onChanged(); return this; } @@ -1678,6 +1794,9 @@ public Builder clearColumns() { * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes of the columns to add. + * @return This builder for chaining. */ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1717,6 +1836,8 @@ public Builder addColumnsBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ public boolean hasKeySet() { return keySetBuilder_ != null || keySet_ != null; @@ -1742,6 +1863,8 @@ public boolean hasKeySet() { * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ public com.google.spanner.v1.KeySet getKeySet() { if (keySetBuilder_ == null) { @@ -1993,6 +2116,8 @@ public com.google.spanner.v1.KeySetOrBuilder getKeySetOrBuilder() { * * * int64 limit = 8; + * + * @return The limit. */ public long getLimit() { return limit_; @@ -2007,6 +2132,9 @@ public long getLimit() { * * * int64 limit = 8; + * + * @param value The limit to set. + * @return This builder for chaining. */ public Builder setLimit(long value) { @@ -2024,6 +2152,8 @@ public Builder setLimit(long value) { * * * int64 limit = 8; + * + * @return This builder for chaining. */ public Builder clearLimit() { @@ -2046,6 +2176,8 @@ public Builder clearLimit() { * * * bytes resume_token = 9; + * + * @return The resumeToken. */ public com.google.protobuf.ByteString getResumeToken() { return resumeToken_; @@ -2063,6 +2195,9 @@ public com.google.protobuf.ByteString getResumeToken() { * * * bytes resume_token = 9; + * + * @param value The resumeToken to set. + * @return This builder for chaining. */ public Builder setResumeToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -2086,6 +2221,8 @@ public Builder setResumeToken(com.google.protobuf.ByteString value) { * * * bytes resume_token = 9; + * + * @return This builder for chaining. */ public Builder clearResumeToken() { @@ -2106,6 +2243,8 @@ public Builder clearResumeToken() { * * * bytes partition_token = 10; + * + * @return The partitionToken. */ public com.google.protobuf.ByteString getPartitionToken() { return partitionToken_; @@ -2121,6 +2260,9 @@ public com.google.protobuf.ByteString getPartitionToken() { * * * bytes partition_token = 10; + * + * @param value The partitionToken to set. + * @return This builder for chaining. */ public Builder setPartitionToken(com.google.protobuf.ByteString value) { if (value == null) { @@ -2142,6 +2284,8 @@ public Builder setPartitionToken(com.google.protobuf.ByteString value) { * * * bytes partition_token = 10; + * + * @return This builder for chaining. */ public Builder clearPartitionToken() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequestOrBuilder.java index 1d6b2f81e35..2d2b47780b2 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface ReadRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface ReadRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -42,6 +61,8 @@ public interface ReadRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -53,6 +74,8 @@ public interface ReadRequestOrBuilder * * * .google.spanner.v1.TransactionSelector transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.TransactionSelector getTransaction(); /** @@ -75,6 +98,8 @@ public interface ReadRequestOrBuilder * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The table. */ java.lang.String getTable(); /** @@ -85,6 +110,8 @@ public interface ReadRequestOrBuilder * * * string table = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for table. */ com.google.protobuf.ByteString getTableBytes(); @@ -101,6 +128,8 @@ public interface ReadRequestOrBuilder * * * string index = 4; + * + * @return The index. */ java.lang.String getIndex(); /** @@ -116,6 +145,8 @@ public interface ReadRequestOrBuilder * * * string index = 4; + * + * @return The bytes for index. */ com.google.protobuf.ByteString getIndexBytes(); @@ -128,6 +159,8 @@ public interface ReadRequestOrBuilder * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return A list containing the columns. */ java.util.List getColumnsList(); /** @@ -139,6 +172,8 @@ public interface ReadRequestOrBuilder * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The count of columns. */ int getColumnsCount(); /** @@ -150,6 +185,9 @@ public interface ReadRequestOrBuilder * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the element to return. + * @return The columns at the given index. */ java.lang.String getColumns(int index); /** @@ -161,6 +199,9 @@ public interface ReadRequestOrBuilder * * * repeated string columns = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * @param index The index of the value to return. + * @return The bytes of the columns at the given index. */ com.google.protobuf.ByteString getColumnsBytes(int index); @@ -185,6 +226,8 @@ public interface ReadRequestOrBuilder * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the keySet field is set. */ boolean hasKeySet(); /** @@ -208,6 +251,8 @@ public interface ReadRequestOrBuilder * * * .google.spanner.v1.KeySet key_set = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The keySet. */ com.google.spanner.v1.KeySet getKeySet(); /** @@ -244,6 +289,8 @@ public interface ReadRequestOrBuilder * * * int64 limit = 8; + * + * @return The limit. */ long getLimit(); @@ -260,6 +307,8 @@ public interface ReadRequestOrBuilder * * * bytes resume_token = 9; + * + * @return The resumeToken. */ com.google.protobuf.ByteString getResumeToken(); @@ -274,6 +323,8 @@ public interface ReadRequestOrBuilder * * * bytes partition_token = 10; + * + * @return The partitionToken. */ com.google.protobuf.ByteString getPartitionToken(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSet.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSet.java index 517a4db5588..c61daab856f 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSet.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSet.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -27,6 +42,12 @@ private ResultSet() { rows_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ResultSet(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -69,9 +90,9 @@ private ResultSet( } case 18: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { rows_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } rows_.add( input.readMessage(com.google.protobuf.ListValue.parser(), extensionRegistry)); @@ -107,7 +128,7 @@ private ResultSet( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { + if (((mutable_bitField0_ & 0x00000001) != 0)) { rows_ = java.util.Collections.unmodifiableList(rows_); } this.unknownFields = unknownFields.build(); @@ -129,7 +150,6 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { com.google.spanner.v1.ResultSet.class, com.google.spanner.v1.ResultSet.Builder.class); } - private int bitField0_; public static final int METADATA_FIELD_NUMBER = 1; private com.google.spanner.v1.ResultSetMetadata metadata_; /** @@ -140,6 +160,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadata_ != null; @@ -152,6 +174,8 @@ public boolean hasMetadata() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ public com.google.spanner.v1.ResultSetMetadata getMetadata() { return metadata_ == null @@ -276,6 +300,8 @@ public com.google.protobuf.ListValueOrBuilder getRowsOrBuilder(int index) { * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return Whether the stats field is set. */ public boolean hasStats() { return stats_ != null; @@ -295,6 +321,8 @@ public boolean hasStats() { * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return The stats. */ public com.google.spanner.v1.ResultSetStats getStats() { return stats_ == null ? com.google.spanner.v1.ResultSetStats.getDefaultInstance() : stats_; @@ -561,7 +589,7 @@ public Builder clear() { } if (rowsBuilder_ == null) { rows_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { rowsBuilder_.clear(); } @@ -598,16 +626,15 @@ public com.google.spanner.v1.ResultSet build() { public com.google.spanner.v1.ResultSet buildPartial() { com.google.spanner.v1.ResultSet result = new com.google.spanner.v1.ResultSet(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; if (metadataBuilder_ == null) { result.metadata_ = metadata_; } else { result.metadata_ = metadataBuilder_.build(); } if (rowsBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0)) { + if (((bitField0_ & 0x00000001) != 0)) { rows_ = java.util.Collections.unmodifiableList(rows_); - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } result.rows_ = rows_; } else { @@ -618,7 +645,6 @@ public com.google.spanner.v1.ResultSet buildPartial() { } else { result.stats_ = statsBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -675,7 +701,7 @@ public Builder mergeFrom(com.google.spanner.v1.ResultSet other) { if (!other.rows_.isEmpty()) { if (rows_.isEmpty()) { rows_ = other.rows_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); } else { ensureRowsIsMutable(); rows_.addAll(other.rows_); @@ -688,7 +714,7 @@ public Builder mergeFrom(com.google.spanner.v1.ResultSet other) { rowsBuilder_.dispose(); rowsBuilder_ = null; rows_ = other.rows_; - bitField0_ = (bitField0_ & ~0x00000002); + bitField0_ = (bitField0_ & ~0x00000001); rowsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getRowsFieldBuilder() @@ -746,6 +772,8 @@ public Builder mergeFrom( * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ public boolean hasMetadata() { return metadataBuilder_ != null || metadata_ != null; @@ -758,6 +786,8 @@ public boolean hasMetadata() { * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ public com.google.spanner.v1.ResultSetMetadata getMetadata() { if (metadataBuilder_ == null) { @@ -916,9 +946,9 @@ public com.google.spanner.v1.ResultSetMetadataOrBuilder getMetadataOrBuilder() { private java.util.List rows_ = java.util.Collections.emptyList(); private void ensureRowsIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { + if (!((bitField0_ & 0x00000001) != 0)) { rows_ = new java.util.ArrayList(rows_); - bitField0_ |= 0x00000002; + bitField0_ |= 0x00000001; } } @@ -1185,7 +1215,7 @@ public Builder addAllRows(java.lang.Iterable getRowsBuilderList( com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder>( - rows_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + rows_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); rows_ = null; } return rowsBuilder_; @@ -1366,6 +1396,8 @@ public java.util.List getRowsBuilderList( * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return Whether the stats field is set. */ public boolean hasStats() { return statsBuilder_ != null || stats_ != null; @@ -1385,6 +1417,8 @@ public boolean hasStats() { * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return The stats. */ public com.google.spanner.v1.ResultSetStats getStats() { if (statsBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadata.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadata.java index 707187a1715..c767eb9a67b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadata.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadata.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -24,6 +39,12 @@ private ResultSetMetadata(com.google.protobuf.GeneratedMessageV3.Builder buil private ResultSetMetadata() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ResultSetMetadata(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -37,7 +58,6 @@ private ResultSetMetadata( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -128,6 +148,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.v1.StructType row_type = 1; + * + * @return Whether the rowType field is set. */ public boolean hasRowType() { return rowType_ != null; @@ -146,6 +168,8 @@ public boolean hasRowType() { * * * .google.spanner.v1.StructType row_type = 1; + * + * @return The rowType. */ public com.google.spanner.v1.StructType getRowType() { return rowType_ == null ? com.google.spanner.v1.StructType.getDefaultInstance() : rowType_; @@ -180,6 +204,8 @@ public com.google.spanner.v1.StructTypeOrBuilder getRowTypeOrBuilder() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transaction_ != null; @@ -193,6 +219,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.Transaction getTransaction() { return transaction_ == null @@ -588,6 +616,8 @@ public Builder mergeFrom( * * * .google.spanner.v1.StructType row_type = 1; + * + * @return Whether the rowType field is set. */ public boolean hasRowType() { return rowTypeBuilder_ != null || rowType_ != null; @@ -606,6 +636,8 @@ public boolean hasRowType() { * * * .google.spanner.v1.StructType row_type = 1; + * + * @return The rowType. */ public com.google.spanner.v1.StructType getRowType() { if (rowTypeBuilder_ == null) { @@ -812,6 +844,8 @@ public com.google.spanner.v1.StructTypeOrBuilder getRowTypeOrBuilder() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ public boolean hasTransaction() { return transactionBuilder_ != null || transaction_ != null; @@ -825,6 +859,8 @@ public boolean hasTransaction() { * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ public com.google.spanner.v1.Transaction getTransaction() { if (transactionBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadataOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadataOrBuilder.java index 2184de354b2..46edad5c33b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadataOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadataOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -22,6 +37,8 @@ public interface ResultSetMetadataOrBuilder * * * .google.spanner.v1.StructType row_type = 1; + * + * @return Whether the rowType field is set. */ boolean hasRowType(); /** @@ -38,6 +55,8 @@ public interface ResultSetMetadataOrBuilder * * * .google.spanner.v1.StructType row_type = 1; + * + * @return The rowType. */ com.google.spanner.v1.StructType getRowType(); /** @@ -66,6 +85,8 @@ public interface ResultSetMetadataOrBuilder * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return Whether the transaction field is set. */ boolean hasTransaction(); /** @@ -77,6 +98,8 @@ public interface ResultSetMetadataOrBuilder * * * .google.spanner.v1.Transaction transaction = 2; + * + * @return The transaction. */ com.google.spanner.v1.Transaction getTransaction(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetOrBuilder.java index 16869a5c390..6ee6c47c806 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -16,6 +31,8 @@ public interface ResultSetOrBuilder * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return Whether the metadata field is set. */ boolean hasMetadata(); /** @@ -26,6 +43,8 @@ public interface ResultSetOrBuilder * * * .google.spanner.v1.ResultSetMetadata metadata = 1; + * + * @return The metadata. */ com.google.spanner.v1.ResultSetMetadata getMetadata(); /** @@ -130,6 +149,8 @@ public interface ResultSetOrBuilder * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return Whether the stats field is set. */ boolean hasStats(); /** @@ -147,6 +168,8 @@ public interface ResultSetOrBuilder * * * .google.spanner.v1.ResultSetStats stats = 3; + * + * @return The stats. */ com.google.spanner.v1.ResultSetStats getStats(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java index b6118dd1465..74252297370 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -65,24 +80,16 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "anner\370\001\001\252\002\027Google.Cloud.Spanner.V1\312\002\027Goo" + "gle\\Cloud\\Spanner\\V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.StructProto.getDescriptor(), - com.google.spanner.v1.QueryPlanProto.getDescriptor(), - com.google.spanner.v1.TransactionProto.getDescriptor(), - com.google.spanner.v1.TypeProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.StructProto.getDescriptor(), + com.google.spanner.v1.QueryPlanProto.getDescriptor(), + com.google.spanner.v1.TransactionProto.getDescriptor(), + com.google.spanner.v1.TypeProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_ResultSet_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_ResultSet_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStats.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStats.java index aaeea300699..c21f0e0bd2e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStats.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStats.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -24,6 +39,12 @@ private ResultSetStats(com.google.protobuf.GeneratedMessageV3.Builder builder private ResultSetStats() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ResultSetStats(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -37,7 +58,6 @@ private ResultSetStats( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -127,7 +147,10 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { private int rowCountCase_ = 0; private java.lang.Object rowCount_; - public enum RowCountCase implements com.google.protobuf.Internal.EnumLite { + public enum RowCountCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { ROW_COUNT_EXACT(3), ROW_COUNT_LOWER_BOUND(4), ROWCOUNT_NOT_SET(0); @@ -136,7 +159,11 @@ public enum RowCountCase implements com.google.protobuf.Internal.EnumLite { private RowCountCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static RowCountCase valueOf(int value) { return forNumber(value); @@ -174,6 +201,8 @@ public RowCountCase getRowCountCase() { * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return Whether the queryPlan field is set. */ public boolean hasQueryPlan() { return queryPlan_ != null; @@ -186,6 +215,8 @@ public boolean hasQueryPlan() { * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return The queryPlan. */ public com.google.spanner.v1.QueryPlan getQueryPlan() { return queryPlan_ == null ? com.google.spanner.v1.QueryPlan.getDefaultInstance() : queryPlan_; @@ -220,6 +251,8 @@ public com.google.spanner.v1.QueryPlanOrBuilder getQueryPlanOrBuilder() { * * * .google.protobuf.Struct query_stats = 2; + * + * @return Whether the queryStats field is set. */ public boolean hasQueryStats() { return queryStats_ != null; @@ -239,6 +272,8 @@ public boolean hasQueryStats() { * * * .google.protobuf.Struct query_stats = 2; + * + * @return The queryStats. */ public com.google.protobuf.Struct getQueryStats() { return queryStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : queryStats_; @@ -272,6 +307,8 @@ public com.google.protobuf.StructOrBuilder getQueryStatsOrBuilder() { * * * int64 row_count_exact = 3; + * + * @return The rowCountExact. */ public long getRowCountExact() { if (rowCountCase_ == 3) { @@ -290,6 +327,8 @@ public long getRowCountExact() { * * * int64 row_count_lower_bound = 4; + * + * @return The rowCountLowerBound. */ public long getRowCountLowerBound() { if (rowCountCase_ == 4) { @@ -743,6 +782,8 @@ public Builder clearRowCount() { * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return Whether the queryPlan field is set. */ public boolean hasQueryPlan() { return queryPlanBuilder_ != null || queryPlan_ != null; @@ -755,6 +796,8 @@ public boolean hasQueryPlan() { * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return The queryPlan. */ public com.google.spanner.v1.QueryPlan getQueryPlan() { if (queryPlanBuilder_ == null) { @@ -931,6 +974,8 @@ public com.google.spanner.v1.QueryPlanOrBuilder getQueryPlanOrBuilder() { * * * .google.protobuf.Struct query_stats = 2; + * + * @return Whether the queryStats field is set. */ public boolean hasQueryStats() { return queryStatsBuilder_ != null || queryStats_ != null; @@ -950,6 +995,8 @@ public boolean hasQueryStats() { * * * .google.protobuf.Struct query_stats = 2; + * + * @return The queryStats. */ public com.google.protobuf.Struct getQueryStats() { if (queryStatsBuilder_ == null) { @@ -1156,6 +1203,8 @@ public com.google.protobuf.StructOrBuilder getQueryStatsOrBuilder() { * * * int64 row_count_exact = 3; + * + * @return The rowCountExact. */ public long getRowCountExact() { if (rowCountCase_ == 3) { @@ -1171,6 +1220,9 @@ public long getRowCountExact() { * * * int64 row_count_exact = 3; + * + * @param value The rowCountExact to set. + * @return This builder for chaining. */ public Builder setRowCountExact(long value) { rowCountCase_ = 3; @@ -1186,6 +1238,8 @@ public Builder setRowCountExact(long value) { * * * int64 row_count_exact = 3; + * + * @return This builder for chaining. */ public Builder clearRowCountExact() { if (rowCountCase_ == 3) { @@ -1205,6 +1259,8 @@ public Builder clearRowCountExact() { * * * int64 row_count_lower_bound = 4; + * + * @return The rowCountLowerBound. */ public long getRowCountLowerBound() { if (rowCountCase_ == 4) { @@ -1221,6 +1277,9 @@ public long getRowCountLowerBound() { * * * int64 row_count_lower_bound = 4; + * + * @param value The rowCountLowerBound to set. + * @return This builder for chaining. */ public Builder setRowCountLowerBound(long value) { rowCountCase_ = 4; @@ -1237,6 +1296,8 @@ public Builder setRowCountLowerBound(long value) { * * * int64 row_count_lower_bound = 4; + * + * @return This builder for chaining. */ public Builder clearRowCountLowerBound() { if (rowCountCase_ == 4) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStatsOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStatsOrBuilder.java index e32124c6b73..efa1ce5e705 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStatsOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStatsOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/result_set.proto @@ -16,6 +31,8 @@ public interface ResultSetStatsOrBuilder * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return Whether the queryPlan field is set. */ boolean hasQueryPlan(); /** @@ -26,6 +43,8 @@ public interface ResultSetStatsOrBuilder * * * .google.spanner.v1.QueryPlan query_plan = 1; + * + * @return The queryPlan. */ com.google.spanner.v1.QueryPlan getQueryPlan(); /** @@ -54,6 +73,8 @@ public interface ResultSetStatsOrBuilder * * * .google.protobuf.Struct query_stats = 2; + * + * @return Whether the queryStats field is set. */ boolean hasQueryStats(); /** @@ -71,6 +92,8 @@ public interface ResultSetStatsOrBuilder * * * .google.protobuf.Struct query_stats = 2; + * + * @return The queryStats. */ com.google.protobuf.Struct getQueryStats(); /** @@ -99,6 +122,8 @@ public interface ResultSetStatsOrBuilder * * * int64 row_count_exact = 3; + * + * @return The rowCountExact. */ long getRowCountExact(); @@ -111,6 +136,8 @@ public interface ResultSetStatsOrBuilder * * * int64 row_count_lower_bound = 4; + * + * @return The rowCountLowerBound. */ long getRowCountLowerBound(); diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequest.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequest.java index 174453f092b..67f4d90be3d 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequest.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -27,6 +42,12 @@ private RollbackRequest() { transactionId_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RollbackRequest(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private RollbackRequest( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -109,6 +129,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -131,6 +153,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -154,6 +178,8 @@ public com.google.protobuf.ByteString getSessionBytes() { * * * bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transactionId. */ public com.google.protobuf.ByteString getTransactionId() { return transactionId_; @@ -499,6 +525,8 @@ public Builder mergeFrom( * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ public java.lang.String getSession() { java.lang.Object ref = session_; @@ -521,6 +549,8 @@ public java.lang.String getSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ public com.google.protobuf.ByteString getSessionBytes() { java.lang.Object ref = session_; @@ -543,6 +573,9 @@ public com.google.protobuf.ByteString getSessionBytes() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The session to set. + * @return This builder for chaining. */ public Builder setSession(java.lang.String value) { if (value == null) { @@ -563,6 +596,8 @@ public Builder setSession(java.lang.String value) { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return This builder for chaining. */ public Builder clearSession() { @@ -580,6 +615,9 @@ public Builder clearSession() { * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @param value The bytes for session to set. + * @return This builder for chaining. */ public Builder setSessionBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -601,6 +639,8 @@ public Builder setSessionBytes(com.google.protobuf.ByteString value) { * * * bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transactionId. */ public com.google.protobuf.ByteString getTransactionId() { return transactionId_; @@ -613,6 +653,9 @@ public com.google.protobuf.ByteString getTransactionId() { * * * bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The transactionId to set. + * @return This builder for chaining. */ public Builder setTransactionId(com.google.protobuf.ByteString value) { if (value == null) { @@ -631,6 +674,8 @@ public Builder setTransactionId(com.google.protobuf.ByteString value) { * * * bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. */ public Builder clearTransactionId() { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequestOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequestOrBuilder.java index 70acbd2bca2..c0e31e1d68c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequestOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequestOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -18,6 +33,8 @@ public interface RollbackRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The session. */ java.lang.String getSession(); /** @@ -30,6 +47,8 @@ public interface RollbackRequestOrBuilder * * string session = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } * + * + * @return The bytes for session. */ com.google.protobuf.ByteString getSessionBytes(); @@ -41,6 +60,8 @@ public interface RollbackRequestOrBuilder * * * bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transactionId. */ com.google.protobuf.ByteString getTransactionId(); } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Session.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Session.java index ae9b2ee6f0d..7a168f2b649 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Session.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Session.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -26,6 +41,12 @@ private Session() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Session(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -59,10 +80,10 @@ private Session( } case 18: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { labels_ = com.google.protobuf.MapField.newMapField(LabelsDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000002; + mutable_bitField0_ |= 0x00000001; } com.google.protobuf.MapEntry labels__ = input.readMessage( @@ -143,7 +164,6 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { com.google.spanner.v1.Session.class, com.google.spanner.v1.Session.Builder.class); } - private int bitField0_; public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; /** @@ -155,6 +175,8 @@ protected com.google.protobuf.MapField internalGetMapField(int number) { * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -176,6 +198,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -316,6 +340,8 @@ public java.lang.String getLabelsOrThrow(java.lang.String key) { * * * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. */ public boolean hasCreateTime() { return createTime_ != null; @@ -328,6 +354,8 @@ public boolean hasCreateTime() { * * * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. */ public com.google.protobuf.Timestamp getCreateTime() { return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; @@ -356,6 +384,8 @@ public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return Whether the approximateLastUseTime field is set. */ public boolean hasApproximateLastUseTime() { return approximateLastUseTime_ != null; @@ -369,6 +399,8 @@ public boolean hasApproximateLastUseTime() { * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return The approximateLastUseTime. */ public com.google.protobuf.Timestamp getApproximateLastUseTime() { return approximateLastUseTime_ == null @@ -698,7 +730,6 @@ public com.google.spanner.v1.Session build() { public com.google.spanner.v1.Session buildPartial() { com.google.spanner.v1.Session result = new com.google.spanner.v1.Session(this); int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; result.name_ = name_; result.labels_ = internalGetLabels(); result.labels_.makeImmutable(); @@ -712,7 +743,6 @@ public com.google.spanner.v1.Session buildPartial() { } else { result.approximateLastUseTime_ = approximateLastUseTimeBuilder_.build(); } - result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -814,6 +844,8 @@ public Builder mergeFrom( * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -835,6 +867,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -856,6 +890,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -875,6 +912,8 @@ public Builder setName(java.lang.String value) { * * * string name = 1; + * + * @return This builder for chaining. */ public Builder clearName() { @@ -891,6 +930,9 @@ public Builder clearName() { * * * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -1111,6 +1153,8 @@ public Builder putAllLabels(java.util.Map va * * * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. */ public boolean hasCreateTime() { return createTimeBuilder_ != null || createTime_ != null; @@ -1123,6 +1167,8 @@ public boolean hasCreateTime() { * * * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. */ public com.google.protobuf.Timestamp getCreateTime() { if (createTimeBuilder_ == null) { @@ -1291,6 +1337,8 @@ public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return Whether the approximateLastUseTime field is set. */ public boolean hasApproximateLastUseTime() { return approximateLastUseTimeBuilder_ != null || approximateLastUseTime_ != null; @@ -1304,6 +1352,8 @@ public boolean hasApproximateLastUseTime() { * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return The approximateLastUseTime. */ public com.google.protobuf.Timestamp getApproximateLastUseTime() { if (approximateLastUseTimeBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionName.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionName.java index f1c2f527909..f9492bc7bc4 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionName.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionName.java @@ -1,15 +1,17 @@ /* - * Copyright 2018 Google LLC + * Copyright 2019 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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. + * 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. */ package com.google.spanner.v1; @@ -22,7 +24,7 @@ import java.util.List; import java.util.Map; -// AUTO-GENERATED DOCUMENTATION AND CLASS +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class SessionName implements ResourceName { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionOrBuilder.java index 17f9724730f..befca8c665b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -17,6 +32,8 @@ public interface SessionOrBuilder * * * string name = 1; + * + * @return The name. */ java.lang.String getName(); /** @@ -28,6 +45,8 @@ public interface SessionOrBuilder * * * string name = 1; + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -123,6 +142,8 @@ public interface SessionOrBuilder * * * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. */ boolean hasCreateTime(); /** @@ -133,6 +154,8 @@ public interface SessionOrBuilder * * * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. */ com.google.protobuf.Timestamp getCreateTime(); /** @@ -155,6 +178,8 @@ public interface SessionOrBuilder * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return Whether the approximateLastUseTime field is set. */ boolean hasApproximateLastUseTime(); /** @@ -166,6 +191,8 @@ public interface SessionOrBuilder * * * .google.protobuf.Timestamp approximate_last_use_time = 4; + * + * @return The approximateLastUseTime. */ com.google.protobuf.Timestamp getApproximateLastUseTime(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java index fbc83f6643f..146f509627c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/spanner.proto @@ -318,32 +333,24 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "jects/{project}/instances/{instance}/dat" + "abases/{database}b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - com.google.api.ClientProto.getDescriptor(), - com.google.api.FieldBehaviorProto.getDescriptor(), - com.google.api.ResourceProto.getDescriptor(), - com.google.protobuf.EmptyProto.getDescriptor(), - com.google.protobuf.StructProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - com.google.rpc.StatusProto.getDescriptor(), - com.google.spanner.v1.KeysProto.getDescriptor(), - com.google.spanner.v1.MutationProto.getDescriptor(), - com.google.spanner.v1.ResultSetProto.getDescriptor(), - com.google.spanner.v1.TransactionProto.getDescriptor(), - com.google.spanner.v1.TypeProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.protobuf.StructProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.rpc.StatusProto.getDescriptor(), + com.google.spanner.v1.KeysProto.getDescriptor(), + com.google.spanner.v1.MutationProto.getDescriptor(), + com.google.spanner.v1.ResultSetProto.getDescriptor(), + com.google.spanner.v1.TransactionProto.getDescriptor(), + com.google.spanner.v1.TypeProto.getDescriptor(), + }); internal_static_google_spanner_v1_CreateSessionRequest_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_CreateSessionRequest_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructType.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructType.java index 42ed643f111..083314c9a56 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructType.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto @@ -26,6 +41,12 @@ private StructType() { fields_ = java.util.Collections.emptyList(); } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StructType(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -115,6 +136,8 @@ public interface FieldOrBuilder * * * string name = 1; + * + * @return The name. */ java.lang.String getName(); /** @@ -131,6 +154,8 @@ public interface FieldOrBuilder * * * string name = 1; + * + * @return The bytes for name. */ com.google.protobuf.ByteString getNameBytes(); @@ -142,6 +167,8 @@ public interface FieldOrBuilder * * * .google.spanner.v1.Type type = 2; + * + * @return Whether the type field is set. */ boolean hasType(); /** @@ -152,6 +179,8 @@ public interface FieldOrBuilder * * * .google.spanner.v1.Type type = 2; + * + * @return The type. */ com.google.spanner.v1.Type getType(); /** @@ -188,6 +217,12 @@ private Field() { name_ = ""; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Field(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -201,7 +236,6 @@ private Field( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -283,6 +317,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -309,6 +345,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -332,6 +370,8 @@ public com.google.protobuf.ByteString getNameBytes() { * * * .google.spanner.v1.Type type = 2; + * + * @return Whether the type field is set. */ public boolean hasType() { return type_ != null; @@ -344,6 +384,8 @@ public boolean hasType() { * * * .google.spanner.v1.Type type = 2; + * + * @return The type. */ public com.google.spanner.v1.Type getType() { return type_ == null ? com.google.spanner.v1.Type.getDefaultInstance() : type_; @@ -723,6 +765,8 @@ public Builder mergeFrom( * * * string name = 1; + * + * @return The name. */ public java.lang.String getName() { java.lang.Object ref = name_; @@ -749,6 +793,8 @@ public java.lang.String getName() { * * * string name = 1; + * + * @return The bytes for name. */ public com.google.protobuf.ByteString getNameBytes() { java.lang.Object ref = name_; @@ -775,6 +821,9 @@ public com.google.protobuf.ByteString getNameBytes() { * * * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. */ public Builder setName(java.lang.String value) { if (value == null) { @@ -799,6 +848,8 @@ public Builder setName(java.lang.String value) { * * * string name = 1; + * + * @return This builder for chaining. */ public Builder clearName() { @@ -820,6 +871,9 @@ public Builder clearName() { * * * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. */ public Builder setNameBytes(com.google.protobuf.ByteString value) { if (value == null) { @@ -846,6 +900,8 @@ public Builder setNameBytes(com.google.protobuf.ByteString value) { * * * .google.spanner.v1.Type type = 2; + * + * @return Whether the type field is set. */ public boolean hasType() { return typeBuilder_ != null || type_ != null; @@ -858,6 +914,8 @@ public boolean hasType() { * * * .google.spanner.v1.Type type = 2; + * + * @return The type. */ public com.google.spanner.v1.Type getType() { if (typeBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructTypeOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructTypeOrBuilder.java index 285f5af1500..8980d085f7e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructTypeOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructTypeOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Transaction.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Transaction.java index f6967065900..65261d84cc0 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Transaction.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Transaction.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -26,6 +41,12 @@ private Transaction() { id_ = com.google.protobuf.ByteString.EMPTY; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Transaction(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -39,7 +60,6 @@ private Transaction( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -120,6 +140,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * bytes id = 1; + * + * @return The id. */ public com.google.protobuf.ByteString getId() { return id_; @@ -139,6 +161,8 @@ public com.google.protobuf.ByteString getId() { * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return Whether the readTimestamp field is set. */ public boolean hasReadTimestamp() { return readTimestamp_ != null; @@ -155,6 +179,8 @@ public boolean hasReadTimestamp() { * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return The readTimestamp. */ public com.google.protobuf.Timestamp getReadTimestamp() { return readTimestamp_ == null @@ -533,6 +559,8 @@ public Builder mergeFrom( * * * bytes id = 1; + * + * @return The id. */ public com.google.protobuf.ByteString getId() { return id_; @@ -551,6 +579,9 @@ public com.google.protobuf.ByteString getId() { * * * bytes id = 1; + * + * @param value The id to set. + * @return This builder for chaining. */ public Builder setId(com.google.protobuf.ByteString value) { if (value == null) { @@ -575,6 +606,8 @@ public Builder setId(com.google.protobuf.ByteString value) { * * * bytes id = 1; + * + * @return This builder for chaining. */ public Builder clearId() { @@ -601,6 +634,8 @@ public Builder clearId() { * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return Whether the readTimestamp field is set. */ public boolean hasReadTimestamp() { return readTimestampBuilder_ != null || readTimestamp_ != null; @@ -617,6 +652,8 @@ public boolean hasReadTimestamp() { * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return The readTimestamp. */ public com.google.protobuf.Timestamp getReadTimestamp() { if (readTimestampBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java index 5907d323a5d..7d2da07b3f2 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -238,6 +253,12 @@ private TransactionOptions(com.google.protobuf.GeneratedMessageV3.Builder bui private TransactionOptions() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TransactionOptions(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -251,7 +272,6 @@ private TransactionOptions( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -377,6 +397,12 @@ private ReadWrite(com.google.protobuf.GeneratedMessageV3.Builder builder) { private ReadWrite() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadWrite(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -818,6 +844,12 @@ private PartitionedDml(com.google.protobuf.GeneratedMessageV3.Builder builder private PartitionedDml() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionedDml(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -1248,6 +1280,8 @@ public interface ReadOnlyOrBuilder * * * bool strong = 1; + * + * @return The strong. */ boolean getStrong(); @@ -1265,6 +1299,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return Whether the minReadTimestamp field is set. */ boolean hasMinReadTimestamp(); /** @@ -1281,6 +1317,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return The minReadTimestamp. */ com.google.protobuf.Timestamp getMinReadTimestamp(); /** @@ -1318,6 +1356,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Duration max_staleness = 3; + * + * @return Whether the maxStaleness field is set. */ boolean hasMaxStaleness(); /** @@ -1338,6 +1378,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Duration max_staleness = 3; + * + * @return The maxStaleness. */ com.google.protobuf.Duration getMaxStaleness(); /** @@ -1378,6 +1420,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return Whether the readTimestamp field is set. */ boolean hasReadTimestamp(); /** @@ -1397,6 +1441,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return The readTimestamp. */ com.google.protobuf.Timestamp getReadTimestamp(); /** @@ -1435,6 +1481,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return Whether the exactStaleness field is set. */ boolean hasExactStaleness(); /** @@ -1453,6 +1501,8 @@ public interface ReadOnlyOrBuilder * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return The exactStaleness. */ com.google.protobuf.Duration getExactStaleness(); /** @@ -1483,6 +1533,8 @@ public interface ReadOnlyOrBuilder * * * bool return_read_timestamp = 6; + * + * @return The returnReadTimestamp. */ boolean getReturnReadTimestamp(); @@ -1510,6 +1562,12 @@ private ReadOnly(com.google.protobuf.GeneratedMessageV3.Builder builder) { private ReadOnly() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadOnly(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -1523,7 +1581,6 @@ private ReadOnly( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -1642,7 +1699,10 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { private int timestampBoundCase_ = 0; private java.lang.Object timestampBound_; - public enum TimestampBoundCase implements com.google.protobuf.Internal.EnumLite { + public enum TimestampBoundCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { STRONG(1), MIN_READ_TIMESTAMP(2), MAX_STALENESS(3), @@ -1654,7 +1714,11 @@ public enum TimestampBoundCase implements com.google.protobuf.Internal.EnumLite private TimestampBoundCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static TimestampBoundCase valueOf(int value) { return forNumber(value); @@ -1698,6 +1762,8 @@ public TimestampBoundCase getTimestampBoundCase() { * * * bool strong = 1; + * + * @return The strong. */ public boolean getStrong() { if (timestampBoundCase_ == 1) { @@ -1721,6 +1787,8 @@ public boolean getStrong() { * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return Whether the minReadTimestamp field is set. */ public boolean hasMinReadTimestamp() { return timestampBoundCase_ == 2; @@ -1739,6 +1807,8 @@ public boolean hasMinReadTimestamp() { * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return The minReadTimestamp. */ public com.google.protobuf.Timestamp getMinReadTimestamp() { if (timestampBoundCase_ == 2) { @@ -1787,6 +1857,8 @@ public com.google.protobuf.TimestampOrBuilder getMinReadTimestampOrBuilder() { * * * .google.protobuf.Duration max_staleness = 3; + * + * @return Whether the maxStaleness field is set. */ public boolean hasMaxStaleness() { return timestampBoundCase_ == 3; @@ -1809,6 +1881,8 @@ public boolean hasMaxStaleness() { * * * .google.protobuf.Duration max_staleness = 3; + * + * @return The maxStaleness. */ public com.google.protobuf.Duration getMaxStaleness() { if (timestampBoundCase_ == 3) { @@ -1860,6 +1934,8 @@ public com.google.protobuf.DurationOrBuilder getMaxStalenessOrBuilder() { * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return Whether the readTimestamp field is set. */ public boolean hasReadTimestamp() { return timestampBoundCase_ == 4; @@ -1881,6 +1957,8 @@ public boolean hasReadTimestamp() { * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return The readTimestamp. */ public com.google.protobuf.Timestamp getReadTimestamp() { if (timestampBoundCase_ == 4) { @@ -1930,6 +2008,8 @@ public com.google.protobuf.TimestampOrBuilder getReadTimestampOrBuilder() { * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return Whether the exactStaleness field is set. */ public boolean hasExactStaleness() { return timestampBoundCase_ == 5; @@ -1950,6 +2030,8 @@ public boolean hasExactStaleness() { * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return The exactStaleness. */ public com.google.protobuf.Duration getExactStaleness() { if (timestampBoundCase_ == 5) { @@ -1992,6 +2074,8 @@ public com.google.protobuf.DurationOrBuilder getExactStalenessOrBuilder() { * * * bool return_read_timestamp = 6; + * + * @return The returnReadTimestamp. */ public boolean getReturnReadTimestamp() { return returnReadTimestamp_; @@ -2490,6 +2574,8 @@ public Builder clearTimestampBound() { * * * bool strong = 1; + * + * @return The strong. */ public boolean getStrong() { if (timestampBoundCase_ == 1) { @@ -2506,6 +2592,9 @@ public boolean getStrong() { * * * bool strong = 1; + * + * @param value The strong to set. + * @return This builder for chaining. */ public Builder setStrong(boolean value) { timestampBoundCase_ = 1; @@ -2522,6 +2611,8 @@ public Builder setStrong(boolean value) { * * * bool strong = 1; + * + * @return This builder for chaining. */ public Builder clearStrong() { if (timestampBoundCase_ == 1) { @@ -2551,6 +2642,8 @@ public Builder clearStrong() { * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return Whether the minReadTimestamp field is set. */ public boolean hasMinReadTimestamp() { return timestampBoundCase_ == 2; @@ -2569,6 +2662,8 @@ public boolean hasMinReadTimestamp() { * * * .google.protobuf.Timestamp min_read_timestamp = 2; + * + * @return The minReadTimestamp. */ public com.google.protobuf.Timestamp getMinReadTimestamp() { if (minReadTimestampBuilder_ == null) { @@ -2810,6 +2905,8 @@ public com.google.protobuf.TimestampOrBuilder getMinReadTimestampOrBuilder() { * * * .google.protobuf.Duration max_staleness = 3; + * + * @return Whether the maxStaleness field is set. */ public boolean hasMaxStaleness() { return timestampBoundCase_ == 3; @@ -2832,6 +2929,8 @@ public boolean hasMaxStaleness() { * * * .google.protobuf.Duration max_staleness = 3; + * + * @return The maxStaleness. */ public com.google.protobuf.Duration getMaxStaleness() { if (maxStalenessBuilder_ == null) { @@ -3100,6 +3199,8 @@ public com.google.protobuf.DurationOrBuilder getMaxStalenessOrBuilder() { * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return Whether the readTimestamp field is set. */ public boolean hasReadTimestamp() { return timestampBoundCase_ == 4; @@ -3121,6 +3222,8 @@ public boolean hasReadTimestamp() { * * * .google.protobuf.Timestamp read_timestamp = 4; + * + * @return The readTimestamp. */ public com.google.protobuf.Timestamp getReadTimestamp() { if (readTimestampBuilder_ == null) { @@ -3381,6 +3484,8 @@ public com.google.protobuf.TimestampOrBuilder getReadTimestampOrBuilder() { * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return Whether the exactStaleness field is set. */ public boolean hasExactStaleness() { return timestampBoundCase_ == 5; @@ -3401,6 +3506,8 @@ public boolean hasExactStaleness() { * * * .google.protobuf.Duration exact_staleness = 5; + * + * @return The exactStaleness. */ public com.google.protobuf.Duration getExactStaleness() { if (exactStalenessBuilder_ == null) { @@ -3643,6 +3750,8 @@ public com.google.protobuf.DurationOrBuilder getExactStalenessOrBuilder() { * * * bool return_read_timestamp = 6; + * + * @return The returnReadTimestamp. */ public boolean getReturnReadTimestamp() { return returnReadTimestamp_; @@ -3656,6 +3765,9 @@ public boolean getReturnReadTimestamp() { * * * bool return_read_timestamp = 6; + * + * @param value The returnReadTimestamp to set. + * @return This builder for chaining. */ public Builder setReturnReadTimestamp(boolean value) { @@ -3672,6 +3784,8 @@ public Builder setReturnReadTimestamp(boolean value) { * * * bool return_read_timestamp = 6; + * + * @return This builder for chaining. */ public Builder clearReturnReadTimestamp() { @@ -3735,7 +3849,10 @@ public com.google.spanner.v1.TransactionOptions.ReadOnly getDefaultInstanceForTy private int modeCase_ = 0; private java.lang.Object mode_; - public enum ModeCase implements com.google.protobuf.Internal.EnumLite { + public enum ModeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { READ_WRITE(1), PARTITIONED_DML(3), READ_ONLY(2), @@ -3745,7 +3862,11 @@ public enum ModeCase implements com.google.protobuf.Internal.EnumLite { private ModeCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static ModeCase valueOf(int value) { return forNumber(value); @@ -3787,6 +3908,8 @@ public ModeCase getModeCase() { * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. */ public boolean hasReadWrite() { return modeCase_ == 1; @@ -3802,6 +3925,8 @@ public boolean hasReadWrite() { * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. */ public com.google.spanner.v1.TransactionOptions.ReadWrite getReadWrite() { if (modeCase_ == 1) { @@ -3840,6 +3965,8 @@ public com.google.spanner.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteO * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return Whether the partitionedDml field is set. */ public boolean hasPartitionedDml() { return modeCase_ == 3; @@ -3855,6 +3982,8 @@ public boolean hasPartitionedDml() { * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return The partitionedDml. */ public com.google.spanner.v1.TransactionOptions.PartitionedDml getPartitionedDml() { if (modeCase_ == 3) { @@ -3894,6 +4023,8 @@ public com.google.spanner.v1.TransactionOptions.PartitionedDml getPartitionedDml * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. */ public boolean hasReadOnly() { return modeCase_ == 2; @@ -3909,6 +4040,8 @@ public boolean hasReadOnly() { * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. */ public com.google.spanner.v1.TransactionOptions.ReadOnly getReadOnly() { if (modeCase_ == 2) { @@ -4577,6 +4710,8 @@ public Builder clearMode() { * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. */ public boolean hasReadWrite() { return modeCase_ == 1; @@ -4592,6 +4727,8 @@ public boolean hasReadWrite() { * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. */ public com.google.spanner.v1.TransactionOptions.ReadWrite getReadWrite() { if (readWriteBuilder_ == null) { @@ -4806,6 +4943,8 @@ public com.google.spanner.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteO * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return Whether the partitionedDml field is set. */ public boolean hasPartitionedDml() { return modeCase_ == 3; @@ -4821,6 +4960,8 @@ public boolean hasPartitionedDml() { * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return The partitionedDml. */ public com.google.spanner.v1.TransactionOptions.PartitionedDml getPartitionedDml() { if (partitionedDmlBuilder_ == null) { @@ -5040,6 +5181,8 @@ public Builder clearPartitionedDml() { * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. */ public boolean hasReadOnly() { return modeCase_ == 2; @@ -5055,6 +5198,8 @@ public boolean hasReadOnly() { * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. */ public com.google.spanner.v1.TransactionOptions.ReadOnly getReadOnly() { if (readOnlyBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptionsOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptionsOrBuilder.java index df67960b697..f9f0395695b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptionsOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptionsOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -19,6 +34,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. */ boolean hasReadWrite(); /** @@ -32,6 +49,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. */ com.google.spanner.v1.TransactionOptions.ReadWrite getReadWrite(); /** @@ -59,6 +78,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return Whether the partitionedDml field is set. */ boolean hasPartitionedDml(); /** @@ -72,6 +93,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.PartitionedDml partitioned_dml = 3; + * + * @return The partitionedDml. */ com.google.spanner.v1.TransactionOptions.PartitionedDml getPartitionedDml(); /** @@ -99,6 +122,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. */ boolean hasReadOnly(); /** @@ -112,6 +137,8 @@ public interface TransactionOptionsOrBuilder * * * .google.spanner.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. */ com.google.spanner.v1.TransactionOptions.ReadOnly getReadOnly(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOrBuilder.java index c6651b8e504..087989a677f 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -22,6 +37,8 @@ public interface TransactionOrBuilder * * * bytes id = 1; + * + * @return The id. */ com.google.protobuf.ByteString getId(); @@ -37,6 +54,8 @@ public interface TransactionOrBuilder * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return Whether the readTimestamp field is set. */ boolean hasReadTimestamp(); /** @@ -51,6 +70,8 @@ public interface TransactionOrBuilder * * * .google.protobuf.Timestamp read_timestamp = 2; + * + * @return The readTimestamp. */ com.google.protobuf.Timestamp getReadTimestamp(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java index 660a9c3c263..7950086094e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -75,22 +90,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "ner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\C" + "loud\\Spanner\\V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.protobuf.DurationProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_TransactionOptions_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_TransactionOptions_fieldAccessorTable = diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java index e8c6222885a..9bac6f1a3a3 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -27,6 +42,12 @@ private TransactionSelector(com.google.protobuf.GeneratedMessageV3.Builder bu private TransactionSelector() {} + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TransactionSelector(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private TransactionSelector( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -126,7 +146,10 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { private int selectorCase_ = 0; private java.lang.Object selector_; - public enum SelectorCase implements com.google.protobuf.Internal.EnumLite { + public enum SelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { SINGLE_USE(1), ID(2), BEGIN(3), @@ -136,7 +159,11 @@ public enum SelectorCase implements com.google.protobuf.Internal.EnumLite { private SelectorCase(int value) { this.value = value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static SelectorCase valueOf(int value) { return forNumber(value); @@ -177,6 +204,8 @@ public SelectorCase getSelectorCase() { * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return Whether the singleUse field is set. */ public boolean hasSingleUse() { return selectorCase_ == 1; @@ -191,6 +220,8 @@ public boolean hasSingleUse() { * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return The singleUse. */ public com.google.spanner.v1.TransactionOptions getSingleUse() { if (selectorCase_ == 1) { @@ -225,6 +256,8 @@ public com.google.spanner.v1.TransactionOptionsOrBuilder getSingleUseOrBuilder() * * * bytes id = 2; + * + * @return The id. */ public com.google.protobuf.ByteString getId() { if (selectorCase_ == 2) { @@ -244,6 +277,8 @@ public com.google.protobuf.ByteString getId() { * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return Whether the begin field is set. */ public boolean hasBegin() { return selectorCase_ == 3; @@ -258,6 +293,8 @@ public boolean hasBegin() { * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return The begin. */ public com.google.spanner.v1.TransactionOptions getBegin() { if (selectorCase_ == 3) { @@ -710,6 +747,8 @@ public Builder clearSelector() { * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return Whether the singleUse field is set. */ public boolean hasSingleUse() { return selectorCase_ == 1; @@ -724,6 +763,8 @@ public boolean hasSingleUse() { * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return The singleUse. */ public com.google.spanner.v1.TransactionOptions getSingleUse() { if (singleUseBuilder_ == null) { @@ -922,6 +963,8 @@ public com.google.spanner.v1.TransactionOptionsOrBuilder getSingleUseOrBuilder() * * * bytes id = 2; + * + * @return The id. */ public com.google.protobuf.ByteString getId() { if (selectorCase_ == 2) { @@ -937,6 +980,9 @@ public com.google.protobuf.ByteString getId() { * * * bytes id = 2; + * + * @param value The id to set. + * @return This builder for chaining. */ public Builder setId(com.google.protobuf.ByteString value) { if (value == null) { @@ -955,6 +1001,8 @@ public Builder setId(com.google.protobuf.ByteString value) { * * * bytes id = 2; + * + * @return This builder for chaining. */ public Builder clearId() { if (selectorCase_ == 2) { @@ -980,6 +1028,8 @@ public Builder clearId() { * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return Whether the begin field is set. */ public boolean hasBegin() { return selectorCase_ == 3; @@ -994,6 +1044,8 @@ public boolean hasBegin() { * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return The begin. */ public com.google.spanner.v1.TransactionOptions getBegin() { if (beginBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java index 747507f329f..03681706f2b 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/transaction.proto @@ -18,6 +33,8 @@ public interface TransactionSelectorOrBuilder * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return Whether the singleUse field is set. */ boolean hasSingleUse(); /** @@ -30,6 +47,8 @@ public interface TransactionSelectorOrBuilder * * * .google.spanner.v1.TransactionOptions single_use = 1; + * + * @return The singleUse. */ com.google.spanner.v1.TransactionOptions getSingleUse(); /** @@ -53,6 +72,8 @@ public interface TransactionSelectorOrBuilder * * * bytes id = 2; + * + * @return The id. */ com.google.protobuf.ByteString getId(); @@ -66,6 +87,8 @@ public interface TransactionSelectorOrBuilder * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return Whether the begin field is set. */ boolean hasBegin(); /** @@ -78,6 +101,8 @@ public interface TransactionSelectorOrBuilder * * * .google.spanner.v1.TransactionOptions begin = 3; + * + * @return The begin. */ com.google.spanner.v1.TransactionOptions getBegin(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java index 44304878924..c0f568492c3 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto @@ -27,6 +42,12 @@ private Type() { code_ = 0; } + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Type(); + } + @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; @@ -40,7 +61,6 @@ private Type( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } - int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -129,6 +149,8 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The enum numeric value on the wire for code. */ public int getCodeValue() { return code_; @@ -141,6 +163,8 @@ public int getCodeValue() { * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The code. */ public com.google.spanner.v1.TypeCode getCode() { @SuppressWarnings("deprecation") @@ -159,6 +183,8 @@ public com.google.spanner.v1.TypeCode getCode() { * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return Whether the arrayElementType field is set. */ public boolean hasArrayElementType() { return arrayElementType_ != null; @@ -172,6 +198,8 @@ public boolean hasArrayElementType() { * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return The arrayElementType. */ public com.google.spanner.v1.Type getArrayElementType() { return arrayElementType_ == null @@ -203,6 +231,8 @@ public com.google.spanner.v1.TypeOrBuilder getArrayElementTypeOrBuilder() { * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return Whether the structType field is set. */ public boolean hasStructType() { return structType_ != null; @@ -216,6 +246,8 @@ public boolean hasStructType() { * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return The structType. */ public com.google.spanner.v1.StructType getStructType() { return structType_ == null @@ -611,6 +643,8 @@ public Builder mergeFrom( * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The enum numeric value on the wire for code. */ public int getCodeValue() { return code_; @@ -623,6 +657,9 @@ public int getCodeValue() { * * * .google.spanner.v1.TypeCode code = 1; + * + * @param value The enum numeric value on the wire for code to set. + * @return This builder for chaining. */ public Builder setCodeValue(int value) { code_ = value; @@ -637,6 +674,8 @@ public Builder setCodeValue(int value) { * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The code. */ public com.google.spanner.v1.TypeCode getCode() { @SuppressWarnings("deprecation") @@ -651,6 +690,9 @@ public com.google.spanner.v1.TypeCode getCode() { * * * .google.spanner.v1.TypeCode code = 1; + * + * @param value The code to set. + * @return This builder for chaining. */ public Builder setCode(com.google.spanner.v1.TypeCode value) { if (value == null) { @@ -669,6 +711,8 @@ public Builder setCode(com.google.spanner.v1.TypeCode value) { * * * .google.spanner.v1.TypeCode code = 1; + * + * @return This builder for chaining. */ public Builder clearCode() { @@ -692,6 +736,8 @@ public Builder clearCode() { * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return Whether the arrayElementType field is set. */ public boolean hasArrayElementType() { return arrayElementTypeBuilder_ != null || arrayElementType_ != null; @@ -705,6 +751,8 @@ public boolean hasArrayElementType() { * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return The arrayElementType. */ public com.google.spanner.v1.Type getArrayElementType() { if (arrayElementTypeBuilder_ == null) { @@ -882,6 +930,8 @@ public com.google.spanner.v1.TypeOrBuilder getArrayElementTypeOrBuilder() { * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return Whether the structType field is set. */ public boolean hasStructType() { return structTypeBuilder_ != null || structType_ != null; @@ -895,6 +945,8 @@ public boolean hasStructType() { * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return The structType. */ public com.google.spanner.v1.StructType getStructType() { if (structTypeBuilder_ == null) { diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java index 1b286c41e06..ec393d51f0e 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto @@ -252,12 +267,20 @@ public final int getNumber() { return value; } - /** @deprecated Use {@link #forNumber(int)} instead. */ + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ @java.lang.Deprecated public static TypeCode valueOf(int value) { return forNumber(value); } + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ public static TypeCode forNumber(int value) { switch (value) { case 0: diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java index a0b60b15d45..8b38540e911 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto @@ -16,6 +31,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The enum numeric value on the wire for code. */ int getCodeValue(); /** @@ -26,6 +43,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.TypeCode code = 1; + * + * @return The code. */ com.google.spanner.v1.TypeCode getCode(); @@ -38,6 +57,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return Whether the arrayElementType field is set. */ boolean hasArrayElementType(); /** @@ -49,6 +70,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.Type array_element_type = 2; + * + * @return The arrayElementType. */ com.google.spanner.v1.Type getArrayElementType(); /** @@ -72,6 +95,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return Whether the structType field is set. */ boolean hasStructType(); /** @@ -83,6 +108,8 @@ public interface TypeOrBuilder * * * .google.spanner.v1.StructType struct_type = 3; + * + * @return The structType. */ com.google.spanner.v1.StructType getStructType(); /** diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java index c86f88b813e..5f69ad66fee 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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 by the protocol buffer compiler. DO NOT EDIT! // source: google/spanner/v1/type.proto @@ -51,20 +66,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Goog" + "le\\Cloud\\Spanner\\V1b\006proto3" }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.api.AnnotationsProto.getDescriptor(), - }, - assigner); + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + }); internal_static_google_spanner_v1_Type_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_spanner_v1_Type_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( diff --git a/releases.txt b/releases.txt new file mode 100644 index 00000000000..d2bd82bc1fb --- /dev/null +++ b/releases.txt @@ -0,0 +1,71 @@ +6739e12:1.47.0 +100cc59:1.46.0 +c88eb1d:1.45.0 +6afd140:1.44.0 +755fd13:1.43.0 +dfe5da3:1.42.0 +44fa57b:1.41.0 +27dc689:1.38.0 +16e4851:1.37.0 +476c4be:1.36.0 +403cd0e:1.35.0 +7e6d7ab:1.34.0 +6d87b65:1.33.0 +2c35b7b:1.32.0 +b9a7f53:1.31.0 +3978864:1.30.0 +0055e0b:1.29.0 +a0ae465:1.28.0 +bbaec8b:1.27.0 +562d0bf:1.26.0 +d1122c9:1.25.0 +04ac5fe:1.24.0 +0fdbb4a:1.23.0 +a892d71:1.22.0 +098e182:1.21.0 +cb48702:1.20.0 +88af93f:1.19.0 +393ab17:1.18.0 +7301f03:1.17.0 +1e748c6:1.16.0 +d2215ef:1.15.0 +2ede22f:1.14.0 +2545e09:1.13.0 +bc3d800:1.12.0 +f892ee9:1.11.0 +e0fc9a4:1.10.0 +ea0d715:1.9.0 +9bca164:1.8.0 +92d4c0c:1.7.0 +e440776:1.6.0 +6ba35ba:1.5.0 +e6c52b5:1.4.0 +2cc884d:1.3.0 +d51f49f:1.2.0 +4ab4705:1.1.0 +4fe36e6:1.0.0 +fddc8b0:0.72.0-beta +50c96ae:0.71.0-beta +567aa6f:0.70.0-beta +2eca299:0.69.0-beta +cf33def:0.68.0-beta +ea5608d:0.67.0-beta +e006e5b:0.66.0-beta +9e8fce1:0.65.0-beta +3000a36:0.64.0-beta +07ef452:0.63.0-beta +8e7a255:0.62.0-beta +eeaff12:0.61.0-beta +3d387a3:0.60.0-beta +0dc9bc5:0.59.0-beta +2f112a3:0.58.0-beta +85bc9e1:0.56.0-beta +f3c446e:0.55.1-beta +844bc14:0.55.0-beta +0d466be:0.54.0-beta +9d30034:0.53.0-beta +d768f1a:0.52.0-beta +3e6489d:0.51.0-beta +12e3e81:0.50.0-beta +6398093:0.49.0-beta +aa7cacb:0.48.0-beta diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000000..02757c63ad2 --- /dev/null +++ b/renovate.json @@ -0,0 +1,50 @@ +{ + "extends": [ + ":separateMajorReleases", + ":combinePatchMinorReleases", + ":ignoreUnstable", + ":prImmediately", + ":updateNotScheduled", + ":automergeDisabled", + ":ignoreModulesAndTests", + ":maintainLockFilesDisabled", + ":autodetectPinVersions" + ], + "packageRules": [ + { + "packagePatterns": [ + "^com.google.guava:" + ], + "versionScheme": "docker" + }, + { + "packagePatterns": [ + "^com.google.api:gax", + "^com.google.auth:", + "^com.google.cloud:google-cloud-core", + "^io.grpc:" + ], + "groupName": "core dependencies" + }, + { + "packagePatterns": [ + "*" + ], + "semanticCommitType": "deps", + "semanticCommitScope": null + }, + { + "packagePatterns": [ + "^org.apache.maven", + "^org.jacoco:", + "^org.codehaus.mojo:", + "^org.sonatype.plugins:", + "^com.coveo:", + "^com.google.cloud:google-cloud-shared-config" + ], + "semanticCommitType": "build", + "semanticCommitScope": "deps" + } + ], + "semanticCommits": true +} diff --git a/synth.metadata b/synth.metadata new file mode 100644 index 00000000000..7771c46df32 --- /dev/null +++ b/synth.metadata @@ -0,0 +1,793 @@ +{ + "updateTime": "2020-01-02T18:28:01.170427Z", + "sources": [ + { + "generator": { + "name": "artman", + "version": "0.42.3", + "dockerImage": "googleapis/artman@sha256:feed210b5723c6f524b52ef6d7740a030f2d1a8f7c29a71c5e5b4481ceaad7f5" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "ec285d3d230810147ebbf8d5b691ee90320c6d2d", + "internalRef": "287608953" + } + }, + { + "template": { + "name": "java_library", + "origin": "synthtool.gcp", + "version": "2019.10.17" + } + } + ], + "destinations": [ + { + "client": { + "source": "googleapis", + "apiName": "spanner", + "apiVersion": "v1", + "language": "java", + "generator": "gapic", + "config": "google/spanner/artman_spanner.yaml" + } + }, + { + "client": { + "source": "googleapis", + "apiName": "spanner", + "apiVersion": "v1", + "language": "java", + "generator": "gapic", + "config": "google/spanner/admin/database/artman_spanner_admin_database.yaml" + } + }, + { + "client": { + "source": "googleapis", + "apiName": "spanner", + "apiVersion": "v1", + "language": "java", + "generator": "gapic", + "config": "google/spanner/admin/instance/artman_spanner_admin_instance.yaml" + } + } + ], + "newFiles": [ + { + "path": "codecov.yaml" + }, + { + "path": "CONTRIBUTING.md" + }, + { + "path": "license-checks.xml" + }, + { + "path": "java.header" + }, + { + "path": "LICENSE" + }, + { + "path": "CODE_OF_CONDUCT.md" + }, + { + "path": "renovate.json" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponse.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceConfigRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/Instance.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/DeleteInstanceRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadataOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigName.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfigOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceName.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ProjectName.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadata.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfoOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponse.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/SpannerInstanceAdminProto.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ReplicaInfo.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstancesRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceMetadataOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceConfig.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceMetadata.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/CreateInstanceRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/ListInstanceConfigsRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/UpdateInstanceRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/GetInstanceRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-instance-v1/src/main/proto/google/spanner/admin/instance/v1/spanner_instance_admin.proto" + }, + { + "path": "grpc-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerGrpc.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNodeOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/RollbackRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponse.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelectorOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadataOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetMetadata.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeysProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSet.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Transaction.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptionsOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionSelector.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionReadRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PlanNode.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SpannerProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructType.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySetOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRange.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DatabaseName.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSetOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsResponse.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/StructTypeOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BatchCreateSessionsRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptionsOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOptions.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/GetSessionRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStats.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionQueryRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteBatchDmlResponse.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartitionOptions.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/PartialResultSet.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ListSessionsResponse.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitResponse.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Mutation.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ReadRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/SessionName.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeySet.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/MutationProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/KeyRangeOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/BeginTransactionRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TransactionOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Session.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ExecuteSqlRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CommitRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanProto.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlanOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/CreateSessionRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/DeleteSessionRequest.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/ResultSetStatsOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Partition.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/QueryPlan.java" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/transaction.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/query_plan.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/result_set.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/mutation.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/keys.proto" + }, + { + "path": "proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/spanner.proto" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadata.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlMetadataOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadataOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseMetadata.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseName.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponse.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateDatabaseDdlRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponse.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/InstanceName.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DropDatabaseRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateDatabaseRequestOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListDatabasesResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlRequest.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetDatabaseDdlResponseOrBuilder.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Database.java" + }, + { + "path": "proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/v1/MockSpanner.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/v1/MockSpannerImpl.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/v1/SpannerClientTest.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdmin.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClientTest.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/MockInstanceAdmin.java" + }, + { + "path": "google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/instance/v1/MockInstanceAdminImpl.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/package-info.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerClient.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/SpannerSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerStub.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/GrpcSpannerCallableFactory.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStub.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/package-info.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminCallableFactory.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/package-info.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/InstanceAdminClient.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminCallableFactory.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/GrpcInstanceAdminStub.java" + }, + { + "path": "google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStub.java" + }, + { + "path": ".kokoro/dependencies.sh" + }, + { + "path": ".kokoro/trampoline.sh" + }, + { + "path": ".kokoro/linkage-monitor.sh" + }, + { + "path": ".kokoro/build.sh" + }, + { + "path": ".kokoro/coerce_logs.sh" + }, + { + "path": ".kokoro/build.bat" + }, + { + "path": ".kokoro/common.cfg" + }, + { + "path": ".kokoro/presubmit/dependencies.cfg" + }, + { + "path": ".kokoro/presubmit/linkage-monitor.cfg" + }, + { + "path": ".kokoro/presubmit/java7.cfg" + }, + { + "path": ".kokoro/presubmit/integration.cfg" + }, + { + "path": ".kokoro/presubmit/clirr.cfg" + }, + { + "path": ".kokoro/presubmit/java11.cfg" + }, + { + "path": ".kokoro/presubmit/java8.cfg" + }, + { + "path": ".kokoro/presubmit/lint.cfg" + }, + { + "path": ".kokoro/presubmit/java8-win.cfg" + }, + { + "path": ".kokoro/presubmit/java8-osx.cfg" + }, + { + "path": ".kokoro/presubmit/common.cfg" + }, + { + "path": ".kokoro/continuous/propose_release.sh" + }, + { + "path": ".kokoro/continuous/propose_release.cfg" + }, + { + "path": ".kokoro/continuous/dependencies.cfg" + }, + { + "path": ".kokoro/continuous/java7.cfg" + }, + { + "path": ".kokoro/continuous/integration.cfg" + }, + { + "path": ".kokoro/continuous/java11.cfg" + }, + { + "path": ".kokoro/continuous/java8.cfg" + }, + { + "path": ".kokoro/continuous/lint.cfg" + }, + { + "path": ".kokoro/continuous/java8-win.cfg" + }, + { + "path": ".kokoro/continuous/java8-osx.cfg" + }, + { + "path": ".kokoro/continuous/common.cfg" + }, + { + "path": ".kokoro/nightly/dependencies.cfg" + }, + { + "path": ".kokoro/nightly/java7.cfg" + }, + { + "path": ".kokoro/nightly/integration.cfg" + }, + { + "path": ".kokoro/nightly/java11.cfg" + }, + { + "path": ".kokoro/nightly/java8.cfg" + }, + { + "path": ".kokoro/nightly/lint.cfg" + }, + { + "path": ".kokoro/nightly/java8-win.cfg" + }, + { + "path": ".kokoro/nightly/java8-osx.cfg" + }, + { + "path": ".kokoro/nightly/common.cfg" + }, + { + "path": ".kokoro/release/bump_snapshot.cfg" + }, + { + "path": ".kokoro/release/stage.sh" + }, + { + "path": ".kokoro/release/promote.sh" + }, + { + "path": ".kokoro/release/snapshot.sh" + }, + { + "path": ".kokoro/release/drop.cfg" + }, + { + "path": ".kokoro/release/snapshot.cfg" + }, + { + "path": ".kokoro/release/publish_javadoc.cfg" + }, + { + "path": ".kokoro/release/publish_javadoc.sh" + }, + { + "path": ".kokoro/release/bump_snapshot.sh" + }, + { + "path": ".kokoro/release/drop.sh" + }, + { + "path": ".kokoro/release/common.cfg" + }, + { + "path": ".kokoro/release/common.sh" + }, + { + "path": ".kokoro/release/stage.cfg" + }, + { + "path": ".kokoro/release/promote.cfg" + }, + { + "path": ".github/PULL_REQUEST_TEMPLATE.md" + }, + { + "path": ".github/release-please.yml" + }, + { + "path": ".github/ISSUE_TEMPLATE/support_request.md" + }, + { + "path": ".github/ISSUE_TEMPLATE/feature_request.md" + }, + { + "path": ".github/ISSUE_TEMPLATE/bug_report.md" + }, + { + "path": "__pycache__/synth.cpython-36.pyc" + }, + { + "path": "grpc-google-cloud-spanner-admin-instance-v1/src/main/java/com/google/spanner/admin/instance/v1/InstanceAdminGrpc.java" + }, + { + "path": "grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java" + } + ] +} \ No newline at end of file diff --git a/synth.py b/synth.py new file mode 100644 index 00000000000..45418c56329 --- /dev/null +++ b/synth.py @@ -0,0 +1,72 @@ +# Copyright 2018 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 +# +# http://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. + +"""This script is used to synthesize generated parts of this library.""" + +import synthtool as s +import synthtool.gcp as gcp +import synthtool.languages.java as java + +gapic = gcp.GAPICGenerator() + +library = gapic.java_library( + service='spanner', + version='v1', + config_path='/google/spanner/artman_spanner.yaml', + artman_output_name='') + +java.fix_proto_headers(library / 'proto-google-cloud-spanner-v1') +java.fix_grpc_headers(library / 'grpc-google-cloud-spanner-v1', 'com.google.spanner.v1') +s.copy(library / 'gapic-google-cloud-spanner-v1/src', 'google-cloud-spanner/src') +s.copy(library / 'grpc-google-cloud-spanner-v1/src', 'grpc-google-cloud-spanner-v1/src') +s.copy(library / 'proto-google-cloud-spanner-v1/src', 'proto-google-cloud-spanner-v1/src') + +library = gapic.java_library( + service='spanner', + version='v1', + config_path='/google/spanner/admin/database/artman_spanner_admin_database.yaml', + artman_output_name='') + +java.fix_proto_headers(library / 'proto-google-cloud-spanner-admin-database-v1') +java.fix_grpc_headers(library / 'grpc-google-cloud-spanner-admin-database-v1', 'com.google.spanner.admin.database.v1') +s.copy(library / 'gapic-google-cloud-spanner-admin-database-v1/src', 'google-cloud-spanner/src') +s.copy(library / 'grpc-google-cloud-spanner-admin-database-v1/src', 'grpc-google-cloud-spanner-admin-database-v1/src') +s.copy(library / 'proto-google-cloud-spanner-admin-database-v1/src', 'proto-google-cloud-spanner-admin-database-v1/src') + +library = gapic.java_library( + service='spanner', + version='v1', + config_path='/google/spanner/admin/instance/artman_spanner_admin_instance.yaml', + artman_output_name='') + +java.fix_proto_headers(library / 'proto-google-cloud-spanner-admin-instance-v1') +java.fix_grpc_headers(library / 'grpc-google-cloud-spanner-admin-instance-v1', 'com.google.spanner.admin.instance.v1') +s.copy(library / 'gapic-google-cloud-spanner-admin-instance-v1/src', 'google-cloud-spanner/src') +s.copy(library / 'grpc-google-cloud-spanner-admin-instance-v1/src', 'grpc-google-cloud-spanner-admin-instance-v1/src') +s.copy(library / 'proto-google-cloud-spanner-admin-instance-v1/src', 'proto-google-cloud-spanner-admin-instance-v1/src') + +java.format_code('google-cloud-spanner/src') +java.format_code('grpc-google-cloud-spanner-v1/src') +java.format_code('proto-google-cloud-spanner-v1/src') +java.format_code('grpc-google-cloud-spanner-admin-database-v1/src') +java.format_code('proto-google-cloud-spanner-admin-database-v1/src') +java.format_code('grpc-google-cloud-spanner-admin-instance-v1/src') +java.format_code('proto-google-cloud-spanner-admin-instance-v1/src') + +common_templates = gcp.CommonTemplates() +templates = common_templates.java_library() +s.copy(templates, excludes=[ + 'README.md', + '.kokoro/common.cfg' +]) diff --git a/versions.txt b/versions.txt new file mode 100644 index 00000000000..58baffef47a --- /dev/null +++ b/versions.txt @@ -0,0 +1,10 @@ +# Format: +# module:released-version:current-version + +proto-google-cloud-spanner-admin-instance-v1:1.47.0:1.47.1-SNAPSHOT +proto-google-cloud-spanner-v1:1.47.0:1.47.1-SNAPSHOT +proto-google-cloud-spanner-admin-database-v1:1.47.0:1.47.1-SNAPSHOT +grpc-google-cloud-spanner-v1:1.47.0:1.47.1-SNAPSHOT +grpc-google-cloud-spanner-admin-instance-v1:1.47.0:1.47.1-SNAPSHOT +grpc-google-cloud-spanner-admin-database-v1:1.47.0:1.47.1-SNAPSHOT +google-cloud-spanner:1.47.0:1.47.1-SNAPSHOT \ No newline at end of file