Skip to content

Commit 43afefc

Browse files
committed
Update release notes for PR #122
1 parent 771b56d commit 43afefc

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

.release-notes/add-copy-out.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

.release-notes/next-release.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,31 @@ actor MyNotify is SessionStatusNotify
466466

467467
The callback has a default no-op implementation, so existing code is unaffected.
468468

469+
## Add COPY TO STDOUT support
470+
471+
You can now bulk-export data from PostgreSQL using `COPY ... TO STDOUT`. Call `session.copy_out()` with a COPY SQL statement and a `CopyOutReceiver` to start the operation. The server drives the flow — data arrives via `pg_copy_data` callbacks, and `pg_copy_complete` fires when all data has been delivered.
472+
473+
```pony
474+
actor Exporter is (SessionStatusNotify & ResultReceiver & CopyOutReceiver)
475+
var _buffer: Array[U8] iso = recover iso Array[U8] end
476+
477+
be pg_session_authenticated(session: Session) =>
478+
session.copy_out("COPY my_table TO STDOUT", this)
479+
480+
be pg_copy_data(session: Session, data: Array[U8] val) =>
481+
_buffer.append(data)
482+
483+
be pg_copy_complete(session: Session, count: USize) =>
484+
let received = String.from_iso_array(
485+
_buffer = recover iso Array[U8] end)
486+
_env.out.print("Exported " + count.string() + " rows")
487+
_env.out.print(received)
488+
489+
be pg_copy_failed(session: Session,
490+
failure: (ErrorResponseMessage | ClientQueryError))
491+
=>
492+
// handle error
493+
```
494+
495+
Data format depends on the COPY command — the default is tab-delimited text with newline row terminators. Data chunks do not necessarily align with row boundaries; the receiver should buffer chunks if row-level processing is needed.
496+

0 commit comments

Comments
 (0)