SQL: change Statement::Column* signatures [chromium/src : main]

0 views
Skip to first unread message

Evan Stade (Gerrit)

unread,
Oct 7, 2025, 4:45:18 PM (3 days ago) Oct 7
to Greg Thompson, Jihad Hanna, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
Attention needed from Colin Blundell, Greg Thompson and Jihad Hanna

Evan Stade added 1 comment

Patchset-level comments
File-level comment, Patchset 10:
Evan Stade . resolved

Greg ptal //sql
Colin ptal (mechanical) changes in //components

Note that the CheckCanReadColumn checks did catch one error in autofill db migration code. (See crbug.com/449188903) Unfortunately this didn't get turned into a crbug issue until Oct 3 which was after M142 branched and these DCHECKs became CHECKs. But that issue is being addressed separately so it seems like we can go ahead and make the planned updates.

Open in Gerrit

Related details

Attention is currently required from:
  • Colin Blundell
  • Greg Thompson
  • Jihad Hanna
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
Gerrit-Change-Number: 6862477
Gerrit-PatchSet: 10
Gerrit-Owner: Evan Stade <evan...@microsoft.com>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
Gerrit-Reviewer: Jihad Hanna <jihad...@google.com>
Gerrit-Attention: Colin Blundell <blun...@chromium.org>
Gerrit-Attention: Jihad Hanna <jihad...@google.com>
Gerrit-Attention: Greg Thompson <g...@chromium.org>
Gerrit-Comment-Date: Tue, 07 Oct 2025 20:44:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Colin Blundell (Gerrit)

unread,
Oct 8, 2025, 3:50:36 AM (3 days ago) Oct 8
to Evan Stade, Colin Blundell, Greg Thompson, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
Attention needed from Evan Stade and Greg Thompson

Colin Blundell voted and added 1 comment

Votes added by Colin Blundell

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Colin Blundell . resolved

Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Evan Stade
  • Greg Thompson
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
    Gerrit-Change-Number: 6862477
    Gerrit-PatchSet: 11
    Gerrit-Owner: Evan Stade <evan...@microsoft.com>
    Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
    Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
    Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
    Gerrit-Attention: Evan Stade <evan...@microsoft.com>
    Gerrit-Attention: Greg Thompson <g...@chromium.org>
    Gerrit-Comment-Date: Wed, 08 Oct 2025 07:49:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Greg Thompson (Gerrit)

    unread,
    Oct 8, 2025, 4:35:01 AM (3 days ago) Oct 8
    to Evan Stade, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
    Attention needed from Evan Stade

    Greg Thompson added 12 comments

    Patchset-level comments
    Greg Thompson . resolved

    mainly lgtm w/ cleanups below. thanks for this. the API is much cleaner this way.

    File components/favicon/core/favicon_database.cc
    Line 378, Patchset 11 (Latest): if (!bitmap_data_blob.empty()) {
    Greg Thompson . unresolved
    this value is only needed within the `if`, so:
    ```
    if (auto blob = ...; !blob.empty()) {
    ...
    }
    ```
    File components/password_manager/core/browser/password_store/login_database_ios_unittest.cc
    Line 347, Patchset 11 (Latest): results.push_back(std::move(encrypted_password));
    Greg Thompson . unresolved

    let's just inline `s.ColumnBlobAsString(0)` here

    Line 364, Patchset 11 (Latest): results.push_back(std::move(encrypted_note));
    Greg Thompson . unresolved

    `s.ColumnBlobAsString(0)` inline

    File components/signin/public/webdata/token_service_table.cc
    Line 206, Patchset 11 (Latest): if (entry_ok) {
    Greg Thompson . unresolved

    inline `!service.empty()` here

    File sql/statement.cc
    Line 111, Patchset 11 (Latest): CHECK_EQ(last_sqlite_result_code_.value(), SqliteResultCode::kRow)
    Greg Thompson . unresolved

    this will cause a crash within the call to `value()` if `last_sqlite_result_code_` doesn't hold a value. this might be a bit confusing to diagnose if it happens. wdyt about changing this to something like `.value_or(SqliteResultCode::kOk)` so that the `CHECK_EQ` will fire in all cases?

    Line 112, Patchset 11 (Latest): << " reading from columns must happen after Step() is called and "
    "returns true";
    Greg Thompson . unresolved

    strings like this take up space in the binary for little benefit. please move this into a comment that immediately precedes the `CHECK_EQ`. it will be trivial to find if this `CHECK` is ever hit.

    Line 120, Patchset 11 (Parent): CHECK_GE(column_index, 0, base::NotFatalUntil::M142);
    Greg Thompson . unresolved

    please retain this check. if you don't think it's necessary: why?

    Line 577, Patchset 11 (Latest): const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
    Greg Thompson . unresolved

    while you're here, please swap the order of these two lines as per https://www.sqlite.org/c3ref/column_blob.html: "you should call sqlite3_column_text(), sqlite3_column_blob(), or sqlite3_column_text16() first to force the result into the desired format, then invoke sqlite3_column_bytes() or sqlite3_column_bytes16() to find the size of the result."

    Line 587, Patchset 11 (Latest): CheckCanReadColumn(column_index);

    const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
    int size = sqlite3_column_bytes(ref_->stmt(), column_index);
    if (result_buffer && size > 0) {
    return std::string(reinterpret_cast<const char*>(result_buffer), size);
    }

    return {};
    Greg Thompson . unresolved
    can we reduce this whole function to:
    ```
    return std::string(base::as_string_view(ColumnBlob(column_index)));
    ```
    (#include "base/strings/string_view_util.h)
    Line 600, Patchset 11 (Latest): CheckCanReadColumn(column_index);

    const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
    int size = sqlite3_column_bytes(ref_->stmt(), column_index);
    if (result_buffer && size > 0) {
    return std::u16string(reinterpret_cast<const char16_t*>(result_buffer),
    size / 2);
    }

    return {};
    Greg Thompson . unresolved
    as above, let's avoid duplication. maybe something like:
    ```
    auto byte_span = ColumnBlob(column_index);
    base::span u16char_span(reinterpret_cast<const char16_t*>(byte_span.data()),
    byte_span.size() / 2);
    return std::u16string(base::as_string_view(u16char_span));
    ```
    i wonder if there's an even cleaner way to do the cast.
    although typing that out, i see that we run the risk of unaligned reads. so maybe it's better to memcpy the data into the resulting string. perhaps:
    ```
    auto byte_span = ColumnBlob(column_index);
    std::u16string result(byte_span.size() / 2, 0u);
    std::ranges::copy(byte_span, base::as_writable_byte_span(result).begin());
    return result;
    ```
    that has the unfortunate side effect of zero-initializing the output string before putting the data into it, but it should avoid unaligned reads.
    Line 614, Patchset 11 (Latest): CheckCanReadColumn(column_index);

    const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
    int size = sqlite3_column_bytes(ref_->stmt(), column_index);
    if (result_buffer && size > 0) {
    return base::ToVector(base::span(static_cast<const uint8_t*>(result_buffer),
    static_cast<size_t>(size)));
    }

    return {};
    Greg Thompson . unresolved
    ```
    auto byte_span = ColumnBlob(column_index);
    return std::vector<uint8_t>(byte_span.begin(), byte_span.end());
    ```
    (and remove the #include of to_vector.h)
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Evan Stade
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
      Gerrit-Change-Number: 6862477
      Gerrit-PatchSet: 11
      Gerrit-Owner: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
      Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
      Gerrit-Attention: Evan Stade <evan...@microsoft.com>
      Gerrit-Comment-Date: Wed, 08 Oct 2025 08:33:59 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Evan Stade (Gerrit)

      unread,
      Oct 8, 2025, 4:24:53 PM (2 days ago) Oct 8
      to Colin Blundell, Greg Thompson, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
      Attention needed from Greg Thompson

      Evan Stade added 11 comments

      File components/favicon/core/favicon_database.cc
      Line 378, Patchset 11: if (!bitmap_data_blob.empty()) {
      Greg Thompson . resolved
      this value is only needed within the `if`, so:
      ```
      if (auto blob = ...; !blob.empty()) {
      ...
      }
      ```
      Evan Stade

      Done

      File components/password_manager/core/browser/password_store/login_database_ios_unittest.cc
      Line 347, Patchset 11: results.push_back(std::move(encrypted_password));
      Greg Thompson . resolved

      let's just inline `s.ColumnBlobAsString(0)` here

      Evan Stade

      Done

      Line 364, Patchset 11: results.push_back(std::move(encrypted_note));
      Greg Thompson . resolved

      `s.ColumnBlobAsString(0)` inline

      Evan Stade

      Done

      File components/signin/public/webdata/token_service_table.cc
      Line 206, Patchset 11: if (entry_ok) {
      Greg Thompson . resolved

      inline `!service.empty()` here

      Evan Stade

      Done

      File sql/statement.cc
      Line 111, Patchset 11: CHECK_EQ(last_sqlite_result_code_.value(), SqliteResultCode::kRow)
      Greg Thompson . unresolved

      this will cause a crash within the call to `value()` if `last_sqlite_result_code_` doesn't hold a value. this might be a bit confusing to diagnose if it happens. wdyt about changing this to something like `.value_or(SqliteResultCode::kOk)` so that the `CHECK_EQ` will fire in all cases?

      Evan Stade

      Using `.value_or(SqliteResultCode::kOk)` wouldn't distinguish between when the value was actually `kOk` and when it was missing, so I guess that a separate `CHECK(has_value())` seems the least confusing/ambiguous to me.

      Line 112, Patchset 11: << " reading from columns must happen after Step() is called and "
      "returns true";
      Greg Thompson . resolved

      strings like this take up space in the binary for little benefit. please move this into a comment that immediately precedes the `CHECK_EQ`. it will be trivial to find if this `CHECK` is ever hit.

      Evan Stade

      Done

      Line 120, Patchset 11 (Parent): CHECK_GE(column_index, 0, base::NotFatalUntil::M142);
      Greg Thompson . resolved

      please retain this check. if you don't think it's necessary: why?

      Evan Stade

      oops, restored.

      Line 577, Patchset 11: const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      Greg Thompson . resolved

      while you're here, please swap the order of these two lines as per https://www.sqlite.org/c3ref/column_blob.html: "you should call sqlite3_column_text(), sqlite3_column_blob(), or sqlite3_column_text16() first to force the result into the desired format, then invoke sqlite3_column_bytes() or sqlite3_column_bytes16() to find the size of the result."

      Evan Stade

      Done

      Line 587, Patchset 11: CheckCanReadColumn(column_index);


      const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      int size = sqlite3_column_bytes(ref_->stmt(), column_index);
      if (result_buffer && size > 0) {
      return std::string(reinterpret_cast<const char*>(result_buffer), size);
      }

      return {};
      Greg Thompson . resolved
      can we reduce this whole function to:
      ```
      return std::string(base::as_string_view(ColumnBlob(column_index)));
      ```
      (#include "base/strings/string_view_util.h)
      Evan Stade

      Done

      Line 600, Patchset 11: CheckCanReadColumn(column_index);


      const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      int size = sqlite3_column_bytes(ref_->stmt(), column_index);
      if (result_buffer && size > 0) {
      return std::u16string(reinterpret_cast<const char16_t*>(result_buffer),
      size / 2);
      }

      return {};
      Greg Thompson . unresolved
      as above, let's avoid duplication. maybe something like:
      ```
      auto byte_span = ColumnBlob(column_index);
      base::span u16char_span(reinterpret_cast<const char16_t*>(byte_span.data()),
      byte_span.size() / 2);
      return std::u16string(base::as_string_view(u16char_span));
      ```
      i wonder if there's an even cleaner way to do the cast.
      although typing that out, i see that we run the risk of unaligned reads. so maybe it's better to memcpy the data into the resulting string. perhaps:
      ```
      auto byte_span = ColumnBlob(column_index);
      std::u16string result(byte_span.size() / 2, 0u);
      std::ranges::copy(byte_span, base::as_writable_byte_span(result).begin());
      return result;
      ```
      that has the unfortunate side effect of zero-initializing the output string before putting the data into it, but it should avoid unaligned reads.
      Evan Stade

      Done, but this makes me wonder if this one's signature needs to remain as is, in case the blob has an odd number of bytes. That should probably be reported as an error rather than ignored. WDYT?

      Line 614, Patchset 11: CheckCanReadColumn(column_index);


      const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      int size = sqlite3_column_bytes(ref_->stmt(), column_index);
      if (result_buffer && size > 0) {
      return base::ToVector(base::span(static_cast<const uint8_t*>(result_buffer),
      static_cast<size_t>(size)));
      }

      return {};
      Greg Thompson . resolved
      ```
      auto byte_span = ColumnBlob(column_index);
      return std::vector<uint8_t>(byte_span.begin(), byte_span.end());
      ```
      (and remove the #include of to_vector.h)
      Evan Stade

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Greg Thompson
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
      Gerrit-Change-Number: 6862477
      Gerrit-PatchSet: 11
      Gerrit-Owner: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
      Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
      Gerrit-Attention: Greg Thompson <g...@chromium.org>
      Gerrit-Comment-Date: Wed, 08 Oct 2025 20:24:24 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Greg Thompson (Gerrit)

      unread,
      Oct 9, 2025, 3:35:03 AM (2 days ago) Oct 9
      to Evan Stade, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
      Attention needed from Evan Stade

      Greg Thompson voted and added 5 comments

      Votes added by Greg Thompson

      Code-Review+1

      5 comments

      Patchset-level comments
      File-level comment, Patchset 12 (Latest):
      Greg Thompson . resolved

      lgtm w/ nits/tweaks. thanks.

      File sql/statement.cc
      Line 111, Patchset 11: CHECK_EQ(last_sqlite_result_code_.value(), SqliteResultCode::kRow)
      Greg Thompson . resolved

      this will cause a crash within the call to `value()` if `last_sqlite_result_code_` doesn't hold a value. this might be a bit confusing to diagnose if it happens. wdyt about changing this to something like `.value_or(SqliteResultCode::kOk)` so that the `CHECK_EQ` will fire in all cases?

      Evan Stade

      Using `.value_or(SqliteResultCode::kOk)` wouldn't distinguish between when the value was actually `kOk` and when it was missing, so I guess that a separate `CHECK(has_value())` seems the least confusing/ambiguous to me.

      Greg Thompson

      Acknowledged

      Line 113, Patchset 12 (Latest): CHECK_EQ(last_sqlite_result_code_.value(), SqliteResultCode::kRow);
      Greg Thompson . unresolved

      nit: now that the line above asserts that this holds a value, please switch to `*last_sqlite_result_code_` here.

      Line 590, Patchset 12 (Latest): std::ranges::copy(bytes, base::as_writable_byte_span(result).begin());
      Greg Thompson . unresolved

      Please fix this WARNING reported by ClangTidy: check: misc-include-cleaner

      no header providing "std::ranges::copy" is directly...

      check: misc-include-cleaner

      no header providing "std::ranges::copy" is directly included (https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html)

      (Note: You can add `Skip-Clang-Tidy-Checks: misc-include-cleaner` footer to the CL description to skip the check)

      (Lint observed on `android-clang-tidy-rel` and `linux-clang-tidy-rel`)

      Line 600, Patchset 11: CheckCanReadColumn(column_index);

      const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      int size = sqlite3_column_bytes(ref_->stmt(), column_index);
      if (result_buffer && size > 0) {
      return std::u16string(reinterpret_cast<const char16_t*>(result_buffer),
      size / 2);
      }

      return {};
      Greg Thompson . unresolved
      as above, let's avoid duplication. maybe something like:
      ```
      auto byte_span = ColumnBlob(column_index);
      base::span u16char_span(reinterpret_cast<const char16_t*>(byte_span.data()),
      byte_span.size() / 2);
      return std::u16string(base::as_string_view(u16char_span));
      ```
      i wonder if there's an even cleaner way to do the cast.
      although typing that out, i see that we run the risk of unaligned reads. so maybe it's better to memcpy the data into the resulting string. perhaps:
      ```
      auto byte_span = ColumnBlob(column_index);
      std::u16string result(byte_span.size() / 2, 0u);
      std::ranges::copy(byte_span, base::as_writable_byte_span(result).begin());
      return result;
      ```
      that has the unfortunate side effect of zero-initializing the output string before putting the data into it, but it should avoid unaligned reads.
      Evan Stade

      Done, but this makes me wonder if this one's signature needs to remain as is, in case the blob has an odd number of bytes. That should probably be reported as an error rather than ignored. WDYT?

      Greg Thompson

      good point. this should be documented, no? something about returning an empty string if the column data isn't an integral number of code units. maybe also worth stating that the column data is not checked to ensure that it's valid UTF-16 (e.g., it could contain invalid code points or invalid/incomplete surrogate pairs).

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Evan Stade
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
      Gerrit-Change-Number: 6862477
      Gerrit-PatchSet: 12
      Gerrit-Owner: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
      Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
      Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
      Gerrit-Attention: Evan Stade <evan...@microsoft.com>
      Gerrit-Comment-Date: Thu, 09 Oct 2025 07:33:57 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Evan Stade <evan...@microsoft.com>
      Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Evan Stade (Gerrit)

      unread,
      Oct 9, 2025, 10:06:44 PM (2 days ago) Oct 9
      to Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
      Attention needed from Colin Blundell and Greg Thompson

      Evan Stade added 3 comments

      File sql/statement.cc
      Line 113, Patchset 12: CHECK_EQ(last_sqlite_result_code_.value(), SqliteResultCode::kRow);
      Greg Thompson . resolved

      nit: now that the line above asserts that this holds a value, please switch to `*last_sqlite_result_code_` here.

      Evan Stade

      Done

      Line 590, Patchset 12: std::ranges::copy(bytes, base::as_writable_byte_span(result).begin());
      Greg Thompson . resolved

      Please fix this WARNING reported by ClangTidy: check: misc-include-cleaner

      no header providing "std::ranges::copy" is directly...

      check: misc-include-cleaner

      no header providing "std::ranges::copy" is directly included (https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html)

      (Note: You can add `Skip-Clang-Tidy-Checks: misc-include-cleaner` footer to the CL description to skip the check)

      (Lint observed on `android-clang-tidy-rel` and `linux-clang-tidy-rel`)

      Evan Stade

      Done

      Line 600, Patchset 11: CheckCanReadColumn(column_index);

      const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
      int size = sqlite3_column_bytes(ref_->stmt(), column_index);
      if (result_buffer && size > 0) {
      return std::u16string(reinterpret_cast<const char16_t*>(result_buffer),
      size / 2);
      }

      return {};
      Greg Thompson . unresolved
      as above, let's avoid duplication. maybe something like:
      ```
      auto byte_span = ColumnBlob(column_index);
      base::span u16char_span(reinterpret_cast<const char16_t*>(byte_span.data()),
      byte_span.size() / 2);
      return std::u16string(base::as_string_view(u16char_span));
      ```
      i wonder if there's an even cleaner way to do the cast.
      although typing that out, i see that we run the risk of unaligned reads. so maybe it's better to memcpy the data into the resulting string. perhaps:
      ```
      auto byte_span = ColumnBlob(column_index);
      std::u16string result(byte_span.size() / 2, 0u);
      std::ranges::copy(byte_span, base::as_writable_byte_span(result).begin());
      return result;
      ```
      that has the unfortunate side effect of zero-initializing the output string before putting the data into it, but it should avoid unaligned reads.
      Evan Stade

      Done, but this makes me wonder if this one's signature needs to remain as is, in case the blob has an odd number of bytes. That should probably be reported as an error rather than ignored. WDYT?

      Greg Thompson

      good point. this should be documented, no? something about returning an empty string if the column data isn't an integral number of code units. maybe also worth stating that the column data is not checked to ensure that it's valid UTF-16 (e.g., it could contain invalid code points or invalid/incomplete surrogate pairs).

      Evan Stade

      I actually meant that we should revert to the original signature. A blob can validly be empty, so we should distinguish between this type of error and the empty blob case. This error could be indicative of a coding error or database corruption.

      I did throw on a `[[nodiscard]]` to make sure callers aren't ignoring this error. We could switch to returning `std::optional<u16string>`, but that leads to somewhat more verbose code at callsites.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Colin Blundell
      • Greg Thompson
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
        Gerrit-Change-Number: 6862477
        Gerrit-PatchSet: 16
        Gerrit-Owner: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
        Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
        Gerrit-Attention: Colin Blundell <blun...@chromium.org>
        Gerrit-Attention: Greg Thompson <g...@chromium.org>
        Gerrit-Comment-Date: Fri, 10 Oct 2025 02:06:17 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Evan Stade (Gerrit)

        unread,
        Oct 9, 2025, 10:08:15 PM (2 days ago) Oct 9
        to Alex Moshchuk, Abhishek Shanthkumar, Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
        Attention needed from Abhishek Shanthkumar, Alex Moshchuk, Colin Blundell and Greg Thompson

        Evan Stade added 1 comment

        Patchset-level comments
        File-level comment, Patchset 16 (Latest):
        Evan Stade . resolved

        +Abhishek ptal database_connection*
        +Alex ptal aggregation_service_storage_sql.cc

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Abhishek Shanthkumar
        • Alex Moshchuk
        • Colin Blundell
        • Greg Thompson
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
        Gerrit-Change-Number: 6862477
        Gerrit-PatchSet: 16
        Gerrit-Owner: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
        Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
        Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
        Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Attention: Colin Blundell <blun...@chromium.org>
        Gerrit-Attention: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
        Gerrit-Attention: Greg Thompson <g...@chromium.org>
        Gerrit-Comment-Date: Fri, 10 Oct 2025 02:07:47 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Greg Thompson (Gerrit)

        unread,
        Oct 10, 2025, 3:12:37 AM (22 hours ago) Oct 10
        to Evan Stade, Alex Moshchuk, Abhishek Shanthkumar, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
        Attention needed from Abhishek Shanthkumar, Alex Moshchuk, Colin Blundell and Evan Stade

        Greg Thompson added 4 comments

        File content/browser/indexed_db/instance/sqlite/database_connection.cc
        Line 121, Patchset 16 (Latest):StatusOr<blink::IndexedDBKeyPath> ColumnKeyPath(sql::Statement& statement,
        Greg Thompson . unresolved

        `StatusOr` is [banned](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-features.md#statusor-banned); use `base::expected` if you want to return a value in the error case, or `std::optional` otherwise.

        Line 127, Patchset 16 (Latest): std::u16string encoded;
        if (!statement.ColumnBlobAsString16(column_index, &encoded)) {
        return base::unexpected(Status::Corruption("Key path unexpected size"));
        }
        Greg Thompson . unresolved

        `ASSIGN_OR_RETURN(std::u16string encoded, statement.ColumnBlobAsString16(column_index, &encoded));` with a lambda if needed to adjust the return type.

        File sql/statement.cc
        Greg Thompson

        ah. `optional` is far better, imo. not only is it more idiomatic and consistent with the style guide, but we have helpers to make it easy for callers; see other comments.

        File sql/statement_unittest.cc
        Line 291, Patchset 16 (Latest): EXPECT_TRUE(select.ColumnBlobAsString16(0, &column_value));
        EXPECT_EQ(value, column_value);
        Greg Thompson . unresolved

        `EXPECT_THAT(select.ColumnBlobAsString16(0, &column_value), ValueIs(value));`

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Abhishek Shanthkumar
        • Alex Moshchuk
        • Colin Blundell
        • Evan Stade
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
        Gerrit-Change-Number: 6862477
        Gerrit-PatchSet: 16
        Gerrit-Owner: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
        Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
        Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
        Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
        Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
        Gerrit-Attention: Evan Stade <evan...@microsoft.com>
        Gerrit-Attention: Colin Blundell <blun...@chromium.org>
        Gerrit-Attention: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
        Gerrit-Comment-Date: Fri, 10 Oct 2025 07:11:39 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Abhishek Shanthkumar (Gerrit)

        unread,
        Oct 10, 2025, 5:36:14 AM (20 hours ago) Oct 10
        to Evan Stade, Alex Moshchuk, Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
        Attention needed from Alex Moshchuk, Colin Blundell and Evan Stade

        Abhishek Shanthkumar voted and added 3 comments

        Votes added by Abhishek Shanthkumar

        Code-Review+1

        3 comments

        Patchset-level comments
        Abhishek Shanthkumar . resolved

        content/browser/indexed_db/instance/sqlite/database_connection.[h,cc] LGTM % a couple of suggestions.

        File content/browser/indexed_db/instance/sqlite/database_connection.cc
        Line 2007, Patchset 16 (Latest): SpecificEvent::kDatabaseNameMismatch));
        Abhishek Shanthkumar . unresolved

        I wonder if reusing this event type is the best approach, and if not logging the event in other places is OK. Could we add a new type and use it everywhere?

        Line 2050, Patchset 16 (Latest): StatusOr<blink::IndexedDBKeyPath> key_path = ColumnKeyPath(statement, 3);
        if (!key_path.has_value()) {
        return base::unexpected(Fatal(key_path.error()));
        }
        index_metadata.key_path = *std::move(key_path);
        Abhishek Shanthkumar . unresolved

        Can use `ASSIGN_OR_RETURN` I believe?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Moshchuk
        • Colin Blundell
        • Evan Stade
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
          Gerrit-Change-Number: 6862477
          Gerrit-PatchSet: 16
          Gerrit-Owner: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
          Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
          Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Attention: Evan Stade <evan...@microsoft.com>
          Gerrit-Attention: Colin Blundell <blun...@chromium.org>
          Gerrit-Comment-Date: Fri, 10 Oct 2025 09:33:50 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Alex Moshchuk (Gerrit)

          unread,
          Oct 10, 2025, 2:45:34 PM (11 hours ago) Oct 10
          to Evan Stade, Abhishek Shanthkumar, Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
          Attention needed from Colin Blundell and Evan Stade

          Alex Moshchuk voted and added 2 comments

          Votes added by Alex Moshchuk

          Code-Review+1

          2 comments

          Patchset-level comments
          Evan Stade . resolved

          +Abhishek ptal database_connection*
          +Alex ptal aggregation_service_storage_sql.cc

          Alex Moshchuk

          aggregation_service_storage_sql.cc LGTM, didn't look at the rest.

          File content/browser/indexed_db/instance/sqlite/database_connection.h
          Line 344, Patchset 17 (Latest): // LINT.ThenChange(//tools/metrics/histograms/metadata/storage/enums.xml:IndexedDbSqliteSpecificEvent)
          Alex Moshchuk . unresolved

          Is this ERROR reported by If This Then That relevant?

          Changes in the preceding block may need to be reflected in these files: /tools/m...

          Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/storage/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Colin Blundell
          • Evan Stade
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
          Gerrit-Change-Number: 6862477
          Gerrit-PatchSet: 17
          Gerrit-Owner: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
          Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
          Gerrit-Attention: Evan Stade <evan...@microsoft.com>
          Gerrit-Attention: Colin Blundell <blun...@chromium.org>
          Gerrit-Comment-Date: Fri, 10 Oct 2025 18:45:02 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Evan Stade <evan...@microsoft.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Evan Stade (Gerrit)

          unread,
          Oct 10, 2025, 6:11:39 PM (7 hours ago) Oct 10
          to Mingyu Lei, Chromium Metrics Reviews, Alex Moshchuk, Abhishek Shanthkumar, Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
          Attention needed from Abhishek Shanthkumar, Alex Moshchuk, Colin Blundell, Greg Thompson and Mingyu Lei

          Evan Stade added 8 comments

          Patchset-level comments
          File-level comment, Patchset 21 (Latest):
          Evan Stade . resolved

          +Mingyu ptal enums.xml

          File content/browser/indexed_db/instance/sqlite/database_connection.h
          Line 344, Patchset 17: // LINT.ThenChange(//tools/metrics/histograms/metadata/storage/enums.xml:IndexedDbSqliteSpecificEvent)
          Alex Moshchuk . resolved

          Is this ERROR reported by If This Then That relevant?

          Changes in the preceding block may need to be reflected in these files: /tools/m...

          Changes in the preceding block may need to be reflected in these files: /tools/metrics/histograms/metadata/storage/enums.xml If this does not apply, add 'NO_IFTTT=some reason...' to your commit message

          Evan Stade

          yes, fixed.

          File content/browser/indexed_db/instance/sqlite/database_connection.cc
          Line 121, Patchset 16:StatusOr<blink::IndexedDBKeyPath> ColumnKeyPath(sql::Statement& statement,
          Greg Thompson . resolved

          `StatusOr` is [banned](https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-features.md#statusor-banned); use `base::expected` if you want to return a value in the error case, or `std::optional` otherwise.

          Evan Stade

          This isn't `absl::StatusOr`, this actually is syntactic sugar for `base::expected`, specifically `base::expected<T, leveldb::Status>`

          Line 127, Patchset 16: std::u16string encoded;

          if (!statement.ColumnBlobAsString16(column_index, &encoded)) {
          return base::unexpected(Status::Corruption("Key path unexpected size"));
          }
          Greg Thompson . resolved

          `ASSIGN_OR_RETURN(std::u16string encoded, statement.ColumnBlobAsString16(column_index, &encoded));` with a lambda if needed to adjust the return type.

          Evan Stade

          ah, didn't realize that those expected macros could also be applied to optional. Thanks, done.

          Line 2007, Patchset 16: SpecificEvent::kDatabaseNameMismatch));
          Abhishek Shanthkumar . resolved

          I wonder if reusing this event type is the best approach, and if not logging the event in other places is OK. Could we add a new type and use it everywhere?

          Evan Stade

          Done

          Line 2050, Patchset 16: StatusOr<blink::IndexedDBKeyPath> key_path = ColumnKeyPath(statement, 3);

          if (!key_path.has_value()) {
          return base::unexpected(Fatal(key_path.error()));
          }
          index_metadata.key_path = *std::move(key_path);
          Abhishek Shanthkumar . resolved

          Can use `ASSIGN_OR_RETURN` I believe?

          Evan Stade

          Done

          File sql/statement.cc
          Line 600, Patchset 11: CheckCanReadColumn(column_index);

          const void* result_buffer = sqlite3_column_blob(ref_->stmt(), column_index);
          int size = sqlite3_column_bytes(ref_->stmt(), column_index);
          if (result_buffer && size > 0) {
          return std::u16string(reinterpret_cast<const char16_t*>(result_buffer),
          size / 2);
          }

          return {};
          Greg Thompson . resolved
          as above, let's avoid duplication. maybe something like:
          ```
          auto byte_span = ColumnBlob(column_index);
          base::span u16char_span(reinterpret_cast<const char16_t*>(byte_span.data()),
          byte_span.size() / 2);
          return std::u16string(base::as_string_view(u16char_span));
          ```
          i wonder if there's an even cleaner way to do the cast.
          although typing that out, i see that we run the risk of unaligned reads. so maybe it's better to memcpy the data into the resulting string. perhaps:
          ```
          auto byte_span = ColumnBlob(column_index);
          std::u16string result(byte_span.size() / 2, 0u);
          std::ranges::copy(byte_span, base::as_writable_byte_span(result).begin());
          return result;
          ```
          that has the unfortunate side effect of zero-initializing the output string before putting the data into it, but it should avoid unaligned reads.
          Evan Stade

          Done, but this makes me wonder if this one's signature needs to remain as is, in case the blob has an odd number of bytes. That should probably be reported as an error rather than ignored. WDYT?

          Greg Thompson

          good point. this should be documented, no? something about returning an empty string if the column data isn't an integral number of code units. maybe also worth stating that the column data is not checked to ensure that it's valid UTF-16 (e.g., it could contain invalid code points or invalid/incomplete surrogate pairs).

          Evan Stade

          I actually meant that we should revert to the original signature. A blob can validly be empty, so we should distinguish between this type of error and the empty blob case. This error could be indicative of a coding error or database corruption.

          I did throw on a `[[nodiscard]]` to make sure callers aren't ignoring this error. We could switch to returning `std::optional<u16string>`, but that leads to somewhat more verbose code at callsites.

          Greg Thompson

          ah. `optional` is far better, imo. not only is it more idiomatic and consistent with the style guide, but we have helpers to make it easy for callers; see other comments.

          Evan Stade

          Done

          File sql/statement_unittest.cc
          Line 291, Patchset 16: EXPECT_TRUE(select.ColumnBlobAsString16(0, &column_value));
          EXPECT_EQ(value, column_value);
          Greg Thompson . resolved

          `EXPECT_THAT(select.ColumnBlobAsString16(0, &column_value), ValueIs(value));`

          Evan Stade

          updated.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Abhishek Shanthkumar
          • Alex Moshchuk
          • Colin Blundell
          • Greg Thompson
          • Mingyu Lei
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
          Gerrit-Change-Number: 6862477
          Gerrit-PatchSet: 21
          Gerrit-Owner: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
          Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
          Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
          Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
          Gerrit-Reviewer: Mingyu Lei <le...@chromium.org>
          Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
          Gerrit-Attention: Alex Moshchuk <ale...@chromium.org>
          Gerrit-Attention: Colin Blundell <blun...@chromium.org>
          Gerrit-Attention: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
          Gerrit-Attention: Mingyu Lei <le...@chromium.org>
          Gerrit-Attention: Greg Thompson <g...@chromium.org>
          Gerrit-Comment-Date: Fri, 10 Oct 2025 22:11:12 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Alex Moshchuk <ale...@chromium.org>
          Comment-In-Reply-To: Evan Stade <evan...@microsoft.com>
          Comment-In-Reply-To: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
          Comment-In-Reply-To: Greg Thompson <g...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Alex Moshchuk (Gerrit)

          unread,
          Oct 10, 2025, 6:13:43 PM (7 hours ago) Oct 10
          to Evan Stade, Mingyu Lei, Chromium Metrics Reviews, Abhishek Shanthkumar, Greg Thompson, Colin Blundell, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chrome-intell...@chromium.org, chrome-intelligence-te...@google.com, jinsukk...@chromium.org, alexmt...@chromium.org, browser-comp...@chromium.org, chili...@chromium.org, dimich...@chromium.org, dmurph+wa...@chromium.org, dmurph+watching...@chromium.org, edgesto...@microsoft.com, eme-r...@chromium.org, enne...@chromium.org, feature-me...@chromium.org, fgorsk...@chromium.org, gcasto+w...@chromium.org, gogerald+pa...@chromium.org, milicau+watchlis...@google.com, npnavarro+p...@chromium.org, rouslan+au...@chromium.org, rouslan+...@chromium.org, sloboda...@chromium.org, vasilii+watchlis...@chromium.org
          Attention needed from Abhishek Shanthkumar, Colin Blundell, Evan Stade, Greg Thompson and Mingyu Lei

          Alex Moshchuk voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Abhishek Shanthkumar
          • Colin Blundell
          • Evan Stade
          • Greg Thompson
          • Mingyu Lei
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement satisfiedCode-Review
            • requirement satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I414f055984538f056a9649a4934abead7e739a56
            Gerrit-Change-Number: 6862477
            Gerrit-PatchSet: 21
            Gerrit-Owner: Evan Stade <evan...@microsoft.com>
            Gerrit-Reviewer: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
            Gerrit-Reviewer: Alex Moshchuk <ale...@chromium.org>
            Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
            Gerrit-Reviewer: Evan Stade <evan...@microsoft.com>
            Gerrit-Reviewer: Greg Thompson <g...@chromium.org>
            Gerrit-Reviewer: Mingyu Lei <le...@chromium.org>
            Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
            Gerrit-Attention: Evan Stade <evan...@microsoft.com>
            Gerrit-Attention: Colin Blundell <blun...@chromium.org>
            Gerrit-Attention: Abhishek Shanthkumar <abhishek.s...@microsoft.com>
            Gerrit-Attention: Mingyu Lei <le...@chromium.org>
            Gerrit-Attention: Greg Thompson <g...@chromium.org>
            Gerrit-Comment-Date: Fri, 10 Oct 2025 22:13:11 +0000
            Gerrit-HasComments: No
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages