Subject: BUG in pg4.1

From: [email-masked] (Wolf-D. Ihlenfeldt)
Date: Thu, 15 Jul 93 03:53:20 -0700

I run postgres4.1 on a sparcII SunOS 4.1.3.

I have stumbled across a mean bug:

E_PRICES,E_PACKSIZES are int4 arrays (variable length).

Go 
* retrieve (Q.E_PRICES)  from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRICES)  from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid"
---------------
| E_PRICES    |
---------------
| {1875,7140,1110,3329,680,2440,419,1900,0}|
---------------

Perfect.

Go 
* retrieve (Q.E_PACKSIZES)  from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PACKSIZES)  from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid"
---------------
| E_PACKSIZES |
---------------
| {10000,50000,5000,25000,10000,50000,5000,25000,0}|
---------------

Also perfect.

Go 
* retrieve (Q.E_PRICES,Q.E_PACKSIZES) from Q in Mol where Q.oid = "195778"\g

Query sent to backend is "retrieve (Q.E_PRICES,Q.E_PACKSIZES) from Q in Mol where Q.oid = "195778""
-----------------------------
| E_PRICES    | E_PACKSIZES |
-----------------------------
| {1875,7140,1110,3329,680,2440,419,1900,0}| {10000,50000,5000,25000,10000,50000,5000,25000,0}|
-----------------------------

Still perfect. Note that there is no time clause in this query.

Go 
* retrieve (Q.E_PRICES,Q.E_PACKSIZES) from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRICES,Q.E_PACKSIZES) from Q in Mol["Thurs Jul 15 17:38:04 1993 GMT"] where Q.oid = "195778"::oid"
Error: No response from the backend, exiting...

The table contains numerous other fields, including
arrays, arrays of arrays and user defined types (even arrays of them).
The crash is reproducibly
avoided even if other fields are added if NO TIME CLAUSE is provided, but
whatever the field combination, if those two fields (E_PACKSIZE,E_PRICES)
are in a time-specific query, a crash with a 2.2 M core results.
Even if the time clause is "now", which should be equivalent to
the non-timed query, the backend crashes.

get_expr() at 0x65edc
flatten_tlistentry() at 0x67848
flatten_tlist_vars() at 0x677bc
query_planner() at 0x5bbe8
init_query_planner() at 0x5ca64
planner() at 0x5c874
plan_union_query() at 0x60b9c
plan_union_queries() at 0x609e4
planner() at 0x5c7c8
pg_plan() at 0x89e38
pg_eval_dest() at 0x89f10
pg_eval() at 0x89ee4
PostgresMain() at 0x8b478
main() at 0x2b78c

Unfortunately, I could not reproduce this fault with some
minitature database with a single entry and only two int4 arrays.
The Mol table has been just produced by appends, at the time of query 
there were some 275 entries. 

Combining either E_PRICES or E_PACKSIZES with other fields is no
problem, if if these fields are not of the same type:

Go 
* retrieve (Q.E_PRODUCER,Q.E_PRICES) from Q in Mol["now"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRODUCER,Q.E_PRICES) from Q in Mol["now"] where Q.oid = "195778"::oid"
-----------------------------
| E_PRODUCER  | E_PRICES    |
-----------------------------
| {"ALDRICH","ALDRICH","CHEMALOG","CHEMALOG","JANSSEN","JANSSEN","LANCSTER","LANCSTER","TCI"}| {1875,7140,1110,3329,680,2440,419,1900,0}|
-----------------------------

Even duplicating the query field (i.e. retrieve 
Go 
* retrieve (Q.E_PRICES,Q.E_PRICES) from Q in Mol["now"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRICES,Q.E_PRICES) from Q in Mol["now"] where Q.oid = "195778"::oid"
-----------------------------
| E_PRICES    | E_PRICES    |
-----------------------------
| {1875,7140,1110,3329,680,2440,419,1900,0}| {1875,7140,1110,3329,680,2440,419,1900,0}|
-----------------------------

or  the equivalent with E_PACKSIZES is no problem.

However, if another pair of arrays (now of type text) is chosen, the same
problem occurs:

Go 
* retrieve (Q.E_PRODUCER,Q.E_COUNTRY) from Q in Mol["now"] where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRODUCER,Q.E_COUNTRY) from Q in Mol["now"] where Q.oid = "195778"::oid"
Error: No response from the backend, exiting...

The crash location in the stack trace is precisely the same.
The text array pair has no problems if the time clause is omitted, again.

Go 
*  retrieve (Q.E_PRODUCER,Q.E_PRICES) from Q in Mol where Q.oid = "195778"::oid\g

Query sent to backend is "retrieve (Q.E_PRODUCER,Q.E_PRICES) from Q in Mol where Q.oid = "195778"::oid"
-----------------------------
| E_PRODUCER  | E_PRICES    |
-----------------------------
| {"ALDRICH","ALDRICH","CHEMALOG","CHEMALOG","JANSSEN","JANSSEN","LANCSTER","LANCSTER","TCI"}| {1875,7140,1110,3329,680,2440,419,1900,0}|
-----------------------------

By the way:
event the query
retrieve (Q.E_PRODUCER,Q.E_PRICES) from Q in Mol] where Q.oid = "195778"::oid\g

(note the superfluous ']') works fine.

All problems occur also if no specific fields are selected, but 'all' is used
for retrieval.

Any ideas ? This is a hideous bug which renders my app unusable.

WDI