Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A372A633DF8 for ; Wed, 3 Mar 2010 10:16:04 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 10437-09 for ; Wed, 3 Mar 2010 14:15:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from blu0-omc1-s36.blu0.hotmail.com (blu0-omc1-s36.blu0.hotmail.com [65.55.116.47]) by mail.postgresql.org (Postfix) with ESMTP id E3423633C78 for ; Wed, 3 Mar 2010 10:15:53 -0400 (AST) Received: from BLU0-SMTP61 ([65.55.116.9]) by blu0-omc1-s36.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 06:15:52 -0800 X-Originating-IP: [207.58.220.206] X-Originating-Email: [user2037@live.com] Message-ID: Received: from [10.3.1.60] ([207.58.220.206]) by BLU0-SMTP61.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 06:15:51 -0800 Date: Wed, 03 Mar 2010 09:15:50 -0500 From: P MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Quirks in Sorting Pg_description Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Mar 2010 14:15:51.0673 (UTC) FILETIME=[079C3690:01CABADC] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.804 tagged_above=-10 required=5 tests=BAYES_50=0.001, MSGID_FROM_MTA_HEADER=0.803 X-Spam-Level: X-Archive-Number: 201003/26 X-Sequence-Number: 33825 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?