Re: connectby for BYTEA keys

From: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: connectby for BYTEA keys
Date: 2004-02-08 09:24:21
Message-ID: 40260045.1070000@zara.6.isreserved.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

Joe Conway wrote:
> regression=# SELECT * FROM connectby('connectby_bytea', 'keyid',
> 'parent_keyid', 'row\\002', 0, '') AS t(keyid bytea, parent_keyid bytea,
> level int, branch text);

Oh, I was specifying the fourth argument in BYTEA (decode('hex...','hex')).

Now that I enter as an escaped string, I get this error:

db1=> SELECT * FROM connectby('treeadj1b', 'id', 'parent_id',
'\\353\\024\\257\\130\\336\\305\\061\\045\\276\\175\\106\\056\\101\\173\\217\\326',
0) AS t(keyid bytea, parent_keyid bytea, level int);
ERROR: invalid input syntax for type bytea

However, direct SELECT is fine:

db1=> select encode(id,'hex'),encode(parent_id,'hex') from treeadj1b
where
id='\\353\\024\\257\\130\\336\\305\\061\\045\\276\\175\\106\\056\\101\\173\\217\\326';
encode | encode
----------------------------------+----------------------------------
eb14af58dec53125be7d462e417b8fd6 | 7c10111b13693b2bc9eea87b00914883
(1 row)

This is 7.4.1.

>> Btw, is recursive join (CONNECT BY ...) in SQL standard? (I have a
>> copy of the 1992 draft and it doesn't seem to be there).
>
> I believe it's covered in SQL99, but it is not called CONNECT BY --
> that's an Oracle-ism.

Thanks. I've looked up the DB2 documentation and saw WITH ... (SELECT
... UNION ALL ... SELECT) ... more verbose than CONNECT BY.

--
dave

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Garamond 2004-02-08 11:42:55 Partial index in other DB
Previous Message nednieuws | charles 2004-02-08 07:36:25 CREATE BLOB

Browse pgsql-patches by date

  From Date Subject
Next Message Joe Conway 2004-02-08 15:53:14 Re: connectby for BYTEA keys
Previous Message Bruce Momjian 2004-02-08 01:38:24 Re: Two-phase commit