postgres sql error in fscache when uploading files

michaelemeyers - October 13, 2004 - 20:29
Project:FSCache
Version:4.5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

when I click on create content/upload file I get the following error at the top of the page:

warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "" in /usr/local/apache/htdocs/includes/database.pgsql.inc on line 104.

user error:
query: SELECT fs.* FROM fscache fs WHERE fs.fsid = '' in /usr/local/apache/htdocs/includes/database.pgsql.inc on line 121.

I can however still submit a file... when you preview the submission, there are no areas of the top of the page, and after submitting the file upload there are no errors -- the error only occurs when you try to create content.

running: drupal 4.5 RC, postgres 7.4.5, rhes3, apache 1.x
* $Id: filestore2.module,v 1.16 2004/09/13 01:38:31 gordon Exp $
* $Id: fscache.module,v 1.7 2004/09/10 03:10:18 gordon Exp $

#1

michaelemeyers - November 3, 2004 - 01:05
Title:postgres sql error when uploading files» postgres sql error in fscache when uploading files

a follow-up on my previous post, now running:
// $Id: fscache.module,v 1.9 2004/10/17 11:48:33 gordon Exp $

when the following function is called: fscache_load($conditions)
$conditions = array(1) { ["fsid"]=> NULL }
check_query ($k) = fsid
check_query ($v) = // WHY ISN'T THIS NULL??

there are two problems.
the first is that NULL becomes/is treated as "" (irrespective of the check_query call)
the second is that even if NULL was passed it can't be wrapped in single quotes
WHERE fs.fsid = 'NULL' -- doesn't work must be: WHERE fs.fsid = NULL (at least for postgres)

in function fscache_load($conditions)
-- $cond[] = "fs.". check_query($k) ." = '". check_query($v) ."'";
++ if (check_query($v) == "") { $cond[] = "fs.". check_query($k) ." = NULL"; } else { $cond[] = "fs.". check_query($k) ." = '". check_query($v) ."'"; }

this doesn't seem to have introduced problems (so far); though I'm sure there is a more elegant solution... thoughts?

 
 

Drupal is a registered trademark of Dries Buytaert.