Page MenuHomePhabricator

categorylinks table is not updated during upgrade (postgresql)
Closed, ResolvedPublic

Description

Author: zbyszek

Description:
I upgraded a mediawiki installation from 1.16-alpha to 1.17-alpha@72382.
After opening any Category page I get an error:


SELECT page_id,page_title,page_namespace,page_len,page_is_redirect,cl_sortkey,cat_id,cat_title,cat_subcats,cat_pages,cat_files,cl_sortkey_prefix FROM page INNER JOIN categorylinks ON ((cl_from = page_id)) LEFT JOIN category ON ((cat_title = page_title AND page_namespace = 14)) WHERE cl_to = 'category-name' AND cl_type = 'page' ORDER BY cl_sortkey LIMIT 201 ;

ERROR: column "cl_sortkey_prefix" does not exist
LINE 1: ...,cat_id,cat_title,cat_subcats,cat_pages,cat_files,cl_sortkey...

^

and the call site is in CategoryPage.php function doCategoryQuery().

I think that the cause is pretty simple: in commit
72026 new columns were added:

+ cl_sortkey_prefix TEXT NOT NULL DEFAULT '',
+ cl_collation SMALLINT NOT NULL DEFAULT 0,
+ cl_type TEXT NOT NULL DEFAULT 'page'

I think that the fix is pretty simple:
add the missing columns when running maintenance/update.php:

ALTER TABLE categorylinks ADD COLUMN cl_sortkey_prefix TEXT NOT NULL DEFAULT '';
ALTER TABLE categorylinks ADD COLUMN cl_collation SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE categorylinks ADD COLUMN cl_type TEXT NOT NULL DEFAULT 'page';

Seem to work after this change :)


Version: 1.17.x
Severity: enhancement

Details

Reference
bz25080

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:13 PM
bzimport set Reference to bz25080.
bzimport added a subscriber: Unknown Object (MLST).

The patch file seems to exist (/phase3/maintenance/postgres/archives/patch-categorylinks-better-collation.sql).

Can't seem to find the entry in the updaters list though.

overlordq wrote:

It was added when the categorylinks collation was still experimental so it wasn't added to the automagic updates list since the design wasn't stable yet. Every time the schema changed having a way to updated from each old version to the current would be messy.

(In reply to comment #2)

It was added when the categorylinks collation was still experimental so it
wasn't added to the automagic updates list since the design wasn't stable yet.
Every time the schema changed having a way to updated from each old version to
the current would be messy.

That's what people get for running trunk, the schema can change ;-)

In general, this would be one of the (many many) reasons I want a sane schema generator/updater/thingie.

zbyszek wrote:

(In reply to comment #4)

Fixed in r72593

Thanks!

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.