esql/source/Database.cpp
2024-02-22 20:04:48 +01:00

28 lines
478 B
C++

#include "Database.hpp"
extern "C" {
#include "sql.tab.h"
#include "yyl.h"
#include "sql.lex.h"
#include "sql-parser.h"
}
int Database::validate(const char * const sql) {
int r;
char * dup = strdup(sql);
struct psql_state * pstate = psql_new();
if(!pstate) {
return 1;
}
psql_set_string_input(pstate, dup);
yyerrno = 0;
r = psql_parse(pstate);
psql_free(pstate);
free(dup);
return r
|| yyerrno;
}