Skip to content

Commit b943f71

Browse files
committed
manage connections with execute-do-with-resolved-connection
1 parent 7c6c0e1 commit b943f71

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/metabase/driver/teradata.clj

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -350,23 +350,24 @@
350350
t (t/sql-timestamp t)]
351351
(.setTimestamp ps i t cal)))
352352

353-
(defmethod sql-jdbc.execute/do-with-connection-with-options :teradata
354-
[driver database _options f]
355-
(let [conn (.getConnection (sql-jdbc.execute/datasource database))]
356-
(try
357-
(sql-jdbc.execute/set-best-transaction-level! driver conn)
358-
(try
359-
(.setReadOnly conn true)
360-
(catch Throwable e
361-
(log/debug e (trs "Error setting connection to read-only"))))
362-
(try
363-
(.setHoldability conn ResultSet/CLOSE_CURSORS_AT_COMMIT)
364-
(catch Throwable e
365-
(log/debug e (trs "Error setting default holdability for connection"))))
366-
(f conn) ;; Pass the connection to the provided function
367-
(catch Throwable e
368-
(.close conn)
369-
(throw e)))))
353+
(defmethod sql-jdbc.execute/do-with-connection-with-options :redshift
354+
[driver db-or-id-or-spec options f]
355+
(sql-jdbc.execute/do-with-resolved-connection
356+
driver
357+
db-or-id-or-spec
358+
options
359+
(fn [^Connection conn]
360+
(when-not (sql-jdbc.execute/recursive-connection?)
361+
(sql-jdbc.execute/set-best-transaction-level! driver conn)
362+
(try
363+
(.setReadOnly conn true)
364+
(catch Throwable e
365+
(log/debug e (trs "Error setting connection to read-only"))))
366+
(try
367+
(.setHoldability conn ResultSet/CLOSE_CURSORS_AT_COMMIT)
368+
(catch Throwable e
369+
(log/debug e (trs "Error setting default holdability for connection")))))
370+
(f conn))))
370371

371372
(defn- cleanup-query
372373
"Remove the OFFSET keyword."

0 commit comments

Comments
 (0)