Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/cypher/cypher-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,24 @@ static void parserSetError(CypherParser *pParser, CypherLexer *pLexer, const cha

CypherAst *cypherParse(CypherParser *pParser, const char *zQuery, char **pzErrMsg) {
if (!zQuery) {
if (pzErrMsg) *pzErrMsg = strdup("Query string is NULL");
if (pzErrMsg) *pzErrMsg = sqlite3_mprintf("%s", "Query string is NULL");
return NULL;
}
CypherLexer *pLexer = cypherLexerCreate(zQuery);
if (!pLexer) {
if (pzErrMsg) *pzErrMsg = strdup("Failed to create lexer");
if (pzErrMsg) *pzErrMsg = sqlite3_mprintf("%s", "Failed to create lexer");
return NULL;
}

pParser->pAst = parseQuery(pLexer, pParser);

if (pParser->zErrorMsg) {
if (pzErrMsg) *pzErrMsg = strdup(pParser->zErrorMsg);
/* Only set error message if parsing failed (pAst is NULL) */
if (!pParser->pAst && pParser->zErrorMsg) {
if (pzErrMsg) {
/* Copy error message using sqlite3_mprintf to ensure proper
* memory management compatibility with sqlite3_free */
*pzErrMsg = sqlite3_mprintf("%s", pParser->zErrorMsg);
}
}

cypherLexerDestroy(pLexer);
Expand Down
Loading