diff --git a/README.md b/README.md index 24c951d..8450f84 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,20 @@ This is based on the output of [libpg_query](https://github.com/lfittl/libpg_que All credit for the hard problems goes to [Lukas Fittl](https://github.com/lfittl). +## How to re-buid + +```sh +git clone -b 10-latest git://github.com/lfittl/libpg_query +cd libpg_query +make +``` + +Then get the `.a` file and drop it in the folder in this repo. + ## Installation ```sh -npm install pg-query-native +npm install pg-query-native-latest ``` ### Documentation diff --git a/libpg_query/include/pg_query.h b/libpg_query/include/pg_query.h index ca4e67b..6745cb8 100644 --- a/libpg_query/include/pg_query.h +++ b/libpg_query/include/pg_query.h @@ -7,7 +7,7 @@ typedef struct { char* filename; // source of exception (e.g. parse.l) int lineno; // source of exception (e.g. 104) int cursorpos; // char in query at which exception occurred - char* context; // additional context (optional) + char* context; // additional context (optional, can be NULL) } PgQueryError; typedef struct { @@ -17,8 +17,7 @@ typedef struct { } PgQueryParseResult; typedef struct { - char* plpgsql_func; - char* stderr_buffer; + char* plpgsql_funcs; PgQueryError* error; } PgQueryPlpgsqlParseResult; @@ -37,7 +36,6 @@ typedef struct { extern "C" { #endif -void pg_query_init(void); PgQueryNormalizeResult pg_query_normalize(const char* input); PgQueryParseResult pg_query_parse(const char* input); PgQueryPlpgsqlParseResult pg_query_parse_plpgsql(const char* input); @@ -49,6 +47,15 @@ void pg_query_free_parse_result(PgQueryParseResult result); void pg_query_free_plpgsql_parse_result(PgQueryPlpgsqlParseResult result); void pg_query_free_fingerprint_result(PgQueryFingerprintResult result); +// Postgres version information +#define PG_VERSION "10.0" +#define PG_MAJORVERSION "10" +#define PG_VERSION_NUM 100000 + +// Deprecated APIs below + +void pg_query_init(void); // Deprecated as of 9.5-1.4.1, this is now run automatically as needed + #ifdef __cplusplus } #endif diff --git a/libpg_query/linux/libpg_query.a b/libpg_query/linux/libpg_query.a index 6a155b5..182ae70 100644 Binary files a/libpg_query/linux/libpg_query.a and b/libpg_query/linux/libpg_query.a differ diff --git a/libpg_query/osx/libpg_query.a b/libpg_query/osx/libpg_query.a index 076bf43..7067b42 100644 Binary files a/libpg_query/osx/libpg_query.a and b/libpg_query/osx/libpg_query.a differ diff --git a/test/index.js b/test/index.js index 712131f..e0602fb 100644 --- a/test/index.js +++ b/test/index.js @@ -3,15 +3,15 @@ var assert = require('assert'); describe('pg-query', function() { it('should parse a query', function() { - assert.equal(typeof query.parse('select 1').query[0].SelectStmt, 'object'); + assert.equal(typeof query.parse('select 1').query[0].RawStmt.stmt.SelectStmt, 'object'); }); it('should parse a null', function() { - assert(query.parse("select null").query[0].SelectStmt.targetList[0].ResTarget.val.A_Const.val.Null); + assert(query.parse("select null").query[0].RawStmt.stmt.SelectStmt.targetList[0].ResTarget.val.A_Const.val.Null); }); it('should parse an empty string', function() { - assert(query.parse("select ''").query[0].SelectStmt.targetList[0].ResTarget.val.A_Const.val.String.str === ''); + assert(query.parse("select ''").query[0].RawStmt.stmt.SelectStmt.targetList[0].ResTarget.val.A_Const.val.String.str === ''); }); it('should not parse a bogus query', function() {