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

Commit65decc3

Browse files
committed
Allow psql to do \p\g. Ingres does it, why not us?
1 parent48fd9a2 commit65decc3

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

‎src/bin/psql/psql.c

Lines changed: 40 additions & 17 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.168 1999/02/03 21:17:44 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.169 1999/02/07 02:56:53 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1753,10 +1753,10 @@ do_shell(const char *command)
17531753
/*
17541754
* HandleSlashCmds:
17551755
*
1756-
* Handles all the different commands that start with \ db_ptr is a pointer to
1757-
* the TgDb* structure line is the current input line prompt_ptr is a pointer
1758-
* to the prompt string, a pointer is used because the prompt can be used
1759-
* with a connection to a new database.
1756+
* Handles all the different commands that start with \
1757+
*db_ptr is a pointer tothe TgDb* structure line is the current input
1758+
*line prompt_ptr is a pointerto the prompt string, a pointer is used
1759+
*because the prompt can be usedwith a connection to a new database.
17601760
* Returns a status:
17611761
*0 - send currently constructed query to backend (i.e. we got a \g)
17621762
*1 - skip processing of this line, continue building up query
@@ -2690,22 +2690,45 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
26902690

26912691
if (!in_quote&&query_start[0]=='\\')
26922692
{
2693-
slashCmdStatus=HandleSlashCmds(pset,
2694-
query_start,
2695-
query);
2696-
if (slashCmdStatus==CMD_SKIP_LINE)
2693+
/* handle \p\g and other backslash combinations */
2694+
while (query_start[0]!='\0')
26972695
{
2698-
if (query[0]=='\0')
2699-
paren_level=0;
2700-
free(line);
2701-
continue;
2696+
charhold_char;
2697+
2698+
#ifndefWIN32
2699+
/* I believe \w \dos\system\x would cause a problem */
2700+
/* do we have '\p\g' or '\p \g' ? */
2701+
if (strlen(query_start)>2&&
2702+
query_start[2+strspn(query_start+2," \t")]=='\\')
2703+
{
2704+
hold_char=query_start[2+strspn(query_start+2," \t")];
2705+
query_start[2+strspn(query_start+2," \t")]='\0';
2706+
}
2707+
else/* spread over #endif */
2708+
#endif
2709+
hold_char='\0';
2710+
2711+
slashCmdStatus=HandleSlashCmds(pset,
2712+
query_start,
2713+
query);
2714+
2715+
if (slashCmdStatus==CMD_SKIP_LINE&& !hold_char)
2716+
{
2717+
if (query[0]=='\0')
2718+
paren_level=0;
2719+
break;
2720+
}
2721+
if (slashCmdStatus==CMD_TERMINATE)
2722+
break;
2723+
2724+
query_start+=strlen(query_start);
2725+
if (hold_char)
2726+
query_start[0]=hold_char;
27022727
}
2728+
free(line);
2729+
/* They did \q, leave the loop */
27032730
if (slashCmdStatus==CMD_TERMINATE)
2704-
{
2705-
free(line);
27062731
break;
2707-
}
2708-
free(line);
27092732
}
27102733
elseif (strlen(query)+strlen(query_start)>MAX_QUERY_BUFFER)
27112734
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp