From 25a64f75192509dee77db6f843fd59bb50226a45 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 21 Sep 1998 02:25:29 +0000 Subject: [PATCH] Fix for \z formatting from Tom Lane. --- src/backend/optimizer/util/ordering.c | 7 +--- src/bin/psql/psql.c | 58 ++++++++++++++++++++++----- src/include/port/svr4.h | 7 ++++ src/include/storage/s_lock.h | 15 ++++++- src/interfaces/ecpg/preproc/Makefile | 2 +- 5 files changed, 72 insertions(+), 17 deletions(-) diff --git a/src/backend/optimizer/util/ordering.c b/src/backend/optimizer/util/ordering.c index 1157a3c709..f440f23080 100644 --- a/src/backend/optimizer/util/ordering.c +++ b/src/backend/optimizer/util/ordering.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.7 1998/09/01 03:23:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.8 1998/09/21 02:25:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,11 @@ equal_path_path_ordering(PathOrder *path_ordering1, if (path_ordering1->ordtype == MERGE_ORDER && path_ordering2->ordtype == MERGE_ORDER) { - return equal(path_ordering1->ord.merge, path_ordering2->ord.merge); - } else if (path_ordering1->ordtype == SORTOP_ORDER && path_ordering2->ordtype == SORTOP_ORDER) { - return (equal_sortops_order(path_ordering1->ord.sortop, path_ordering2->ord.sortop)); @@ -53,14 +50,12 @@ equal_path_path_ordering(PathOrder *path_ordering1, else if (path_ordering1->ordtype == MERGE_ORDER && path_ordering2->ordtype == SORTOP_ORDER) { - return (path_ordering2->ord.sortop && (path_ordering1->ord.merge->left_operator == path_ordering2->ord.sortop[0])); } else { - return (path_ordering1->ord.sortop && (path_ordering1->ord.sortop[0] == path_ordering2->ord.merge->left_operator)); diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index 80a917cb1d..dfc91ee794 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.160 1998/09/03 05:08:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.161 1998/09/21 02:25:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -156,6 +156,7 @@ static int tableList(PsqlSettings *pset, bool deep_tablelist, static int tableDesc(PsqlSettings *pset, char *table, FILE *fout); static int objectDescription(PsqlSettings *pset, char *object); static int rightsList(PsqlSettings *pset); +static void emitNtimes (FILE *fout, const char *str, int N); static void prompt_for_password(char *username, char *password); static char *gets_noreadline(char *prompt, FILE *source); @@ -244,7 +245,7 @@ slashUsage(PsqlSettings *pset) /* if you add/remove a line here, change the row test above */ fprintf(fout, " \\? -- help\n"); - fprintf(fout, " \\a -- toggle field-alignment (currenty %s)\n", on(pset->opt.align)); + fprintf(fout, " \\a -- toggle field-alignment (currently %s)\n", on(pset->opt.align)); fprintf(fout, " \\C [] -- set html3 caption (currently '%s')\n", pset->opt.caption ? pset->opt.caption : ""); fprintf(fout, " \\connect -- connect to new database (currently '%s')\n", PQdb(pset->db)); fprintf(fout, " \\copy table {from | to} \n"); @@ -540,6 +541,8 @@ rightsList(PsqlSettings *pset) char listbuf[512]; int nColumns; int i; + int maxCol1Len; + int maxCol2Len; int usePipe = 0; char *pagerenv; FILE *fout; @@ -583,21 +586,50 @@ rightsList(PsqlSettings *pset) else fout = stdout; + /* choose column widths */ + maxCol1Len = strlen("Relation"); + maxCol2Len = strlen("Grant/Revoke Permissions"); + for (i = 0; i < PQntuples(res); i++) + { + int l = strlen(PQgetvalue(res, i, 0)); + if (l > maxCol1Len) + maxCol1Len = l; + l = strlen(PQgetvalue(res, i, 1)); + if (l > maxCol2Len) + maxCol2Len = l; + } + /* Display the information */ fprintf(fout, "\nDatabase = %s\n", PQdb(pset->db)); - fprintf(fout, " +------------------+----------------------------------------------------+\n"); - fprintf(fout, " | Relation | Grant/Revoke Permissions |\n"); - fprintf(fout, " +------------------+----------------------------------------------------+\n"); + fprintf(fout, " +"); + emitNtimes(fout, "-", maxCol1Len+2); + fprintf(fout, "+"); + emitNtimes(fout, "-", maxCol2Len+2); + fprintf(fout, "+\n"); + fprintf(fout, " | %-*s | %-*s |\n", + maxCol1Len, "Relation", + maxCol2Len, "Grant/Revoke Permissions"); + fprintf(fout, " +"); + emitNtimes(fout, "-", maxCol1Len+2); + fprintf(fout, "+"); + emitNtimes(fout, "-", maxCol2Len+2); + fprintf(fout, "+\n"); /* next, print out the instances */ for (i = 0; i < PQntuples(res); i++) { - fprintf(fout, " | %-16.16s", PQgetvalue(res, i, 0)); - fprintf(fout, " | %-50.50s | ", PQgetvalue(res, i, 1)); - fprintf(fout, "\n"); + fprintf(fout, " | %-*s | %-*s |\n", + maxCol1Len, PQgetvalue(res, i, 0), + maxCol2Len, PQgetvalue(res, i, 1)); } - fprintf(fout, " +------------------+----------------------------------------------------+\n"); + + fprintf(fout, " +"); + emitNtimes(fout, "-", maxCol1Len+2); + fprintf(fout, "+"); + emitNtimes(fout, "-", maxCol2Len+2); + fprintf(fout, "+\n"); + PQclear(res); if (usePipe) { @@ -614,6 +646,14 @@ rightsList(PsqlSettings *pset) } } +static void emitNtimes (FILE *fout, const char *str, int N) +{ + int i; + for (i = 0; i < N; i++) { + fputs(str, fout); + } +} + /* * Describe a table * diff --git a/src/include/port/svr4.h b/src/include/port/svr4.h index 56e7dbd9e2..b5d2a80e56 100644 --- a/src/include/port/svr4.h +++ b/src/include/port/svr4.h @@ -8,3 +8,10 @@ #define BYTE_ORDER BIG_ENDIAN #endif #endif + +#ifdef sinix +#define HAS_TEST_AND_SET + +#include +typedef abilock_t slock_t; +#endif diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 7b531fda72..d3f9d6d9b2 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.49 1998/09/18 17:18:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.50 1998/09/21 02:25:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -273,6 +273,19 @@ static const slock_t clear_lock = #define S_LOCK_FREE(lock) (test_then_add(lock,0) == 0) #endif /* __sgi */ +#if defined(sinix) +/* + * SINIX / Reliant UNIX + * slock_t is defined as a struct abilock_t, which has a single unsigned long + * member. (Basically same as SGI) + * + */ +#define TAS(lock) (!acquire_lock(lock)) +#define S_UNLOCK(lock) release_lock(lock) +#define S_INIT_LOCK(lock) init_lock(lock) +#define S_LOCK_FREE(lock) (stat_lock(lock) == UNLOCKED) +#endif /* sinix */ + #if defined(_AIX) /* diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index 2072595595..9ddd1fdd18 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -25,7 +25,7 @@ uninstall: # Rule that really do something. ecpg: $(OBJ) - $(CC) -o ecpg $(OBJ) $(LEXLIB) + $(CC) -o ecpg $(OBJ) $(LEXLIB) $(LDFLAGS) y.tab.h y.tab.c: preproc.y $(YACC) $(YFLAGS) $<