Skip to content

ext/pdo_pgsql: Expanding COPY input from an array to an iterable - #15893

Closed
KentarouTakeda wants to merge 3 commits into
php:masterfrom
KentarouTakeda:pdo-pgsql-copy-from-iterable
Closed

KentarouTakeda wants to merge 3 commits into
php:masterfrom
KentarouTakeda:pdo-pgsql-copy-from-iterable

Conversation

@KentarouTakeda

@KentarouTakeda KentarouTakeda commented Sep 15, 2024 •

Copy link
Copy Markdown
Contributor

This pull request allows PDO::pgsqlCopyFromArray to accept Iterable instead of just array. This is not a breaking change since it still accepts array.

The PostgreSQL COPY statement is a great interface. We can bulk insert a set of records by inputting them as CSV or TSV. PostgreSQL also supports processing them as a stream.

However, the current pgsqlCopyFromArray does not take full advantage of this capability. It requires that the records to be inserted be input as a single array, so it cannot be processed by piping external input to PostgreSQL's COPY.

This weakness will be overcome by supporting not only simple arrays but also Traversable and Generator.

@devnexen

devnexen commented Sep 15, 2024 •

Copy link
Copy Markdown
Member

Nice feature and qualifies for the next major release I think. looking ok overall, I would suggest trying to refactor, as much as you can, common code between the two modes.

@KentarouTakeda

Copy link
Copy Markdown
Contributor Author

I'll try it.

@KentarouTakeda
KentarouTakeda marked this pull request as draft September 15, 2024 09:04
@KentarouTakeda
KentarouTakeda force-pushed the pdo-pgsql-copy-from-iterable branch from 36ff68d to e141a5e Compare September 15, 2024 10:17
@KentarouTakeda
KentarouTakeda force-pushed the pdo-pgsql-copy-from-iterable branch from e141a5e to 5691fb3 Compare September 15, 2024 10:55
@KentarouTakeda

Copy link
Copy Markdown
Contributor Author

I tried to do as much as I could.
(Actually, I'm not very familiar with the C language. Please feel free to let me know if I'm doing something strange.)

@KentarouTakeda
KentarouTakeda marked this pull request as ready for review September 15, 2024 10:58
@devnexen

Copy link
Copy Markdown
Member

Couple of things to look at I think, good news is because of this

qualifies for the next major release I think

you have the time.

see next comments.

Comment thread ext/pdo_pgsql/pgsql_driver.c Outdated
Comment thread ext/pdo_pgsql/pgsql_driver.c Outdated
Comment thread ext/pdo_pgsql/pgsql_driver.c Outdated
@devnexen

Copy link
Copy Markdown
Member

Looking good to me, implementation-wise. I ll let it rest if someone wants to chime in about tests.

@devnexen devnexen closed this in 7f5e96d Sep 28, 2024
devnexen added a commit to devnexen/php-src that referenced this pull request Sep 30, 2024
inspired from the Pdo\Pgsql new feature phpGH-15893.
devnexen added a commit that referenced this pull request Oct 1, 2024
inspired from the Pdo\Pgsql new feature GH-15893.

close GH-16124
devnexen added a commit to devnexen/php-src that referenced this pull request Oct 1, 2024
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Oct 1, 2024
jorgsowa pushed a commit to jorgsowa/php-src that referenced this pull request Oct 1, 2024
inspired from the Pdo\Pgsql new feature phpGH-15893.

close phpGH-16124
@KentarouTakeda
KentarouTakeda deleted the pdo-pgsql-copy-from-iterable branch September 23, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants