Skip to content

fix(db): restore missing sb_bans composite indexes - #79

Merged
Rushaway merged 2 commits into
mainfrom
fix/bans-composite-indexes
Oct 26, 2026
Merged

Rushaway merged 2 commits into
mainfrom
fix/bans-composite-indexes

Conversation

@Rushaway

@Rushaway Rushaway commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Port of upstream sbpp#1605.

Problem

702.php adds the type_authid / type_ip indexes on :prefix_bans, but some long-lived installs carry a config.version past 702 without them, so the migration never runs there. Upstream it made PruneBans() fatal (FORCE INDEX, error 1176). This fork's PruneBans() never had the hints, so here it's "only" a full-table scan on every ban check / banlist / PruneBans.

Fix

Updater migration 815 (upstream's 812; 811-814 are taken here) creates both indexes idempotently through an information_schema probe (portable, no MariaDB-only IF NOT EXISTS). Fresh installs already get them from struc.sql.

Tests

Updater815BansIndexesTest (drops the indexes, runs PruneBans, runs the migration twice) + UpdaterMigrationPortableSqlTest: OK.

Merge before the plugin PR: that one adds migration 816 and is stacked on this branch.

CHANGELOG: 2.2.3-srcdslab (run updater required).

Port of upstream sbpp#1605 (584ef2e).

`702.php` adds `type_authid` / `type_ip` on `:prefix_bans`, but some
long-lived installs carry a `config.version` past 702 without them, so
702 never runs there. Add a migration that creates both indexes
idempotently (portable information_schema probe, no MariaDB-only
`ADD INDEX IF NOT EXISTS`).

Fork adaptations:
- upstream's migration 812 lands as 815 (811-814 are taken here);
- the `PruneBans()` half of the upstream fix (dropping the FORCE INDEX
  hints that fatal with error 1176 without the indexes) is not needed:
  this fork's PruneBans() never had the hints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rushaway
Rushaway merged commit 1ea4963 into main Oct 26, 2026
6 checks passed
@Rushaway
Rushaway deleted the fix/bans-composite-indexes branch October 26, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant