Page MenuHomePhabricator

Failed to run update.php for PostgresQL: invalid input syntax for type bytea
Closed, ResolvedPublic

Description

Author: beta

Description:
When I run update.php, following exception raised:

Changing column type of 'uploadstash.us_image_bits' from 'integer' to 'smallint'

...column 'oldimage.oi_bits' is already set as NULL
...column 'oldimage.oi_timestamp' is already set as NULL
...column 'oldimage.oi_major_mime' is already set as NULL
...column 'oldimage.oi_minor_mime' is already set as NULL
Changing 'image.img_metadata' default value
A database query syntax error has occurred.
The last attempted database query was:
"ALTER TABLE image ALTER img_metadata SET DEFAULT '\x'::bytea"
from within function "".
Database returned error "22P02: ERROR: invalid input syntax for type bytea"

PostgresQL version: 8.3.14


Version: 1.20.x
Severity: major
OS: Windows Server 2008
Platform: PC

Details

Reference
bz36087

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.

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:23 AM
bzimport set Reference to bz36087.

Hi Pei-Tang,

which version of MediaWiki are you upgrading to?

beta wrote:

Dear Marcin,

I am using the most recent version from git.

Here is a proposed fix:

https://gerrit.wikimedia.org/r/5307

Can you try:

git fetch https://gerrit.wikimedia.org/r/p/mediawiki/core refs/changes/07/5307/1 && git checkout -b bug/36087 FETCH_HEAD

and test the upgrade again?

In any way I would be interested in having output from

pg_dump -U <pgsuperuser> -s -Fp -n mediawiki --quote-all-identifiers -O -x <yourdatabasename>

BEFORE and AFTER upgrade. (Change "mediawiki" to your PostgreSQL schema if using other than the default).

beta wrote:

After checkout the proposed branch, I got another error:

...index 'logging_page_id_time' on table 'logging' already exists
...index 'iwl_prefix_title_from' on table 'iwlinks' already exists
Creating index 'job_timestamp_idx' on table 'job' (job_timestamp)
A database query syntax error has occurred.
The last attempted database query was:
"

			SELECT opcname,
				attname,
				i.indoption[s.g] as option,
				pg_am.amname
			FROM
				(SELECT generate_subscripts(isub.indkey, 1) AS g
					FROM
						pg_index isub
					JOIN pg_class cis
						ON cis.oid=isub.indexrelid
					JOIN pg_namespace ns
						ON cis.relnamespace = ns.oid
					WHERE cis.relname='pagelink_unique' AND ns.nspname='mediawiki') AS s,
				pg_attribute,
				pg_opclass opcls,
				pg_am,
				pg_class ci
				JOIN pg_index i
					ON ci.oid=i.indexrelid
				JOIN pg_class ct
					ON ct.oid = i.indrelid
				JOIN pg_namespace n
					ON ci.relnamespace = n.oid
				WHERE
					ci.relname='pagelink_unique' AND n.nspname='mediawiki'
					AND	attrelid = ct.oid
					AND	i.indkey[s.g] = attnum
					AND	i.indclass[s.g] = opcls.oid
					AND	pg_am.oid = opcls.opcmethod"

from within function "DatabasePostgres::indexAttributes".
Database returned error "42883: ERROR: function generate_subscripts(int2vector, integer) does not exist
LINE 7: (SELECT generate_subscripts(isub.indkey, 1) AS g

^

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

I found that "generate_subscripts" function was introduced in PostgresQL 8.4, is PostgresQL 8.3 not supported by MediaWiki anymore?

Without having checked the actual problem: Why not use "''::BYTEA" as the default? It is equivalent to "'\x'::BYTEA" and compatible with earlier versions of PostgreSQL.

This seems to be not necessary at all, I checked with Mediawiki 1.7.2 upgrade and we get the default properly.

The problem is I didn't check with PostgreSQL 8.3 so now I need to fix indexAttributes.

(In reply to comment #4)

LINE 7: (SELECT generate_subscripts(isub.indkey, 1) AS g

^

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

I found that "generate_subscripts" function was introduced in PostgresQL 8.4,
is PostgresQL 8.3 not supported by MediaWiki anymore?

No, it should work.

I have updated the patch to fix this problem. Currently installing PostgreSQL 8.2 to test.

(In reply to comment #7)

[...]
I have updated the patch to fix this problem. Currently installing PostgreSQL
8.2 to test.

8.2 is no longer supported by PostgreSQL. I think supporting 8.3 is backbender enough :-).

Right. We support 8.3 as the minimum (8.2 does not have ENUM's we need for some tables).

I have tested migration of the MW 1.7.2 database structure on 8.3 to 1.20 and it works with the Patchset Two of gerrit change 5307

git fetch https://gerrit.wikimedia.org/r/p/mediawiki/core refs/changes/07/5307/2 git checkout -b bug/36087 FETCH_HEAD

beta wrote:

(In reply to comment #9)

I have tested migration of the MW 1.7.2 database structure on 8.3 to 1.20 and
it works with the Patchset Two of Gerrit change #5307

That patch works for me too, thank you!

Jdforrester-WMF subscribed.

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