pg_query 0.7.0

PostgreSQL parser that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.
Documentation
const char* tests[] = {
  "SELECT 1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT 1; SELECT 2",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"stmt_len\":8},{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":2}},\"location\":17}},\"location\":17}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"stmt_location\":9}]}",
  "select sum(unique1) FILTER (WHERE unique1 IN (SELECT unique1 FROM onek where unique1 < 100)) FROM tenk1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"sum\"}}],\"args\":[{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":11}}],\"agg_filter\":{\"SubLink\":{\"subLinkType\":\"ANY_SUBLINK\",\"testexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":34}},\"subselect\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":53}},\"location\":53}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"onek\",\"inh\":true,\"relpersistence\":\"p\",\"location\":66}}],\"whereClause\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"\\u003c\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":77}},\"rexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":100}},\"location\":87}},\"location\":85}},\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"location\":42}},\"location\":7}},\"location\":7}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"tenk1\",\"inh\":true,\"relpersistence\":\"p\",\"location\":98}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "select sum(unique1) FILTER (WHERE unique1 = ANY (SELECT unique1 FROM onek where unique1 < 100)) FROM tenk1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"sum\"}}],\"args\":[{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":11}}],\"agg_filter\":{\"SubLink\":{\"subLinkType\":\"ANY_SUBLINK\",\"testexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":34}},\"operName\":[{\"String\":{\"str\":\"=\"}}],\"subselect\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":56}},\"location\":56}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"onek\",\"inh\":true,\"relpersistence\":\"p\",\"location\":69}}],\"whereClause\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"\\u003c\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"unique1\"}}],\"location\":80}},\"rexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":100}},\"location\":90}},\"location\":88}},\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"location\":42}},\"location\":7}},\"location\":7}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"tenk1\",\"inh\":true,\"relpersistence\":\"p\",\"location\":101}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "CREATE FOREIGN TABLE films (code char(5) NOT NULL, title varchar(40) NOT NULL, did integer NOT NULL, date_prod date, kind varchar(10), len interval hour to minute) SERVER film_server;",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"CreateForeignTableStmt\":{\"base\":{\"relation\":{\"relname\":\"films\",\"inh\":true,\"relpersistence\":\"p\",\"location\":21},\"tableElts\":[{\"ColumnDef\":{\"colname\":\"code\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"bpchar\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":5}},\"location\":38}}],\"typemod\":-1,\"location\":33},\"is_local\":true,\"constraints\":[{\"Constraint\":{\"contype\":\"CONSTR_NOTNULL\",\"location\":41}}],\"location\":28}},{\"ColumnDef\":{\"colname\":\"title\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"varchar\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":40}},\"location\":65}}],\"typemod\":-1,\"location\":57},\"is_local\":true,\"constraints\":[{\"Constraint\":{\"contype\":\"CONSTR_NOTNULL\",\"location\":69}}],\"location\":51}},{\"ColumnDef\":{\"colname\":\"did\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"int4\"}}],\"typemod\":-1,\"location\":83},\"is_local\":true,\"constraints\":[{\"Constraint\":{\"contype\":\"CONSTR_NOTNULL\",\"location\":91}}],\"location\":79}},{\"ColumnDef\":{\"colname\":\"date_prod\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"date\"}}],\"typemod\":-1,\"location\":111},\"is_local\":true,\"location\":101}},{\"ColumnDef\":{\"colname\":\"kind\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"varchar\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":10}},\"location\":130}}],\"typemod\":-1,\"location\":122},\"is_local\":true,\"location\":117}},{\"ColumnDef\":{\"colname\":\"len\",\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"interval\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":3072}},\"location\":148}}],\"typemod\":-1,\"location\":139},\"is_local\":true,\"location\":135}}],\"oncommit\":\"ONCOMMIT_NOOP\"},\"servername\":\"film_server\"}},\"stmt_len\":182}]}",
  "CREATE FOREIGN TABLE ft1 () SERVER no_server",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"CreateForeignTableStmt\":{\"base\":{\"relation\":{\"relname\":\"ft1\",\"inh\":true,\"relpersistence\":\"p\",\"location\":21},\"oncommit\":\"ONCOMMIT_NOOP\"},\"servername\":\"no_server\"}}}]}",
  "SELECT parse_ident(E'\"c\".X XXXX\002XXXXXX')",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"parse_ident\"}}],\"args\":[{\"A_Const\":{\"val\":{\"String\":{\"str\":\"\\\"c\\\".X XXXX\\u0002XXXXXX\"}},\"location\":19}}],\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "ALTER ROLE postgres LOGIN SUPERUSER PASSWORD 'xyz'",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"AlterRoleStmt\":{\"role\":{\"roletype\":\"ROLESPEC_CSTRING\",\"rolename\":\"postgres\",\"location\":11},\"options\":[{\"DefElem\":{\"defname\":\"canlogin\",\"arg\":{\"Integer\":{\"ival\":1}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":20}},{\"DefElem\":{\"defname\":\"superuser\",\"arg\":{\"Integer\":{\"ival\":1}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":26}},{\"DefElem\":{\"defname\":\"password\",\"arg\":{\"String\":{\"str\":\"xyz\"}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":36}}],\"action\":1}}}]}",
  "SELECT extract($1 FROM $2)",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"date_part\"}}],\"args\":[{\"ParamRef\":{\"number\":1,\"location\":15}},{\"ParamRef\":{\"number\":2,\"location\":23}}],\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "WITH w AS NOT MATERIALIZED (SELECT * FROM big_table) SELECT * FROM w LIMIT 1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"A_Star\":{}}],\"location\":60}},\"location\":60}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"w\",\"inh\":true,\"relpersistence\":\"p\",\"location\":67}}],\"limitCount\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":75}},\"limitOption\":\"LIMIT_OPTION_COUNT\",\"withClause\":{\"ctes\":[{\"CommonTableExpr\":{\"ctename\":\"w\",\"ctematerialized\":\"CTEMaterializeNever\",\"ctequery\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"A_Star\":{}}],\"location\":35}},\"location\":35}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"big_table\",\"inh\":true,\"relpersistence\":\"p\",\"location\":42}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"location\":5}}]},\"op\":\"SETOP_NONE\"}}}]}",
  "CREATE USER test PASSWORD $1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"CreateRoleStmt\":{\"stmt_type\":\"ROLESTMT_USER\",\"role\":\"test\",\"options\":[{\"DefElem\":{\"defname\":\"password\",\"arg\":{\"ParamRef\":{\"number\":1,\"location\":26}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":17}}]}}}]}",
  "ALTER USER test ENCRYPTED PASSWORD $2",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"AlterRoleStmt\":{\"role\":{\"roletype\":\"ROLESPEC_CSTRING\",\"rolename\":\"test\",\"location\":11},\"options\":[{\"DefElem\":{\"defname\":\"password\",\"arg\":{\"ParamRef\":{\"number\":2,\"location\":35}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":16}}],\"action\":1}}}]}",
  "SET SCHEMA $3",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"VariableSetStmt\":{\"kind\":\"VAR_SET_VALUE\",\"name\":\"search_path\",\"args\":[{\"ParamRef\":{\"number\":3,\"location\":11}}]}}}]}",
  "SET ROLE $4",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"VariableSetStmt\":{\"kind\":\"VAR_SET_VALUE\",\"name\":\"role\",\"args\":[{\"ParamRef\":{\"number\":4,\"location\":9}}]}}}]}",
  "SET SESSION AUTHORIZATION $5",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"VariableSetStmt\":{\"kind\":\"VAR_SET_VALUE\",\"name\":\"session_authorization\",\"args\":[{\"ParamRef\":{\"number\":5,\"location\":26}}]}}}]}",
  "SELECT EXTRACT($1 FROM TIMESTAMP $2)",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"date_part\"}}],\"args\":[{\"ParamRef\":{\"number\":1,\"location\":15}},{\"TypeCast\":{\"arg\":{\"ParamRef\":{\"number\":2,\"location\":33}},\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"timestamp\"}}],\"typemod\":-1,\"location\":23},\"location\":-1}}],\"location\":7}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT DATE $1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"TypeCast\":{\"arg\":{\"ParamRef\":{\"number\":1,\"location\":12}},\"typeName\":{\"names\":[{\"String\":{\"str\":\"date\"}}],\"typemod\":-1,\"location\":7},\"location\":-1}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT INTERVAL $1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"TypeCast\":{\"arg\":{\"ParamRef\":{\"number\":1,\"location\":16}},\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"interval\"}}],\"typemod\":-1,\"location\":7},\"location\":-1}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT INTERVAL $1 YEAR",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"TypeCast\":{\"arg\":{\"ParamRef\":{\"number\":1,\"location\":16}},\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"interval\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":4}},\"location\":19}}],\"typemod\":-1,\"location\":7},\"location\":-1}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT INTERVAL (6) $1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"TypeCast\":{\"arg\":{\"ParamRef\":{\"number\":1,\"location\":20}},\"typeName\":{\"names\":[{\"String\":{\"str\":\"pg_catalog\"}},{\"String\":{\"str\":\"interval\"}}],\"typmods\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":32767}},\"location\":-1}},{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":6}},\"location\":17}}],\"typemod\":-1,\"location\":7},\"location\":-1}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SET search_path = $1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"VariableSetStmt\":{\"kind\":\"VAR_SET_VALUE\",\"name\":\"search_path\",\"args\":[{\"ParamRef\":{\"number\":1,\"location\":18}}]}}}]}",
  "ALTER ROLE postgres LOGIN SUPERUSER PASSWORD ?",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"AlterRoleStmt\":{\"role\":{\"roletype\":\"ROLESPEC_CSTRING\",\"rolename\":\"postgres\",\"location\":11},\"options\":[{\"DefElem\":{\"defname\":\"canlogin\",\"arg\":{\"Integer\":{\"ival\":1}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":20}},{\"DefElem\":{\"defname\":\"superuser\",\"arg\":{\"Integer\":{\"ival\":1}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":26}},{\"DefElem\":{\"defname\":\"password\",\"arg\":{\"ParamRef\":{\"location\":45}},\"defaction\":\"DEFELEM_UNSPEC\",\"location\":36}}],\"action\":1}}}]}",
  "WITH a AS (SELECT * FROM x WHERE x.y = ? AND x.z = 1) SELECT * FROM a WHERE b = 5",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"A_Star\":{}}],\"location\":61}},\"location\":61}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"a\",\"inh\":true,\"relpersistence\":\"p\",\"location\":68}}],\"whereClause\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"=\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"b\"}}],\"location\":76}},\"rexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":5}},\"location\":80}},\"location\":78}},\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"withClause\":{\"ctes\":[{\"CommonTableExpr\":{\"ctename\":\"a\",\"ctematerialized\":\"CTEMaterializeDefault\",\"ctequery\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"A_Star\":{}}],\"location\":18}},\"location\":18}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"x\",\"inh\":true,\"relpersistence\":\"p\",\"location\":25}}],\"whereClause\":{\"BoolExpr\":{\"boolop\":\"AND_EXPR\",\"args\":[{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"=\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"x\"}},{\"String\":{\"str\":\"y\"}}],\"location\":33}},\"rexpr\":{\"ParamRef\":{\"location\":39}},\"location\":37}},{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"=\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"x\"}},{\"String\":{\"str\":\"z\"}}],\"location\":45}},\"rexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":51}},\"location\":49}}],\"location\":41}},\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}},\"location\":5}}]},\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT count(*) from testjsonb  WHERE j->'array' ? 'bar'",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"count\"}}],\"agg_star\":true,\"location\":7}},\"location\":7}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"testjsonb\",\"inh\":true,\"relpersistence\":\"p\",\"location\":21}}],\"whereClause\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"?\"}}],\"lexpr\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"-\\u003e\"}}],\"lexpr\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"j\"}}],\"location\":38}},\"rexpr\":{\"A_Const\":{\"val\":{\"String\":{\"str\":\"array\"}},\"location\":41}},\"location\":39}},\"rexpr\":{\"A_Const\":{\"val\":{\"String\":{\"str\":\"bar\"}},\"location\":51}},\"location\":49}},\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT DISTINCT a FROM b",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"distinctClause\":[{}],\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"String\":{\"str\":\"a\"}}],\"location\":16}},\"location\":16}}],\"fromClause\":[{\"RangeVar\":{\"relname\":\"b\",\"inh\":true,\"relpersistence\":\"p\",\"location\":23}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT * FROM generate_series(1, 2)",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"ColumnRef\":{\"fields\":[{\"A_Star\":{}}],\"location\":7}},\"location\":7}}],\"fromClause\":[{\"RangeFunction\":{\"functions\":[{\"List\":{\"items\":[{\"FuncCall\":{\"funcname\":[{\"String\":{\"str\":\"generate_series\"}}],\"args\":[{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":30}},{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":2}},\"location\":33}}],\"location\":14}},{}]}}]}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}",
  "SELECT 1 + 1",
  "{\"version\":130003,\"stmts\":[{\"stmt\":{\"SelectStmt\":{\"targetList\":[{\"ResTarget\":{\"val\":{\"A_Expr\":{\"kind\":\"AEXPR_OP\",\"name\":[{\"String\":{\"str\":\"+\"}}],\"lexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":7}},\"rexpr\":{\"A_Const\":{\"val\":{\"Integer\":{\"ival\":1}},\"location\":11}},\"location\":9}},\"location\":7}}],\"limitOption\":\"LIMIT_OPTION_DEFAULT\",\"op\":\"SETOP_NONE\"}}}]}"
};

size_t testsLength = __LINE__ - 4;