@@ -56,12 +56,7 @@ protected function simulateQuery(string $queryString)
56
56
} catch (PDOException $ e ) {
57
57
return $ this ->cache [$ queryString ] = $ e ;
58
58
} 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 ();
65
60
}
66
61
67
62
$ this ->cache [$ queryString ] = [];
@@ -91,6 +86,8 @@ protected function simulateQuery(string $queryString)
91
86
++$ columnIndex ;
92
87
}
93
88
89
+ $ stmt ->closeCursor ();
90
+
94
91
return $ this ->cache [$ queryString ];
95
92
}
96
93
@@ -114,21 +111,25 @@ protected function checkInformationSchema(string $tableName): Iterator
114
111
);
115
112
}
116
113
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
+ }
131
130
}
131
+ } finally {
132
+ $ this ->stmt ->closeCursor ();
132
133
}
133
134
}
134
135
}
0 commit comments