Follow-up 36f4daf32c: allow no-write database connections to use transactions
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 20 Dec 2017 14:25:35 +0000 (15:25 +0100)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 20 Dec 2017 14:25:35 +0000 (15:25 +0100)
commit4ddb207a32e0235e87954b0d4167c5d7afa85b64
tree4880cadcfc6da6085a8b13a4d899956467bc0cf2
parentd26f3a3232f769803bec779735b21dcda5fdacc7
Follow-up 36f4daf32c: allow no-write database connections to use transactions

After 36f4daf32c was merged, Aaron pointed out on Gerrit that:

    Transaction can be used on replicas for REPEATABLE-READ mode, so
    queries in that transaction see the same version of the DB. Those
    do not involve writes and things would probably break sometimes
    without it (like reads following foreign keys and reference in
    separate queries).

So allow no-write connections to call begin() and commit(), and only
throw an exception when a write query is attempted.

Bug: T183265
Change-Id: I138677a714df13ead08061c3e9ef794c3befbe9d
includes/libs/rdbms/database/Database.php