Strange postresSQL errors...

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Jul 19 19:29:35 UTC 2004


On Mon, Jul 19, 2004 at 03:18:25PM -0400, Madison Kelly wrote:
> Hi all,
> 
>   I was working on my backup program when I started getting this error. 
> It seems out of the blue because what I was working on had nothing to do 
> with the operations around this error. The error is in the middle of 
> some database calls the program was making and the number before the DB 
> call is the program line number. PostgresSQL 7.4 on Fedora Core 1:
> 
> 
> =- Error -=
> 
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE file_parent_dir='/Business/AlteevesNiche/Archive' AND 
> file_name='3d' AND file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE file_parent_dir='/Business/AlteevesNiche/Archive/3d' AND 
> file_name='Tt' AND file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE file_parent_dir='/Business/AlteevesNiche/Archive' AND 
> file_name='Alteeve's Niche' AND 
                    ^--- you must escape quotes in strings before
		    passing them to postgres.
> file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
> 
> DBD::Pg::st execute failed: ERROR:  syntax error at or near "s" at 
> character 173 at ./cron.pl line 2589.

The 's made it look like end of string followed by an unexpected s
keyword.

> DBD::Pg::st fetchrow_array failed: no statement executing at ./cron.pl 
> line 2590.
> sh: -c: line 1: unexpected EOF while looking for matching `''
> sh: -c: line 2: syntax error: unexpected end of file
> 
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE file_parent_dir='/Business/AlteevesNiche/Archive' AND 
> file_name='an-webmail' AND 
> file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE 
> file_parent_dir='/Business/AlteevesNiche/Archive/an-webmail' AND 
> file_name='webmail' AND file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
>  | |- 2587 DBI: SELECT file_backup, file_restore, file_display FROM 
> file_dir WHERE 
> file_parent_dir='/Business/AlteevesNiche/Archive/an-webmail/webmail' AND 
> file_name='class' AND file_src_uuid='21b8155e-bf55-446c-9776-7d72b451e91e'
> 
>  =- End error -=
> 
> Here is the chunk of code with the line numbers:
> 
>  =- Code Snippet -=
> 
> 2587: $ln=__LINE__; print " | |- $ln DBI: SELECT file_backup, 
> file_restore, file_display FROM file_dir WHERE 
> file_parent_dir='$file_parent_dir' AND file_name='$file_name' AND 
> file_src_uuid='$file_src_uuid'\n";
> 2588: $DBreq=$DB->prepare("SELECT file_backup, file_restore FROM 
> file_dir WHERE file_parent_dir='$file_parent_dir' AND 
> file_name='$file_name' AND file_src_uuid='$file_src_uuid'") || die 
> $DBI::errstr;
> 2589: $passed_file_backup=$DBreq->execute();
> 2590: @passed_file_backup=$DBreq->fetchrow_array();
> 2591: $passed_file_backup=@passed_file_backup[0];
> 
>  =- End Code Snippet -=
> 
>   It looks like it is erroring on the 'execute' and 'fetchrow_array'. 
> It performs this call hundreds of times and the error only pops up once 
> or twice. Any insight will be greatly appreciated!!

Hope that helps.  There are usually functions to automatically do it for
you in most DB libraries.  In the case of postgresql, you escape with '\'.


Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list