exwiw 0.9.4 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c472ab8d5098ed7cd796e8549329dadba6b4cce31b2d44b956f463699643a353
4
- data.tar.gz: c5b53ba657142131d1dacdb44b3bca0117b55052384d9da2257108be6073b511
3
+ metadata.gz: 26a737cacfa93caa21e4198a6b82df13daa24708940ef3792a1df8a948c22a39
4
+ data.tar.gz: 8a8ab4cd417c3555d364fad969c2c6e930303b04c1795f7dda85d8b5f57eae24
5
5
  SHA512:
6
- metadata.gz: 79879008903ad2eff63b7c14851611fd4d6b8161726240faef77cf4533a1c172a9cbed140abe71dde1e1026de521d4d81b5d2eff074d977a8883476979f10ad0
7
- data.tar.gz: bbb86bbd868783c891a1a45a337977160e569c920ded2e3a8782c098e702dabfe0f6bbbad599fd0db0b0949731a471193529c65f382de6d22c31524c776468ef
6
+ metadata.gz: 980386da8daf57851f67f6f67deee5d0c107407d3458946985528624224a4a4462bf551008e57f2c4e9055a82e53146f253ec256cfca1bfccf3695aba2571fdb
7
+ data.tar.gz: f9e0abde493ddaf4bf714eab396e1d8e9a7ce0b828d87cff3e22b1b5b1bb70584148a940a664cfa09f6a0a1f4a798c56b375479c94c176cf391b88a0a7b5b73e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.5] - 2026-07-07
6
+
7
+ ### Fixed
8
+
9
+ - **PostgreSQL: a `COMMENT ON EXTENSION` for a skipped extension no longer aborts the restore.** pg_dump emits `COMMENT ON EXTENSION <name> IS '...'` right after each `CREATE EXTENSION`. When the `CREATE` was skipped by the graceful `DO … EXCEPTION WHEN feature_not_supported` block (a target that cannot provide the extension — e.g. AlloyDB's `google_vacuum_mgmt` restored into vanilla PostgreSQL), the bare `COMMENT` then failed with `undefined_object` (`extension "…" does not exist`) and aborted the whole restore. A new `DdlPostprocessor.wrap_comment_on_extension_in_do_block` pass wraps each `COMMENT ON EXTENSION` in a `DO $exwiw$ … EXCEPTION WHEN undefined_object THEN NULL … $exwiw$` block, so it applies when the extension exists and is a no-op when it was skipped. This makes any managed-platform extension (AlloyDB `google_*`, `alloydb_scann`, etc.) skip cleanly, not just the one reported.
10
+
5
11
  ## [0.9.4] - 2026-07-07
6
12
 
7
13
  ### Changed
@@ -136,10 +136,14 @@ module Exwiw
136
136
  # robustness: enums swallow duplicate_object on re-restore; extensions
137
137
  # warn-and-skip feature_not_supported / invalid_schema_name so a target
138
138
  # that cannot provide the extension (e.g. pglogical's schema absent, or a
139
- # managed-platform extension) does not abort the restore.
139
+ # managed-platform extension) does not abort the restore. The COMMENT ON
140
+ # EXTENSION that pg_dump emits alongside is likewise wrapped to swallow
141
+ # undefined_object, so a skipped extension's trailing comment does not
142
+ # abort the restore either.
140
143
  idempotent = stdout
141
144
  idempotent = DdlPostprocessor.wrap_create_type_enum_in_do_block(idempotent)
142
145
  idempotent = DdlPostprocessor.wrap_create_extension_in_do_block(idempotent)
146
+ idempotent = DdlPostprocessor.wrap_comment_on_extension_in_do_block(idempotent)
143
147
  idempotent = DdlPostprocessor.add_if_not_exists_to_create_schema(idempotent)
144
148
  idempotent = DdlPostprocessor.add_if_not_exists_to_create_sequence(idempotent)
145
149
  idempotent = DdlPostprocessor.add_if_not_exists_to_create_table(idempotent)
@@ -106,6 +106,26 @@ module Exwiw
106
106
  end
107
107
  end
108
108
 
109
+ # pg_dump emits `COMMENT ON EXTENSION <name> IS '...';` right after the
110
+ # matching CREATE EXTENSION. When the CREATE was skipped (its DO block caught
111
+ # feature_not_supported because the target cannot provide the extension —
112
+ # e.g. AlloyDB's google_vacuum_mgmt restored into vanilla PostgreSQL), this
113
+ # bare COMMENT then aborts the whole restore with `undefined_object` (42704,
114
+ # "extension ... does not exist"). Wrap each COMMENT in a DO block that
115
+ # swallows undefined_object, so it applies when the extension exists and is a
116
+ # no-op when it was skipped. The IS clause is matched as a whole single-quoted
117
+ # string (doubled quotes escaped) or NULL, so an embedded `;` does not end the
118
+ # match early.
119
+ COMMENT_ON_EXTENSION_RE =
120
+ /^[ \t]*COMMENT\s+ON\s+EXTENSION\s+(?:"[^"]+"|[^\s]+)\s+IS\s+(?:'(?:[^']|'')*'|NULL)\s*;/i.freeze
121
+
122
+ def wrap_comment_on_extension_in_do_block(sql)
123
+ sql.gsub(COMMENT_ON_EXTENSION_RE) do
124
+ stmt = Regexp.last_match(0).strip
125
+ "DO $exwiw$ BEGIN #{stmt} EXCEPTION WHEN undefined_object THEN NULL; END $exwiw$;"
126
+ end
127
+ end
128
+
109
129
  # Generate idempotent CREATE TYPE ... AS ENUM statements.
110
130
  # +enum_types+ is an Array of Hashes with keys :schema, :name, :labels.
111
131
  def create_type_enum_statements(enum_types)
data/lib/exwiw/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Exwiw
4
- VERSION = "0.9.4"
4
+ VERSION = "0.9.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exwiw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia