projects
/
ftsbench.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e4c06c3
)
Some cleanups
author
teodor
<teodor>
Wed, 25 Oct 2006 16:25:53 +0000
(16:25 +0000)
committer
teodor
<teodor>
Wed, 25 Oct 2006 16:25:53 +0000
(16:25 +0000)
ftsbench.c
patch
|
blob
|
history
pgdriver.c
patch
|
blob
|
history
stopfilter.c
patch
|
blob
|
history
diff --git
a/ftsbench.c
b/ftsbench.c
index
83adbcf
..
f577336
100644
(file)
--- a/
ftsbench.c
+++ b/
ftsbench.c
@@
-338,7
+338,7
@@
main(int argn, char *argv[]) {
res = pthread_cond_timedwait( &condFinish, &mutexFinish, &sleepTo );
if ( !(res == ETIMEDOUT || res == 0) ) {
res = pthread_cond_timedwait( &condFinish, &mutexFinish, &sleepTo );
if ( !(res == ETIMEDOUT || res == 0) ) {
- fprintf(stderr,"pthread_cond_timedwait failed: %s", strerror(errno));
+ fprintf(stderr,"pthread_cond_timedwait failed: %s
\n
", strerror(errno));
exit(1);
}
}
exit(1);
}
}
diff --git
a/pgdriver.c
b/pgdriver.c
index
a64fbab
..
1ee408a
100644
(file)
--- a/
pgdriver.c
+++ b/
pgdriver.c
@@
-114,7
+114,7
@@
pgflush(ftsPG *db) {
/* success write, waits for read */
db->state = SS_READ;
} else {
/* success write, waits for read */
db->state = SS_READ;
} else {
- fprintf(stderr, "PQflush failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PQflush failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
}
exit(1);
}
}
@@
-161,7
+161,7
@@
waitResult(ftsPG *db) {
if ( pfd.events ) {
int ret = poll( &pfd, 1, INFTIM);
if ( ret<0 ) {
if ( pfd.events ) {
int ret = poll( &pfd, 1, INFTIM);
if ( ret<0 ) {
- fprintf(stderr,"poll failed: %s", strerror(errno));
+ fprintf(stderr,"poll failed: %s
\n
", strerror(errno));
exit(1);
}
exit(1);
}
@@
-178,7
+178,7
@@
waitResult(ftsPG *db) {
while ( (res = PQgetResult(db->conn))!= NULL ) {
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
while ( (res = PQgetResult(db->conn))!= NULL ) {
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "Execution of prepared statement failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "Execution of prepared statement failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-211,15
+211,13
@@
execQuery(ftsDB* adb, char ** words, int flags) {
db->flags = flags;
db->flags = flags;
- if ( flags & FLG_FUNC )
- sprintf(buf, "SELECT count(*) FROM ftsbench WHERE to_tsvector(body) @@ to_tsquery( $1 ::text );");
- else
- sprintf(buf, "SELECT count(*) FROM ftsbench WHERE fts @@ to_tsquery( $1 ::text );");
+ sprintf(buf, "SELECT count(*) FROM ftsbench WHERE %s @@ to_tsquery( $1 ::text );",
+ ( flags & FLG_FUNC ) ? "to_tsvector(body)" : "fts" );
res = PQprepare( db->conn, "search_ftsbench", buf, 1, NULL );
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
res = PQprepare( db->conn, "search_ftsbench", buf, 1, NULL );
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "PREPARE SELECT command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PREPARE SELECT command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-281,7
+279,7
@@
startCreateScheme(ftsDB* adb, int flags) {
res = PQexec(db->conn, "DROP TABLE IF EXISTS ftsbench CASCADE;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
res = PQexec(db->conn, "DROP TABLE IF EXISTS ftsbench CASCADE;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "DROP TABLE command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "DROP TABLE command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-295,14
+293,14
@@
startCreateScheme(ftsDB* adb, int flags) {
res = PQexec(db->conn, buf);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
res = PQexec(db->conn, buf);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "CREATE TABLE command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "CREATE TABLE command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
res = PQexec(db->conn, "BEGIN;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
exit(1);
}
PQclear(res);
res = PQexec(db->conn, "BEGIN;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "CREATE TABLE command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "CREATE TABLE command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-319,14
+317,14
@@
finishCreateScheme(ftsDB* adb) {
waitResult(db);
if ( PQsetnonblocking(db->conn, 0) != 0 ) {
waitResult(db);
if ( PQsetnonblocking(db->conn, 0) != 0 ) {
- fprintf(stderr, "PQsetnonblocking command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PQsetnonblocking command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
}
res = PQexec(db->conn, "COMMIT;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
exit(1);
}
}
res = PQexec(db->conn, "COMMIT;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "CREATE TABLE command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "CREATE TABLE command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-346,7
+344,7
@@
finishCreateScheme(ftsDB* adb) {
res = PQexec(db->conn, buf);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
res = PQexec(db->conn, buf);
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "CREATE INDEX command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "CREATE INDEX command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-360,7
+358,7
@@
finishCreateScheme(ftsDB* adb) {
res = PQexec(db->conn, "VACUUM ANALYZE ftsbench;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
res = PQexec(db->conn, "VACUUM ANALYZE ftsbench;");
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "VACUUM ANALYZE command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "VACUUM ANALYZE command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
exit(1);
}
PQclear(res);
@@
-388,13
+386,13
@@
InsertRow(ftsDB* adb, int id, char *txt) {
2, NULL );
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
2, NULL );
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
- fprintf(stderr, "PREPARE INSERT command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PREPARE INSERT command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
PQclear(res);
if ( PQsetnonblocking(db->conn, 1) != 0 ) {
exit(1);
}
PQclear(res);
if ( PQsetnonblocking(db->conn, 1) != 0 ) {
- fprintf(stderr, "PQsetnonblocking command failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PQsetnonblocking command failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
} else {
exit(1);
}
} else {
@@
-408,7
+406,7
@@
InsertRow(ftsDB* adb, int id, char *txt) {
if ( PQsendQueryPrepared( db->conn, "insert_ftsbench",
2, paramValues,
paramLengths, paramFormats, 0) == 0 ) {
if ( PQsendQueryPrepared( db->conn, "insert_ftsbench",
2, paramValues,
paramLengths, paramFormats, 0) == 0 ) {
- fprintf(stderr, "PQsendQueryPrepared failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "PQsendQueryPrepared failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
exit(1);
}
@@
-428,7
+426,7
@@
PGInit(char * connstr) {
db->conn = PQconnectdb(conninfo);
if (PQstatus(db->conn) != CONNECTION_OK) {
db->conn = PQconnectdb(conninfo);
if (PQstatus(db->conn) != CONNECTION_OK) {
- fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(db->conn));
+ fprintf(stderr, "Connection to database failed: %s
\n
", PQerrorMessage(db->conn));
exit(1);
}
exit(1);
}
diff --git
a/stopfilter.c
b/stopfilter.c
index
12e452c
..
ced7c29
100644
(file)
--- a/
stopfilter.c
+++ b/
stopfilter.c
@@
-79,7
+79,7
@@
readstoplist(char *filename, StopList * s)
tmp = (char **) realloc((void *) stop, sizeof(char *) * reallen);
if (!tmp)
{
tmp = (char **) realloc((void *) stop, sizeof(char *) * reallen);
if (!tmp)
{
- fprintf(stderr,"Not enough memory");
+ fprintf(stderr,"Not enough memory
\n
");
exit(1);
}
stop = tmp;
exit(1);
}
stop = tmp;
@@
-88,7
+88,7
@@
readstoplist(char *filename, StopList * s)
stop[s->len] = strdup(buf);
if (!stop[s->len])
{
stop[s->len] = strdup(buf);
if (!stop[s->len])
{
- fprintf(stderr,"Not enough memory");
+ fprintf(stderr,"Not enough memory
\n
");
exit(1);
}
exit(1);
}