File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -712,11 +712,15 @@ void pgsqlCopyFromArray_internal(INTERNAL_FUNCTION_PARAMETERS)
712712 }
713713 } ZEND_HASH_FOREACH_END ();
714714 } else {
715- iter = Z_OBJ_P (pg_rows )-> ce -> get_iterator (Z_OBJCE_P (pg_rows ), pg_rows , 0 );
715+ iter = Z_OBJCE_P (pg_rows )-> get_iterator (Z_OBJCE_P (pg_rows ), pg_rows , 0 );
716716 if (iter == NULL || EG (exception )) {
717717 RETURN_THROWS ();
718718 }
719719
720+ if (iter -> funcs -> rewind ) {
721+ iter -> funcs -> rewind (iter );
722+ }
723+
720724 for (; iter -> funcs -> valid (iter ) == SUCCESS && EG (exception ) == NULL ; iter -> funcs -> move_forward (iter )) {
721725 tmp = iter -> funcs -> get_current_data (iter );
722726 if (!_pdo_pgsql_send_copy_data (H , tmp )) {
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ $iterator = new class implements Iterator{
4242 }
4343};
4444
45+ try {
46+ $ db ->pgsqlCopyFromArray ('test_copy_from_traversable ' ,new stdClass ());
47+ } catch (\TypeError $ e ) {
48+ echo $ e ->getMessage () . PHP_EOL ;
49+ }
50+
4551$ db ->pgsqlCopyFromArray ('test_copy_from_traversable ' ,$ iterator );
4652
4753$ stmt = $ db ->query ("select * from test_copy_from_traversable order by 1 " );
@@ -56,6 +62,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
5662$ db ->query ('DROP TABLE IF EXISTS test_copy_from_traversable CASCADE ' );
5763?>
5864--EXPECT--
65+ PDO::pgsqlCopyFromArray(): Argument #2 ($rows) must be of type array or Traversable
5966array (
6067 0 => 1,
6168 1 => 1,
You can’t perform that action at this time.
0 commit comments