Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
cad3e709
Commit
cad3e709
authored
27 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Fix for backslash quote.
parent
38d2ca54
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/psql/psql.c
+22
-21
22 additions, 21 deletions
src/bin/psql/psql.c
with
22 additions
and
21 deletions
src/bin/psql/psql.c
+
22
−
21
View file @
cad3e709
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.9
7
1997/09/
19 03:42:3
9 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.9
8
1997/09/
23 19:47:5
9 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1185,7 +1185,7 @@ do_help(PsqlSettings *pset, const char *topic)
...
@@ -1185,7 +1185,7 @@ do_help(PsqlSettings *pset, const char *topic)
printf
(
"%-25s
\n
"
,
QL_HELP
[
i
].
cmd
);
printf
(
"%-25s
\n
"
,
QL_HELP
[
i
].
cmd
);
left_center_right
=
'L'
;
left_center_right
=
'L'
;
break
;
break
;
}
;
}
i
++
;
i
++
;
}
}
if
(
left_center_right
!=
'L'
)
if
(
left_center_right
!=
'L'
)
...
@@ -1649,6 +1649,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1649,6 +1649,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
/* We've reached the end of our command input. */
/* We've reached the end of our command input. */
bool
success
;
bool
success
;
bool
in_quote
;
bool
in_quote
;
bool
was_bslash
;
/* backslash */
int
paren_level
;
int
paren_level
;
char
*
query_start
;
char
*
query_start
;
...
@@ -1737,7 +1738,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1737,7 +1738,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
{
{
query_start
=
line
;
query_start
=
line
;
xcomment
=
line
;
xcomment
=
line
;
}
;
}
if
(
line
==
NULL
)
if
(
line
==
NULL
)
{
/* No more input. Time to quit */
{
/* No more input. Time to quit */
...
@@ -1774,9 +1775,11 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1774,9 +1775,11 @@ MainLoop(PsqlSettings *pset, FILE *source)
{
{
int
i
;
int
i
;
was_bslash
=
false
;
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
i
=
0
;
i
<
len
;
i
++
)
{
{
if
(
line
[
i
]
==
'\\'
)
if
(
line
[
i
]
==
'\\'
&&
!
in_quote
)
{
{
char
hold_char
=
line
[
i
];
char
hold_char
=
line
[
i
];
...
@@ -1791,7 +1794,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1791,7 +1794,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
else
else
{
{
strcpy
(
query
,
query_start
);
strcpy
(
query
,
query_start
);
}
;
}
}
}
line
[
i
]
=
hold_char
;
line
[
i
]
=
hold_char
;
query_start
=
line
+
i
;
query_start
=
line
+
i
;
...
@@ -1806,32 +1809,32 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1806,32 +1809,32 @@ MainLoop(PsqlSettings *pset, FILE *source)
querySent
=
false
;
querySent
=
false
;
}
}
if
(
was_bslash
)
was_bslash
=
false
;
else
if
(
i
>
0
&&
line
[
i
-
1
]
==
'\\'
)
was_bslash
=
true
;
/* inside a quote? */
/* inside a quote? */
if
(
in_quote
&&
(
line
[
i
]
!=
'\''
))
if
(
in_quote
&&
(
line
[
i
]
!=
'\''
||
was_bslash
))
{
{
continue
;
/* do nothing */
;
/* inside an extended comment? */
}
}
else
if
(
xcomment
!=
NULL
)
else
if
(
xcomment
!=
NULL
)
/*inside an extended comment?*/
{
{
if
(
line
[
i
]
==
'*'
&&
line
[
i
+
1
]
==
'/'
)
if
(
line
[
i
]
==
'*'
&&
line
[
i
+
1
]
==
'/'
)
{
{
xcomment
=
NULL
;
xcomment
=
NULL
;
i
++
;
i
++
;
};
}
continue
;
/* possible backslash command? */
}
}
/* possible backslash command? */
else
if
(
line
[
i
]
==
'/'
&&
line
[
i
+
1
]
==
'*'
)
else
if
(
line
[
i
]
==
'/'
&&
line
[
i
+
1
]
==
'*'
)
{
{
xcomment
=
line
+
i
;
xcomment
=
line
+
i
;
i
++
;
i
++
;
continue
;
/* single-line comment? truncate line */
}
}
/* single-line comment? truncate line */
else
if
((
line
[
i
]
==
'-'
&&
line
[
i
+
1
]
==
'-'
)
||
else
if
((
line
[
i
]
==
'-'
&&
line
[
i
+
1
]
==
'-'
)
||
(
line
[
i
]
==
'/'
&&
line
[
i
+
1
]
==
'/'
))
(
line
[
i
]
==
'/'
&&
line
[
i
+
1
]
==
'/'
))
{
{
...
@@ -1840,14 +1843,12 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1840,14 +1843,12 @@ MainLoop(PsqlSettings *pset, FILE *source)
fprintf
(
stdout
,
"%s
\n
"
,
line
+
i
);
fprintf
(
stdout
,
"%s
\n
"
,
line
+
i
);
line
[
i
]
=
'\0'
;
/* remove comment */
line
[
i
]
=
'\0'
;
/* remove comment */
break
;
break
;
}
}
else
if
(
line
[
i
]
==
'\''
)
else
if
(
line
[
i
]
==
'\''
)
{
{
in_quote
^=
1
;
in_quote
^=
1
;
/* semi-colon? then send query now */
}
}
/* semi-colon? then send query now */
else
if
(
!
paren_level
&&
line
[
i
]
==
';'
)
else
if
(
!
paren_level
&&
line
[
i
]
==
';'
)
{
{
char
hold_char
=
line
[
i
+
1
];
char
hold_char
=
line
[
i
+
1
];
...
@@ -1878,10 +1879,10 @@ MainLoop(PsqlSettings *pset, FILE *source)
...
@@ -1878,10 +1879,10 @@ MainLoop(PsqlSettings *pset, FILE *source)
else
if
(
paren_level
&&
line
[
i
]
==
')'
)
else
if
(
paren_level
&&
line
[
i
]
==
')'
)
{
{
paren_level
--
;
paren_level
--
;
}
;
}
}
}
}
}
puts
(
line
);
/* nothing on line after trimming? then ignore */
/* nothing on line after trimming? then ignore */
if
(
line
[
0
]
==
'\0'
)
if
(
line
[
0
]
==
'\0'
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment