Commit 265c283e authored by Bruce Momjian's avatar Bruce Momjian

> > > This patches src/bin/psql/psql.c.

> > >
> > > This patch is in responce to the following TODO list item:
> > >  * have psql \d on a view show the query
> > > -Ryan
parent f621b85a
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "utils/builtins.h" /* where the function declarations go */ #include "utils/builtins.h" /* where the function declarations go */
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
static int like(pg_wchar * text, pg_wchar * p); static int like(pg_wchar *text, pg_wchar *p);
/* /*
* interface routines called by the function manager * interface routines called by the function manager
...@@ -38,7 +38,7 @@ static int like(pg_wchar * text, pg_wchar * p); ...@@ -38,7 +38,7 @@ static int like(pg_wchar * text, pg_wchar * p);
charlen - the length of the string charlen - the length of the string
*/ */
static bool static bool
fixedlen_like(char *s, struct varlena * p, int charlen) fixedlen_like(char *s, struct varlena *p, int charlen)
{ {
pg_wchar *sterm, pg_wchar *sterm,
*pterm; *pterm;
...@@ -83,7 +83,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen) ...@@ -83,7 +83,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen)
} }
bool bool
namelike(NameData *n, struct varlena * p) namelike(NameData *n, struct varlena *p)
{ {
if (!n) if (!n)
return FALSE; return FALSE;
...@@ -91,13 +91,13 @@ namelike(NameData *n, struct varlena * p) ...@@ -91,13 +91,13 @@ namelike(NameData *n, struct varlena * p)
} }
bool bool
namenlike(NameData *s, struct varlena * p) namenlike(NameData *s, struct varlena *p)
{ {
return !namelike(s, p); return !namelike(s, p);
} }
bool bool
textlike(struct varlena * s, struct varlena * p) textlike(struct varlena *s, struct varlena *p)
{ {
if (!s) if (!s)
return FALSE; return FALSE;
...@@ -105,13 +105,13 @@ textlike(struct varlena * s, struct varlena * p) ...@@ -105,13 +105,13 @@ textlike(struct varlena * s, struct varlena * p)
} }
bool bool
textnlike(struct varlena * s, struct varlena * p) textnlike(struct varlena *s, struct varlena *p)
{ {
return !textlike(s, p); return !textlike(s, p);
} }
/* $Revision: 1.21 $ /* $Revision: 1.22 $
** "like.c" A first attempt at a LIKE operator for Postgres95. ** "like.c" A first attempt at a LIKE operator for Postgres95.
** **
** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. ** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
...@@ -146,7 +146,7 @@ textnlike(struct varlena * s, struct varlena * p) ...@@ -146,7 +146,7 @@ textnlike(struct varlena * s, struct varlena * p)
** Match text and p, return LIKE_TRUE, LIKE_FALSE, or LIKE_ABORT. ** Match text and p, return LIKE_TRUE, LIKE_FALSE, or LIKE_ABORT.
*/ */
static int static int
DoMatch(pg_wchar * text, pg_wchar * p) DoMatch(pg_wchar *text, pg_wchar *p)
{ {
int matched; int matched;
...@@ -189,7 +189,7 @@ DoMatch(pg_wchar * text, pg_wchar * p) ...@@ -189,7 +189,7 @@ DoMatch(pg_wchar * text, pg_wchar * p)
** User-level routine. Returns TRUE or FALSE. ** User-level routine. Returns TRUE or FALSE.
*/ */
static int static int
like(pg_wchar * text, pg_wchar * p) like(pg_wchar *text, pg_wchar *p)
{ {
if (p[0] == '%' && p[1] == '\0') if (p[0] == '%' && p[1] == '\0')
return TRUE; return TRUE;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.171 1999/02/21 03:49:39 scrappy Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.172 1999/03/15 02:18:37 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -760,11 +760,35 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout) ...@@ -760,11 +760,35 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
fout = stdout; fout = stdout;
} }
/*
* Extract the veiw name and veiw definition from pg_views.
* -Ryan 2/14/99
*/
descbuf[0] = '\0';
strcat(descbuf, "SELECT viewname, definition ");
strcat(descbuf, "FROM pg_views ");
strcat(descbuf, "WHERE viewname like '");
strcat(descbuf, table);
strcat(descbuf, "' ");
if(!(res2 = PSQLexec(pset, descbuf)))
return -1;
/* /*
* Display the information * Display the information
*/ */
if(PQntuples(res2)) {
/*
* display the query.
* -Ryan 2/14/99
*/
fprintf(fout, "\nView = %s\n", table);
fprintf(fout, "Query = %s\n", PQgetvalue(res2, 0, 1));
} else {
fprintf(fout, "\nTable = %s\n", table);
}
PQclear(res2);
fprintf(fout, "\nTable = %s\n", table);
fprintf(fout, "+----------------------------------+----------------------------------+-------+\n"); fprintf(fout, "+----------------------------------+----------------------------------+-------+\n");
fprintf(fout, "| Field | Type | Length|\n"); fprintf(fout, "| Field | Type | Length|\n");
fprintf(fout, "+----------------------------------+----------------------------------+-------+\n"); fprintf(fout, "+----------------------------------+----------------------------------+-------+\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment