Skip to content

Commit

Permalink
Merge pull request #167 from pganalyze/15-latest-dev
Browse files Browse the repository at this point in the history
This upgrades `libpg_query` to Postgres 15.1. All tests have been
updated, and tests were added for new constructs.

- `Boolean` nodes have been added to the parser, replacing usage of
integers with the values `1`/`0`.
- In the postgres parser, `Value` was changed to be a union stored in
the `A_Const` type. For this upgrade, we block `A_Const` from code
generation, and instead manually implement the relevant required
functions.
- The `COPY` statement deparser was also updated to attempt deparsing into
the old Postgres 8.4-style syntax (e.g. `COPY foo FROM STDIN FREEZE
CSV`). This ensures that the regression tests keep working, as new
changes in the parse structures mean that these two syntaxes result in
equivalent but slightly different parse trees.
- Support was added for `MERGE` statements.
- Support was added for more advanced publication objects, e.g.
  `CREATE PUBLICATION foo FOR TABLES IN SCHEMA CURRENT_SCHEMA`
- Support was added for `ALTER TABLE ALL IN TABLESPACE ...` statements
  • Loading branch information
msepga committed Dec 13, 2022
2 parents 9b4a3bf + 81946ee commit 1ada550
Show file tree
Hide file tree
Showing 579 changed files with 160,941 additions and 128,738 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All versions are tagged by the major Postgres version, plus an individual semver for this library itself.

## 15-4.0.0 2022-11-29

* Update to Postgres 15.1
* Add support for `MERGE` statements
* Add support for `ALTER TABLE ALL IN TABLESPACE ...` statements
* Add support for publication objects
- E.g. `CREATE PUBLICATION foo FOR TABLES IN SCHEMA CURRENT_SCHEMA`
* Deparser now attempts to deparse `COPY` statements first using the old
Postgres 8.4-style syntax (e.g. `COPY foo FROM STDIN FREEZE CSV`).

## 14-3.0.0 2022-11-17

Special thanks to @wolfgangwalther and @tlisanti for most of the work done on this release.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ ARLIB = lib$(TARGET).a
PGDIR = $(root_dir)/tmp/postgres
PGDIRBZ2 = $(root_dir)/tmp/postgres.tar.bz2

PG_VERSION = 14.6
PG_VERSION = 15.1
PG_VERSION_MAJOR = $(call word-dot,$(PG_VERSION),1)
PROTOC_VERSION = 3.14.0

VERSION = 3.0.0
VERSION = 4.0.0
VERSION_MAJOR = $(call word-dot,$(VERSION),1)
VERSION_MINOR = $(call word-dot,$(VERSION),2)
VERSION_PATCH = $(call word-dot,$(VERSION),3)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can find further background to why a query's parse tree is useful here: http
## Installation

```sh
git clone -b 14-latest git://github.com/pganalyze/libpg_query
git clone -b 15-latest git://github.com/pganalyze/libpg_query
cd libpg_query
make
```
Expand Down Expand Up @@ -51,7 +51,7 @@ This will output the parse tree (whitespace adjusted here for better readability

```json
{
"version": 140006,
"version": 150001,
"stmts": [
{
"stmt": {
Expand Down Expand Up @@ -124,7 +124,7 @@ int main() {
This will output the following:

```
version: 140006, tokens: 7, size: 77
version: 150001, tokens: 7, size: 77
"SELECT" = [ 0, 6, SELECT, RESERVED_KEYWORD ]
"update" = [ 7, 13, UPDATE, UNRESERVED_KEYWORD ]
"AS" = [ 14, 16, AS, RESERVED_KEYWORD ]
Expand Down Expand Up @@ -231,7 +231,8 @@ Each major version is maintained in a dedicated git branch. Only the latest Post
| PostgreSQL Major Version | Branch | Status |
|--------------------------|------------|---------------------|
| 14 | 14-latest | Active development |
| 15 | 15-latest | Active development |
| 14 | 14-latest | Critical fixes only |
| 13 | 13-latest | Critical fixes only |
| 12 | (n/a) | Not supported |
| 11 | (n/a) | Not supported |
Expand Down
4 changes: 2 additions & 2 deletions patches/01_parser_additional_param_ref_support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ index 74339aa4db..4529fea74e 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -168,6 +168,8 @@ static Node *makeBitStringConst(char *str, int location);
static Node *makeBitStringConst(char *str, int location);
static Node *makeNullAConst(int location);
static Node *makeAConst(Value *v, int location);
static Node *makeBoolAConst(bool state, int location);
static Node *makeAConst(Node *v, int location);
+static Node *makeParamRef(int number, int location);
+static Node *makeParamRefCast(int number, int location, TypeName *typename);
static RoleSpec *makeRoleSpec(RoleSpecType type, int location);
Expand Down
6 changes: 3 additions & 3 deletions pg_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ void pg_query_free_fingerprint_result(PgQueryFingerprintResult result);
void pg_query_exit(void);

// Postgres version information
#define PG_MAJORVERSION "14"
#define PG_VERSION "14.6"
#define PG_VERSION_NUM 140006
#define PG_MAJORVERSION "15"
#define PG_VERSION "15.1"
#define PG_VERSION_NUM 150001

// Deprecated APIs below

Expand Down
Loading

0 comments on commit 1ada550

Please sign in to comment.