43 char *TableName =
"demomod";
44 char *CreateTableSQL =
45 "CREATE TABLE demomod ( \ 46 demomod_pk serial NOT NULL PRIMARY KEY, \ 49 firstbytes character(65), \ 50 FOREIGN KEY (pfile_fk) REFERENCES pfile(pfile_pk) ON DELETE CASCADE, \ 51 FOREIGN KEY (agent_fk) REFERENCES agent(agent_pk) ON DELETE CASCADE \ 53 COMMENT ON TABLE demomod IS 'table for demo module'; \ 54 COMMENT ON COLUMN demomod.firstbytes IS 'Hex string of first 32 bytes of the pfile'; \ 72 LOG_FATAL(
"%s table could not be created", AgentARSName);
84 result = PQexec(
pgConn, CreateTableSQL);
87 LOG_ERROR(
"Failed to create %s table.", TableName);
103 FUNCTION
void Char2Hex(
char *InBuf,
int NumBytes,
char *OutBuf)
107 for (i=0; i<NumBytes; i++) pbuf += sprintf(pbuf,
"%02X", (
unsigned char)InBuf[i]);
124 if (ExitVal) LOG_ERROR(
"Exiting with status %d", ExitVal);
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.
FUNCTION void Char2Hex(char *InBuf, int NumBytes, char *OutBuf)
Convert a character buffer to a hex string.
void fo_scheduler_disconnect(int retcode)
Disconnect the scheduler connection.
FUNCTION void CheckTable(char *AgentARSName)
Check to make sure the demomod and demomod_ars tables exists.
FUNCTION void ExitNow(int ExitVal)
Exit function. This does all cleanup and should be used instead of calling exit() or main() return...
FUNCTION int fo_CreateARSTable(PGconn *pgConn, const char *tableName)
Create ars table if it doesn't already exist.
int fo_tableExists(PGconn *pgConn, const char *tableName)
Check if table exists. Note, this assumes the database name is 'fossology'.
psqlCopy_t psqlcpy
fo_sqlCopy struct used for fast data insertion