Re: 7.1.2 release - Mailing list pgsql-hackers

From Tom Lane
Subject Re: 7.1.2 release
Date
Msg-id 2600.989558902@sss.pgh.pa.us
Whole thread Raw
In response to Re: 7.1.2 release  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: 7.1.2 release  (Philip Warner <pjw@rhyme.com.au>)
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
> Yes - it's waiting on the problem Zoltan reported (the select from
> pg_rewrite etc). I can't reproduce the problem on any of my DBs.

I've just realized that the problem is a lot simpler than it appears.
The given string is too long for a NAME:

regression=# select ('_RET' || 'szallitolevel_tetele_ervenyes')::name;           ?column?
---------------------------------_RETszallitolevel_tetele_erveny
(1 row)

When you write
select oid from pg_rewrite where        rulename='_RETszallitolevel_tetele_ervenyes'

the unknown-type literal is coerced to NAME --- ie truncated --- and
then the comparison works.  But when you write
select oid from pg_rewrite where        rulename='_RET' || 'szallitolevel_tetele_ervenyes'

the result of the || will be type TEXT not type NAME.  So the rulename
gets promoted to TEXT and texteq is used ... with the result that
_RETszallitolevel_tetele_ervenye does not match
_RETszallitolevel_tetele_ervenyes.

Solution: don't use ||, or explicitly cast its result to NAME:
select oid from pg_rewrite where        rulename=('_RET' || 'szallitolevel_tetele_ervenyes')::name
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.1.2 release
Next
From: Klaus Reger
Date:
Subject: Re: Converting PL/SQL to PL/PGSQL