Re: Strange interaction with php's pg_query - Mailing list pgsql-general

From Tom Lane
Subject Re: Strange interaction with php's pg_query
Date
Msg-id 22614.1021347111@sss.pgh.pa.us
Whole thread Raw
In response to Strange interaction with php's pg_query  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
Bill Moran <wmoran@potentialtech.com> writes:
> And if I start psql and enter:
> "select * from sysinfo"
> I get the expected list of name/value pairs that were entered
> into the table at an earlier operation.

> However, if I execute the same query using pg_query() in php,
> I get the error:
> Warning: pg_query() query failed: ERROR: Relation "sysinfo" does not exist in
/usr/home/group/webpages/epd/class/base.class.phpon line 44 

I think your php client must be connecting to a different database
than you are connecting to when you run psql by hand.  If you are
allowing the default choice of database name = user name to be taken,
this isn't real surprising...

> This really confuses me, as "sysinfo" isn't even a relation and
> why should the parser even imagine it to be a relation?

"relation" and "table" are more or less synonymous in PG error messages.
(IMHO the exact meaning of "relation" in our code is "something with a
pg_class entry", which covers also views, sequences, indexes, etc; but
you probably didn't need to know that.)

            regards, tom lane

pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Strange interaction with php's pg_query
Next
From: Paul M Foster
Date:
Subject: Re: Quotes in SQL