summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorMark Wong <markwkm@gmail.com>2007-09-27 21:11:25 -0700
committerMark Wong <markwkm@gmail.com>2007-09-27 21:11:25 -0700
commit91d124604245ac6fba15c4c06c881d7622ecfb0f (patch)
treecc258253af4b33ea5a67331de4daed369648c386 /commands.c
parentafa3812f7bad5f7397200ca2113d2671b456c3ed (diff)
Made the display of the held locks nicer looking, it not more efficient.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/commands.c b/commands.c
index c286aa6..c3b104c 100644
--- a/commands.c
+++ b/commands.c
@@ -599,7 +599,7 @@ show_explain(char *conninfo, int procpid)
void
show_locks(char *conninfo, int procpid)
{
- int i;
+ int i, j, k;
int rows;
char *sql;
char info[64];
@@ -640,14 +640,26 @@ show_locks(char *conninfo, int procpid)
if (strlen(PQgetvalue(pgresult, i, 3)) > width[4])
width[4] = strlen(PQgetvalue(pgresult, i, 3));
}
- sprintf(header_format, "%%-%ds | %%-%ds | %%-%ds | %%-%ds | %%-%ds\n\n",
+ sprintf(header_format, "%%-%ds | %%-%ds | %%-%ds | %%-%ds | %%-%ds\n",
width[0], width[1], width[2], width[3], width[4]);
sprintf(line_format, "%%%dd | %%-%ds | %%-%ds | %%-%ds | %%-%ds\n",
width[0], width[1], width[2], width[3], width[4]);
- /* Display data. */
+ /* Display the header. */
sprintf(line, header_format, "", "database", "table", "type", "granted");
display_pager(line);
+ for (i = 0, k = 0; i < 5; i++) {
+ for (j = 0; j < width[i]; j++, k++) {
+ line[k] = '-';
+ }
+ line[k++] = '-';
+ line[k++] = '+';
+ line[k++] = '-';
+ }
+ line[k - 3] = '\0';
+ display_pager(line);
+
+ /* Display data. */
for (i = 0; i < rows; i++) {
sprintf(line, line_format, i + 1, PQgetvalue(pgresult, i, 0),
PQgetvalue(pgresult, i, 1), PQgetvalue(pgresult, i, 2),