30 int *bucketList,
int agent_pk,
int nomosagent_pk,
int bucketpool_pk)
32 char *fcnName =
"writeBuckets";
37 if (
debug) printf(
"debug: %s:%s() pfile: %d, uploadtree_pk: %d\n", __FILE__, fcnName, pfile_pk, uploadtree_pk);
49 snprintf(sql,
sizeof(sql),
50 "UPDATE bucket_file set bucket_fk = %d from bucket_def where pfile_fk = %d and \
51 bucket_fk= bucket_pk and bucket_def.bucketpool_fk = %d;",
52 *bucketList, pfile_pk, bucketpool_pk);
56 snprintf(sql,
sizeof(sql),
57 "insert into bucket_file (bucket_fk, pfile_fk, agent_fk, nomosagent_fk) values(%d,%d,%d,%d)",
58 *bucketList, pfile_pk,
agent_pk, nomosagent_pk);
61 printf(
"%s(%d): %s\n", __FILE__, __LINE__, sql);
62 result = PQexec(
pgConn, sql);
64 if ((result==0) || ((PQresultStatus(result) != PGRES_COMMAND_OK) &&
65 (strncmp(
"23505", PQresultErrorField(result, PG_DIAG_SQLSTATE),5))))
67 printf(
"ERROR: %s.%s().%d: Failed to add bucket to bucket_file.\n",
68 __FILE__,fcnName, __LINE__);
77 snprintf(sql,
sizeof(sql),
78 "insert into bucket_container (bucket_fk, uploadtree_fk, agent_fk, nomosagent_fk) \
79 values(%d,%d,%d,%d)", *bucketList, uploadtree_pk,
agent_pk, nomosagent_pk);
81 printf(
"%s(%d): %s\n", __FILE__, __LINE__, sql);
83 result = PQexec(
pgConn, sql);
84 if ((PQresultStatus(result) != PGRES_COMMAND_OK) &&
85 (strncmp(
"23505", PQresultErrorField(result, PG_DIAG_SQLSTATE),5)))
88 printf(
"ERROR: %s.%s().%d: Failed to add bucket to bucket_file. %s\n: %s\n",
89 __FILE__,fcnName, __LINE__,
90 PQresultErrorMessage(result), sql);
96 if (result) PQclear(result);
101 if (
debug) printf(
"%s:%s() returning rv=%d\n", __FILE__, fcnName, rv);
PGconn * pgConn
Database connection.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
void fo_scheduler_heart(int i)
This function must be called by agents to let the scheduler know they are alive and how many items th...
FUNCTION int processed(PGconn *pgConn, int agent_pk, int nomos_agent_pk, int pfile_pk, int uploadtree_pk, int bucketpool_pk, int bucket_pk)
Has this pfile or uploadtree_pk already been bucket processed? This only works if the bucket has been...
FUNCTION int writeBuckets(PGconn *pgConn, int pfile_pk, int uploadtree_pk, int *bucketList, int agent_pk, int nomosagent_pk, int bucketpool_pk)
Write bucket results to either db (bucket_file, bucket_container) or stdout.