|
3 | 3 | *
|
4 | 4 | * Copyright 2000 by PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.51 2002/04/24 05:24:00 petere Exp $ |
| 6 | + * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.52 2002/04/24 06:17:04 petere Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 | #include "describe.h"
|
@@ -662,21 +662,31 @@ describeTableDetails(const char *name, bool desc)
|
662 | 662 | }
|
663 | 663 | else
|
664 | 664 | {
|
| 665 | + PQExpBufferData tmpbuf; |
665 | 666 | char *indisunique = PQgetvalue(result, 0, 0);
|
666 | 667 | char *indisprimary = PQgetvalue(result, 0, 1);
|
667 | 668 | char *indamname = PQgetvalue(result, 0, 2);
|
668 | 669 | char *indtable = PQgetvalue(result, 0, 3);
|
669 | 670 | char *indpred = PQgetvalue(result, 0, 4);
|
670 | 671 |
|
| 672 | + initPQExpBuffer(&tmpbuf); |
| 673 | + |
| 674 | + if (strcmp(indisprimary, "t") == 0) |
| 675 | + printfPQExpBuffer(&tmpbuf, _("primary key, ")); |
| 676 | + else if (strcmp(indisunique, "t") == 0) |
| 677 | + printfPQExpBuffer(&tmpbuf, _("unique, ")); |
| 678 | + else |
| 679 | + resetPQExpBuffer(&tmpbuf); |
| 680 | + appendPQExpBuffer(&tmpbuf, "%s, ", indamname); |
| 681 | + |
| 682 | + appendPQExpBuffer(&tmpbuf, _("for table \"%s\""), indtable); |
| 683 | + if (strlen(indpred)) |
| 684 | + appendPQExpBuffer(&tmpbuf, ", predicate %s", indpred); |
| 685 | + |
671 | 686 | footers = xmalloc(2 * sizeof(*footers));
|
672 |
| - /* XXX This construction is poorly internationalized. */ |
673 |
| - footers[0] = xmalloc(NAMEDATALEN*4 + 128); |
674 |
| - snprintf(footers[0], NAMEDATALEN*4 + 128, "%s%s for %s \"%s\"%s%s", |
675 |
| - strcmp(indisprimary, "t") == 0 ? _("primary key ") : |
676 |
| - strcmp(indisunique, "t") == 0 ? _("unique ") : "", |
677 |
| - indamname, _("table"), indtable, |
678 |
| - strlen(indpred) ? " WHERE " : "",indpred); |
| 687 | + footers[0] = xstrdup(tmpbuf.data); |
679 | 688 | footers[1] = NULL;
|
| 689 | + termPQExpBuffer(&tmpbuf); |
680 | 690 | }
|
681 | 691 |
|
682 | 692 | PQclear(result);
|
|
0 commit comments