Module Pg_query
A thin wrapper around libpg_query.
type parse_error
=
{
}
Represents a syntax error in parsing some SQL.
message
andcursorpos
are probably the most useful fields. Note thatfilename
,funcname
andlineno
refer to the location in the parsing code that the error occured, not to the input SQL.
type parse_result
=
{
parse_tree : string;
The parse tree of the query, as JSON
stderr_buffer : string option;
A field of unknown purpose
error : parse_error option;
Some parse_error
for queries where parsing failed andNone
for successful ones}
Represents the overall result of a parse
val raw_parse : string -> parse_result
Parses a string containing SQL and return a
parse_result
corresponding to the libpg_query struct
val parse : string -> (string, string) Stdlib.result
Parses a string containing SQL and returns either
Ok parse_tree
orError error_message
val show_parse_error : parse_error -> string
Derived function to display a parse error
val show_parse_result : parse_result -> string
Derived function to display a parse_result