Page MenuHomePhabricator

populateCategory does not work with Postgres
Closed, ResolvedPublic

Description

Author: overlordq

Description:
I got this error message once when browsing the wiki normally, a refresh of the page didn't show the error message again so I thought it was just some caching error since I just updated from svn. However somebody in MediaWiki-General was asking about schema changes and I came across r32085 so I tried running the maintnence script, and sure enough, there was that error message again:

Warning: pg_query(): Query failed: ERROR: current transaction is aborted, commands ignored until end of transaction block in /home/wiki/includes/DatabasePostgres.php on line 553
A database error has occurred
Query: SELECT COUNT(*) AS pages,COUNT(IF(page_namespace=14,1,NULL)) AS subcats,COUNT(IF(page_namespace=6,1,NULL)) AS files FROM categorylinks,page WHERE cl_to = 'Rainbow_Tables' AND (page_id = cl_from)
Function: Category::refreshCounts
Error: 1 ERROR: current transaction is aborted, commands ignored until end of transaction block

Backtrace:
#0 /home/wiki/includes/Database.php(799): DatabasePostgres->reportQueryError('ERROR: current...', 1, 'SELECT COUNT(*...', 'Category::refre...', false)
#1 /home/wiki/includes/Database.php(1244): Database->query('SELECT COUNT(*...', 'Category::refre...')
#2 /home/wiki/includes/Database.php(1263): Database->select(Array, Array, Array, 'Category::refre...', '1OCK IN SHARE M...')
#3 /home/wiki/includes/Category.php(285): Database->selectRow(Array, Array, Array, 'Category::refre...', 'LOCK IN SHARE M...')
#4 /home/wiki/maintenance/populateCategory.inc(61): Category->refreshCounts()
#5 /home/wiki/maintenance/populateCategory.php(51): populateCategory('', 10, 0, false)

#6 {main}

If I try running that through something like phppgadmin you get a more helpful error message:

ERROR: function if(boolean, integer, unknown) does not exist
LINE 1: SELECT COUNT(*) AS pages,COUNT(IF(page_namespace=14,1,NULL)...

^

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

In statement:

SELECT COUNT(*) AS pages,COUNT(IF(page_namespace=14,1,NULL)) AS subcats,COUNT(IF(page_namespace=6,1,NULL)) AS files FROM mediawiki.categorylinks,mediawiki.page WHERE cl_to = 'Rainbow_Tables' AND (page_id = cl_from)

for PG that should be something like:

SELECT COUNT(*) AS pages,COUNT(CASE WHEN page_namespace=14 THEN 1 ELSE NULL END) AS subcats,COUNT(CASE WHEN page_namespace=6 THEN 1 ELSE NULL END) AS files FROM categorylinks,page WHERE cl_to = 'Rainbow_Tables' AND (page_id = cl_from)

Problem is on line 278 of trunk/phase3/includes/Category.php


Version: 1.13.x
Severity: normal

Details

Reference
bz13430

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, 10:05 PM
bzimport set Reference to bz13430.
bzimport added a subscriber: Unknown Object (MLST).

Should be fixed now, as of r32173. You will need to run maintenance/update.php to add the new category table first.

Jdforrester-WMF subscribed.

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