Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.318 diff -c -r1.318 pg_dump.c *** src/bin/pg_dump/pg_dump.c 2003/02/13 22:56:52 1.318 --- src/bin/pg_dump/pg_dump.c 2003/02/27 06:17:00 *************** *** 5653,5658 **** --- 5653,5659 ---- int i_indexdef; int i_contype; int i_indkey; + int i_indisclustered; int i_indnkeys; for (i = 0; i < numTables; i++) *************** *** 5682,5688 **** "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 " --- 5683,5689 ---- "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 " *************** *** 5702,5708 **** "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 " --- 5703,5709 ---- "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 " *************** *** 5727,5732 **** --- 5728,5734 ---- 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++) *************** *** 5735,5740 **** --- 5737,5743 ---- 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); *************** *** 5788,5793 **** --- 5791,5808 ---- 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. XXX There + * has to be a better way, as this will cause a CLUSTER during restore. + */ + if (indisclustered) { + appendPQExpBuffer(q, "\nCLUSTER %s", + fmtId(indexrelname)); + appendPQExpBuffer(q, " ON %s;\n", + fmtId(tbinfo->relname)); + } + ArchiveEntry(fout, indexreloid, indexrelname, tbinfo->relnamespace->nspname, *************** *** 5804,5809 **** --- 5819,5836 ---- { /* 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. XXX There + * has to be a better way, as this will cause a CLUSTER during restore. + */ + if (indisclustered) { + appendPQExpBuffer(q, "\nCLUSTER %s", + fmtId(indexrelname)); + appendPQExpBuffer(q, " ON %s;\n", + fmtId(tbinfo->relname)); + } /* * DROP must be fully qualified in case same name appears