Thread:Project:Support desk/Problems with rebuildImages.php

I have problems with the rebuildImages.php maintenance script in Mediawiki 1.21.5 with PostgreSQL.

This script fails on some images in this query:

INSERT INTO "image" (img_name,img_size,img_width,img_height,img_bits,img_media_type,img_major_mime,img_minor_mime,img_timestamp, img_description,img_user,img_user_text,img_metadata,img_sha1) VALUES ('HMS_Voracious_SLV_Green_1945.jpg','5711993','5252','3608','8','BITMAP','image','jpeg','2013-07-09 08:37:01 GMT','(recovered file, missing upload log entry)','0','127.0.0.1','a:2:{s:15:"JPEGFileComment";a:1:{i:0;s:138:"Capturefile: D:\glass neg raws\Allen C. Green Series\bSoftware: Capture One PRO for Windows";}s:22:"MEDIAWIKI_EXIF_VERSION";i:2;}','9r3obqv4ikfdtkx45tlgho2clgka0lc')

The error is:

ERROR: invalid input syntax for type bytea LINE 1: ... file, missing upload log entry)','0','127.0.0.1','a:2:{s:15...

I can manually execute this query if I set empty img_metadata column data.

I launch this script for a huge amount of images and it fails for about 1 of approximately 1000 images. What is the problem with it?

--UPD--

I've discovered that if I remove this part from the query it runs ok:

D:\glass neg raws\Allen C. Green Series\bSoftware: Capture One PRO for Windows

This is a part of image metadata. Why does it cause sql problems?