mutation.proto 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.spanner.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/protobuf/struct.proto";
  18. import "google/spanner/v1/keys.proto";
  19. option csharp_namespace = "Google.Cloud.Spanner.V1";
  20. option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
  21. option java_multiple_files = true;
  22. option java_outer_classname = "MutationProto";
  23. option java_package = "com.google.spanner.v1";
  24. option php_namespace = "Google\\Cloud\\Spanner\\V1";
  25. option ruby_package = "Google::Cloud::Spanner::V1";
  26. // A modification to one or more Cloud Spanner rows. Mutations can be
  27. // applied to a Cloud Spanner database by sending them in a
  28. // [Commit][google.spanner.v1.Spanner.Commit] call.
  29. message Mutation {
  30. // Arguments to [insert][google.spanner.v1.Mutation.insert], [update][google.spanner.v1.Mutation.update], [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and
  31. // [replace][google.spanner.v1.Mutation.replace] operations.
  32. message Write {
  33. // Required. The table whose rows will be written.
  34. string table = 1 [(google.api.field_behavior) = REQUIRED];
  35. // The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written.
  36. //
  37. // The list of columns must contain enough columns to allow
  38. // Cloud Spanner to derive values for all primary key columns in the
  39. // row(s) to be modified.
  40. repeated string columns = 2;
  41. // The values to be written. `values` can contain more than one
  42. // list of values. If it does, then multiple rows are written, one
  43. // for each entry in `values`. Each list in `values` must have
  44. // exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns]
  45. // above. Sending multiple lists is equivalent to sending multiple
  46. // `Mutation`s, each containing one `values` entry and repeating
  47. // [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are
  48. // encoded as described [here][google.spanner.v1.TypeCode].
  49. repeated google.protobuf.ListValue values = 3;
  50. }
  51. // Arguments to [delete][google.spanner.v1.Mutation.delete] operations.
  52. message Delete {
  53. // Required. The table whose rows will be deleted.
  54. string table = 1 [(google.api.field_behavior) = REQUIRED];
  55. // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The
  56. // primary keys must be specified in the order in which they appear in the
  57. // `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL
  58. // statement used to create the table).
  59. // Delete is idempotent. The transaction will succeed even if some or all
  60. // rows do not exist.
  61. KeySet key_set = 2 [(google.api.field_behavior) = REQUIRED];
  62. }
  63. // Required. The operation to perform.
  64. oneof operation {
  65. // Insert new rows in a table. If any of the rows already exist,
  66. // the write or transaction fails with error `ALREADY_EXISTS`.
  67. Write insert = 1;
  68. // Update existing rows in a table. If any of the rows does not
  69. // already exist, the transaction fails with error `NOT_FOUND`.
  70. Write update = 2;
  71. // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then
  72. // its column values are overwritten with the ones provided. Any
  73. // column values not explicitly written are preserved.
  74. //
  75. // When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT
  76. // NULL` columns in the table must be given a value. This holds true
  77. // even when the row already exists and will therefore actually be updated.
  78. Write insert_or_update = 3;
  79. // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is
  80. // deleted, and the column values provided are inserted
  81. // instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not
  82. // explicitly written become `NULL`.
  83. //
  84. // In an interleaved table, if you create the child table with the
  85. // `ON DELETE CASCADE` annotation, then replacing a parent row
  86. // also deletes the child rows. Otherwise, you must delete the
  87. // child rows before you replace the parent row.
  88. Write replace = 4;
  89. // Delete rows from a table. Succeeds whether or not the named
  90. // rows were present.
  91. Delete delete = 5;
  92. }
  93. }