Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit265c283

Browse files
committed
> > > 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
1 parentf621b85 commit265c283

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

‎src/backend/utils/adt/like.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include"utils/builtins.h"/* where the function declarations go */
2424
#include"mb/pg_wchar.h"
2525

26-
staticintlike(pg_wchar*text,pg_wchar*p);
26+
staticintlike(pg_wchar*text,pg_wchar*p);
2727

2828
/*
2929
*interface routines called by the function manager
@@ -38,7 +38,7 @@ static intlike(pg_wchar * text, pg_wchar * p);
3838
charlen - the length of the string
3939
*/
4040
staticbool
41-
fixedlen_like(char*s,structvarlena*p,intcharlen)
41+
fixedlen_like(char*s,structvarlena*p,intcharlen)
4242
{
4343
pg_wchar*sterm,
4444
*pterm;
@@ -83,35 +83,35 @@ fixedlen_like(char *s, struct varlena * p, int charlen)
8383
}
8484

8585
bool
86-
namelike(NameData*n,structvarlena*p)
86+
namelike(NameData*n,structvarlena*p)
8787
{
8888
if (!n)
8989
return FALSE;
9090
returnfixedlen_like(n->data,p,NAMEDATALEN);
9191
}
9292

9393
bool
94-
namenlike(NameData*s,structvarlena*p)
94+
namenlike(NameData*s,structvarlena*p)
9595
{
9696
return !namelike(s,p);
9797
}
9898

9999
bool
100-
textlike(structvarlena*s,structvarlena*p)
100+
textlike(structvarlena*s,structvarlena*p)
101101
{
102102
if (!s)
103103
return FALSE;
104104
returnfixedlen_like(VARDATA(s),p,VARSIZE(s)-VARHDRSZ);
105105
}
106106

107107
bool
108-
textnlike(structvarlena*s,structvarlena*p)
108+
textnlike(structvarlena*s,structvarlena*p)
109109
{
110110
return !textlike(s,p);
111111
}
112112

113113

114-
/*$Revision: 1.21 $
114+
/*$Revision: 1.22 $
115115
**"like.c" A first attempt at a LIKE operator for Postgres95.
116116
**
117117
**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)
146146
**Match text and p, return LIKE_TRUE, LIKE_FALSE, or LIKE_ABORT.
147147
*/
148148
staticint
149-
DoMatch(pg_wchar*text,pg_wchar*p)
149+
DoMatch(pg_wchar*text,pg_wchar*p)
150150
{
151151
intmatched;
152152

@@ -189,7 +189,7 @@ DoMatch(pg_wchar * text, pg_wchar * p)
189189
**User-level routine. Returns TRUE or FALSE.
190190
*/
191191
staticint
192-
like(pg_wchar*text,pg_wchar*p)
192+
like(pg_wchar*text,pg_wchar*p)
193193
{
194194
if (p[0]=='%'&&p[1]=='\0')
195195
return TRUE;

‎src/bin/psql/psql.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.171 1999/02/21 03:49:39 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.172 1999/03/15 02:18:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -760,11 +760,35 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
760760
fout=stdout;
761761
}
762762

763+
/*
764+
* Extract the veiw name and veiw definition from pg_views.
765+
* -Ryan 2/14/99
766+
*/
767+
768+
descbuf[0]='\0';
769+
strcat(descbuf,"SELECT viewname, definition ");
770+
strcat(descbuf,"FROM pg_views ");
771+
strcat(descbuf,"WHERE viewname like '");
772+
strcat(descbuf,table);
773+
strcat(descbuf,"' ");
774+
if(!(res2=PSQLexec(pset,descbuf)))
775+
return-1;
776+
763777
/*
764778
* Display the information
765779
*/
780+
if(PQntuples(res2)) {
781+
/*
782+
* display the query.
783+
* -Ryan 2/14/99
784+
*/
785+
fprintf(fout,"\nView = %s\n",table);
786+
fprintf(fout,"Query = %s\n",PQgetvalue(res2,0,1));
787+
}else {
788+
fprintf(fout,"\nTable = %s\n",table);
789+
}
790+
PQclear(res2);
766791

767-
fprintf(fout,"\nTable = %s\n",table);
768792
fprintf(fout,"+----------------------------------+----------------------------------+-------+\n");
769793
fprintf(fout,"| Field | Type | Length|\n");
770794
fprintf(fout,"+----------------------------------+----------------------------------+-------+\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp