Page MenuHomePhabricator

Upload a new version of this file, postgres database error
Closed, ResolvedPublic

Description

Author: elly

Description:

  • MediaWiki: 1.11.0
  • PHP: 5.2.0 (apache2handler)
  • PostgreSQL: PostgreSQL 8.2rc1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
  • Apache 2.0.52

When uploading a new version of the same file (image), get database error.

Internal error
A database error has occurred Query: INSERT INTO oldimage (oi_name,oi_archive_name,oi_size,oi_width,oi_height,oi_bits,oi_timestamp,oi_description,oi_user,oi_user_text,oi_metadata,oi_media_type,oi_major_mime,oi_minor_mime,oi_sha1) SELECT img_name,'20070915224357!ToolsInteroperability.jpg',img_size,img_width,img_height,img_bits,img_timestamp,img_description,img_user,img_user_text,img_metadata,img_media_type,img_major_mime,img_minor_mime,img_sha1 FROM image WHERE img_name = 'ToolsInteroperability.jpg' Function: LocalFile::recordUpload2 Error: 1 ERROR: column "oi_metadata" is of type bytea but expression is of type text LINE 1: ...,oi_timestamp,oi_description,oi_user,oi_user_text,oi_metadat... ^ HINT: You will need to rewrite or cast the expression.

Backtrace:

#0 /var/www/html/mediawiki/includes/Database.php(779): DatabasePostgres->reportQueryError('ERROR: column ...', 1, 'INSERT INTO ol...', 'LocalFile::reco...', false)
#1 /var/www/html/mediawiki/includes/Database.php(1845): Database->query('INSERT INTO ol...', 'LocalFile::reco...')
#2 /var/www/html/mediawiki/includes/filerepo/LocalFile.php(746): Database->insertSelect('oldimage', 'image', Array, Array, 'LocalFile::reco...')
#3 /var/www/html/mediawiki/includes/filerepo/LocalFile.php(642): LocalFile->recordUpload2('20070915224357!...', 'Shows the relat...', 'Shows the relat...', Array, false)
#4 /var/www/html/mediawiki/includes/SpecialUpload.php(436): LocalFile->upload('/tmp/phpf93Xho', 'Shows the relat...', 'Shows the relat...', 1, Array)
#5 /var/www/html/mediawiki/includes/SpecialUpload.php(248): UploadForm->processUpload()
#6 /var/www/html/mediawiki/includes/SpecialUpload.php(14): UploadForm->execute()
#7 /var/www/html/mediawiki/includes/SpecialPage.php(653): wfSpecialUpload(NULL, Object(SpecialPage))
#8 /var/www/html/mediawiki/includes/SpecialPage.php(459): SpecialPage->execute(NULL)
#9 /var/www/html/mediawiki/includes/Wiki.php(201): SpecialPage::executePath(Object(Title))
#10 /var/www/html/mediawiki/includes/Wiki.php(45): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest))
#11 /var/www/html/mediawiki/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest))
#12 {main}


Version: 1.11.x
Severity: major
OS: Linux
Platform: PC
URL: http://wiki.nsdl.org

Details

Reference
bz11363

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:00 PM
bzimport set Reference to bz11363.
bzimport added a subscriber: Unknown Object (MLST).

Probably needs some encodeBlob wrappers around the *_metadata column calls from a quick guess, no time to look into the code right now.

elly wrote:

From what we can tell, the problem looks to be related to the fact that the table "image" has a column img.metadata with type "text" and table "oldimage" has a column oi.metadata with type "bytea" and on line 728 in "includes/FileRepo/LocalFile.php" the "$dbw->insertSelect" moves the previous values without casting the column type.

If we change oldimage.oi_metadata type to "text" in the database manually, the error goes away, but there may be another reason for this table.column type to be bytea that I am not aware of. This error occurred with upgrade to 1.11.0 after using the "maintenance/update.php" process which used the "maintenance/postgres/tables.sql" file.

Thanks, elly

Yes, those should all be bytea at this point. Made the change in r26042. You should now be able to
run php update.php from the maintenance directory and it will update your schema for you. Or
just run this manually from psql:

ALTER TABLE image ALTER img_metadata TYPE bytea USING decode(img_metadata,'escape');
ALTER TABLE filearchive ALTER fa_metadata TYPE bytea USING decode(fa_metadata,'escape');

cbandy wrote:

*** Bug 12365 has been marked as a duplicate of this bug. ***

overlordq wrote:

*** Bug 13021 has been marked as a duplicate of this bug. ***

  • Bug 13345 has been marked as a duplicate of this bug. ***
Gilles raised the priority of this task from Medium to Unbreak Now!.Dec 4 2014, 10:25 AM
Gilles added a project: Multimedia.
Gilles moved this task from Untriaged to Done on the Multimedia board.
Gilles lowered the priority of this task from Unbreak Now! to Medium.Dec 4 2014, 11:21 AM
Jdforrester-WMF subscribed.

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