@@ -56,12 +56,7 @@ protected function simulateQuery(string $queryString)
5656 } catch (PDOException $ e ) {
5757 return $ this ->cache [$ queryString ] = $ e ;
5858 } finally {
59- try {
60- $ this ->pdo ->rollBack ();
61- } catch (PDOException $ e ) {
62- // not all drivers may support transactions
63- throw new \RuntimeException ('Failed to rollback transaction ' , $ e ->getCode (), $ e );
64- }
59+ $ this ->pdo ->rollBack ();
6560 }
6661
6762 $ this ->cache [$ queryString ] = [];
@@ -91,6 +86,8 @@ protected function simulateQuery(string $queryString)
9186 ++$ columnIndex ;
9287 }
9388
89+ $ stmt ->closeCursor ();
90+
9491 return $ this ->cache [$ queryString ];
9592 }
9693
@@ -114,21 +111,25 @@ protected function checkInformationSchema(string $tableName): Iterator
114111 );
115112 }
116113
117- $ this ->stmt ->execute ([$ tableName ]);
118- $ result = $ this ->stmt ->fetchAll (PDO ::FETCH_ASSOC );
119-
120- /** @var array{column_default?: string, column_name: string, is_nullable: string} $row */
121- foreach ($ result as $ row ) {
122- $ default = $ row ['column_default ' ] ?? '' ;
123- $ columnName = $ row ['column_name ' ];
124- $ isNullable = 'YES ' === $ row ['is_nullable ' ];
125-
126- if (!$ isNullable ) {
127- yield $ columnName => PgsqlTypeMapper::FLAG_NOT_NULL ;
128- }
129- if (str_contains ($ default , 'nextval ' )) {
130- yield $ columnName => PgsqlTypeMapper::FLAG_AUTO_INCREMENT ;
114+ try {
115+ $ this ->stmt ->execute ([$ tableName ]);
116+ $ result = $ this ->stmt ->fetchAll (PDO ::FETCH_ASSOC );
117+
118+ /** @var array{column_default?: string, column_name: string, is_nullable: string} $row */
119+ foreach ($ result as $ row ) {
120+ $ default = $ row ['column_default ' ] ?? '' ;
121+ $ columnName = $ row ['column_name ' ];
122+ $ isNullable = 'YES ' === $ row ['is_nullable ' ];
123+
124+ if (!$ isNullable ) {
125+ yield $ columnName => PgsqlTypeMapper::FLAG_NOT_NULL ;
126+ }
127+ if (str_contains ($ default , 'nextval ' )) {
128+ yield $ columnName => PgsqlTypeMapper::FLAG_AUTO_INCREMENT ;
129+ }
131130 }
131+ } finally {
132+ $ this ->stmt ->closeCursor ();
132133 }
133134 }
134135}
0 commit comments