Key_name = Seq_in_index = Column_name = Sub_part = -1;
asprintf(&sql, "show index from %s", table);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, sql);
+ glite_common_log(ctx_gen->log_category, LOG_PRIORITY_DEBUG, sql);
if (glite_lbu_ExecSQLMysql(ctx_gen,sql,&stmt)<0) {
free(sql);
return STATUS(ctx);
(*caps) &= ~GLITE_LBU_DB_CAP_TRANSACTIONS;
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, "SHOW TABLES");
+ glite_common_log(ctx->log_category, LOG_PRIORITY_DEBUG, "SHOW TABLES");
if ((retval = glite_lbu_ExecSQLMysql(ctx, "SHOW TABLES", &stmt)) <= 0 || glite_lbu_FetchRowMysql(stmt, 1, NULL, table) < 0) goto quit;
glite_lbu_FreeStmtMysql(&stmt);
trio_asprintf(&cmd, "SHOW CREATE TABLE %|Ss", table[0]);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, cmd);
+ glite_common_log(ctx->log_category, LOG_PRIORITY_DEBUG, cmd);
if (glite_lbu_ExecSQLMysql(ctx, cmd, &stmt) <= 0 || (retval = glite_lbu_FetchRowMysql(stmt, 2, NULL, res)) < 0 ) goto quit;
if (retval != 2 || strcmp(res[0], table[0])) {
ERR(ctx, EIO, "unexpected show create result");
else pgcs = pgcsbuf;
free(buf);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG,
+ glite_common_log(ctx_gen->log_category, LOG_PRIORITY_DEBUG,
"connection string = %s\n", pgcs);
ctx->conn = psql_module.PQconnectdb(pgcs);
free(pgcsbuf);
int has_prepared = 0;
char *res = NULL;
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, "SHOW server_version");
+ glite_common_log(ctx_gen->log_category, LOG_PRIORITY_DEBUG, "SHOW server_version");
if (glite_lbu_ExecSQLPsql(ctx_gen, "SHOW server_version", &stmt) == -1) return -1;
switch (glite_lbu_FetchRowPsql(stmt, 1, NULL, &res)) {
case 1:
if (stmt->res) psql_module.PQclear(stmt->res);
if (stmt->name) {
asprintf(&sql, "DEALLOCATE %s", stmt->name);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, sql);
+ glite_common_log(ctx->generic.log_category, LOG_PRIORITY_DEBUG, sql);
stmt->res = psql_module.PQexec(ctx->conn, sql);
free(sql);
psql_module.PQclear(stmt->res);
PGresult *res;
//lprintf("command = %s\n", cmd);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, "command = %s\n", cmd);
+ glite_common_log(ctx_gen->log_category, LOG_PRIORITY_DEBUG, "command = %s\n", cmd);
if (stmt_out) *stmt_out = NULL;
if ((res = psql_module.PQexec(ctx->conn, cmd)) == NULL) {
ctx->generic.err.code = ENOMEM;
asprintf(&stmt->name, "%s%d", prepared_names[i], ++ctx->prepared_counts[i]);
asprintf(&sqlPrep, "PREPARE %s AS %s", stmt->name, stmt->sql);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, sqlPrep);
+ glite_common_log(ctx_gen->log_category, LOG_PRIORITY_DEBUG, sqlPrep);
res = psql_module.PQexec(ctx->conn, sqlPrep);
if (psql_module.PQresultStatus(res) != PGRES_COMMAND_OK) {
asprintf(&s, "error preparing command: %s", psql_module.PQerrorMessage(ctx->conn));
s = va_arg(ap, char *);
binary_len = va_arg(ap, unsigned long);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG,
+ glite_common_log(ctx->generic.log_category, LOG_PRIORITY_DEBUG,
"blob, len = %lu, ptr = %p\n", binary_len, s);
if (s) {
tmp = malloc(2*binary_len + 1);
psql_module.PQescapeStringConn(ctx->conn, tmp, s, binary_len, NULL);
asprintf(&tmpdata[i], "'%s'", tmp);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, "escaped: '%s'\n", tmpdata[i]);
+ glite_common_log(ctx->generic.log_category, LOG_PRIORITY_DEBUG, "escaped: '%s'\n", tmpdata[i]);
free(tmp);
} else
tmpdata[i] = strdup("NULL");
break;
default:
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG,
+ glite_common_log(ctx->generic.log_category, LOG_PRIORITY_DEBUG,
"unknown type %d\n", type);
set_error(ctx, EINVAL, "unimplemented type");
goto quit;
}
if (n) strcat(sql, ")");
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, sql);
+ glite_common_log(ctx->generic.log_category, LOG_PRIORITY_DEBUG, sql);
stmt->res = psql_module.PQexec(ctx->conn, sql);
status = psql_module.PQresultStatus(stmt->res);
if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) {
va_end(ap);
} else
ctx->err.desc = NULL;
- glite_common_log(set_log_category, LOG_PRIORITY_WARN,
+ glite_common_log(ctx->log_category, LOG_PRIORITY_WARN,
"[db %d] %s:%d %s\n", getpid(), func, line, ctx->err.desc);
return code;
}
if (!VALID(backend)) return EINVAL;
if (backends[backend]->backend != backend) return ENOTSUP;
ret = backends[backend]->initContext(ctx);
- if (ctx && *ctx) (*ctx)->backend = backend;
- set_log_category = log_category;
+ if (ctx && *ctx) {
+ (*ctx)->backend = backend;
+ (*ctx)->log_category = log_category;
+ }
return ret;
}
trio_asprintf(&stmt, "insert into %|Ss(%|Ss) values %s;",
bi->table_name, bi->columns, vals);
- glite_common_log(set_log_category, LOG_PRIORITY_DEBUG, stmt);
+ glite_common_log(bi->ctx->log_category, LOG_PRIORITY_DEBUG, stmt);
if (glite_lbu_ExecSQL(bi->ctx,stmt,NULL) < 0) {
if (STATUS(bi->ctx) == EEXIST)