Page MenuHomePhabricator

Move SQL building code from Database class to SQLPlatform
Closed, ResolvedPublic

Details

Show related patches Customize query in gerrit

Event Timeline

Ladsgroup triaged this task as Medium priority.May 4 2022, 6:46 PM
Ladsgroup moved this task from Triage to In progress on the DBA board.

Change 789251 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Move out more functions from Database to SQLPlatform

https://gerrit.wikimedia.org/r/789251

Change 789317 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/extensions/CheckUser@master] Mock db platform

https://gerrit.wikimedia.org/r/789317

Change 789317 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] tests: Mock db platform

https://gerrit.wikimedia.org/r/789317

Change 789251 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Move out more functions from Database to SQLPlatform

https://gerrit.wikimedia.org/r/789251

Change 791065 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Prepare for moving Database::selectSQLText to SQLPlatform

https://gerrit.wikimedia.org/r/791065

Change 791065 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Prepare for moving Database::selectSQLText to SQLPlatform

https://gerrit.wikimedia.org/r/791065

Change 792689 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Move four more functions from Database to SQLPlatform

https://gerrit.wikimedia.org/r/792689

Change 792690 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Move handling index and table aliases to SQLPlatform

https://gerrit.wikimedia.org/r/792690

Change 792704 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] [WIP] rdbms: Move selectSQLText to SQLPlatform

https://gerrit.wikimedia.org/r/792704

Change 792689 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Move four more functions from Database to SQLPlatform

https://gerrit.wikimedia.org/r/792689

Change 792690 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Move handling index and table aliases to SQLPlatform

https://gerrit.wikimedia.org/r/792690

Change 792704 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Move selectSQLText to SQLPlatform

https://gerrit.wikimedia.org/r/792704

Change 802763 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] [WIP] rdbms: Move assertion logic in sql building to sql platform

https://gerrit.wikimedia.org/r/802763

@Ladsgroup Per T310214, we could probably do with a test that ensures the double escaping issue doesn't happen again. If we already have a case of e.g. select( [ 'x' => tableName('x') ], .. ), then maybe the issue is expanding it to include coverage to sqlite/mysql/postgres for the jobs that enable those, either with sql text based assertions or perhaps a simple end-to-end test that selects something simple from a table.

Sure, please remind me when I'm back. I want to focus on unblocking train atm (I have a very little time rn)

Change 808844 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Move methods delegated to platform to one central place

https://gerrit.wikimedia.org/r/808844

Change 808852 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate buildGroupConcatField and buildSelectSubquery to platform

https://gerrit.wikimedia.org/r/808852

Change 808844 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Move methods delegated to platform to one central place

https://gerrit.wikimedia.org/r/808844

Change 808852 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate buildGroupConcatField and buildSelectSubquery to platform

https://gerrit.wikimedia.org/r/808852

Change 809054 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate insert sql building code to sql platform

https://gerrit.wikimedia.org/r/809054

Change 809054 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate insert sql building code to sql platform

https://gerrit.wikimedia.org/r/809054

Change 816169 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate delete and update sql building to SQLPlatform

https://gerrit.wikimedia.org/r/816169

Change 816169 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate delete and update sql building to SQLPlatform

https://gerrit.wikimedia.org/r/816169

Change 817782 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate dropTable sql building to SQLPlatform

https://gerrit.wikimedia.org/r/817782

Change 817782 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate dropTable sql building to SQLPlatform

https://gerrit.wikimedia.org/r/817782

Change 817807 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate SQL anlysis code pieces to SQLPlatform

https://gerrit.wikimedia.org/r/817807

Change 802763 abandoned by Ladsgroup:

[mediawiki/core@master] [WIP] rdbms: Move assertion logic in sql building to sql platform

Reason:

done in other patches, there is no hope to bring this back without practically rewriting it.

https://gerrit.wikimedia.org/r/802763

Change 817807 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate SQL analysis code pieces to SQLPlatform

https://gerrit.wikimedia.org/r/817807

Change 818459 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate several more Database::do* to SqlPlatform

https://gerrit.wikimedia.org/r/818459

Change 818463 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate delegated protected functions of Database and drop them

https://gerrit.wikimedia.org/r/818463

Change 818473 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Bump the minimum required version of PG to 9.5

https://gerrit.wikimedia.org/r/818473

Change 818459 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate several more Database::do* to SqlPlatform

https://gerrit.wikimedia.org/r/818459

Change 818463 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate delegated protected functions of Database and drop them

https://gerrit.wikimedia.org/r/818463

Change 818473 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Bump the minimum required version of PG to 9.5

https://gerrit.wikimedia.org/r/818473

Change 819157 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] rdbms: Migrate SchemaVar and replaceVars from Database to SQLPlatform

https://gerrit.wikimedia.org/r/819157

Change 819157 merged by jenkins-bot:

[mediawiki/core@master] rdbms: Migrate SchemaVar and replaceVars from Database to SQLPlatform

https://gerrit.wikimedia.org/r/819157

Ladsgroup closed this task as Resolved.EditedAug 2 2022, 8:56 PM

Now there is no large chunk of code left in Database class that could be moved to SQLPlatform.

It is much cleaner and the complexity score of the class has fallen to ~600 out of ~1000 and it's no longer the most complex class of MediaWiki. We deprecated and removed six Database::do* methods.

Of course way more work could to be done. There is a long-tail of small clean ups. Improving mocking in tests (now that we can rely on the mocked addQuotes(), lots of tests use new SQLPlatformTestHelper( new AddQuoterMock() ); for platform) and small code pieces could be refactored to move to platform but that can happen in its own time.

As far as I'm concerned, this is done. 🎉