pg_query 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Rakefile +2 -2
- data/ext/pg_query/pg_query_deparse.c +8 -4
- data/ext/pg_query/pg_query_normalize.c +3 -1
- 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
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
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
|
+
|
5
14
|
|
6
15
|
## 2.0.2 2021-03-31
|
7
16
|
|
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 = '13-2.0.
|
9
|
-
LIB_PG_QUERY_SHA256SUM = '
|
8
|
+
LIB_PG_QUERY_TAG = '13-2.0.4'.freeze
|
9
|
+
LIB_PG_QUERY_SHA256SUM = 'a67ef3e3b6c9cb1297f362888d6660dac165d3b020f78d23afe4293b8ceaf190'.freeze
|
10
10
|
|
11
11
|
Rake::ExtensionTask.new 'pg_query' do |ext|
|
12
12
|
ext.lib_dir = 'lib/pg_query'
|
@@ -6678,9 +6678,11 @@ static void deparseCopyStmt(StringInfo str, CopyStmt *copy_stmt)
|
|
6678
6678
|
else
|
6679
6679
|
Assert(false);
|
6680
6680
|
}
|
6681
|
-
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))
|
6682
6682
|
{
|
6683
|
-
appendStringInfoString(str, "FREEZE
|
6683
|
+
appendStringInfoString(str, "FREEZE");
|
6684
|
+
if (def_elem->arg != NULL && intVal(def_elem->arg) == 1)
|
6685
|
+
appendStringInfoString(str, " 1");
|
6684
6686
|
}
|
6685
6687
|
else if (strcmp(def_elem->defname, "delimiter") == 0)
|
6686
6688
|
{
|
@@ -6692,9 +6694,11 @@ static void deparseCopyStmt(StringInfo str, CopyStmt *copy_stmt)
|
|
6692
6694
|
appendStringInfoString(str, "NULL ");
|
6693
6695
|
deparseStringLiteral(str, strVal(def_elem->arg));
|
6694
6696
|
}
|
6695
|
-
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))
|
6696
6698
|
{
|
6697
|
-
appendStringInfoString(str, "HEADER
|
6699
|
+
appendStringInfoString(str, "HEADER");
|
6700
|
+
if (def_elem->arg != NULL && intVal(def_elem->arg) == 1)
|
6701
|
+
appendStringInfoString(str, " 1");
|
6698
6702
|
}
|
6699
6703
|
else if (strcmp(def_elem->defname, "quote") == 0)
|
6700
6704
|
{
|
@@ -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);
|
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
|