pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedsimple question about using an empty string building a partial index
3+ messages / 3 participants
[nested] [flat]
* simple question about using an empty string building a partial index
@ 2011-05-03 03:52 Tom Hartnett <tdhartnett@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Hartnett @ 2011-05-03 03:52 UTC (permalink / raw)
To: pgsql-admin
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: simple question about using an empty string building a partial index
@ 2011-05-03 06:48 Guillaume Lelarge <guillaume@lelarge.info>
parent: Tom Hartnett <tdhartnett@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Guillaume Lelarge @ 2011-05-03 06:48 UTC (permalink / raw)
To: Tom Hartnett <tdhartnett@gmail.com>; +Cc: pgsql-admin
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.
--
Guillaume
http://www.postgresql.fr
http://dalibo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: simple question about using an empty string building a partial index
@ 2011-05-03 16:05 Ross J. Reedstrom <reedstrm@rice.edu>
parent: Guillaume Lelarge <guillaume@lelarge.info>
0 siblings, 0 replies; 3+ messages in thread
From: Ross J. Reedstrom @ 2011-05-03 16:05 UTC (permalink / raw)
To: pgsql-admin
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-05-03 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-03 03:52 simple question about using an empty string building a partial index Tom Hartnett <tdhartnett@gmail.com>
2011-05-03 06:48 ` Guillaume Lelarge <guillaume@lelarge.info>
2011-05-03 16:05 ` Ross J. Reedstrom <reedstrm@rice.edu>
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