Last modified: 2010-05-15 15:51:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 9908 - PostgreSQL and tsearch2 Problems
PostgreSQL and tsearch2 Problems
Product: MediaWiki
Classification: Unclassified
Search (Other open bugs)
PC Linux
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: 9916 (view as bug list)
Depends on:
Blocks: postgres
  Show dependency treegraph
Reported: 2007-05-14 14:39 UTC by Alessandro Fernandes Martins
Modified: 2010-05-15 15:51 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Alessandro Fernandes Martins 2007-05-14 14:39:26 UTC
have a problem with MediaWiki 1.10.0 and PostgreSQL 8.1.9 (from Ubuntu
Server 6.06.1 LTS).

Well, my little problem started today, when I do an update in MediaWiki
from 1.9.3 to 1.10.1.

Everything worked fine, but when I tried to search to something I got:

Warning: pg_query() []: Query failed: ERROR:
unrecognized normalization method: 5 in
/var/www/embratel-wiki/includes/DatabasePostgres.php on line 497
Internal error

A database error has occurred Query: SELECT page_id, page_namespace,
page_title, rank(textvector, to_tsquery('default','ECT'),5) AS score
FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id
AND r.rev_text_id = c.old_id AND textvector @@
to_tsquery('default','ECT') AND page_is_redirect = 0 AND page_namespace
IN (0) ORDER BY score DESC, page_id DESC LIMIT 20 OFFSET 0 Function:
Error: 1 ERROR: unrecognized normalization method: 5


#0 /var/www/embratel-wiki/includes/Database.php(762):
DatabasePostgres->reportQueryError('ERROR: unrecog...', 1, 'SELECT
page_id,...', '', false)
#1 /var/www/embratel-wiki/includes/SearchPostgres.php(44):
Database->query('SELECT page_id,...')
#2 /var/www/embratel-wiki/includes/SpecialSearch.php(158):
#3 /var/www/embratel-wiki/includes/SpecialSearch.php(108):
#4 /var/www/embratel-wiki/includes/SpecialSearch.php(40):
#5 /var/www/embratel-wiki/includes/Wiki.php(143): wfSpecialSearch()
#6 /var/www/embratel-wiki/includes/Wiki.php(45):
MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage),
#7 /var/www/embratel-wiki/index.php(89):
MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User),
#8 {main}


The update.php command executed fine...

I think that this problem is related with tsearch2, because if I
executed the query without rank parameter[1], I got:



1-) SELECT page_id, page_namespace, page_title, rank(textvector,
to_tsquery('default','ect')) AS score FROM page p, revision r,
pagecontent c WHERE p.page_latest = r.rev_id AND r.rev_text_id =
c.old_id AND textvector @@ to_tsquery('default','ect') AND
page_is_redirect = 0 AND page_namespace IN (0) ORDER BY score DESC,
page_id DESC LIMIT 20 OFFSET 0
Comment 1 Alessandro Fernandes Martins 2007-05-14 14:42:51 UTC
Greg Sabino Mullane, ask me the following information:

> select current_setting('server_encoding');

wikidbprd=# select current_setting('server_encoding');
(1 row)

> select current_setting('lc_ctype');

wikidbprd=# select current_setting('lc_ctype');
(1 row)

> select * from pg_ts_cfg;

wikidbprd=# select * from pg_ts_cfg;
     ts_name     | prs_name |    locale
 default_russian | default  | ru_RU.KOI8-R
 simple          | default  |
 default         | default  | en_US.UTF-8
(3 rows)

> Also, does this do this for all search requests?

No, I perceived that if I search a word that does not exist, the error
does not happen!
Comment 2 Bricklen Anderson 2007-05-14 17:33:23 UTC
I had the same error. My solution:

At line 144 of includes/SearchPostgres.php, I changed the 5 to a 0
(normalization method):
"rank($fulltext, to_tsquery('default',$searchstring),0) AS score"

The normalization methods are shown on
under "Document length normalization".

Here is the relevant section:
Document length normalization
    It's possible to normalize rank of document by document length (total number
of indexed words) To do so, you need to specify the last argument in ranking
function - rank(tsvector,query,len_norm), where len_norm:

    * 0 (default) - no normalization
    * 1 - normalized by log (document length)
    * 2 - normalized by document length itself

It appears the default of 5 is not a valid normalization method. Maybe I
installed tsearch2 or mediawiki incorrectly, but either way, I figured I'd
report what worked for me.
Comment 3 Alessandro Fernandes Martins 2007-05-15 12:06:49 UTC

Your workaround solves my problem!


Comment 4 Greg Sabino Mullane 2007-05-15 12:40:01 UTC
Fixed in r22188
Comment 5 Greg Sabino Mullane 2007-05-15 18:19:47 UTC
*** Bug 9916 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.