pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Quirks in Sorting Pg_description
2+ messages / 2 participants
[nested] [flat]

* Quirks in Sorting Pg_description
@ 2010-03-03 14:15  P <user2037@live.com>
  0 siblings, 1 reply; 2+ messages in thread

From: P @ 2010-03-03 14:15 UTC (permalink / raw)
  To: pgsql-admin

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?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Quirks in Sorting Pg_description
@ 2010-03-03 15:13  Tom Lane <tgl@sss.pgh.pa.us>
  parent: P <user2037@live.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2010-03-03 15:13 UTC (permalink / raw)
  To: P <user2037@live.com>; +Cc: pgsql-admin

P <user2037@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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-03-03 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-03-03 14:15 Quirks in Sorting Pg_description P <user2037@live.com>
2010-03-03 15:13 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox