commit | 1ff47e97f77c94e87fc4f1c1e68e33e3e7dce1b1 | [log] [tgz] |
---|---|---|
author | Victor Costan <[email protected]> | Fri Dec 07 11:10:43 2018 |
committer | Commit Bot <[email protected]> | Fri Dec 07 11:10:43 2018 |
tree | 8b916f1e386b21cf0d1a70090ca1ca7665a50fe6 | |
parent | 7f306df5fecd9d0bc712e2127d383aa11b235bb2 [diff] |
sql: Use SQLite API instead of PRAGMA to check for column existence. sql::Database::DoesColumnExist currently compiles and runs a "PRAGMA table_info" [1] SQL query and iterates over the result looking for the desired column name. This is more brittle and expensive than using the the sqlite3_table_column_metadata() [2] API, which pulls schema data directly, bypassing query compilation and execution. This CL introduces a behavior change -- the previous PRAGMA table_info implementation works for views [3, 4], whereas sqlite3_table_column_metadata() only works for tables. The behavior change is not visible, because Chrome currently uses views in a single feature [5], namely extensions [6]. DoesColumnExist should only be used for migrations, which should operate on concrete tables. In steady-state, each feature should have the database schema migrated to the current version, so column existence is known statically. So, removing support for views in DoesColumnExist() is acceptable. [1] https://www.sqlite.org/pragma.html#pragma_table_info [2] https://www.sqlite.org/c3ref/table_column_metadata.html [3] https://www.sqlite.org/matrix/pragma.html [4] https://www.sqlite.org/matrix/matrix_dpragma.html#R-35224-32827-55933-44478-17553-06933-55583-57822 [5] https://cs.chromium.org/search/?q=file:%5C.cc+sql::+VIEW+case:yes [6] https://cs.chromium.org/chromium/src/chrome/browser/extensions/activity_log/counting_policy.cc?q=VIEW+case:yes Bug: 910955 Change-Id: I44474585e6bb2523b5cd91c76c3444058822e601 Reviewed-on: https://chromium-review.googlesource.com/c/1357825 Reviewed-by: Chris Mumford <[email protected]> Commit-Queue: Victor Costan <[email protected]> Cr-Commit-Position: refs/heads/master@{#614663}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .