39 if (!arrayA || !arrayB)
return 0;
47 if (*arrayA == *arrayB)
break;
50 if (!*arrayB)
return 0;
65 FUNCTION
int intAinB(
int intA,
int *arrayB)
68 if (!arrayB)
return 0;
72 if (intA == *arrayB)
return 1;
97 char *fcnName =
"validate_pk";
102 result = PQexec(pgConn, sql);
104 if (PQntuples(result) > 0) pk = atoi(PQgetvalue(result, 0, 0));
116 printf(
"Usage: %s [debug options]\n", Name);
117 printf(
" Debug options are:\n");
118 printf(
" -i :: Initialize the database, then exit.\n");
119 printf(
" -n :: bucketpool name of bucketpool to use.\n");
120 printf(
" -p :: bucketpool_pk of bucketpool to use.\n");
121 printf(
" -r :: rerun buckets.\n");
122 printf(
" -t :: uploadtree_pk, root of tree to scan.\n");
123 printf(
" -u :: upload_pk to scan.\n");
124 printf(
" -v :: verbose (turns on copious debugging output)\n");
125 printf(
" -V :: print the version info, then exit.\n");
126 printf(
" -c SYSCONFDIR :: Specify the directory for the system configuration. \n");
127 printf(
" NOTE: -n and -p are mutually exclusive. If both are specified\n");
128 printf(
" -p is used. One of these is required.\n");
129 printf(
" NOTE: -t and -u are mutually exclusive. If both are specified\n");
130 printf(
" -u is used. One of these is required.\n");
131 printf(
" NOTE: If none of -nptu are specified, the bucketpool_pk and upload_pk are read from stdin, one comma delimited pair per line. For example, 'bppk=123, upk=987' where 123 is the bucketpool_pk and 987 is the upload_pk. This is the normal execution from the scheduler.\n");
151 int bucketpool_pk,
int bucket_pk)
153 char *fcnName =
"processed";
163 "select bf_pk from bucket_file, bucket_def \ 164 where pfile_fk=%d and agent_fk=%d and nomosagent_fk=%d and bucketpool_fk=%d \ 165 and bucket_pk=%d and bucket_fk=bucket_pk \ 167 select bf_pk from bucket_container, bucket_def \ 168 where uploadtree_fk=%d and agent_fk=%d and nomosagent_fk=%d and bucketpool_fk=%d \ 169 and bucket_pk=%d and bucket_fk=bucket_pk limit 1",
170 pfile_pk, agent_pk, nomos_agent_pk, bucketpool_pk, bucket_pk,
171 uploadtree_pk, agent_pk, nomos_agent_pk, bucketpool_pk, bucket_pk);
176 "select bf_pk from bucket_file, bucket_def \ 177 where pfile_fk=%d and agent_fk=%d and nomosagent_fk=%d and bucketpool_fk=%d \ 178 and bucket_fk=bucket_pk \ 180 select bf_pk from bucket_container, bucket_def \ 181 where uploadtree_fk=%d and agent_fk=%d and nomosagent_fk=%d and bucketpool_fk=%d \ 182 and bucket_fk=bucket_pk limit 1",
183 pfile_pk, agent_pk, nomos_agent_pk, bucketpool_pk,
184 uploadtree_pk, agent_pk, nomos_agent_pk, bucketpool_pk);
186 result = PQexec(pgConn, sqlbuf);
187 if (
fo_checkPQresult(pgConn, result, sqlbuf, __FILE__, __LINE__))
return -1;
188 numRecs = PQntuples(result);
191 if (
debug) printf(
"%s: returning %d, for pfile_pk %d, uploadtree_pk %d\n",fcnName,numRecs,pfile_pk, uploadtree_pk);
216 int pfile_pk,
int uploadtree_pk,
219 char *fcnName =
"UploadProcessed";
226 "select ars_pk from bucket_ars \ 227 where agent_fk=%d and nomosagent_fk=%d and upload_fk=%d and bucketpool_fk=%d \ 228 and ars_success=true limit 1",
229 bucketagent_pk, nomosagent_pk, upload_pk, bucketpool_pk);
230 result = PQexec(pgConn, sqlbuf);
232 numRecs = PQntuples(result);
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
FUNCTION int arrayAinB(int *arrayA, int *arrayB)
Verify that all the values in array A are also in B.
PGconn * pgConn
Database connection.
FUNCTION void Usage(char *Name)
FUNCTION int validate_pk(PGconn *pgConn, char *sql)
Verify a primary key exists.
FUNCTION int intAinB(int intA, int *arrayB)
Verify that all the value A is a member of array B.
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 UploadProcessed(PGconn *pgConn, int bucketagent_pk, int nomosagent_pk, int pfile_pk, int uploadtree_pk, int upload_pk, int bucketpool_pk)
Has this upload already been bucket processed? This function checks buckets_ars to see if the upload ...