pg_query 6.2.3 → 6.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -1
- data/Rakefile +2 -2
- data/ext/pg_query/include/pg_query_fingerprint_defs.c +8 -0
- data/ext/pg_query/include/pg_query_outfuncs_defs.c +4 -0
- data/ext/pg_query/include/pg_query_readfuncs_defs.c +4 -0
- data/ext/pg_query/include/postgres/copyfuncs.funcs.c +4 -0
- data/ext/pg_query/include/postgres/equalfuncs.funcs.c +4 -0
- data/ext/pg_query/include/postgres/nodes/parsenodes.h +8 -0
- data/ext/pg_query/include/protobuf/pg_query.pb-c.h +282 -278
- data/ext/pg_query/pg_query.pb-c.c +64 -12
- data/ext/pg_query/pg_query_normalize.c +45 -47
- data/ext/pg_query/pg_query_readfuncs_protobuf.c +8 -5
- data/ext/pg_query/postgres_deparse.c +224 -5
- data/ext/pg_query/src_backend_nodes_makefuncs.c +2 -0
- data/ext/pg_query/src_backend_parser_gram.c +30322 -30090
- data/lib/pg_query/fingerprint.rb +6 -0
- data/lib/pg_query/parse.rb +77 -1
- data/lib/pg_query/pg_query_pb.rb +1 -1
- data/lib/pg_query/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 562e4dee230d79e497d81f4b15b37574e084e183fc4ce722d62f3d30e4610315
|
|
4
|
+
data.tar.gz: bb92ff67386d19430475cf0e36fbb4ab1dbe971e77c3b0da2258b12d85cf3201
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca16555eccbf189e0248a9c6d8046d222232bb3fa030f4bb2c6693a5c9325fb361b8f649c33aeebf0837098c757e07c2117ee09847fe83980099c2a4c09a738a
|
|
7
|
+
data.tar.gz: 0ec4d547d4c33b645be78ab02ddaa7dc60c3c47a7c88ed58b4e586edd7cd0c2371e68858230b962586701511e1969aceab4448db9862b696f8266ee07b39abe9
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* Fix `#tables` dropping a relation when a CTE shares its name
|
|
6
|
+
- A non-recursive CTE is not visible inside its own definition, so
|
|
7
|
+
`WITH users AS (SELECT * FROM users) SELECT * FROM users` reads the `users`
|
|
8
|
+
table in the CTE body and the CTE in the outer query. Previously any
|
|
9
|
+
unqualified reference matching a CTE name was treated as the CTE, so this
|
|
10
|
+
returned `tables == []` and the relation was lost entirely.
|
|
11
|
+
- `WITH RECURSIVE` self-references are still correctly excluded, as are
|
|
12
|
+
references to a CTE that is already visible from an enclosing scope.
|
|
13
|
+
- DML/DDL targets are no longer treated as CTE references, since a CTE cannot
|
|
14
|
+
be the target of `INSERT`/`UPDATE`/`DELETE`/`COPY` or DDL. This fixes
|
|
15
|
+
`#dml_tables` being empty for e.g.
|
|
16
|
+
`WITH users AS (...) UPDATE users SET ...`.
|
|
17
|
+
|
|
18
|
+
## 6.2.5 2026-09-30
|
|
19
|
+
|
|
20
|
+
* Upgrade to libpg_query 17-6.2.5
|
|
21
|
+
- Security fix: Heap out-of-bounds write and read in `PgQuery.normalize` ([GHSA-6ggm-xmc9-8ffg](https://github.com/pganalyze/libpg_query/security/advisories/GHSA-6ggm-xmc9-8ffg))
|
|
22
|
+
- When normalizing certain utility statements (e.g. `DO ... LANGUAGE`, statements with
|
|
23
|
+
string options, or `CREATE/ALTER SUBSCRIPTION ... CONNECTION`), the normalizer
|
|
24
|
+
searched the query text for the location of string constants, which could yield
|
|
25
|
+
wrong locations for crafted input. This could cause out-of-bounds writes and reads
|
|
26
|
+
on the heap, leaking process memory in the normalized output or crashing the process.
|
|
27
|
+
- Constant locations are now recorded by the parser instead, and the normalizer checks
|
|
28
|
+
at runtime that constant locations never overlap
|
|
29
|
+
- This adds new location fields to the parse tree output (`DefElem.arg_location`,
|
|
30
|
+
`NotifyStmt.payload_location`, `CreateSubscriptionStmt.conninfo_location` and
|
|
31
|
+
`AlterSubscriptionStmt.conninfo_location`). Like other location fields, these are
|
|
32
|
+
ignored for fingerprinting.
|
|
33
|
+
- Applications that normalize untrusted query text should upgrade
|
|
34
|
+
- Reported by Paul Gerste (Cure53)
|
|
35
|
+
- Deparser: Add strict checking for unexpected pointer values
|
|
36
|
+
- This ensures that a bad input parse tree doesn't cause the deparser to crash, and
|
|
37
|
+
instead raises an error
|
|
38
|
+
- Reported by Paul Gerste (Cure53)
|
|
39
|
+
- Normalize:
|
|
40
|
+
- Add support for `NOTIFY` statements [#340](https://github.com/pganalyze/libpg_query/pull/340)
|
|
41
|
+
- Avoid undefined behaviour for overly large parameter references [#346](https://github.com/pganalyze/libpg_query/pull/346)
|
|
6
42
|
|
|
7
43
|
## 6.2.3 2026-08-26
|
|
8
44
|
|
data/Rakefile
CHANGED
|
@@ -5,8 +5,8 @@ require 'rspec/core/rake_task'
|
|
|
5
5
|
require 'rubocop/rake_task'
|
|
6
6
|
require 'open-uri'
|
|
7
7
|
|
|
8
|
-
LIB_PG_QUERY_TAG = '17-6.2.
|
|
9
|
-
LIB_PG_QUERY_SHA256SUM = '
|
|
8
|
+
LIB_PG_QUERY_TAG = '17-6.2.5'.freeze
|
|
9
|
+
LIB_PG_QUERY_SHA256SUM = '344ee7a39d3fa4eb5e8cdff8aa7db514a30883423c65731c9ce04b2b7089abb6'.freeze
|
|
10
10
|
|
|
11
11
|
Rake::ExtensionTask.new 'pg_query' do |ext|
|
|
12
12
|
ext.lib_dir = 'lib/pg_query'
|
|
@@ -5754,6 +5754,8 @@ _fingerprintDefElem(FingerprintContext *ctx, const DefElem *node, const void *pa
|
|
|
5754
5754
|
XXH3_freeState(prev);
|
|
5755
5755
|
}
|
|
5756
5756
|
|
|
5757
|
+
// Intentionally ignoring node->arg_location for fingerprinting
|
|
5758
|
+
|
|
5757
5759
|
if (true) {
|
|
5758
5760
|
_fingerprintString(ctx, "defaction");
|
|
5759
5761
|
_fingerprintString(ctx, _enumToStringDefElemAction(node->defaction));
|
|
@@ -13428,6 +13430,8 @@ _fingerprintNotifyStmt(FingerprintContext *ctx, const NotifyStmt *node, const vo
|
|
|
13428
13430
|
_fingerprintString(ctx, node->payload);
|
|
13429
13431
|
}
|
|
13430
13432
|
|
|
13433
|
+
// Intentionally ignoring node->payload_location for fingerprinting
|
|
13434
|
+
|
|
13431
13435
|
}
|
|
13432
13436
|
|
|
13433
13437
|
static void
|
|
@@ -14865,6 +14869,8 @@ _fingerprintCreateSubscriptionStmt(FingerprintContext *ctx, const CreateSubscrip
|
|
|
14865
14869
|
_fingerprintString(ctx, node->conninfo);
|
|
14866
14870
|
}
|
|
14867
14871
|
|
|
14872
|
+
// Intentionally ignoring node->conninfo_location for fingerprinting
|
|
14873
|
+
|
|
14868
14874
|
if (node->options != NULL && node->options->length > 0) {
|
|
14869
14875
|
XXH3_state_t* prev = XXH3_createState();
|
|
14870
14876
|
XXH64_hash_t hash;
|
|
@@ -14912,6 +14918,8 @@ _fingerprintAlterSubscriptionStmt(FingerprintContext *ctx, const AlterSubscripti
|
|
|
14912
14918
|
_fingerprintString(ctx, node->conninfo);
|
|
14913
14919
|
}
|
|
14914
14920
|
|
|
14921
|
+
// Intentionally ignoring node->conninfo_location for fingerprinting
|
|
14922
|
+
|
|
14915
14923
|
if (true) {
|
|
14916
14924
|
_fingerprintString(ctx, "kind");
|
|
14917
14925
|
_fingerprintString(ctx, _enumToStringAlterSubscriptionType(node->kind));
|
|
@@ -1234,6 +1234,7 @@ _outDefElem(OUT_TYPE(DefElem, DefElem) out, const DefElem *node)
|
|
|
1234
1234
|
WRITE_NODE_PTR_FIELD(arg, arg, arg);
|
|
1235
1235
|
WRITE_ENUM_FIELD(DefElemAction, defaction, defaction, defaction);
|
|
1236
1236
|
WRITE_INT_FIELD(location, location, location);
|
|
1237
|
+
WRITE_INT_FIELD(arg_location, arg_location, arg_location);
|
|
1237
1238
|
}
|
|
1238
1239
|
|
|
1239
1240
|
static void
|
|
@@ -2534,6 +2535,7 @@ _outNotifyStmt(OUT_TYPE(NotifyStmt, NotifyStmt) out, const NotifyStmt *node)
|
|
|
2534
2535
|
{
|
|
2535
2536
|
WRITE_STRING_FIELD(conditionname, conditionname, conditionname);
|
|
2536
2537
|
WRITE_STRING_FIELD(payload, payload, payload);
|
|
2538
|
+
WRITE_INT_FIELD(payload_location, payload_location, payload_location);
|
|
2537
2539
|
}
|
|
2538
2540
|
|
|
2539
2541
|
static void
|
|
@@ -2862,6 +2864,7 @@ _outCreateSubscriptionStmt(OUT_TYPE(CreateSubscriptionStmt, CreateSubscriptionSt
|
|
|
2862
2864
|
WRITE_STRING_FIELD(conninfo, conninfo, conninfo);
|
|
2863
2865
|
WRITE_LIST_FIELD(publication, publication, publication);
|
|
2864
2866
|
WRITE_LIST_FIELD(options, options, options);
|
|
2867
|
+
WRITE_INT_FIELD(conninfo_location, conninfo_location, conninfo_location);
|
|
2865
2868
|
}
|
|
2866
2869
|
|
|
2867
2870
|
static void
|
|
@@ -2872,6 +2875,7 @@ _outAlterSubscriptionStmt(OUT_TYPE(AlterSubscriptionStmt, AlterSubscriptionStmt)
|
|
|
2872
2875
|
WRITE_STRING_FIELD(conninfo, conninfo, conninfo);
|
|
2873
2876
|
WRITE_LIST_FIELD(publication, publication, publication);
|
|
2874
2877
|
WRITE_LIST_FIELD(options, options, options);
|
|
2878
|
+
WRITE_INT_FIELD(conninfo_location, conninfo_location, conninfo_location);
|
|
2875
2879
|
}
|
|
2876
2880
|
|
|
2877
2881
|
static void
|
|
@@ -1411,6 +1411,7 @@ _readDefElem(OUT_TYPE(DefElem, DefElem) msg)
|
|
|
1411
1411
|
READ_NODE_PTR_FIELD(arg, arg, arg);
|
|
1412
1412
|
READ_ENUM_FIELD(DefElemAction, defaction, defaction, defaction);
|
|
1413
1413
|
READ_INT_FIELD(location, location, location);
|
|
1414
|
+
READ_INT_FIELD(arg_location, arg_location, arg_location);
|
|
1414
1415
|
return node;
|
|
1415
1416
|
}
|
|
1416
1417
|
|
|
@@ -2966,6 +2967,7 @@ _readNotifyStmt(OUT_TYPE(NotifyStmt, NotifyStmt) msg)
|
|
|
2966
2967
|
NotifyStmt *node = makeNode(NotifyStmt);
|
|
2967
2968
|
READ_STRING_FIELD(conditionname, conditionname, conditionname);
|
|
2968
2969
|
READ_STRING_FIELD(payload, payload, payload);
|
|
2970
|
+
READ_INT_FIELD(payload_location, payload_location, payload_location);
|
|
2969
2971
|
return node;
|
|
2970
2972
|
}
|
|
2971
2973
|
|
|
@@ -3376,6 +3378,7 @@ _readCreateSubscriptionStmt(OUT_TYPE(CreateSubscriptionStmt, CreateSubscriptionS
|
|
|
3376
3378
|
READ_STRING_FIELD(conninfo, conninfo, conninfo);
|
|
3377
3379
|
READ_LIST_FIELD(publication, publication, publication);
|
|
3378
3380
|
READ_LIST_FIELD(options, options, options);
|
|
3381
|
+
READ_INT_FIELD(conninfo_location, conninfo_location, conninfo_location);
|
|
3379
3382
|
return node;
|
|
3380
3383
|
}
|
|
3381
3384
|
|
|
@@ -3388,6 +3391,7 @@ _readAlterSubscriptionStmt(OUT_TYPE(AlterSubscriptionStmt, AlterSubscriptionStmt
|
|
|
3388
3391
|
READ_STRING_FIELD(conninfo, conninfo, conninfo);
|
|
3389
3392
|
READ_LIST_FIELD(publication, publication, publication);
|
|
3390
3393
|
READ_LIST_FIELD(options, options, options);
|
|
3394
|
+
READ_INT_FIELD(conninfo_location, conninfo_location, conninfo_location);
|
|
3391
3395
|
return node;
|
|
3392
3396
|
}
|
|
3393
3397
|
|
|
@@ -1378,6 +1378,7 @@ _copyDefElem(const DefElem *from)
|
|
|
1378
1378
|
COPY_NODE_FIELD(arg);
|
|
1379
1379
|
COPY_SCALAR_FIELD(defaction);
|
|
1380
1380
|
COPY_LOCATION_FIELD(location);
|
|
1381
|
+
COPY_LOCATION_FIELD(arg_location);
|
|
1381
1382
|
|
|
1382
1383
|
return newnode;
|
|
1383
1384
|
}
|
|
@@ -3174,6 +3175,7 @@ _copyNotifyStmt(const NotifyStmt *from)
|
|
|
3174
3175
|
|
|
3175
3176
|
COPY_STRING_FIELD(conditionname);
|
|
3176
3177
|
COPY_STRING_FIELD(payload);
|
|
3178
|
+
COPY_LOCATION_FIELD(payload_location);
|
|
3177
3179
|
|
|
3178
3180
|
return newnode;
|
|
3179
3181
|
}
|
|
@@ -3666,6 +3668,7 @@ _copyCreateSubscriptionStmt(const CreateSubscriptionStmt *from)
|
|
|
3666
3668
|
COPY_STRING_FIELD(conninfo);
|
|
3667
3669
|
COPY_NODE_FIELD(publication);
|
|
3668
3670
|
COPY_NODE_FIELD(options);
|
|
3671
|
+
COPY_LOCATION_FIELD(conninfo_location);
|
|
3669
3672
|
|
|
3670
3673
|
return newnode;
|
|
3671
3674
|
}
|
|
@@ -3680,6 +3683,7 @@ _copyAlterSubscriptionStmt(const AlterSubscriptionStmt *from)
|
|
|
3680
3683
|
COPY_STRING_FIELD(conninfo);
|
|
3681
3684
|
COPY_NODE_FIELD(publication);
|
|
3682
3685
|
COPY_NODE_FIELD(options);
|
|
3686
|
+
COPY_LOCATION_FIELD(conninfo_location);
|
|
3683
3687
|
|
|
3684
3688
|
return newnode;
|
|
3685
3689
|
}
|
|
@@ -1191,6 +1191,7 @@ _equalDefElem(const DefElem *a, const DefElem *b)
|
|
|
1191
1191
|
COMPARE_NODE_FIELD(arg);
|
|
1192
1192
|
COMPARE_SCALAR_FIELD(defaction);
|
|
1193
1193
|
COMPARE_LOCATION_FIELD(location);
|
|
1194
|
+
COMPARE_LOCATION_FIELD(arg_location);
|
|
1194
1195
|
|
|
1195
1196
|
return true;
|
|
1196
1197
|
}
|
|
@@ -2737,6 +2738,7 @@ _equalNotifyStmt(const NotifyStmt *a, const NotifyStmt *b)
|
|
|
2737
2738
|
{
|
|
2738
2739
|
COMPARE_STRING_FIELD(conditionname);
|
|
2739
2740
|
COMPARE_STRING_FIELD(payload);
|
|
2741
|
+
COMPARE_LOCATION_FIELD(payload_location);
|
|
2740
2742
|
|
|
2741
2743
|
return true;
|
|
2742
2744
|
}
|
|
@@ -3147,6 +3149,7 @@ _equalCreateSubscriptionStmt(const CreateSubscriptionStmt *a, const CreateSubscr
|
|
|
3147
3149
|
COMPARE_STRING_FIELD(conninfo);
|
|
3148
3150
|
COMPARE_NODE_FIELD(publication);
|
|
3149
3151
|
COMPARE_NODE_FIELD(options);
|
|
3152
|
+
COMPARE_LOCATION_FIELD(conninfo_location);
|
|
3150
3153
|
|
|
3151
3154
|
return true;
|
|
3152
3155
|
}
|
|
@@ -3159,6 +3162,7 @@ _equalAlterSubscriptionStmt(const AlterSubscriptionStmt *a, const AlterSubscript
|
|
|
3159
3162
|
COMPARE_STRING_FIELD(conninfo);
|
|
3160
3163
|
COMPARE_NODE_FIELD(publication);
|
|
3161
3164
|
COMPARE_NODE_FIELD(options);
|
|
3165
|
+
COMPARE_LOCATION_FIELD(conninfo_location);
|
|
3162
3166
|
|
|
3163
3167
|
return true;
|
|
3164
3168
|
}
|
|
@@ -817,6 +817,8 @@ typedef struct DefElem
|
|
|
817
817
|
* TypeName */
|
|
818
818
|
DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
|
|
819
819
|
ParseLoc location; /* token location, or -1 if unknown */
|
|
820
|
+
/* location of arg's string constant, or -1 if not a string constant */
|
|
821
|
+
ParseLoc arg_location pg_node_attr(query_jumble_ignore);
|
|
820
822
|
} DefElem;
|
|
821
823
|
|
|
822
824
|
/*
|
|
@@ -3624,6 +3626,8 @@ typedef struct NotifyStmt
|
|
|
3624
3626
|
NodeTag type;
|
|
3625
3627
|
char *conditionname; /* condition name to notify */
|
|
3626
3628
|
char *payload; /* the payload string, or NULL if none */
|
|
3629
|
+
/* location of payload's string constant; only set when payload is */
|
|
3630
|
+
ParseLoc payload_location pg_node_attr(query_jumble_ignore);
|
|
3627
3631
|
} NotifyStmt;
|
|
3628
3632
|
|
|
3629
3633
|
/* ----------------------
|
|
@@ -4198,6 +4202,8 @@ typedef struct CreateSubscriptionStmt
|
|
|
4198
4202
|
char *conninfo; /* Connection string to publisher */
|
|
4199
4203
|
List *publication; /* One or more publication to subscribe to */
|
|
4200
4204
|
List *options; /* List of DefElem nodes */
|
|
4205
|
+
/* location of conninfo's string constant; only set when conninfo is */
|
|
4206
|
+
ParseLoc conninfo_location pg_node_attr(query_jumble_ignore);
|
|
4201
4207
|
} CreateSubscriptionStmt;
|
|
4202
4208
|
|
|
4203
4209
|
typedef enum AlterSubscriptionType
|
|
@@ -4220,6 +4226,8 @@ typedef struct AlterSubscriptionStmt
|
|
|
4220
4226
|
char *conninfo; /* Connection string to publisher */
|
|
4221
4227
|
List *publication; /* One or more publication to subscribe to */
|
|
4222
4228
|
List *options; /* List of DefElem nodes */
|
|
4229
|
+
/* location of conninfo's string constant; only set when conninfo is */
|
|
4230
|
+
ParseLoc conninfo_location pg_node_attr(query_jumble_ignore);
|
|
4223
4231
|
} AlterSubscriptionStmt;
|
|
4224
4232
|
|
|
4225
4233
|
typedef struct DropSubscriptionStmt
|