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 05:07:11 *************** *** 2413,2418 **** --- 2413,2420 ---- int i_atttypname; int i_atttypmod; int i_attstattarget; + int i_attstorage; + int i_typstorage; int i_attnotnull; int i_atthasdef; int i_attisdropped; *************** *** 2457,2469 **** if (g_fout->remoteVersion >= 70300) { ! appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, attstattarget, " ! "attnotnull, atthasdef, attisdropped, attislocal, " ! "pg_catalog.format_type(atttypid,atttypmod) as atttypname " ! "from pg_catalog.pg_attribute a " ! "where attrelid = '%s'::pg_catalog.oid " ! "and attnum > 0::pg_catalog.int2 " ! "order by attrelid, attnum", tbinfo->oid); } else if (g_fout->remoteVersion >= 70100) --- 2459,2472 ---- if (g_fout->remoteVersion >= 70300) { ! appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, " ! "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, " ! "pg_catalog.format_type(a.atttypid,a.atttypmod) as atttypname " ! "from pg_catalog.pg_attribute a, pg_catalog.pg_type t " ! "where a.atttypid = t.oid " ! "and a.attrelid = '%s'::pg_catalog.oid " ! "and a.attnum > 0::pg_catalog.int2 " ! "order by a.attrelid, a.attnum", tbinfo->oid); } else if (g_fout->remoteVersion >= 70100) *************** *** 2473,2491 **** * but we don't dump it because we can't tell whether it's * been explicitly set or was just a default. */ ! appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 as attstattarget, " ! "attnotnull, atthasdef, false as attisdropped, null as attislocal, " ! "format_type(atttypid,atttypmod) as atttypname " ! "from pg_attribute a " ! "where attrelid = '%s'::oid " ! "and attnum > 0::int2 " ! "order by attrelid, attnum", tbinfo->oid); } else { /* format_type not available before 7.1 */ ! appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 as attstattarget, " "attnotnull, atthasdef, false as attisdropped, null as attislocal, " "(select typname from pg_type where oid = atttypid) as atttypname " "from pg_attribute a " --- 2476,2495 ---- * but we don't dump it because we can't tell whether it's * been explicitly set or was just a default. */ ! appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 as attstattarget, a.attstorage, t.typstorage, " ! "a.attnotnull, a.atthasdef, false as attisdropped, null as attislocal, " ! "format_type(a.atttypid,a.atttypmod) as atttypname " ! "from pg_attribute a, pg_type t " ! "where a.atttypid = t.oid" ! "and a.attrelid = '%s'::oid " ! "and a.attnum > 0::int2 " ! "order by a.attrelid, a.attnum", tbinfo->oid); } else { /* format_type not available before 7.1 */ ! appendPQExpBuffer(q, "SELECT attnum, attname, atttypmod, -1 as attstattarget, attstorage, 'p' as typstorage, " "attnotnull, atthasdef, false as attisdropped, null as attislocal, " "(select typname from pg_type where oid = atttypid) as atttypname " "from pg_attribute a " *************** *** 2509,2514 **** --- 2513,2520 ---- i_atttypname = PQfnumber(res, "atttypname"); i_atttypmod = PQfnumber(res, "atttypmod"); i_attstattarget = PQfnumber(res, "attstattarget"); + i_attstorage = PQfnumber(res, "attstorage"); + i_typstorage = PQfnumber(res, "typstorage"); i_attnotnull = PQfnumber(res, "attnotnull"); i_atthasdef = PQfnumber(res, "atthasdef"); i_attisdropped = PQfnumber(res, "attisdropped"); *************** *** 2519,2524 **** --- 2525,2532 ---- tbinfo->atttypnames = (char **) malloc(ntups * sizeof(char *)); tbinfo->atttypmod = (int *) malloc(ntups * sizeof(int)); tbinfo->attstattarget = (int *) malloc(ntups * sizeof(int)); + tbinfo->attstorage = (char *) malloc(ntups * sizeof(char)); + tbinfo->typstorage = (char *) malloc(ntups * sizeof(char)); tbinfo->attisdropped = (bool *) malloc(ntups * sizeof(bool)); tbinfo->attislocal = (bool *) malloc(ntups * sizeof(bool)); tbinfo->attisserial = (bool *) malloc(ntups * sizeof(bool)); *************** *** 2535,2540 **** --- 2543,2550 ---- tbinfo->atttypnames[j] = strdup(PQgetvalue(res, j, i_atttypname)); tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, i_atttypmod)); tbinfo->attstattarget[j] = atoi(PQgetvalue(res, j, i_attstattarget)); + tbinfo->attstorage[j] = *(PQgetvalue(res, j, i_attstorage)); + tbinfo->typstorage[j] = *(PQgetvalue(res, j, i_typstorage)); tbinfo->attisdropped[j] = (PQgetvalue(res, j, i_attisdropped)[0] == 't'); tbinfo->attislocal[j] = (PQgetvalue(res, j, i_attislocal)[0] == 't'); tbinfo->attisserial[j] = false; /* fix below */ *************** *** 5252,5257 **** --- 5262,5268 ---- int *parentIndexes; int actual_atts; /* number of attrs in this CREATE statment */ char *reltypename; + char *storage; char *objoid; const char *((*commentDeps)[]); int j, *************** *** 5564,5576 **** appendPQExpBuffer(q, ";\n"); ! /* ! * Dump per-column statistics information. We only issue an ALTER ! * TABLE statement if the attstattarget entry for this column is ! * non-negative (i.e. it's not the default value) ! */ for (j = 0; j < tbinfo->numatts; j++) { if (tbinfo->attstattarget[j] >= 0 && !tbinfo->attisdropped[j]) { --- 5575,5588 ---- appendPQExpBuffer(q, ";\n"); ! /* Loop dumping statistics and storage statements */ for (j = 0; j < tbinfo->numatts; j++) { + /* + * Dump per-column statistics information. We only issue an ALTER + * TABLE statement if the attstattarget entry for this column is + * non-negative (i.e. it's not the default value) + */ if (tbinfo->attstattarget[j] >= 0 && !tbinfo->attisdropped[j]) { *************** *** 5580,5585 **** --- 5592,5630 ---- fmtId(tbinfo->attnames[j])); appendPQExpBuffer(q, "SET STATISTICS %d;\n", tbinfo->attstattarget[j]); + } + + /* + * Dump per-column storage information. The statement is only dumped if + * the storage has been changed. + */ + if(!tbinfo->attisdropped[j] && tbinfo->attstorage[j] != tbinfo->typstorage[j]) + { + switch (tbinfo->attstorage[j]) { + case 'p': + storage = "PLAIN"; + break; + case 'e': + storage = "EXTERNAL"; + break; + case 'm': + storage = "MAIN"; + break; + case 'x': + storage = "EXTENDED"; + break; + default: + storage = NULL; + } + /* Only dump the statement if it's a storage type we recognize */ + if (storage != NULL) { + appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", + fmtId(tbinfo->relname)); + appendPQExpBuffer(q, "ALTER COLUMN %s ", + fmtId(tbinfo->attnames[j])); + appendPQExpBuffer(q, "SET STORAGE %s;\n", + storage); + } } } } Index: src/bin/pg_dump/pg_dump.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_dump.h,v retrieving revision 1.100 diff -c -r1.100 pg_dump.h *** src/bin/pg_dump/pg_dump.h 2002/10/09 16:20:25 1.100 --- src/bin/pg_dump/pg_dump.h 2003/02/27 05:07:11 *************** *** 128,133 **** --- 128,135 ---- char **atttypnames; /* attribute type names */ int *atttypmod; /* type-specific type modifiers */ int *attstattarget; /* attribute statistics targets */ + char *attstorage; /* attribute storage scheme */ + char *typstorage; /* type storage scheme */ bool *attisdropped; /* true if attr is dropped; don't dump it */ bool *attislocal; /* true if attr has local definition */ bool *attisserial; /* true if attr is serial or bigserial */