Skip to content

ext/pgsql: pgsql_copy_from to support iterable. - #16124

Closed
devnexen wants to merge 2 commits into
php:masterfrom
devnexen:pgsql_copy_from_iterable
Closed

devnexen wants to merge 2 commits into
php:masterfrom
devnexen:pgsql_copy_from_iterable

Conversation

@devnexen

Copy link
Copy Markdown
Member

inspired from the Pdo\Pgsql new feature GH-15893.

inspired from the Pdo\Pgsql new feature phpGH-15893.
@devnexen
devnexen force-pushed the pgsql_copy_from_iterable branch from 7dd144c to 1eef6df Compare September 30, 2024 12:22
@devnexen
devnexen marked this pull request as ready for review September 30, 2024 12:24
@devnexen
devnexen requested review from Girgias and removed request for kocsismate September 30, 2024 12:24
Comment thread ext/pgsql/pgsql.c Outdated
Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
Z_PARAM_PATH_STR(table_name)
Z_PARAM_ARRAY(pg_rows)
Z_PARAM_ARRAY_OR_OBJECT(pg_rows)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Z_PARAM_ITERABLE

Comment thread ext/pgsql/pgsql.c Outdated
}
} ZEND_HASH_FOREACH_END();
} else {
zend_object_iterator *iter = Z_OBJ_P(pg_rows)->ce->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_object_iterator *iter = Z_OBJ_P(pg_rows)->ce->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);
zend_object_iterator *iter = Z_OBJCE_P(pg_rows)->get_iterator(Z_OBJCE_P(pg_rows), pg_rows, 0);

Comment thread ext/pgsql/pgsql.c
Comment thread ext/pgsql/pgsql.stub.php Outdated
function pg_copy_to(PgSql\Connection $connection, string $table_name, string $separator = "\t", string $null_as = "\\\\N"): array|false {}

function pg_copy_from(PgSql\Connection $connection, string $table_name, array $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|object $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|object $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}
function pg_copy_from(PgSql\Connection $connection, string $table_name, array|Traversable $rows, string $separator = "\t", string $null_as = "\\\\N"): bool {}

@Girgias

Girgias commented Oct 1, 2024

Copy link
Copy Markdown
Member

The changes will need to be applied to #15893

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTM

@devnexen devnexen closed this in e609a21 Oct 1, 2024
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
inspired from the Pdo\Pgsql new feature phpGH-15893.

close phpGH-16124
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