31 char *TableName =
"demomod";
32 char *CreateTableSQL =
33 "CREATE TABLE demomod ( \
34 demomod_pk serial NOT NULL PRIMARY KEY, \
37 firstbytes character(65), \
38 FOREIGN KEY (pfile_fk) REFERENCES pfile(pfile_pk) ON DELETE CASCADE, \
39 FOREIGN KEY (agent_fk) REFERENCES agent(agent_pk) ON DELETE CASCADE \
41 COMMENT ON TABLE demomod IS 'table for demo module'; \
42 COMMENT ON COLUMN demomod.firstbytes IS 'Hex string of first 32 bytes of the pfile'; \
60 LOG_FATAL(
"%s table could not be created", AgentARSName);
72 result = PQexec(
pgConn, CreateTableSQL);
75 LOG_ERROR(
"Failed to create %s table.", TableName);
91 FUNCTION
void Char2Hex(
char *InBuf,
int NumBytes,
char *OutBuf)
95 for (i=0; i<NumBytes; i++) pbuf += sprintf(pbuf,
"%02X", (
unsigned char)InBuf[i]);
112 if (ExitVal) LOG_ERROR(
"Exiting with status %d", ExitVal);
FUNCTION void Char2Hex(char *InBuf, int NumBytes, char *OutBuf)
Convert a character buffer to a hex string.
PGconn * pgConn
Database connection.
FUNCTION void ExitNow(int ExitVal)
Exit function. This does all cleanup and should be used instead of calling exit() or main() return.
psqlCopy_t psqlcpy
fo_sqlCopy struct used for fast data insertion
FUNCTION void CheckTable(char *AgentARSName)
Check to make sure the demomod and demomod_ars tables exists.
FUNCTION int fo_CreateARSTable(PGconn *pgConn, const char *tableName)
Create ars table if it doesn't already exist.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.