22 col_text = calloc(NumTextBytes + 1,
sizeof(
char));
25 ERROR_RETURN(
"Allocating test text data failed.")
28 for (i = 0; i < NumTextBytes; i++) col_text[i] =
'a';
33 int main(
int argc,
char** argv)
38 char* TestTable =
"TestsqlCopy";
39 char col_vc[40] =
"This is \n\r column vc[40] 123456789\r";
49 clock_t StartTime, EndTime;
55 printf(
"Usage: %s RowsToTest NumTextBytes CopyDataBufferSize\n", argv[0]);
63 RowsToTest = atoi(argv[1]);
64 NumTextBytes = atoi(argv[2]);
65 CopyBufSize = atoi(argv[3]);
69 datasize = NumTextBytes + 8 + 40 + 1;
70 DataBuf = calloc(datasize,
sizeof(
char));
74 ERROR_RETURN(
"Allocating test data buffer failed.")
81 snprintf(sql, sizeof(sql), "create table %
s (col_int integer, col_text text, col_vc varchar(40))", TestTable);
82 result = PQexec(
pgConn, sql);
90 "col_int", "col_text", "col_vc");
94 for (RowNum = 0; RowNum < RowsToTest; RowNum++)
96 snprintf(DataBuf, datasize,
"%d\t%s\t%s\n", RowNum, col_text, col_vc);
106 printf(
"%.6f Seconds to load.\n", ((
double) (EndTime - StartTime)) / CLOCKS_PER_SEC);
109 snprintf(sql,
sizeof(sql),
"select count(*) from %s", TestTable);
110 result = PQexec(
pgConn, sql);
112 printf(
"%d records inserted, %d expected\n",
113 atoi(PQgetvalue(result, 0, 0)),
PGconn * pgConn
Database connection.
int s
The socket that the CLI will use to communicate.
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
The main FOSSology C library.
if(!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
get monk license list of one specified uploadtree_id
char * GetTextCol(int NumTextBytes)
int fo_sqlCopyAdd(psqlCopy_t pCopy, char *DataRow)
Add a data row to an sqlCopy Use '\N' to pass in a null.
void fo_sqlCopyDestroy(psqlCopy_t pCopy, int ExecuteFlag)
Destructor for sqlCopy_struct.
psqlCopy_t fo_sqlCopyCreate(PGconn *pGconn, char *TableName, int BufSize, int NumColumns,...)
Constructor for sqlCopy_struct.
char * DBConfFile
DB conf file location.