OT: Re: pg_atoi: zero-length string - Mailing list pgsql-admin

From Dani Oderbolz
Subject OT: Re: pg_atoi: zero-length string
Date
Msg-id 3FABC7CF.9000609@ecologic.de
Whole thread Raw
In response to pg_atoi: zero-length string  (Dani Oderbolz <oderbolz@ecologic.de>)
List pgsql-admin
Dani Oderbolz wrote:

> ....
>
> I have an Application (www.phpgroupware), which submits
> suboptimal Queries like
>
> SELECT * FROM phpgw_accounts WHERE account_id=''
>
> Now Postgresql responds like this:
>
> *PostgreSQL Error*: 1 (ERROR: pg_atoi: zero-length string )
>
> Is there a workaround for this (eg. a Startup-Parameter that can be set)?
>
If anybody else has got troubles with this Application:
I guess I have a Workaround with is not too hard.
In the file $INSTALL_DIR/phpgwapi/inc/class.db_pgsql.inc.php
change the function query, so that it looks like this:

/* Postgres chokes on  Queries like WHERE id='' */
 $Query_String = str_replace("''","'0'",$Query_String);

$this->Query_ID = @pg_Exec($this->Link_ID, $Query_String);

In other words: right before phpgroupware does a call to pg_Exec,
I replace any '' by '0' which causes Postgres to behave properly.
Thanks to Oli and Jon Pastore for ginving me the crucial hints.

Regards,
Dani




pgsql-admin by date:

Previous
From: Michiel Lange
Date:
Subject: Re: I feel a bit dumb, but getting a bit clueless
Next
From: Larry Rosenman
Date:
Subject: Re: pg_atoi: zero-length string