Thread: Is this a bug in 7.1?

Is this a bug in 7.1?

From
"Oliver Elphick"
Date:
Is this a bug or missing feature in 7.1? or have I got the SQL
wrong?

bray=# SELECT DISTINCT p.id, p.name, a.town
bray-#   FROM (
bray(#         SELECT id, name
bray(#           FROM customer
bray(#         UNION
bray(#         SELECT id, name
bray(#           FROM supplier
bray(#        ) AS p
bray-#        LEFT OUTER JOIN address AS a
bray-#          ON p.address = a.id
bray-#   WHERE p.id = '22002';
ERROR:  function applied to tuple is not supported for subSELECTs

What does the error message mean?  I can't see where a function
is involved.


--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Who is like Thee among the gods, O Lord? Who is like
      Thee, majestic in holiness, awesome in praises,
      working wonders?"
                              Exodus 15:11



Re: Is this a bug in 7.1?

From
"Oliver Elphick"
Date:
"Oliver Elphick" wrote:
  >Is this a bug or missing feature in 7.1? or have I got the SQL
  >wrong?
  >
  >bray=# SELECT DISTINCT p.id, p.name, a.town
  >bray-#   FROM (
  >bray(#         SELECT id, name
  >bray(#           FROM customer
  >bray(#         UNION
  >bray(#         SELECT id, name
  >bray(#           FROM supplier
  >bray(#        ) AS p
  >bray-#        LEFT OUTER JOIN address AS a
  >bray-#          ON p.address = a.id
  >bray-#   WHERE p.id = '22002';

The SQL was wrong; I had missed out "address" from the fields in the
subselect.  However, the error message was very misleading:

  >ERROR:  function applied to tuple is not supported for subSELECTs
  >
  >What does the error message mean?  I can't see where a function
  >is involved.
--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Who is like Thee among the gods, O Lord? Who is like
      Thee, majestic in holiness, awesome in praises,
      working wonders?"
                              Exodus 15:11



Re: Re: Is this a bug in 7.1?

From
"Richard Huxton"
Date:
From: "Oliver Elphick" <olly@lfix.co.uk>


> "Oliver Elphick" wrote:
>   >Is this a bug or missing feature in 7.1? or have I got the SQL
>   >wrong?
>   >
>   >bray=# SELECT DISTINCT p.id, p.name, a.town
>   >bray-#   FROM (
>   >bray(#         SELECT id, name
>   >bray(#           FROM customer
>   >bray(#         UNION
>   >bray(#         SELECT id, name
>   >bray(#           FROM supplier
>   >bray(#        ) AS p
>   >bray-#        LEFT OUTER JOIN address AS a
>   >bray-#          ON p.address = a.id
>   >bray-#   WHERE p.id = '22002';
>
> The SQL was wrong; I had missed out "address" from the fields in the
> subselect.  However, the error message was very misleading:
>
>   >ERROR:  function applied to tuple is not supported for subSELECTs
>   >
>   >What does the error message mean?  I can't see where a function
>   >is involved.

Misleading, but does make some sense. Looks like you can define a function
with a table-name as parameter and use it as though an attribute:

    create function foo(tbl) returns...

    select tbl.foo;

Seems to call the function foo(...) - something to do with defining your own
types?

- Richard Huxton


Re: Is this a bug in 7.1?

From
Tom Lane
Date:
"Oliver Elphick" <olly@lfix.co.uk> writes:
> bray=# SELECT DISTINCT p.id, p.name, a.town
> bray-#   FROM (
> bray(#         SELECT id, name
> bray(#           FROM customer
> bray(#         UNION
> bray(#         SELECT id, name
> bray(#           FROM supplier
> bray(#        ) AS p
> bray-#        LEFT OUTER JOIN address AS a
> bray-#          ON p.address = a.id
> bray-#   WHERE p.id = '22002';

> ERROR:  function applied to tuple is not supported for subSELECTs

> What does the error message mean?

table.functionname is an ancient PostQUEL notation for functions that
take whole tuples --- think "address(p)" and you'll have a better idea
what the parser is seeing here.

This notation is something we're probably going to have to retire soon,
since I doubt it will play well with schema notation (too hard to guess
what foo.bar.baz means).  I doubt anyone but the regression tests still
use the PostQUEL notation for function calls anyway.

            regards, tom lane