Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

All notable changes to pgclone are documented in this file.

## [Unreleased]
## [4.8.0]

### Docs
- README: add an "Upgrading" section — restart PostgreSQL after `make install` and before `ALTER EXTENSION pgclone UPDATE` (a stale preloaded library causes `could not find function ... in file pgclone.so`, issue #35).
This release has no SQL-level changes; after `make install`, **restart PostgreSQL**, then `ALTER EXTENSION pgclone UPDATE`.

### Added
- `"conflict": "ignore"` (discussion #24): if the target table already exists, keep its definition (skip table DDL, constraints, indexes, triggers) and still load the data. Works in the sync and async paths.

### Fixed
- **Partitioned tables clone correctly (issue #38).** `pgclone.schema()`, `schema_async()` (including the parallel pool) and `table_async()` used to create a partitioned parent as a plain table and then abort with `cannot copy from partitioned table`. A partitioned parent is now created with `PARTITION BY`, each partition with `PARTITION OF <parent> FOR VALUES ...` (sub-partitioning included), and rows are copied once, from leaf partitions only. Partitions inherit the parent's primary key / indexes / triggers instead of having them cloned twice, and the table list is ordered so parents exist before their partitions (a pool worker waits for the parent). `pgclone.table()` on a partitioned parent creates just the parent; clone the schema (or each partition) to get the partitions.
- **Generated columns stay generated, and COPY skips them.** `CREATE TABLE` reconstruction treated every `pg_attrdef` entry as a `DEFAULT`, so `GENERATED ALWAYS AS (...) STORED` columns (and PostgreSQL 18 `VIRTUAL` columns) were cloned as ordinary defaults. Once a column stays generated, a bare `COPY table` fails on the way in (`column "..." is a generated column`). Table DDL now emits `GENERATED ALWAYS AS (...) STORED` or `VIRTUAL`, and both the synchronous COPY path and the background worker omit generated columns so the target recomputes them. Ordinary defaults are unchanged. A generated column named in an explicit `"columns"` list is still rejected by the server; leave those columns out of the list. Virtual generated columns need PostgreSQL 18 on the target.
- **`table_async()` on tables with `serial` / `bigserial` columns (issue #33).** The single-table background path created the table without its sequence (`relation "..._id_seq" does not exist`). It now pre-creates the dependent sequences before `CREATE TABLE` and replays their current values after the copy, like `pgclone.table()`.
- **Background workers ignored SIGTERM on PostgreSQL 17+.** The worker's SIGTERM handler only sets `ShutdownRequestPending`, which `CHECK_FOR_INTERRUPTS()` does not service, so `pg_terminate_backend()` and server shutdown waited for the whole copy. Interrupt checks now also test that flag (`PGCLONE_CHECK_SHUTDOWN()`), and the COPY loop checks for interrupts, so a killed worker marks its job `failed` ("worker exited unexpectedly").

### Changed
- `test/test_chaos.sh` now actually exercises worker/coordinator termination: PIDs come from `pg_stat_activity`, workers are sent SIGTERM (SIGKILL crash-restarts the server), and the fixture is large enough to outlast the signal. Previously the tests passed without killing anything.
- New `test/test_partitions.sh` and async test 9 (`bigserial`); pgTAP plan 164 -> 168 (`conflict=ignore`) and group 32 (generated columns).

### Docs
- README: add an "Upgrading" section — restart PostgreSQL after `make install` and before `ALTER EXTENSION pgclone UPDATE` (a stale preloaded library causes `could not find function ... in file pgclone.so`, issue #35).

## [4.7.0]

Expand Down
6 changes: 3 additions & 3 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "pgclone",
"abstract": "Clone PostgreSQL databases, schemas, tables between staging, test, dev and prod environments",
"description": "PostgreSQL extension for easily cloning your DB, Schemas, Tables and more between environments",
"version": "4.7.0",
"version": "4.8.0",
"maintainer": "Valeh Agayev <valeh.agayev@gmail.com>",
"license": "postgresql",
"provides": {
"pgclone": {
"abstract": "Clone PostgreSQL databases, schemas, and tables across environments",
"file": "sql/pgclone--4.7.0.sql",
"version": "4.7.0"
"file": "sql/pgclone--4.8.0.sql",
"version": "4.8.0"
}
},
"prereqs": {
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ pgclone uses Unix domain sockets for local loopback connections, so the default
- [x] v4.5.0: Clone a table from Oracle into PostgreSQL — `pgclone.table_from_oracle()` with Oracle→PG type mapping, `dry_run`, CLOB/RAW support and an optional OCI build (`WITH_ORACLE=1`); verified in CI against Oracle Free
- [x] v4.6.0: Clone a table from Microsoft SQL Server into PostgreSQL — `pgclone.table_from_sqlserver()` with SQL Server→PG type mapping, `dry_run`, `NVARCHAR(MAX)`/`VARBINARY`/`UNIQUEIDENTIFIER` support and an optional FreeTDS build (`WITH_SQLSERVER=1`); CI job against SQL Server 2022
- [x] v4.7.0: Clone a table from MySQL / MariaDB into PostgreSQL — `pgclone.table_from_mysql()` with MySQL→PG type mapping, `dry_run`, unsigned/`BIT`/`JSON`/`ENUM`/`SET`/`BLOB` support, zero-date handling and an optional client build (`WITH_MYSQL=1`); CI job against MySQL 8.0
- [ ] v4.8.0: FK-aware referential sampling — sample N rows and follow foreign keys to keep child rows consistent (`pgclone.table_sample`)
- [x] v4.8.0: `"conflict": "ignore"`, partitioned-table cloning (`PARTITION BY` / `PARTITION OF`), generated columns, `table_async` sequences, PG17+ worker SIGTERM fix — see [CHANGELOG](CHANGELOG.md)
- [ ] v4.9.0: FK-aware referential sampling — sample N rows and follow foreign keys to keep child rows consistent (`pgclone.table_sample`)

## License

Expand Down
2 changes: 1 addition & 1 deletion pgclone.control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pgclone extension
comment = 'Clone PostgreSQL databases, schemas, tables, roles and permissions with selective columns, data filtering, data masking/anonymization, async, parallel cloning, materialized views, resume, and conflict resolution, and Oracle-, SQL Server- and MySQL-to-PostgreSQL table cloning (optional OCI / FreeTDS / MySQL client builds)'
default_version = '4.7.0'
default_version = '4.8.0'
module_pathname = '$libdir/pgclone'
relocatable = false
superuser = true
10 changes: 10 additions & 0 deletions sql/pgclone--4.7.0--4.8.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* pgclone--4.7.0--4.8.0.sql */
\echo Use "ALTER EXTENSION pgclone UPDATE" to load this file. \quit

-- v4.8.0: no SQL-level changes. This release is C-level only:
-- * "conflict": "ignore" option
-- * partitioned tables cloned with PARTITION BY / PARTITION OF
-- * generated columns stay generated
-- * table_async creates and syncs sequences
-- * background workers honor SIGTERM on PG17+
-- Restart PostgreSQL after installing the new library (shared_preload_libraries).
Loading
Loading