Subject: retyping attributes in postquel queries

From: Stan Yates <[email-masked]>
Date: Thu, 14 May 92 13:38:20 -0700

I am new to Postgres and am working my way through the manual.  I'm
discovering that some of the examples don't work as written because of type
conflicts.  For example, EMP.age is defined as int4 and EMP.salary as
float8.  So the following sort of thing happens:

Welcome to the C POSTGRES terminal monitor

Go
* retrieve(emp.all)\g

Query sent to backend is "retrieve(emp.all)"
---------------------------------------------------------
| name        | salary      | age         | dept        |
---------------------------------------------------------
| Sam         | 1.20000000000000000e+03| 29          | toy         |
---------------------------------------------------------
| Bill        | 1.60000000000000000e+03| 36          | candy       |
---------------------------------------------------------
| Joe         | 1.20000000000000000e+03| 40          | shoe        |
---------------------------------------------------------

Go
* retrieve(result=emp.salary/emp.age)\g

Query sent to backend is "retrieve(result=emp.salary/emp.age)"
NOTICE:May 14 15:33:07:there is no operator / for types float8 and int4

NOTICE:May 14 15:33:07:You will either have to retype this query using an

NOTICE:May 14 15:33:07:explicit cast, or you will have to define the operator

WARN:May 14 15:33:07:/ for float8 and int4 using DEFINE OPERATOR

    Is there a way to retype an attribute on the fly within a
postquel query?  I tried the following with no result:

Go
* retrieve(result=emp.salary/(float8)emp.age)\g

Query sent to backend is "retrieve(result=emp.salary/(float8)emp.age)"
WARN:May 14 15:34:02:type id lookup of 356 failed

Go
* retrieve(result=emp.salary/emp.age::float8)\g

Query sent to backend is "retrieve(result=emp.salary/emp.age::float8)"
NOTICE:May 14 15:34:28:there is no operator / for types float8 and int4

NOTICE:May 14 15:34:28:You will either have to retype this query using an

NOTICE:May 14 15:34:28:explicit cast, or you will have to define the operator

WARN:May 14 15:34:28:/ for float8 and int4 using DEFINE OPERATOR

    Thanks in advance.

--Stan Yates

---

From: postarch (Postgres Mailing Archive)
Date: Tue, 19 May 92 09:10:39 PDT

> Query sent to backend is "retrieve(emp.all)"

This is a manual bug.  You should change emp.salary to be of type int4 in
the create query (There are other manual bugs of this same nature, in
particular beware of what it says you can do with postquel functions).

> Query sent to backend is "retrieve(result=emp.salary/emp.age::float8)"

Unfortunately you can't cast attributes only constants.

Jeff