void PG_Lock(struct DBdesc *db) { PGresult *PGret; if (!db->fail) { PGret = PQexec(db->desc, lock_clause); if (PQresultStatus(PGret) != PGRES_COMMAND_OK) { db->errmsg = PQresultErrorMessage(PGret); sql_db_errmsg(db); sql_db_fail(db); } PQclear(PGret); /* If using COPY, let's initialize it */ if (config.sql_use_copy) { PGret = PQexec(db->desc, copy_clause); if (PQresultStatus(PGret) != PGRES_COPY_IN) { db->errmsg = PQresultErrorMessage(PGret); sql_db_errmsg(db); sql_db_fail(db); } else Log(LOG_DEBUG, "DEBUG ( %s/%s ): %s\n", config.name, config.type, copy_clause); PQclear(PGret); } } }
void SQLI_create_dyn_table(struct DBdesc *db, char *buf) { if (!db->fail) { if (sqlite3_exec(db->desc, buf, NULL, NULL, NULL)) { Log(LOG_DEBUG, "DEBUG ( %s/%s ): FAILED query follows:\n%s\n", config.name, config.type, buf); SQLI_get_errmsg(db); sql_db_errmsg(db); } } }
void SQLI_Lock(struct DBdesc *db) { if (!db->fail) { if (sqlite3_exec(db->desc, lock_clause, NULL, NULL, NULL)) { SQLI_get_errmsg(db); sql_db_errmsg(db); sql_db_fail(db); } } }
void MY_Lock(struct DBdesc *db) { if (!db->fail) { if (mysql_query(db->desc, lock_clause)) { MY_get_errmsg(db); sql_db_errmsg(db); sql_db_fail(db); } } }
void SQLI_DB_Connect(struct DBdesc *db, char *host) { if (!db->fail) { if (sqlite3_open(db->filename, (sqlite3 **)&db->desc)) { sql_db_fail(db); SQLI_get_errmsg(db); sql_db_errmsg(db); } else sql_db_ok(db); } }
void MY_create_dyn_table(struct DBdesc *db, char *buf) { if (!db->fail) { if (mysql_query(db->desc, buf)) { if (mysql_errno(db->desc) != 1050 /* ER_TABLE_EXISTS_ERROR */) { Log(LOG_DEBUG, "DEBUG ( %s/%s ): FAILED query follows:\n%s\n", config.name, config.type, buf); MY_get_errmsg(db); sql_db_errmsg(db); } } } }
void MY_DB_Connect(struct DBdesc *db, char *host) { MYSQL *dbptr = db->desc; if (!db->fail) { mysql_init(db->desc); dbptr->reconnect = TRUE; if (!mysql_real_connect(db->desc, host, config.sql_user, config.sql_passwd, config.sql_db, 0, NULL, 0)) { sql_db_fail(db); MY_get_errmsg(db); sql_db_errmsg(db); } else sql_db_ok(db); } }
void PG_DB_Connect(struct DBdesc *db, char *host) { if (!db->fail) { db->desc = PQconnectdb(db->conn_string); if (PQstatus(db->desc) == CONNECTION_BAD) { char errmsg[64+SRVBUFLEN]; sql_db_fail(db); strcpy(errmsg, "Failed connecting to "); strcat(errmsg, db->conn_string); db->errmsg = errmsg; sql_db_errmsg(db); } else sql_db_ok(db); } }