Fix for SQL casting error with Postgres
In Special:ProtectedPages, a text field is compared directly to an integer, which moden versions of Postgres do not like. Error seen:
Query:
SELECT pr_id,page_namespace,page_title,page_len,pr_type,pr_level,pr_expiry,pr_cascade,log_timestamp,log_user,log_comment,log_deleted FROM "page","page_restrictions" LEFT JOIN "log_search" ON (ls_field = 'pr_id' AND (ls_value = pr_id)) LEFT JOIN "logging" ON ((ls_log_id = log_id)) WHERE (pr_expiry > '2014-06-25 01:59:54 GMT'OR pr_expiry IS NULL) AND (page_id=pr_page) AND (pr_type='edit') ORDER BY pr_id LIMIT 51
Function: IndexPager::buildQueryInfo (ProtectedPagesPager)
Error: 42883 ERROR: operator does not exist: text = integer LINE 1: ..."log_search" ON (ls_field = 'pr_id' AND (ls_value = pr_id)) ... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Yes, Postgres is being pedantic, but it is weird that the where clause has a proper cast right before it:
ON (ls_field = 'pr_id' AND (ls_value = pr_id))
The solution is to quote the pr_id. Diff attached.
Version: unspecified
Severity: normal
Attached: