Index: pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.322 diff -c -r1.322 pg_dump.c *** pg_dump.c 2003/03/20 07:05:21 1.322 --- pg_dump.c 2003/03/21 04:23:34 *************** *** 5707,5712 **** --- 5707,5713 ---- int i_indexdef; int i_contype; int i_indkey; + int i_indisclustered; int i_indnkeys; for (i = 0; i < numTables; i++) *************** *** 5736,5742 **** "SELECT i.indexrelid as indexreloid, " "coalesce(c.conname, t.relname) as indexrelname, " "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " ! "i.indkey, " "t.relnatts as indnkeys, " "coalesce(c.contype, '0') as contype " "FROM pg_catalog.pg_index i " --- 5737,5743 ---- "SELECT i.indexrelid as indexreloid, " "coalesce(c.conname, t.relname) as indexrelname, " "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " ! "i.indkey, i.indisclustered, " "t.relnatts as indnkeys, " "coalesce(c.contype, '0') as contype " "FROM pg_catalog.pg_index i " *************** *** 5756,5762 **** "SELECT i.indexrelid as indexreloid, " "t.relname as indexrelname, " "pg_get_indexdef(i.indexrelid) as indexdef, " ! "i.indkey, " "t.relnatts as indnkeys, " "CASE WHEN i.indisprimary THEN 'p'::char " "ELSE '0'::char END as contype " --- 5757,5763 ---- "SELECT i.indexrelid as indexreloid, " "t.relname as indexrelname, " "pg_get_indexdef(i.indexrelid) as indexdef, " ! "i.indkey, false as indisclustered, " "t.relnatts as indnkeys, " "CASE WHEN i.indisprimary THEN 'p'::char " "ELSE '0'::char END as contype " *************** *** 5781,5786 **** --- 5782,5788 ---- i_indexdef = PQfnumber(res, "indexdef"); i_contype = PQfnumber(res, "contype"); i_indkey = PQfnumber(res, "indkey"); + i_indisclustered = PQfnumber(res, "indisclustered"); i_indnkeys = PQfnumber(res, "indnkeys"); for (j = 0; j < ntups; j++) *************** *** 5789,5794 **** --- 5791,5797 ---- const char *indexrelname = PQgetvalue(res, j, i_indexrelname); const char *indexdef = PQgetvalue(res, j, i_indexdef); char contype = *(PQgetvalue(res, j, i_contype)); + bool indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't'); resetPQExpBuffer(q); resetPQExpBuffer(delq); *************** *** 5841,5846 **** --- 5844,5859 ---- fmtId(tbinfo->relname)); appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n", fmtId(indexrelname)); + /* + * If the index is clustered, we need to issue a CLUSTER command + * since that is the only way of setting indisclustered. + */ + if (indisclustered) { + appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER", + fmtId(tbinfo->relname)); + appendPQExpBuffer(q, " ON %s;\n", + fmtId(indexrelname)); + } ArchiveEntry(fout, indexreloid, indexrelname, *************** *** 5858,5863 **** --- 5871,5887 ---- { /* Plain secondary index */ appendPQExpBuffer(q, "%s;\n", indexdef); + + /* + * If the index is clustered, we need to issue a CLUSTER command + * since that is the only way of setting indisclustered. + */ + if (indisclustered) { + appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER", + fmtId(tbinfo->relname)); + appendPQExpBuffer(q, " ON %s;\n", + fmtId(indexrelname)); + } /* * DROP must be fully qualified in case same name appears