From 21c5ff681be1175a7e5f1dd840a335bc71e7c0d7 Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Mon, 21 Sep 2020 01:47:37 +0200 Subject: [PATCH] pg: add binding for PQfinish (close) (#6435) --- vlib/pg/pg.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/pg/pg.v b/vlib/pg/pg.v index 4783144bbe..a55b0d0b46 100644 --- a/vlib/pg/pg.v +++ b/vlib/pg/pg.v @@ -37,6 +37,7 @@ fn C.PQnfields(voidptr) int fn C.PQexec(voidptr) voidptr fn C.PQexecParams(voidptr) voidptr fn C.PQclear(voidptr) voidptr +fn C.PQfinish(voidptr) pub fn connect(config Config) ?DB { conninfo := 'host=$config.host port=$config.port user=$config.user dbname=$config.dbname password=$config.password' @@ -67,6 +68,11 @@ fn res_to_rows(res voidptr) []Row { return rows } +// close frees the underlaying resource allocated by the database connection +pub fn (db DB) close() { + C.PQfinish(db.conn) +} + pub fn (db DB) q_int(query string) int { rows := db.exec(query) if rows.len == 0 {