diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index e64f701dc9..cc306d4d4d 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -272,6 +272,9 @@ base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, core_yyscan_t yyscanner)
 				/* Again save and restore *llocp */
 				cur_yylloc = *llocp;
 
+				/* Un-truncate current token so errors point to third token */
+				*(yyextra->lookahead_end) = yyextra->lookahead_hold_char;
+
 				/* Get third token */
 				next_token = core_yylex(&(yyextra->lookahead_yylval),
 										llocp, yyscanner);
