Schema description invalid for PostgreSQL

spydmobile - July 2, 2009 - 15:15
Project:Image FUpload
Version:6.x-3.0-rc2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Installing this on a live postgres fails to to bad syntax on INT - using INT(10) does not work. This has been addressed before in previous versions but for some reason it is still an issue.

Here are the errors:

warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "(" LINE 3: uid int(10) NOT NULL default 0, ^ in /var/www/sparcs/includes/database.pgsql.inc on line 139.
user warning: query: CREATE TABLE fupload_previewlist ( fieldname varchar(32) NOT NULL default '', uid int(10) NOT NULL default 0, nid int(10) NOT NULL default 0, fid int(11) default 0, created int(11) NOT NULL default 0, PRIMARY KEY (fid) ) in /var/www/sparcs/includes/database.inc on line 515.
warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "fupload_previewlist" does not exist in /var/www/sparcs/includes/database.pgsql.inc on line 139.
user warning: query: CREATE INDEX fupload_previewlist_fieldname_idx ON fupload_previewlist (fieldname) in /var/www/sparcs/includes/database.inc on line 515.
warning: pg_query() [function.pg-query]: Query failed: ERROR: relation "fupload_previewlist" does not exist in /var/www/sparcs/includes/database.pgsql.inc on line 139.
user warning: query: CREATE INDEX fupload_previewlist_uid_idx ON fupload_previewlist (uid) in /var/www/sparcs/includes/database.inc on line 515.
There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately! See the available updates page for more information.

removing the (10) sizes solved it for me, or perhaps using the tiny, big etc conventions.

this worked for me:

CREATE TABLE fupload_previewlist ( fieldname varchar(32) NOT NULL default '', uid int NOT NULL default 0, nid int NOT NULL default 0, fid int default 0, created int NOT NULL default 0, PRIMARY KEY (fid));
CREATE INDEX fupload_previewlist_fieldname_idx ON fupload_previewlist (fieldname) ;
CREATE INDEX fupload_previewlist_uid_idx ON fupload_previewlist (uid) ;

#1

grandcat - July 2, 2009 - 15:27
Title:Install on postgres fails - showstopper for average user.» Schema description invalid for PostgreSQL

Thank you for the detailed report.

#2

ronhoogwater - July 12, 2009 - 13:04
Status:active» needs review

Hello,

As described in http://api.drupal.org/api/group/schemaapi/6 the 'field' attribute in hook_schema() should only be used for types varchar and text. In the image_fupload module I found it defined for int also.

I removed the field attributes in this (quick) patch. I tested it on my installation: drupal 6.13 with a postgresql database. I tested only once and not on a clean installation.

I think it is a bug in the core also. The referenced page says the field attribute is ignored for other types than varchar and text, but that is not true (http://api.drupal.org/api/function/_db_create_field_sql/6).

Hope this helps,

Ron

AttachmentSize
image_fupload-508312.patch 1.29 KB
 
 

Drupal is a registered trademark of Dries Buytaert.