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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 710ab71b06be359f6072242754970015712cdad8839c1811470292fad47c880e
4
- data.tar.gz: 1c16c458bdc5f32798dc74839a9d6721bbfa56b754768a64a8bbcbd3b63f13c8
3
+ metadata.gz: f19538f4d41c891a9b7704cd56becd762e44f5f766fba06c07f89b2e1d61b69f
4
+ data.tar.gz: df5a48fd5582bacd09098a5d37c21794a6f1caff82b16fe4597be2257bb0eaa1
5
5
  SHA512:
6
- metadata.gz: 4263eebc1add9d84d008d9405e6188dcccc01beec592ed915c80ae6edaaf18a452bb947a18b1af0279d7c5be7e68e871e727cb50d2f36c831694825774fa74de
7
- data.tar.gz: 6e4b4ed4202cf46562cd2dc2281cec07c487e19db79f1df14b3797dba512182daedcccb9299cd0374d4b3163c5400579b71aa18800280e75f9fa499eec997a9a
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.2'.freeze
9
- LIB_PG_QUERY_SHA256SUM = 'fe485f48bb51dcc5ed146b1c9929da417357ae8844c2f0c8fe1e235fa1d14257'.freeze
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 1");
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 1");
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);
@@ -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 |_expr, k, v, location|
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),
@@ -1,3 +1,3 @@
1
1
  module PgQuery
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
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.2
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-03-31 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler