Adding a column with default value possibly corrupting a functional index. - Mailing list pgsql-admin

From Rajesh Kumar Mallah
Subject Adding a column with default value possibly corrupting a functional index.
Date
Msg-id a97c77030612160824w102c2326n23706171ba8a6b3a@mail.gmail.com
Whole thread Raw
Responses Re: Adding a column with default value possibly corrupting a functional index.  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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_master where  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_master where  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_master where  upper(general.cat_url(category_id)::text) = 'AGRICULTURE';
+-------------+
| category_id |
+-------------+
|           1 |
+-------------+
(1 row)


pgsql-admin by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: PostgreSQL Log Messages
Next
From: Tom Lane
Date:
Subject: Re: Adding a column with default value possibly corrupting a functional index.