Drop index (serial column) failed

Bug #1158185 reported by Alvin Peng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stado
Fix Committed
Undecided
Unassigned

Bug Description

Stado -> create table test(id serial, i int, c char, vc2 varchar(2)) partitioning key id on all;
OK
Stado -> create index idx on test(id);
OK
Stado -> show indexes on test;
+---------------------------------+
| indexname | isunique | columns |
+---------------------------------+
| IDX_SERIAL | NO | id |
| idx | NO | id |
+---------------------------------+
2 row(s).

It shows there are two indexes created. After reading the codes, I know that IDX_SERIAL is created by system. The index "idx" is not really created in underlying databases, while metadata is updated. This is because id is a serial column.

When trying to drop the index "idx", it failed.

Stado -> drop index idx;
SQLException: ERROR: ERROR: index "idx" does not exist

SqlDropIndex.java:
public void prepare() throws Exception {
...
if (columns.size() != 1
                    || columns.get(0) != table.getSerialColumn()) {
...

columns.get(0) != table.getSerialColumn() returns true, which is not the expected result.

The cause is when trying to create the index "idx", metadata is updated, and SyncCreateIndex.refresh() will re-read the table info. Thus, the columnlist will be re-created for the table.
However, the serialcolumn is cached and not updated.

SysTable.java:
...
    // Any table can have at most one serial column - this function
    // will get hold of that
    // particular sys column.
    public SysColumn getSerialColumn() {
        if (serialColumn == null) {
...

Related branches

Revision history for this message
Alvin Peng (pengalvin) wrote :

/src/org/postgresql/stado/metadata/SysTable.java:

void readTableInfo(boolean force) throws XDBServerException {
...
add below line to clear cached data:

          serialColumn = null;

Changed in stado:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.