Quirks in Sorting Pg_description

The following query works from Psql's prompt but not from Psql's "-c"
command or from PHP's PDO interface.

SELECT description FROM pg_catalog.pg_description WHERE description
SIMILAR TO '\d+' ORDER BY description::integer DESC LIMIT 1;

The result should be the description with the highest integer value.
Instead it appears to be sorting like text even though it has been cast
to an integer.

Anyone know of a workaround?

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
P [ Mi, 03 März 2010 15:15 ] [ ID #2033905 ]

Re: Quirks in Sorting Pg_description

P <user2037 [at] live.com> writes:
> The following query works from Psql's prompt but not from Psql's "-c"
> command or from PHP's PDO interface.

> SELECT description FROM pg_catalog.pg_description WHERE description
> SIMILAR TO '\d+' ORDER BY description::integer DESC LIMIT 1;

1. I think you'll find that "SIMILAR TO '\d+'" doesn't do what you
think; or at least, if it does, that's an implementation artifact
not to be relied on. Use a POSIX regex operator instead.

2. Perhaps the context sensitivity of the behavior is explained by the
shell or PHP eating the backslash? It certainly seems like you're at
risk for different numbers of levels of backslash processing in these
cases.

regards, tom lane

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Tom Lane [ Mi, 03 März 2010 16:13 ] [ ID #2033907 ]
Datenbanken » gmane.comp.db.postgresql.admin » Quirks in Sorting Pg_description

Vorheriges Thema: --with-wal-segsize in-effective?
Nächstes Thema: Restart failed with 'service postgresql restart'