Lines Matching defs:dbi
77 db_connect(struct dbinfo *dbi) {
78 dbi->conn = PQsetdbLogin(dbi->host, NULL, NULL, NULL, dbi->database,
79 dbi->user, dbi->passwd);
81 if (PQstatus(dbi->conn) == CONNECTION_OK)
92 maybe_reconnect(struct dbinfo *dbi) {
93 if (PQstatus(dbi->conn) == CONNECTION_OK)
96 return (db_connect(dbi));
117 struct dbinfo *dbi = dbdata;
135 "lower(NAME) = lower('%s')", dbi->table, canonname);
138 result = maybe_reconnect(dbi);
142 res = PQexec(dbi->conn, str);
180 struct dbinfo *dbi = dbdata;
190 dbi->table);
192 result = maybe_reconnect(dbi);
196 res = PQexec(dbi->conn, str);
243 struct dbinfo *dbi;
252 dbi = isc_mem_get(ns_g_mctx, sizeof(struct dbinfo));
253 if (dbi == NULL)
255 dbi->conn = NULL;
256 dbi->database = NULL;
257 dbi->table = NULL;
258 dbi->host = NULL;
259 dbi->user = NULL;
260 dbi->passwd = NULL;
271 STRDUP_OR_FAIL(dbi->database, argv[0]);
272 STRDUP_OR_FAIL(dbi->table, argv[1]);
274 STRDUP_OR_FAIL(dbi->host, argv[2]);
276 STRDUP_OR_FAIL(dbi->user, argv[3]);
278 STRDUP_OR_FAIL(dbi->passwd, argv[4]);
280 result = db_connect(dbi);
284 *dbdata = dbi;
288 pgsqldb_destroy(zone, driverdata, (void **)&dbi);
297 struct dbinfo *dbi = *dbdata;
302 if (dbi->conn != NULL)
303 PQfinish(dbi->conn);
304 if (dbi->database != NULL)
305 isc_mem_free(ns_g_mctx, dbi->database);
306 if (dbi->table != NULL)
307 isc_mem_free(ns_g_mctx, dbi->table);
308 if (dbi->host != NULL)
309 isc_mem_free(ns_g_mctx, dbi->host);
310 if (dbi->user != NULL)
311 isc_mem_free(ns_g_mctx, dbi->user);
312 if (dbi->passwd != NULL)
313 isc_mem_free(ns_g_mctx, dbi->passwd);
314 if (dbi->database != NULL)
315 isc_mem_free(ns_g_mctx, dbi->database);
316 isc_mem_put(ns_g_mctx, dbi, sizeof(struct dbinfo));