wip-fixes.diff.txt

text/plain

Filename: wip-fixes.diff.txt
Type: text/plain
Part: 0
Message: Re: WIP Incremental JSON Parser
diff --git a/src/common/jsonapi.c b/src/common/jsonapi.c
index 8273b35b01..f7608f84b9 100644
--- a/src/common/jsonapi.c
+++ b/src/common/jsonapi.c
@@ -928,11 +928,12 @@ pg_parse_json_incremental(JsonLexContext *lex,
 				case JSON_TOKEN_END:
 					ctx = JSON_PARSE_END;
 					break;
-
-					/*
-					 * mostly we don't need to worry about non-terminals here,
-					 * but there are a few cases where we do.
-					 */
+				case JSON_NT_MORE_ARRAY_ELEMENTS:
+					ctx = JSON_PARSE_ARRAY_NEXT;
+					break;
+				case JSON_NT_ARRAY_ELEMENTS:
+					ctx = JSON_PARSE_ARRAY_START;
+					break;
 				case JSON_NT_MORE_KEY_PAIRS:
 					ctx = JSON_PARSE_OBJECT_NEXT;
 					break;
@@ -1412,7 +1413,7 @@ json_lex(JsonLexContext *lex)
 		 * see json_lex_string's handling of invalid escapes.
 		 */
 		lex->token_start = dummy_lex.token_start;
-		lex->token_terminator = ptok->data + ptok->len;
+		lex->token_terminator = dummy_lex.token_terminator;
 		if (partial_result == JSON_SUCCESS)
 			lex->inc_state->partial_completed = true;
 		return partial_result;