Skip to content
Commit 88147c43 authored by Zim's avatar Zim Committed by Zimuzo Ezeozue
Browse files

Fix 'ALTER RENAME TABLE' compat issue

This CL disables SQLite's new behavior in "ALTER RENAME TABLE"
introduced in version 3.25.0 (https://www.sqlite.org/changes.html).
In this new behavior, when renaming a table, SQLite would automatically
update all the views and triggers referencing to it, which is nice if an
app is always using 3.25 or later. However, in practice, almost all
android apps have to support older android versions where this behavior
is not supported, apps just can't rely on this feature.

Other downsides of the new behavior (in the context of android ecosystem)
includes:
- Because the new behavior would crash an app when a rename would cause
  a dangling view or trigger *even when the app does have a fix-up step
  after ALTER RENAME TABLE* in which case it'd just work fine at the end,
  it is very risky to enable the new behavior on all apps.

- This new behavior also means existing upgrade steps (which may have
  been introduced years ago) could suddenly fail, if the step is executed
  in R. This means, if an app used an "ALTER TABLE RENAME" in the upgrade
  step from ver 1 to ver 2 five years ago and never after, and almost all
  users are already running ver 2 or newer, *if* there's still a user who
  are on ver 1, upgrading the app to the latest version could suddenly
  fail on R.

Applications wishing to enable the new behavior can enable it at runtime
with the following call:

SQLiteDatabase db = ....; // open a DB
db.execPerConnectionSQL("PRAGMA legacy_alter_table = 0;", null);

Test: atest SQLiteSecurityTest
Bug: 147928666
Change-Id: I64546deebd3782ed685fcb46498bc487e0f8d5b6
parent 0f62c1a0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment