feat: export via COPY TO STDOUT instead of temporary view (SUPPORT-17025)#171
Draft
terezaskalova wants to merge 1 commit into
Draft
feat: export via COPY TO STDOUT instead of temporary view (SUPPORT-17025)#171terezaskalova wants to merge 1 commit into
terezaskalova wants to merge 1 commit into
Conversation
Co-Authored-By: tereza.skalova <tereza.skalova@keboola.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
Copyexport adapter no longer creates a temporary view on the source database. Previously, when the DB user could create a view, each export ran DDL against the source:The temp view existed only to work around a psql limitation: the client-side
\copymeta-command must fit on a single line, so multi-line queries fail unless wrapped in a view.This PR switches to the server-side
COPY (...) TO STDOUTSQL statement, redirecting its output to the target file with psql's\ometa-command:COPY ... TO STDOUTis a regular SQL statement, so it handles multi-line queries without any DDL and requires no special privileges (any user that canSELECTcan run it). Output CSV is byte-for-byte the same as before.Because no view is created anymore, the pre-flight
canUserCreateView()(has_schema_privilege(...)) andisTransactionReadOnly()(SHOW transaction_read_only) probe queries — and the whole view/non-view branch — are removed. This also drops two round-trip queries per export.This directly addresses the customer request in SUPPORT-17025 (replication with no DDL updates on the source).
Testing
composer cipasses (phpcs, phpstan, unit + functional).run-action-row-debug-logging(logged SQL) anderror-invalid-query(error now referencesCOPY (...) TO STDOUTinstead ofCREATE TEMP VIEW).run-action-with-read-only-userstill passes, confirming read-only users export correctly via the new path.Release Notes
Justification, description
Customer (SUPPORT-17025) requires DB replication with no DDL changes on the source. The Postgres extractor's
Copyadapter created/dropped a temporary view per export; it now usesCOPY (...) TO STDOUTredirected to the output file, avoiding all DDL while producing identical output.Plans for Customer Communication
Provide the customer with a testing image tag to validate against their source before release.
Impact Analysis
Applies to all Postgres extractor exports using the
Copy(psql) adapter. Output CSV is unchanged. Multi-line queries continue to work (previously handled via the temp view). Read-only users and users without CREATE privilege are unaffected (already used a direct COPY path).Deployment Plan
Standard component release after review + CI.
Rollback Plan
Revert this PR / redeploy the previous image tag.
Post-Release Support Plan
Monitor extractor job error rates in Datadog for the
Copyadapter.Link to Devin session: https://app.devin.ai/sessions/66131de271cc4c3f98cda8411b9c4602
Requested by: @terezaskalova