Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.116
diff -2 -c -r1.116 psql-ref.sgml
*** doc/src/sgml/ref/psql-ref.sgml 18 Jun 2004 06:13:05 -0000 1.116
--- doc/src/sgml/ref/psql-ref.sgml 28 Jun 2004 17:59:31 -0000
***************
*** 785,789 ****
For each relation (table, view, index, or sequence) matching the
pattern, show all
! columns, their types, and any special
attributes such as NOT NULL or defaults, if
any. Associated indexes, constraints, rules, and triggers are
--- 785,790 ----
For each relation (table, view, index, or sequence) matching the
pattern, show all
! columns, their types, the tablespace they reside in (if this differs
! from the database default) and any special
attributes such as NOT NULL or defaults, if
any. Associated indexes, constraints, rules, and triggers are
Index: src/bin/psql/common.h
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/bin/psql/common.h,v
retrieving revision 1.35
diff -2 -c -r1.35 common.h
*** src/bin/psql/common.h 19 Apr 2004 17:42:58 -0000 1.35
--- src/bin/psql/common.h 24 Jun 2004 03:16:02 -0000
***************
*** 21,24 ****
--- 21,27 ----
#endif
+ #define atooid(x) ((Oid) strtoul((x), NULL, 10))
+
+
/*
* Safer versions of some standard C library functions. If an
Index: src/bin/psql/describe.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/bin/psql/describe.c,v
retrieving revision 1.99
diff -2 -c -r1.99 describe.c
*** src/bin/psql/describe.c 18 Jun 2004 06:14:04 -0000 1.99
--- src/bin/psql/describe.c 28 Jun 2004 18:02:08 -0000
***************
*** 40,43 ****
--- 40,46 ----
const char *altnamevar, const char *visibilityrule);
+ static void add_tablespace_footer(char relkind, Oid tablespace,
+ char **footers, int *count, PQExpBufferData buf);
+
/*----------------
* Handlers for various slash commands displaying some sort of list
***************
*** 683,686 ****
--- 686,690 ----
bool hasrules;
bool hasoids;
+ Oid tablespace;
} tableinfo;
bool show_modifiers = false;
***************
*** 695,699 ****
/* Get general table info */
printfPQExpBuffer(&buf,
! "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, relhasoids\n"
"FROM pg_catalog.pg_class WHERE oid = '%s'",
oid);
--- 699,704 ----
/* Get general table info */
printfPQExpBuffer(&buf,
! "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n"
! "relhasoids, reltablespace \n"
"FROM pg_catalog.pg_class WHERE oid = '%s'",
oid);
***************
*** 718,721 ****
--- 723,727 ----
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
+ tableinfo.tablespace = atooid(PQgetvalue(res, 0, 6));
PQclear(res);
***************
*** 869,873 ****
/* Make footers */
! if (tableinfo.relkind == 'i')
{
/* Footer information about an index */
--- 875,893 ----
/* Make footers */
! if(tableinfo.relkind == 'S' || tableinfo.relkind == 't')
! {
! /*
! * We can handle TOAST and sequences together, as the only
! * footer is tablespace
! */
! int count_footers = 0;
!
! footers = pg_malloc_zero(3 * sizeof(*footers));
!
! add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
! &footers[0], &count_footers, buf);
! footers[count_footers] = NULL;
! }
! else if (tableinfo.relkind == 'i')
{
/* Footer information about an index */
***************
*** 898,901 ****
--- 918,922 ----
char *indtable = PQgetvalue(result, 0, 4);
char *indpred = PQgetvalue(result, 0, 5);
+ int count_footers = 0;
if (strcmp(indisprimary, "t") == 0)
***************
*** 917,923 ****
appendPQExpBuffer(&tmpbuf, _(", CLUSTER"));
! footers = pg_malloc_zero(2 * sizeof(*footers));
! footers[0] = pg_strdup(tmpbuf.data);
! footers[1] = NULL;
}
--- 938,947 ----
appendPQExpBuffer(&tmpbuf, _(", CLUSTER"));
! footers = pg_malloc_zero(4 * sizeof(*footers));
! footers[count_footers++] = pg_strdup(tmpbuf.data);
! add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
! footers, &count_footers, tmpbuf);
! footers[count_footers] = NULL;
!
}
***************
*** 1104,1108 ****
inherits_count = PQntuples(result6);
! footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 6)
* sizeof(*footers));
--- 1128,1132 ----
inherits_count = PQntuples(result6);
! footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 7 + 1)
* sizeof(*footers));
***************
*** 1237,1240 ****
--- 1261,1266 ----
}
+ add_tablespace_footer(tableinfo.relkind, tableinfo.tablespace,
+ footers, &count_footers, buf);
/* end of list marker */
footers[count_footers] = NULL;
***************
*** 1287,1290 ****
--- 1313,1350 ----
}
+
+ static void
+ add_tablespace_footer(char relkind, Oid tablespace, char **footers,
+ int *count, PQExpBufferData buf)
+ {
+ /* relkinds for which we support tablespaces */
+ if(relkind == 'r' || relkind == 'S' || relkind == 'i' || relkind == 't')
+ {
+ /*
+ * We ignore the database default tablespace so that users not
+ * using tablespaces don't need to know about them.
+ */
+ if(tablespace != 0)
+ {
+ PGresult *result1 = NULL;
+ printfPQExpBuffer(&buf, "SELECT spcname FROM pg_tablespace \n"
+ "WHERE oid = '%u';", tablespace);
+ result1 = PSQLexec(buf.data, false);
+ if (!result1)
+ return;
+ /* Should always be the case, but.... */
+ if(PQntuples(result1) > 0)
+ {
+ printfPQExpBuffer(&buf, _("Tablespace:"));
+ footers[(*count)++] = pg_strdup(buf.data);
+ printfPQExpBuffer(&buf, _(" \"%s\""),
+ PQgetvalue(result1, 0, 0));
+
+ footers[(*count)++] = pg_strdup(buf.data);
+ }
+ PQclear(result1);
+ }
+ }
+ }
/*
Index: src/bin/psql/large_obj.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/bin/psql/large_obj.c,v
retrieving revision 1.31
diff -2 -c -r1.31 large_obj.c
*** src/bin/psql/large_obj.c 29 Nov 2003 19:52:06 -0000 1.31
--- src/bin/psql/large_obj.c 24 Jun 2004 03:16:26 -0000
***************
*** 17,23 ****
- #define atooid(x) ((Oid) strtoul((x), NULL, 10))
-
-
/*
* Prepare to do a large-object operation. We *must* be inside a transaction
--- 17,20 ----