mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
> > > 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
This commit is contained in:
@ -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);
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
** 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)
|
|||||||
** 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 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -761,10 +761,34 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display the information
|
* Extract the veiw name and veiw definition from pg_views.
|
||||||
|
* -Ryan 2/14/99
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fprintf(fout, "\nTable = %s\n", table);
|
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
|
||||||
|
*/
|
||||||
|
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, "+----------------------------------+----------------------------------+-------+\n");
|
fprintf(fout, "+----------------------------------+----------------------------------+-------+\n");
|
||||||
fprintf(fout, "| Field | Type | Length|\n");
|
fprintf(fout, "| Field | Type | Length|\n");
|
||||||
fprintf(fout, "+----------------------------------+----------------------------------+-------+\n");
|
fprintf(fout, "+----------------------------------+----------------------------------+-------+\n");
|
||||||
|
Reference in New Issue
Block a user