pg_query 2.0.1 → 2.0.3
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 +164 -114
- data/Rakefile +6 -7
- data/ext/pg_query/extconf.rb +2 -1
- data/ext/pg_query/include/pg_config.h +1 -0
- data/ext/pg_query/pg_query_deparse.c +27 -21
- data/ext/pg_query/pg_query_fingerprint.c +4 -1
- data/ext/pg_query/pg_query_normalize.c +3 -1
- data/lib/pg_query/filter_columns.rb +2 -0
- data/lib/pg_query/parse.rb +2 -2
- data/lib/pg_query/truncate.rb +12 -4
- 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: f19538f4d41c891a9b7704cd56becd762e44f5f766fba06c07f89b2e1d61b69f
|
4
|
+
data.tar.gz: df5a48fd5582bacd09098a5d37c21794a6f1caff82b16fe4597be2257bb0eaa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0326c810f5589b03d3a1809e98c199984c6bc013dfd93228cb6e35e5378cf39421ff0690c5dc67431f4b1501815fa80245d5e0cfcb1c75186054aa5d1300d684
|
7
|
+
data.tar.gz: 476514b25750f97ab9f27c55ccf6c221b6ab16687677178adc9f2ed219a85286dca983a36b25e703a3f0e9f080268ce6e82b69fbb932d4e50195bc711f434530
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,33 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
* ...
|
6
|
+
|
7
|
+
|
8
|
+
## 2.0.3 2021-04-05
|
9
|
+
|
10
|
+
* Update to libpg_query 13-2.0.4
|
11
|
+
- Normalize: Fix handling of two subsequent DefElem elements (avoids crash)
|
12
|
+
- Deparser: Fix crash in CopyStmt with HEADER or FREEZE inside WITH parens
|
13
|
+
|
14
|
+
|
15
|
+
## 2.0.2 2021-03-31
|
16
|
+
|
17
|
+
* `COALESCE` arguments are now included in `#filter_columns`
|
18
|
+
* Improve error message for protobuf parse failures
|
19
|
+
* Extconf: Fix object path regexp
|
20
|
+
- This accidentally replaced `.c` in the wrong parts of the path in some cases,
|
21
|
+
causing build failures
|
22
|
+
* Update to libpg_query 13-2.0.2
|
23
|
+
- Fix ARM builds: Avoid dependency on cpuid.h header
|
24
|
+
- Simplify deparser of TableLikeClause
|
25
|
+
- Fix asprintf warnings by ensuring _GNU_SOURCE is set early enough
|
26
|
+
|
27
|
+
|
3
28
|
## 2.0.1 2021-03-18
|
4
29
|
|
5
|
-
* Fix
|
30
|
+
* Fix gemspec to correctly reference include files
|
6
31
|
- This would have shown as a build failure when using the published `2.0.0` gem
|
7
32
|
|
8
33
|
|
@@ -19,23 +44,23 @@
|
|
19
44
|
* Use new deparser maintained directly in libpg_query
|
20
45
|
* This replaces the complete Ruby deparser with a new, more complete deparser
|
21
46
|
that is directly maintained in libpg_query. Further deparser improvements
|
22
|
-
should be directly contributed to [libpg_query]
|
23
|
-
* Tables helper: Return more details through
|
24
|
-
* This is renamed from the previously badly named
|
47
|
+
should be directly contributed to [libpg_query]
|
48
|
+
* Tables helper: Return more details through `#tables_with_details` method
|
49
|
+
* This is renamed from the previously badly named `#tables_with_types`
|
25
50
|
method. Note that this change should not affect the output of the
|
26
|
-
primary
|
51
|
+
primary `tables` helper.
|
27
52
|
* Replace on-demand libpg_query source download with bundled source code
|
28
53
|
* Its unnecessary to download the source on-demand, and makes this more
|
29
54
|
complex than it needs to be. Instead, introduce a new "update_source" rake
|
30
55
|
task that can be called to refresh the source for a specified revision.
|
31
56
|
* Re-implement smart truncation without requiring a special node type
|
32
|
-
* This ensures the truncate method works with the new deparser, without
|
57
|
+
* This ensures the `#truncate` method works with the new deparser, without
|
33
58
|
the C level code needing to know about it. We may add it in the C library
|
34
59
|
in the future for edge cases that can't be covered by this slightly
|
35
60
|
hack-ish approach, but for now this avoids unnecessary C library
|
36
61
|
deparser modifications with non-standard node types.
|
37
|
-
* Update Ruby
|
38
|
-
* Note that its recommended to use PgQuery.fingerprint for performance
|
62
|
+
* Update Ruby fingerprinting to new fingerprint format and XXH3 hash
|
63
|
+
* Note that its recommended to use `PgQuery.fingerprint` for performance
|
39
64
|
reasons, but when the tree has been modified, it can be convenient to
|
40
65
|
run a Ruby-side fingerprint instead of the C-based one that is faster.
|
41
66
|
|
@@ -44,25 +69,25 @@
|
|
44
69
|
|
45
70
|
* Incorporate newer libpg_query updates in 10-1.0.3 and 10-1.0.4
|
46
71
|
* Adds support for running on ARM
|
47
|
-
* Fixes asprintf warning during builds
|
72
|
+
* Fixes an asprintf warning during builds
|
48
73
|
* Updates to newer Postgres 10 patch release (10.15)
|
49
|
-
* Deparsing improvements by [@emin100]
|
50
|
-
* Add support for additional DROP statements (#147)
|
51
|
-
* Fix CREATE TABLE AS - Support without TEMP
|
52
|
-
* Empty target list support (#156)
|
53
|
-
* UNION parentheses (#158)
|
54
|
-
* OVERLAY keyword function (#161)
|
55
|
-
* Array indirection (#162)
|
56
|
-
* ARRAY functions (#163)
|
57
|
-
* Correctly handle column names that need escaping in INSERT and UPDATE statements (#164)
|
58
|
-
* INSERT INTO ON CONFLICT (#166)
|
59
|
-
* LATERAL JOIN (#168)
|
60
|
-
* UPDATE FROM clause (#170)
|
61
|
-
* SELECT aggregate FILTER (#175)
|
62
|
-
* INTERSECT operator (#176)
|
63
|
-
* Deparsing: Improve handling of boolean type casts [@himanshu-pro]
|
64
|
-
* `tables` method: Find tables in the subquery of CREATE TABLE AS (#172
|
65
|
-
* Support Ruby 3.0, verify SHA256 checksum of downloaded libpg_query (#178
|
74
|
+
* Deparsing improvements by [@emin100]
|
75
|
+
* Add support for additional DROP statements ([#147](https://github.com/pganalyze/pg_query/pull/147))
|
76
|
+
* Fix `CREATE TABLE AS` - Support without `TEMP`, Add `ON COMMIT` ([#149](https://github.com/pganalyze/pg_query/pull/149))
|
77
|
+
* Empty target list support ([#156](https://github.com/pganalyze/pg_query/pull/156))
|
78
|
+
* `UNION` parentheses ([#158](https://github.com/pganalyze/pg_query/pull/158))
|
79
|
+
* `OVERLAY` keyword function ([#161](https://github.com/pganalyze/pg_query/pull/161))
|
80
|
+
* Array indirection ([#162](https://github.com/pganalyze/pg_query/pull/162))
|
81
|
+
* `ARRAY` functions ([#163](https://github.com/pganalyze/pg_query/pull/163))
|
82
|
+
* Correctly handle column names that need escaping in `INSERT` and `UPDATE` statements ([#164](https://github.com/pganalyze/pg_query/pull/164))
|
83
|
+
* `INSERT INTO ON CONFLICT` ([#166](https://github.com/pganalyze/pg_query/pull/166))
|
84
|
+
* `LATERAL JOIN` ([#168](https://github.com/pganalyze/pg_query/pull/168))
|
85
|
+
* `UPDATE FROM` clause ([#170](https://github.com/pganalyze/pg_query/pull/170))
|
86
|
+
* `SELECT` aggregate `FILTER` ([#175](https://github.com/pganalyze/pg_query/pull/175))
|
87
|
+
* `INTERSECT` operator ([#176](https://github.com/pganalyze/pg_query/pull/176))
|
88
|
+
* Deparsing: Improve handling of boolean type casts [@himanshu-pro] & [@emin100]
|
89
|
+
* `tables` method: Find tables in the subquery of `CREATE TABLE AS` ([#172](https://github.com/pganalyze/pg_query/pull/172)) [@Tassosb]
|
90
|
+
* Support Ruby 3.0, verify SHA256 checksum of downloaded libpg_query ([#178](https://github.com/pganalyze/pg_query/pull/178)) [@stanhu]
|
66
91
|
* Verify SHA256 checksum to guard against any malicious attempts to change the archive
|
67
92
|
* Use `URI.open` to fix Ruby 3.0 support
|
68
93
|
|
@@ -78,69 +103,69 @@
|
|
78
103
|
|
79
104
|
## 1.1.1 2019-11-10
|
80
105
|
|
81
|
-
* Deparsing improvements by [@emin100]
|
82
|
-
* Deparse ILIKE
|
83
|
-
* CREATE CAST (#136)
|
84
|
-
* CREATE SCHEMA (#136)
|
85
|
-
* UNION
|
86
|
-
* CREATE DOMAIN (#145)
|
87
|
-
* Subquery indirection (#157)
|
88
|
-
* Fix Type Cast Parentheses Problem (#152)
|
89
|
-
* SELECT INTO (#151)
|
90
|
-
* SET DEFAULT in INSERT INTO (#154)
|
91
|
-
* REVOKE (#155)
|
92
|
-
* PREPARE and EXECUTE (#148)
|
93
|
-
* INSERT INTO ... RETURNING (#153)
|
94
|
-
* Fix Alter .. RENAME SQL (#146)
|
95
|
-
* Deparsing improvements by [@herwinw]
|
96
|
-
* Fix subquery in COPY in deparse (#112)
|
97
|
-
* Function call indirection (#116)
|
98
|
-
* Function without parameters (#117)
|
99
|
-
* CREATE AGGREGATE
|
100
|
-
* CREATE OPERATOR
|
101
|
-
* CREATE TYPE
|
102
|
-
* GRANT statements
|
103
|
-
* DROP SCHEMA
|
104
|
-
* Deparsing improvements by [@akiellor]
|
105
|
-
* Named window functions (#150)
|
106
|
-
* Deparsing improvements by [@himanshu]
|
107
|
-
* Arguments in custom types (#143)
|
108
|
-
* Use "double precision" instead of "double" type name (#139)
|
109
|
-
* Use explicit -z flag to support OpenBSD tar (#134
|
106
|
+
* Deparsing improvements by [@emin100]
|
107
|
+
* Deparse `ILIKE`, `COLLATE` and `DISCARD` ([#133](https://github.com/pganalyze/pg_query/pull/133))
|
108
|
+
* `CREATE CAST` ([#136](https://github.com/pganalyze/pg_query/pull/136))
|
109
|
+
* `CREATE SCHEMA` ([#136](https://github.com/pganalyze/pg_query/pull/136))
|
110
|
+
* `UNION`, `UNION ALL` and `EXCEPT` in `SELECT` queries ([#136](https://github.com/pganalyze/pg_query/pull/136))
|
111
|
+
* `CREATE DOMAIN` ([#145](https://github.com/pganalyze/pg_query/pull/145))
|
112
|
+
* Subquery indirection ([#157](https://github.com/pganalyze/pg_query/pull/157))
|
113
|
+
* Fix Type Cast Parentheses Problem ([#152](https://github.com/pganalyze/pg_query/pull/152))
|
114
|
+
* `SELECT INTO` ([#151](https://github.com/pganalyze/pg_query/pull/151))
|
115
|
+
* `SET DEFAULT` in `INSERT INTO` ([#154](https://github.com/pganalyze/pg_query/pull/154))
|
116
|
+
* `REVOKE` ([#155](https://github.com/pganalyze/pg_query/pull/155))
|
117
|
+
* `PREPARE` and `EXECUTE` ([#148](https://github.com/pganalyze/pg_query/pull/148))
|
118
|
+
* `INSERT INTO ... RETURNING` ([#153](https://github.com/pganalyze/pg_query/pull/153))
|
119
|
+
* Fix Alter .. `RENAME SQL` ([#146](https://github.com/pganalyze/pg_query/pull/146))
|
120
|
+
* Deparsing improvements by [@herwinw]
|
121
|
+
* Fix subquery in `COPY` in deparse ([#112](https://github.com/pganalyze/pg_query/pull/112))
|
122
|
+
* Function call indirection ([#116](https://github.com/pganalyze/pg_query/pull/116))
|
123
|
+
* Function without parameters ([#117](https://github.com/pganalyze/pg_query/pull/117))
|
124
|
+
* `CREATE AGGREGATE`
|
125
|
+
* `CREATE OPERATOR`
|
126
|
+
* `CREATE TYPE`
|
127
|
+
* `GRANT` statements
|
128
|
+
* `DROP SCHEMA`
|
129
|
+
* Deparsing improvements by [@akiellor]
|
130
|
+
* Named window functions ([#150](https://github.com/pganalyze/pg_query/pull/150))
|
131
|
+
* Deparsing improvements by [@himanshu]
|
132
|
+
* Arguments in custom types ([#143](https://github.com/pganalyze/pg_query/pull/143))
|
133
|
+
* Use "double precision" instead of "double" type name ([#139](https://github.com/pganalyze/pg_query/pull/139))
|
134
|
+
* Use explicit -z flag to support OpenBSD tar ([#134](https://github.com/pganalyze/pg_query/pull/134)) [@sirn]
|
110
135
|
* Add Ruby 2.6 to Travis tests
|
111
136
|
* Escape identifiers in more cases, if necessary
|
112
137
|
|
113
138
|
|
114
139
|
## 1.1.0 2018-10-04
|
115
140
|
|
116
|
-
* Deparsing improvements by [@herwinw]
|
117
|
-
* Add NULLS FIRST
|
118
|
-
* VACUUM [#97](https://github.com/pganalyze/pg_query/pull/97)
|
119
|
-
* UPDATE with multiple columns [#99](https://github.com/pganalyze/pg_query/pull/99)
|
120
|
-
* DISTINCT ON [#101](https://github.com/pganalyze/pg_query/pull/101)
|
121
|
-
* CREATE TABLE AS [#102](https://github.com/pganalyze/pg_query/pull/102)
|
141
|
+
* Deparsing improvements by [@herwinw]
|
142
|
+
* Add `NULLS FIRST`/`LAST` to `ORDER BY` [#95](https://github.com/pganalyze/pg_query/pull/95)
|
143
|
+
* `VACUUM` [#97](https://github.com/pganalyze/pg_query/pull/97)
|
144
|
+
* `UPDATE` with multiple columns [#99](https://github.com/pganalyze/pg_query/pull/99)
|
145
|
+
* `DISTINCT ON` [#101](https://github.com/pganalyze/pg_query/pull/101)
|
146
|
+
* `CREATE TABLE AS` [#102](https://github.com/pganalyze/pg_query/pull/102)
|
122
147
|
* SQL value functions [#103](https://github.com/pganalyze/pg_query/pull/103)
|
123
|
-
* LOCK [#105](https://github.com/pganalyze/pg_query/pull/105)
|
124
|
-
* EXPLAIN [#107](https://github.com/pganalyze/pg_query/pull/107)
|
125
|
-
* COPY [#108](https://github.com/pganalyze/pg_query/pull/108)
|
126
|
-
* DO [#109](https://github.com/pganalyze/pg_query/pull/109)
|
127
|
-
* Ignore pg_query.so in git checkout [#110](https://github.com/pganalyze/pg_query/pull/110) [@herwinw]
|
128
|
-
* Prefer __dir__ over File.dirname(__FILE__) [#110](https://github.com/pganalyze/pg_query/pull/104) [@herwinw]
|
148
|
+
* `LOCK` [#105](https://github.com/pganalyze/pg_query/pull/105)
|
149
|
+
* `EXPLAIN` [#107](https://github.com/pganalyze/pg_query/pull/107)
|
150
|
+
* `COPY` [#108](https://github.com/pganalyze/pg_query/pull/108)
|
151
|
+
* `DO` [#109](https://github.com/pganalyze/pg_query/pull/109)
|
152
|
+
* Ignore pg_query.so in git checkout [#110](https://github.com/pganalyze/pg_query/pull/110) [@herwinw]
|
153
|
+
* Prefer `__dir__` over `File.dirname(__FILE__)` [#110](https://github.com/pganalyze/pg_query/pull/104) [@herwinw]
|
129
154
|
|
130
155
|
|
131
156
|
## 1.0.2 2018-04-11
|
132
157
|
|
133
158
|
* Deparsing improvements
|
134
|
-
* SELECT DISTINCT clause [#77](https://github.com/pganalyze/pg_query/pull/77) [@Papierkorb]
|
135
|
-
* "CASE expr WHEN ... END" clause [#78](https://github.com/pganalyze/pg_query/pull/78) [@Papierkorb]
|
136
|
-
* LEFT
|
137
|
-
* SELECT that includes schema name [#80](https://github.com/pganalyze/pg_query/pull/80) [@jcsjcs]
|
159
|
+
* `SELECT DISTINCT` clause [#77](https://github.com/pganalyze/pg_query/pull/77) [@Papierkorb]
|
160
|
+
* "`CASE expr WHEN ... END`" clause [#78](https://github.com/pganalyze/pg_query/pull/78) [@Papierkorb]
|
161
|
+
* `LEFT`/`RIGHT`/`FULL`/`NATURAL JOIN` [#79](https://github.com/pganalyze/pg_query/pull/79) [@Papierkorb]
|
162
|
+
* `SELECT` that includes schema name [#80](https://github.com/pganalyze/pg_query/pull/80) [@jcsjcs]
|
138
163
|
|
139
164
|
|
140
165
|
## 1.0.1 2018-02-02
|
141
166
|
|
142
|
-
* Parse CTEs and nested selects in INSERT/UPDATE [#76](https://github.com/pganalyze/pg_query/pull/76) [@jcoleman]
|
143
|
-
* Drop explicit json dependency [#74](https://github.com/pganalyze/pg_query/pull/74) [@yuki24]
|
167
|
+
* Parse CTEs and nested selects in INSERT/UPDATE [#76](https://github.com/pganalyze/pg_query/pull/76) [@jcoleman]
|
168
|
+
* Drop explicit json dependency [#74](https://github.com/pganalyze/pg_query/pull/74) [@yuki24]
|
144
169
|
|
145
170
|
|
146
171
|
## 1.0.0 2017-10-31
|
@@ -155,7 +180,7 @@
|
|
155
180
|
## 0.13.5 2017-10-26
|
156
181
|
|
157
182
|
* Update to libpg_query 9.5-1.7.1
|
158
|
-
- Allow "
|
183
|
+
- Allow "`$1 FROM $2`" to be parsed (new with pg_stat_statements in Postgres 10)
|
159
184
|
|
160
185
|
|
161
186
|
## 0.13.4 2017-10-20
|
@@ -166,12 +191,12 @@
|
|
166
191
|
|
167
192
|
## 0.13.3 2017-09-04
|
168
193
|
|
169
|
-
* Fix table detection for SELECTs that have sub-SELECTs without FROM clause [#69](https://github.com/pganalyze/pg_query/issues/69)
|
194
|
+
* Fix table detection for SELECTs that have sub-SELECTs without `FROM` clause [#69](https://github.com/pganalyze/pg_query/issues/69)
|
170
195
|
|
171
196
|
|
172
197
|
## 0.13.2 2017-08-10
|
173
198
|
|
174
|
-
* Support table detection in sub-SELECTs in
|
199
|
+
* Support table detection in sub-SELECTs in `JOIN`s [#68](https://github.com/pganalyze/pg_query/pull/65) [@seanmdick]
|
175
200
|
* Legacy ".parsetree" helper: Fix "Between" and "In" operator does not have "AEXPR" [#66](https://github.com/pganalyze/pg_query/issues/66)
|
176
201
|
* For new applications please use ".tree" method which uses the native structure
|
177
202
|
returned from libpg_query which resembles Postgres node names more closely
|
@@ -179,13 +204,13 @@
|
|
179
204
|
|
180
205
|
## 0.13.1 2017-08-03
|
181
206
|
|
182
|
-
* Fix regression in 0.13.1 that broke ".tables" logic for COPY statements that
|
207
|
+
* Fix regression in 0.13.1 that broke ".tables" logic for `COPY` statements that
|
183
208
|
don't have a target table (i.e. are reading out data vs copying in)
|
184
209
|
|
185
210
|
|
186
211
|
## 0.13.0 2017-07-30
|
187
212
|
|
188
|
-
* Introduce split between SELECT/DML/DDL for tables method [#65](https://github.com/pganalyze/pg_query/pull/65) [@chrisfrommann]
|
213
|
+
* Introduce split between SELECT/DML/DDL for tables method [#65](https://github.com/pganalyze/pg_query/pull/65) [@chrisfrommann]
|
189
214
|
* Backwards compatible, use the new select_tables/dml_tables/ddl_tables to
|
190
215
|
access the categorized table references
|
191
216
|
* Update libpg_query to 9.5-1.6.2
|
@@ -213,14 +238,14 @@
|
|
213
238
|
|
214
239
|
## 0.11.5 2017-07-09
|
215
240
|
|
216
|
-
* Deparse coldeflist [#64](https://github.com/pganalyze/pg_query/pull/64) [@jcsjcs]
|
217
|
-
* Use Integer class for checking integer instead of Fixnum [#62](https://github.com/pganalyze/pg_query/pull/62) [@makimoto]
|
241
|
+
* Deparse coldeflist [#64](https://github.com/pganalyze/pg_query/pull/64) [@jcsjcs]
|
242
|
+
* Use Integer class for checking integer instead of Fixnum [#62](https://github.com/pganalyze/pg_query/pull/62) [@makimoto]
|
218
243
|
|
219
244
|
|
220
245
|
## 0.11.4 2017-01-18
|
221
246
|
|
222
|
-
* Compatibility with Ruby 2.4 [#59](https://github.com/pganalyze/pg_query/pull/59) [@merqlove]
|
223
|
-
* Deparse varchar and numeric casts without arguments [#61](https://github.com/pganalyze/pg_query/pull/61) [@jcsjcs]
|
247
|
+
* Compatibility with Ruby 2.4 [#59](https://github.com/pganalyze/pg_query/pull/59) [@merqlove]
|
248
|
+
* Deparse varchar and numeric casts without arguments [#61](https://github.com/pganalyze/pg_query/pull/61) [@jcsjcs]
|
224
249
|
|
225
250
|
|
226
251
|
## 0.11.3 2016-12-06
|
@@ -228,12 +253,12 @@
|
|
228
253
|
* Update to newest libpg_query version (9.5-1.4.2)
|
229
254
|
* Cut off fingerprints at 100 nodes deep to avoid excessive runtimes/memory
|
230
255
|
* Fix warning on Linux due to missing asprintf include
|
231
|
-
* Improved deparsing [@jcsjcs]
|
256
|
+
* Improved deparsing [@jcsjcs]
|
232
257
|
* Float [#54](https://github.com/pganalyze/pg_query/pull/54)
|
233
|
-
* BETWEEN [#55](https://github.com/pganalyze/pg_query/pull/55)
|
234
|
-
* NULLIF [#56](https://github.com/pganalyze/pg_query/pull/56)
|
235
|
-
* SELECT NULL and BooleanTest [#57](https://github.com/pganalyze/pg_query/pull/57)
|
236
|
-
* Fix build on BSD systems [#58](https://github.com/pganalyze/pg_query/pull/58) [@myfreeweb]
|
258
|
+
* `BETWEEN` [#55](https://github.com/pganalyze/pg_query/pull/55)
|
259
|
+
* `NULLIF` [#56](https://github.com/pganalyze/pg_query/pull/56)
|
260
|
+
* `SELECT NULL` and BooleanTest [#57](https://github.com/pganalyze/pg_query/pull/57)
|
261
|
+
* Fix build on BSD systems [#58](https://github.com/pganalyze/pg_query/pull/58) [@myfreeweb]
|
237
262
|
|
238
263
|
|
239
264
|
## 0.11.2 2016-06-27
|
@@ -251,11 +276,11 @@
|
|
251
276
|
|
252
277
|
## 0.11.0 2016-06-22
|
253
278
|
|
254
|
-
* Improved table name analysis (
|
255
|
-
* Don't include CTE names, make them accessible as
|
279
|
+
* Improved table name analysis (`#tables` method)
|
280
|
+
* Don't include CTE names, make them accessible as `#cte_names` instead [#52](https://github.com/pganalyze/pg_query/issues/52)
|
256
281
|
* Include table names in target list sub selects [#38](https://github.com/pganalyze/pg_query/issues/38)
|
257
|
-
* Add support for ORDER
|
258
|
-
* Fix parsing of DROP TYPE statements
|
282
|
+
* Add support for `ORDER`/`GROUP BY`, `HAVING`, and booleans in `WHERE` [#53](https://github.com/pganalyze/pg_query/pull/53) [@jcoleman]
|
283
|
+
* Fix parsing of `DROP TYPE` statements
|
259
284
|
|
260
285
|
|
261
286
|
## 0.10.0 2016-05-31
|
@@ -263,9 +288,9 @@
|
|
263
288
|
* Based on PostgreSQL 9.5.3
|
264
289
|
* Use LLVM extracted parser for significantly improved build times (via libpg_query)
|
265
290
|
* Deparsing Improvements
|
266
|
-
* SET statements [#48](https://github.com/pganalyze/pg_query/pull/48) [@Winslett]
|
267
|
-
* LIKE
|
268
|
-
* CREATE FUNCTION improvements [#50](https://github.com/pganalyze/pg_query/pull/50) [@Winslett]
|
291
|
+
* `SET` statements [#48](https://github.com/pganalyze/pg_query/pull/48) [@Winslett]
|
292
|
+
* `LIKE`/`NOT LIKE` [#49](https://github.com/pganalyze/pg_query/pull/49) [@Winslett]
|
293
|
+
* `CREATE FUNCTION` improvements [#50](https://github.com/pganalyze/pg_query/pull/50) [@Winslett]
|
269
294
|
|
270
295
|
|
271
296
|
## 0.9.2 2016-05-03
|
@@ -301,17 +326,17 @@
|
|
301
326
|
## 0.7.2 2015-12-20
|
302
327
|
|
303
328
|
* Deparsing
|
304
|
-
* Quote all column refs [#40](https://github.com/pganalyze/pg_query/pull/40) [@avinoamr]
|
305
|
-
* Quote all range vars [#43](https://github.com/pganalyze/pg_query/pull/43) [@avinoamr]
|
306
|
-
* Support for COUNT(DISTINCT ...) [#42](https://github.com/pganalyze/pg_query/pull/42) [@avinoamr]
|
329
|
+
* Quote all column refs [#40](https://github.com/pganalyze/pg_query/pull/40) [@avinoamr]
|
330
|
+
* Quote all range vars [#43](https://github.com/pganalyze/pg_query/pull/43) [@avinoamr]
|
331
|
+
* Support for `COUNT(DISTINCT ...)` [#42](https://github.com/pganalyze/pg_query/pull/42) [@avinoamr]
|
307
332
|
|
308
333
|
|
309
334
|
## 0.7.1 2015-11-17
|
310
335
|
|
311
336
|
* Abstracted parser access into libpg_query [#24](https://github.com/pganalyze/pg_query/pull/35)
|
312
337
|
* libpg_query
|
313
|
-
* Use UTF-8 encoding for parsing [#4](https://github.com/lfittl/libpg_query/pull/4) [@zhm]
|
314
|
-
* Add type to A_CONST nodes[#5](https://github.com/lfittl/libpg_query/pull/5) [@zhm]
|
338
|
+
* Use UTF-8 encoding for parsing [#4](https://github.com/lfittl/libpg_query/pull/4) [@zhm]
|
339
|
+
* Add type to A_CONST nodes[#5](https://github.com/lfittl/libpg_query/pull/5) [@zhm]
|
315
340
|
|
316
341
|
|
317
342
|
## 0.7.0 2015-10-17
|
@@ -320,25 +345,25 @@
|
|
320
345
|
* Avoid bison/flex dependency to make deployment easier [#31](https://github.com/pganalyze/pg_query/issues/31)
|
321
346
|
* Solve issues with deployments to Heroku [#32](https://github.com/pganalyze/pg_query/issues/32)
|
322
347
|
* Deparsing
|
323
|
-
* HAVING and FOR UPDATE [#36](https://github.com/pganalyze/pg_query/pull/36) [@JackDanger]
|
348
|
+
* `HAVING` and `FOR UPDATE` [#36](https://github.com/pganalyze/pg_query/pull/36) [@JackDanger]
|
324
349
|
|
325
350
|
|
326
351
|
## 0.6.4 2015-10-01
|
327
352
|
|
328
353
|
* Deparsing
|
329
|
-
* Constraints & Interval Types [#28](https://github.com/pganalyze/pg_query/pull/28) [@JackDanger]
|
330
|
-
* Cross joins [#29](https://github.com/pganalyze/pg_query/pull/29) [@mme]
|
331
|
-
* ALTER TABLE [#30](https://github.com/pganalyze/pg_query/pull/30) [@JackDanger]
|
332
|
-
* LIMIT and OFFSET [#33](https://github.com/pganalyze/pg_query/pull/33) [@jcsjcs]
|
354
|
+
* Constraints & Interval Types [#28](https://github.com/pganalyze/pg_query/pull/28) [@JackDanger]
|
355
|
+
* Cross joins [#29](https://github.com/pganalyze/pg_query/pull/29) [@mme]
|
356
|
+
* `ALTER TABLE` [#30](https://github.com/pganalyze/pg_query/pull/30) [@JackDanger]
|
357
|
+
* `LIMIT and OFFSET` [#33](https://github.com/pganalyze/pg_query/pull/33) [@jcsjcs]
|
333
358
|
|
334
359
|
|
335
360
|
## 0.6.3 2015-08-20
|
336
361
|
|
337
362
|
* Deparsing
|
338
|
-
* COUNT(*) [@JackDanger]
|
339
|
-
* Window clauses [Chris Martin]
|
340
|
-
* CREATE TABLE
|
341
|
-
* Return exact location for parser errors [@JackDanger]
|
363
|
+
* `COUNT(*)` [@JackDanger]
|
364
|
+
* Window clauses [Chris Martin]
|
365
|
+
* `CREATE TABLE`/`VIEW/FUNCTION` [@JackDanger]
|
366
|
+
* Return exact location for parser errors [@JackDanger]
|
342
367
|
|
343
368
|
|
344
369
|
## 0.6.2 2015-08-06
|
@@ -348,7 +373,7 @@
|
|
348
373
|
|
349
374
|
## 0.6.1 2015-08-06
|
350
375
|
|
351
|
-
* Deparsing: Support WITH clauses in INSERT
|
376
|
+
* Deparsing: Support `WITH` clauses in `INSERT`/`UPDATE`/`DELETE` [@JackDanger]
|
352
377
|
* Make sure gemspec includes all necessary files
|
353
378
|
|
354
379
|
|
@@ -357,20 +382,20 @@
|
|
357
382
|
* Deparsing (experimental)
|
358
383
|
* Turns parse trees into SQL again
|
359
384
|
* New truncate method to smartly truncate based on less important query parts
|
360
|
-
* Thanks to [@mme]
|
385
|
+
* Thanks to [@mme] & [@JackDanger] for their contributions
|
361
386
|
* Restructure extension C code
|
362
387
|
* Add table/filter columns support for CTEs
|
363
|
-
* Extract views as tables from CREATE
|
388
|
+
* Extract views as tables from `CREATE`/`REFRESH VIEW`
|
364
389
|
* Refactor code using generic treewalker
|
365
|
-
* fingerprint: Normalize IN lists
|
390
|
+
* fingerprint: Normalize `IN` lists
|
366
391
|
* param_refs: Fix length attribute in result
|
367
392
|
|
368
393
|
|
369
394
|
## 0.5.0 2015-03-26
|
370
395
|
|
371
396
|
* Query fingerprinting
|
372
|
-
* Filter columns (aka columns referenced in a query's WHERE clause)
|
373
|
-
* Parameter references: Returns all
|
397
|
+
* Filter columns (aka columns referenced in a query's `WHERE` clause)
|
398
|
+
* Parameter references: Returns all `$1`/`$2`/etc like references in the query with their location
|
374
399
|
* Remove dependency on active_support
|
375
400
|
|
376
401
|
|
@@ -387,3 +412,28 @@
|
|
387
412
|
|
388
413
|
|
389
414
|
See git commit log for previous releases.
|
415
|
+
|
416
|
+
[libpg_query]: https://github.com/pganalyze/libpg_query
|
417
|
+
[@emin100]: https://github.com/emin100
|
418
|
+
[@akiellor]: https://github.com/akiellor
|
419
|
+
[@himanshu-pro]: https://github.com/himanshu-pro
|
420
|
+
[@himanshu]: https://github.com/himanshu
|
421
|
+
[@Tassosb]: https://github.com/Tassosb
|
422
|
+
[@herwinw]: https://github.com/herwinw
|
423
|
+
[@stanhu]: https://github.com/stanhu
|
424
|
+
[@Papierkorb]: https://github.com/Papierkorb
|
425
|
+
[@jcsjcs]: https://github.com/jcsjcs
|
426
|
+
[@jcoleman]: https://github.com/jcoleman
|
427
|
+
[@yuki24]: https://github.com/yuki24
|
428
|
+
[@seanmdick]: https://github.com/seanmdick
|
429
|
+
[@chrisfrommann]: https://github.com/chrisfrommann
|
430
|
+
[@makimoto]: https://github.com/makimoto
|
431
|
+
[@merqlove]: https://github.com/merqlove
|
432
|
+
[@myfreeweb]: https://github.com/myfreeweb
|
433
|
+
[@Winslett]: https://github.com/Winslett
|
434
|
+
[@avinoamr]: https://github.com/avinoamr
|
435
|
+
[@zhm]: https://github.com/zhm
|
436
|
+
[@mme]: https://github.com/mme
|
437
|
+
[@JackDanger]: https://github.com/JackDanger
|
438
|
+
[Chris Martin]: https://github.com/cmrtn
|
439
|
+
[@sirn]: https://github.com/sirn
|
data/Rakefile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/clean'
|
2
3
|
require 'rake/extensiontask'
|
3
4
|
require 'rspec/core/rake_task'
|
4
5
|
require 'rubocop/rake_task'
|
5
6
|
require 'open-uri'
|
6
7
|
|
7
|
-
LIB_PG_QUERY_TAG = '13-2.0.
|
8
|
-
LIB_PG_QUERY_SHA256SUM = '
|
8
|
+
LIB_PG_QUERY_TAG = '13-2.0.4'.freeze
|
9
|
+
LIB_PG_QUERY_SHA256SUM = 'a67ef3e3b6c9cb1297f362888d6660dac165d3b020f78d23afe4293b8ceaf190'.freeze
|
9
10
|
|
10
11
|
Rake::ExtensionTask.new 'pg_query' do |ext|
|
11
12
|
ext.lib_dir = 'lib/pg_query'
|
@@ -20,11 +21,9 @@ task default: %i[spec lint]
|
|
20
21
|
task test: :spec
|
21
22
|
task lint: :rubocop
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
FileUtils.rm_f File.join(__dir__, 'lib/pg_query/pg_query.bundle')
|
27
|
-
end
|
24
|
+
CLEAN << 'tmp/**/*'
|
25
|
+
CLEAN << 'ext/pg_query/*.o'
|
26
|
+
CLEAN << 'lib/pg_query/pg_query.bundle'
|
28
27
|
|
29
28
|
task :update_source do
|
30
29
|
workdir = File.join(__dir__, 'tmp')
|
data/ext/pg_query/extconf.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
require 'digest'
|
4
4
|
require 'mkmf'
|
5
5
|
require 'open-uri'
|
6
|
+
require 'pathname'
|
6
7
|
|
7
|
-
$objs = Dir.glob(File.join(__dir__, '*.c')).map { |f| f.
|
8
|
+
$objs = Dir.glob(File.join(__dir__, '*.c')).map { |f| Pathname.new(f).sub_ext('.o').to_s }
|
8
9
|
|
9
10
|
$CFLAGS << " -I#{File.join(__dir__, 'include')} -O3 -Wall -fno-strict-aliasing -fwrapv -fstack-protector -Wno-unused-function -Wno-unused-variable -g"
|
10
11
|
|
@@ -4018,23 +4018,25 @@ static void deparseTableLikeClause(StringInfo str, TableLikeClause *table_like_c
|
|
4018
4018
|
|
4019
4019
|
if (table_like_clause->options == CREATE_TABLE_LIKE_ALL)
|
4020
4020
|
appendStringInfoString(str, "INCLUDING ALL ");
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
|
4026
|
-
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
|
4036
|
-
|
4037
|
-
|
4021
|
+
else
|
4022
|
+
{
|
4023
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS)
|
4024
|
+
appendStringInfoString(str, "INCLUDING COMMENTS ");
|
4025
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_CONSTRAINTS)
|
4026
|
+
appendStringInfoString(str, "INCLUDING CONSTRAINTS ");
|
4027
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_DEFAULTS)
|
4028
|
+
appendStringInfoString(str, "INCLUDING DEFAULTS ");
|
4029
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_IDENTITY)
|
4030
|
+
appendStringInfoString(str, "INCLUDING IDENTITY ");
|
4031
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_GENERATED)
|
4032
|
+
appendStringInfoString(str, "INCLUDING GENERATED ");
|
4033
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_INDEXES)
|
4034
|
+
appendStringInfoString(str, "INCLUDING INDEXES ");
|
4035
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_STATISTICS)
|
4036
|
+
appendStringInfoString(str, "INCLUDING STATISTICS ");
|
4037
|
+
if (table_like_clause->options & CREATE_TABLE_LIKE_STORAGE)
|
4038
|
+
appendStringInfoString(str, "INCLUDING STORAGE ");
|
4039
|
+
}
|
4038
4040
|
removeTrailingSpace(str);
|
4039
4041
|
}
|
4040
4042
|
|
@@ -6676,9 +6678,11 @@ static void deparseCopyStmt(StringInfo str, CopyStmt *copy_stmt)
|
|
6676
6678
|
else
|
6677
6679
|
Assert(false);
|
6678
6680
|
}
|
6679
|
-
else if (strcmp(def_elem->defname, "freeze") == 0 && intVal(def_elem->arg) == 1)
|
6681
|
+
else if (strcmp(def_elem->defname, "freeze") == 0 && (def_elem->arg == NULL || intVal(def_elem->arg) == 1))
|
6680
6682
|
{
|
6681
|
-
appendStringInfoString(str, "FREEZE
|
6683
|
+
appendStringInfoString(str, "FREEZE");
|
6684
|
+
if (def_elem->arg != NULL && intVal(def_elem->arg) == 1)
|
6685
|
+
appendStringInfoString(str, " 1");
|
6682
6686
|
}
|
6683
6687
|
else if (strcmp(def_elem->defname, "delimiter") == 0)
|
6684
6688
|
{
|
@@ -6690,9 +6694,11 @@ static void deparseCopyStmt(StringInfo str, CopyStmt *copy_stmt)
|
|
6690
6694
|
appendStringInfoString(str, "NULL ");
|
6691
6695
|
deparseStringLiteral(str, strVal(def_elem->arg));
|
6692
6696
|
}
|
6693
|
-
else if (strcmp(def_elem->defname, "header") == 0 && intVal(def_elem->arg) == 1)
|
6697
|
+
else if (strcmp(def_elem->defname, "header") == 0 && (def_elem->arg == NULL || intVal(def_elem->arg) == 1))
|
6694
6698
|
{
|
6695
|
-
appendStringInfoString(str, "HEADER
|
6699
|
+
appendStringInfoString(str, "HEADER");
|
6700
|
+
if (def_elem->arg != NULL && intVal(def_elem->arg) == 1)
|
6701
|
+
appendStringInfoString(str, " 1");
|
6696
6702
|
}
|
6697
6703
|
else if (strcmp(def_elem->defname, "quote") == 0)
|
6698
6704
|
{
|
@@ -1,3 +1,7 @@
|
|
1
|
+
// Ensure we have asprintf's definition on glibc-based platforms to avoid compiler warnings
|
2
|
+
#define _GNU_SOURCE
|
3
|
+
#include <stdio.h>
|
4
|
+
|
1
5
|
#include "pg_query.h"
|
2
6
|
#include "pg_query_internal.h"
|
3
7
|
#include "pg_query_fingerprint.h"
|
@@ -13,7 +17,6 @@
|
|
13
17
|
#include "nodes/parsenodes.h"
|
14
18
|
#include "nodes/value.h"
|
15
19
|
|
16
|
-
#include <stdio.h>
|
17
20
|
#include <unistd.h>
|
18
21
|
#include <fcntl.h>
|
19
22
|
|
@@ -318,8 +318,10 @@ static bool const_record_walker(Node *node, pgssConstLocations *jstate)
|
|
318
318
|
DefElem * defElem = (DefElem *) node;
|
319
319
|
if (defElem->arg != NULL && IsA(defElem->arg, String)) {
|
320
320
|
for (int i = defElem->location; i < jstate->query_len; i++) {
|
321
|
-
if (jstate->query[i] == '\'')
|
321
|
+
if (jstate->query[i] == '\'') {
|
322
322
|
RecordConstLocation(jstate, i);
|
323
|
+
break;
|
324
|
+
}
|
323
325
|
}
|
324
326
|
}
|
325
327
|
return const_record_walker((Node *) ((DefElem *) node)->arg, jstate);
|
@@ -62,6 +62,8 @@ module PgQuery
|
|
62
62
|
condition_items << next_item.a_expr.rexpr if next_item.a_expr.rexpr
|
63
63
|
when :bool_expr
|
64
64
|
condition_items += next_item.bool_expr.args
|
65
|
+
when :coalesce_expr
|
66
|
+
condition_items += next_item.coalesce_expr.args
|
65
67
|
when :row_expr
|
66
68
|
condition_items += next_item.row_expr.args
|
67
69
|
when :column_ref
|
data/lib/pg_query/parse.rb
CHANGED
@@ -4,8 +4,8 @@ module PgQuery
|
|
4
4
|
|
5
5
|
begin
|
6
6
|
result = PgQuery::ParseResult.decode(result)
|
7
|
-
rescue Google::Protobuf::ParseError
|
8
|
-
raise PgQuery::ParseError.new('Failed to parse tree', __FILE__, __LINE__, -1)
|
7
|
+
rescue Google::Protobuf::ParseError => e
|
8
|
+
raise PgQuery::ParseError.new(format('Failed to parse tree: %s', e.message), __FILE__, __LINE__, -1)
|
9
9
|
end
|
10
10
|
|
11
11
|
warnings = []
|
data/lib/pg_query/truncate.rb
CHANGED
@@ -24,9 +24,10 @@ module PgQuery
|
|
24
24
|
dummy_column_ref = PgQuery::Node.new(column_ref: PgQuery::ColumnRef.new(fields: [PgQuery::Node.new(string: PgQuery::String.new(str: '…'))]))
|
25
25
|
case truncation.node_type
|
26
26
|
when :target_list
|
27
|
+
res_target_name = '…' if node.is_a?(PgQuery::UpdateStmt) || node.is_a?(PgQuery::OnConflictClause)
|
27
28
|
node.target_list.replace(
|
28
29
|
[
|
29
|
-
PgQuery::Node.new(res_target: PgQuery::ResTarget.new(val: dummy_column_ref))
|
30
|
+
PgQuery::Node.new(res_target: PgQuery::ResTarget.new(name: res_target_name, val: dummy_column_ref))
|
30
31
|
]
|
31
32
|
)
|
32
33
|
when :where_clause
|
@@ -34,7 +35,7 @@ module PgQuery
|
|
34
35
|
when :ctequery
|
35
36
|
node.ctequery = PgQuery::Node.new(select_stmt: PgQuery::SelectStmt.new(where_clause: dummy_column_ref, op: :SETOP_NONE))
|
36
37
|
when :cols
|
37
|
-
node.cols.replace([PgQuery::Node.from(PgQuery::ResTarget.new(name: '…'))])
|
38
|
+
node.cols.replace([PgQuery::Node.from(PgQuery::ResTarget.new(name: '…'))]) if node.is_a?(PgQuery::InsertStmt)
|
38
39
|
else
|
39
40
|
raise ArgumentError, format('Unexpected truncation node type: %s', truncation.node_type)
|
40
41
|
end
|
@@ -50,21 +51,28 @@ module PgQuery
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
|
-
def find_possible_truncations
|
54
|
+
def find_possible_truncations # rubocop:disable Metrics/CyclomaticComplexity
|
54
55
|
truncations = []
|
55
56
|
|
56
|
-
treewalker! @tree do |
|
57
|
+
treewalker! @tree do |node, k, v, location|
|
57
58
|
case k
|
58
59
|
when :target_list
|
60
|
+
next unless node.is_a?(PgQuery::SelectStmt) || node.is_a?(PgQuery::UpdateStmt) || node.is_a?(PgQuery::OnConflictClause)
|
59
61
|
length = PgQuery.deparse_stmt(PgQuery::SelectStmt.new(k => v.to_a, op: :SETOP_NONE)).size - 7 # 'SELECT '.size
|
60
62
|
truncations << PossibleTruncation.new(location, :target_list, length, true)
|
61
63
|
when :where_clause
|
64
|
+
next unless node.is_a?(PgQuery::SelectStmt) || node.is_a?(PgQuery::UpdateStmt) || node.is_a?(PgQuery::DeleteStmt) ||
|
65
|
+
node.is_a?(PgQuery::CopyStmt) || node.is_a?(PgQuery::IndexStmt) || node.is_a?(PgQuery::RuleStmt) ||
|
66
|
+
node.is_a?(PgQuery::InferClause) || node.is_a?(PgQuery::OnConflictClause)
|
67
|
+
|
62
68
|
length = PgQuery.deparse_expr(v).size
|
63
69
|
truncations << PossibleTruncation.new(location, :where_clause, length, false)
|
64
70
|
when :ctequery
|
71
|
+
next unless node.is_a?(PgQuery::CommonTableExpr)
|
65
72
|
length = PgQuery.deparse_stmt(v[v.node.to_s]).size
|
66
73
|
truncations << PossibleTruncation.new(location, :ctequery, length, false)
|
67
74
|
when :cols
|
75
|
+
next unless node.is_a?(PgQuery::InsertStmt)
|
68
76
|
length = PgQuery.deparse_stmt(
|
69
77
|
PgQuery::InsertStmt.new(
|
70
78
|
relation: PgQuery::RangeVar.new(relname: 'x', inh: true),
|
data/lib/pg_query/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Fittl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|