Adding a column with default value possibly corrupting a functional index.

From: "Rajesh Kumar Mallah" <mallah(dot)rajesh(at)gmail(dot)com>
To: "Lista Postgres" <pgsql-admin(at)postgresql(dot)org>
Subject: Adding a column with default value possibly corrupting a functional index.
Date: 2006-12-16 16:24:36
Message-ID: a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

I have an index on upper(general.cat_url(category_id)) on a table.
when i add a column *with* default value , a query that previously
used to give result does not give results anymore. REINDEX'ing the
table produces correct result. if no default value is giving while adding
the column the query continues to give proper result.

Regds
mallah.

tradein_clients=> SELECT category_id from
general.web_category_masterwhere upper(
general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)

tradein_clients=> explain SELECT category_id from
general.web_category_master where upper(general.cat_url(category_id)::text)
= 'AGRICULTURE';
+-------------------------------------------------------------------------------------------------------------+
| QUERY
PLAN |
+-------------------------------------------------------------------------------------------------------------+
| Index Scan using web_category_master_upper_cat_url on web_category_master
(cost=0.00..8.02 rows=1 width=4) |
| Index Cond: (upper((general.cat_url(category_id))::text) =
'AGRICULTURE'::text) |
+-------------------------------------------------------------------------------------------------------------+
(2 rows)

tradein_clients=> ALTER TABLE general.web_category_master add test_id int
default 0;
ALTER TABLE
tradein_clients=> SELECT category_id from
general.web_category_masterwhere upper(
general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
+-------------+
(0 rows)

tradein_clients=> REINDEX TABLE general.web_category_master;
REINDEX
tradein_clients=> SELECT category_id from
general.web_category_masterwhere upper(
general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
| 1 |
+-------------+
(1 row)

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2006-12-16 16:58:42 Re: Adding a column with default value possibly corrupting a functional index.
Previous Message Scott Marlowe 2006-12-15 19:03:46 Re: PostgreSQL Log Messages