Skip site navigation (1) Skip section navigation (2)

Re: BUG #5716: Regression joining tables in UPDATE with composite types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andrew Tipton" <andrew(at)adioso(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5716: Regression joining tables in UPDATE with composite types
Date: 2010-10-19 19:15:06
Message-ID: 7068.1287515706@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Andrew Tipton" <andrew(at)adioso(dot)com> writes:
> Attempting to execute an UPDATE that joins to another table where the join
> condition is comparing a composite type fails with the (presumably internal)
> error message "psql:testcase.sql:29: ERROR:  could not find pathkey item to
> sort".

Fixed, thanks for the report!

BTW ... while this is unrelated to the cause of the problem, I think
this is quite an inefficient coding technique:

> CREATE TYPE price_key AS (
>     id INTEGER
> );

> CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
>     SELECT $1.id
> $$ LANGUAGE SQL IMMUTABLE;

> CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
>     SELECT $1.id
> $$ LANGUAGE SQL IMMUTABLE;

> UPDATE price ...
>     WHERE price_key_from_table(price.*) = price_key_from_input(input_prices.*);

Comparing composite types is probably a good two orders of magnitude
slower than comparing plain ints would be.  I'm sure that coding
technique looks cute, but you're paying through the nose for it.
Consider making price_key a simple domain over int.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Jeff DavisDate: 2010-10-19 19:40:14
Subject: Re: Recovery bug
Previous:From: Jeff DavisDate: 2010-10-19 16:51:35
Subject: Re: Recovery bug

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group