From: Ross J. Reedstrom <reedstrm@rice.edu>
To: pgsql-admin@postgresql.org
Subject: Re: simple question about using an empty string building a partial index
Date: Tue, 3 May 2011 11:05:38 -0500
Message-ID: <20110503160537.GA434@rice.edu> (raw)
In-Reply-To: <4DBFA533.6080700@lelarge.info>
References: <BANLkTimkN8c4WVtNGQY0nbY_aPdR-yiEfg@mail.gmail.com>
<4DBFA533.6080700@lelarge.info>
On Tue, May 03, 2011 at 08:48:19AM +0200, Guillaume Lelarge wrote:
> On 05/03/2011 05:52 AM, Tom Hartnett wrote:
> > can it be done?
> >
> > create index my_idx on my_table(col1) where col1='';
> >
> > ERROR: invalid input syntax for integer: ""
> >
> > Seems simple enough but I don't know what the trick is.
> >
>
> col1 is an integer, not a string. And you cannot check for empty string
> in an integer column.
So if you've got a lot of records that display that column as an emtpy
string, it's actually probably filled with a NULL, so your index create
command would be something like:
create index my_idx on my_table(col1) where col1 is null;
Ross
--
Ross Reedstrom, Ph.D. reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist phone: 713-348-6166
Connexions http://cnx.org fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: reedstrm@rice.edu
Subject: Re: simple question about using an empty string building a partial index
In-Reply-To: <20110503160537.GA434@rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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