Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db12a63

Browse files
committed
The \p\g fix didn't turn out to be so bad. It even works in other
circumstances: => select * from foo\x\t\pset border 0 \p\g\\select * from bar; Also the release prep update so the sql_help.h is generated before packaging. Peter.
1 parent d286f13 commit db12a63

File tree

3 files changed

+24
-397
lines changed

3 files changed

+24
-397
lines changed

src/bin/psql/command.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ static bool
5858
* Handles all the different commands that start with '\',
5959
* ordinarily called by MainLoop().
6060
*
61-
* 'line' is the current input line, which must start with a '\'
61+
* 'line' is the current input line, which should not start with a '\'
62+
* but with the actual command name
6263
* (that is taken care of by MainLoop)
6364
*
6465
* 'query_buf' contains the query-so-far, which may be modified by
@@ -89,16 +90,22 @@ HandleSlashCmds(PsqlSettings *pset,
8990
my_line = xstrdup(line);
9091

9192
/*
92-
* Find the first whitespace (or backslash) line[blank_loc] will now
93+
* Find the first whitespace. line[blank_loc] will now
9394
* be the whitespace character or the \0 at the end
95+
*
96+
* Also look for a backslash, so stuff like \p\g works.
9497
*/
95-
blank_loc = strcspn(my_line, " \t");
98+
blank_loc = strcspn(my_line, " \t\\");
9699

100+
if (my_line[blank_loc] == '\\')
101+
{
102+
continue_parse = &my_line[blank_loc];
103+
my_line[blank_loc] = '\0';
104+
}
97105
/* do we have an option string? */
98-
if (my_line[blank_loc] != '\0')
99-
{
100-
options_string = &my_line[blank_loc + 1];
101-
106+
else if (my_line[blank_loc] != '\0')
107+
{
108+
options_string = &my_line[blank_loc + 1];
102109
my_line[blank_loc] = '\0';
103110
}
104111

@@ -198,7 +205,6 @@ HandleSlashCmds(PsqlSettings *pset,
198205
}
199206

200207
cmd = my_line;
201-
202208
status = exec_command(cmd, options, options_string, query_buf, pset);
203209

204210
if (status == CMD_UNKNOWN)

0 commit comments

Comments
 (0)