/[pgswish]/trunk/pgswish.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/pgswish.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 22 by dpavlin, Sun May 29 22:41:20 2005 UTC revision 23 by dpavlin, Sun May 29 23:00:19 2005 UTC
# Line 77  Datum pgswish(PG_FUNCTION_ARGS) { Line 77  Datum pgswish(PG_FUNCTION_ARGS) {
77                   * STDOUT and STDERR (just to be sure) */                   * STDOUT and STDERR (just to be sure) */
78                  if ( logfh = fopen("/tmp/pgswish.log", "a") ) {                  if ( logfh = fopen("/tmp/pgswish.log", "a") ) {
79                          set_error_handle( logfh );                          set_error_handle( logfh );
80                          elog(INFO, "loggin swish-e errors to /tmp/pgswish.log");                          elog(DEBUG1, "loggin swish-e errors to /tmp/pgswish.log");
81                          /* redirect STDOUT and STDERR to log */                          /* redirect STDOUT and STDERR to log */
82                          dup2(1, logfh);                          dup2(1, logfh);
83                          dup2(2, logfh);                          dup2(2, logfh);
# Line 85  Datum pgswish(PG_FUNCTION_ARGS) { Line 85  Datum pgswish(PG_FUNCTION_ARGS) {
85                          elog(INFO, "can't open /tmp/pgswish.log -- errors from swish-e won't be cought and may result in back-end crashes!");                          elog(INFO, "can't open /tmp/pgswish.log -- errors from swish-e won't be cought and may result in back-end crashes!");
86                  }                  }
87    
88                  elog(INFO, "pgswish: SwishInit(%s)", index_path);                  elog(DEBUG1, "pgswish: SwishInit(%s)", index_path);
89    
90                  swish_handle = SwishInit( index_path );                  swish_handle = SwishInit( index_path );
91    
92                  if ( SwishError( swish_handle ) )                  if ( SwishError( swish_handle ) || ! swish_handle) {
93                          elog(INFO, "pgswish: SwishInit(%s) failed: %s", index_path, SwishErrorString( swish_handle ));                          elog(ERROR, "pgswish: SwishInit(%s) failed: %s", index_path, SwishErrorString( swish_handle ));
94                                    
                 elog(INFO, "handle: %08x", swish_handle);  
   
                 if (! swish_handle) {  
                         elog(ERROR, "pgswish: can't open %s", index_path);  
95                          SRF_RETURN_DONE(funcctx);                          SRF_RETURN_DONE(funcctx);
96                  }                  }
97                                    
# Line 104  Datum pgswish(PG_FUNCTION_ARGS) { Line 100  Datum pgswish(PG_FUNCTION_ARGS) {
100                  SwishRankScheme( swish_handle, 0 );                  SwishRankScheme( swish_handle, 0 );
101                  if (error_or_abort( swish_handle )) SRF_RETURN_DONE(funcctx);                  if (error_or_abort( swish_handle )) SRF_RETURN_DONE(funcctx);
102    
103                  elog(INFO, "pgswish: SwishQuery(%s)", query);                  elog(DEBUG1, "pgswish: SwishQuery(%s)", query);
104                  /* Here's a short-cut to searching that creates a search object and searches at the same time */                  /* Here's a short-cut to searching that creates a search object and searches at the same time */
105                  swish_results = SwishQuery( swish_handle, query);                  swish_results = SwishQuery( swish_handle, query);
106                  if (error_or_abort( swish_handle )) SRF_RETURN_DONE(funcctx);                  if (error_or_abort( swish_handle )) SRF_RETURN_DONE(funcctx);
# Line 116  Datum pgswish(PG_FUNCTION_ARGS) { Line 112  Datum pgswish(PG_FUNCTION_ARGS) {
112                  if ( 0 == funcctx->max_calls )                  if ( 0 == funcctx->max_calls )
113                          elog(INFO, "no results for: %s", query );                          elog(INFO, "no results for: %s", query );
114    
115                  elog(INFO, "pgswish: SwishHits = %d", funcctx->max_calls);                  elog(DEBUG1, "pgswish: SwishHits = %d", funcctx->max_calls);
116    
117                  /* Build a tuple description for a __pgswish tuple */                  /* Build a tuple description for a __pgswish tuple */
118                  tupdesc = RelationNameGetTupleDesc("__pgswish");                  tupdesc = RelationNameGetTupleDesc("__pgswish");
# Line 136  Datum pgswish(PG_FUNCTION_ARGS) { Line 132  Datum pgswish(PG_FUNCTION_ARGS) {
132    
133                  MemoryContextSwitchTo(oldcontext);                  MemoryContextSwitchTo(oldcontext);
134    
135                  elog(INFO, "SRF_IS_FIRSTCALL done");                  elog(DEBUG1, "SRF_IS_FIRSTCALL done");
136          }          }
137    
138          /* stuff done on every call of the function */          /* stuff done on every call of the function */
# Line 152  Datum pgswish(PG_FUNCTION_ARGS) { Line 148  Datum pgswish(PG_FUNCTION_ARGS) {
148                  HeapTuple       tuple;                  HeapTuple       tuple;
149                  Datum           result;                  Datum           result;
150    
151                  elog(INFO, "pgswish: loop count %d", call_cntr);                  elog(DEBUG1, "pgswish: loop count %d", call_cntr);
152    
153                  if (! swish_results) {                  if (! swish_results) {
154                          elog(ERROR, "pgswish: no swish-e results");                          elog(ERROR, "pgswish: no swish-e results");
# Line 176  Datum pgswish(PG_FUNCTION_ARGS) { Line 172  Datum pgswish(PG_FUNCTION_ARGS) {
172                          SRF_RETURN_DONE(funcctx);                          SRF_RETURN_DONE(funcctx);
173                  }                  }
174                                    
175                  elog(INFO, "Path: %s\n  Rank: %lu\n  Size: %lu\n  Title: %s\n  Index: %s\n  Modified: %s\n  Record #: %lu\n  File   #: %lu\n\n",                  elog(DEBUG1, "Path: %s\n  Rank: %lu\n  Size: %lu\n  Title: %s\n  Index: %s\n  Modified: %s\n  Record #: %lu\n  File   #: %lu\n\n",
176                          SwishResultPropertyStr   ( sw_res, "swishdocpath" ),                          SwishResultPropertyStr   ( sw_res, "swishdocpath" ),
177                          SwishResultPropertyULong ( sw_res, "swishrank" ),                          SwishResultPropertyULong ( sw_res, "swishrank" ),
178                          SwishResultPropertyULong ( sw_res, "swishdocsize" ),                          SwishResultPropertyULong ( sw_res, "swishdocsize" ),
# Line 222  Datum pgswish(PG_FUNCTION_ARGS) { Line 218  Datum pgswish(PG_FUNCTION_ARGS) {
218                    
219                  SRF_RETURN_NEXT(funcctx, result);                  SRF_RETURN_NEXT(funcctx, result);
220          } else {          } else {
221                  elog(INFO, "loop over");                  elog(DEBUG1, "loop over");
222    
223                  /* free swish object and close */                  /* free swish object and close */
224                  Free_Search_Object( search );                  Free_Search_Object( search );
# Line 366  Datum pgswish_arr(PG_FUNCTION_ARGS) Line 362  Datum pgswish_arr(PG_FUNCTION_ARGS)
362           * STDOUT and STDERR (just to be sure) */           * STDOUT and STDERR (just to be sure) */
363          if ( logfh = fopen("/tmp/pgswish.log", "a") ) {          if ( logfh = fopen("/tmp/pgswish.log", "a") ) {
364                  set_error_handle( logfh );                  set_error_handle( logfh );
365                  elog(INFO, "loggin swish-e errors to /tmp/pgswish.log");                  elog(DEBUG1, "loggin swish-e errors to /tmp/pgswish.log");
366                  /* redirect STDOUT and STDERR to log */                  /* redirect STDOUT and STDERR to log */
367                  dup2(1, logfh);                  dup2(1, logfh);
368                  dup2(2, logfh);                  dup2(2, logfh);
# Line 374  Datum pgswish_arr(PG_FUNCTION_ARGS) Line 370  Datum pgswish_arr(PG_FUNCTION_ARGS)
370                  elog(INFO, "can't open /tmp/pgswish.log -- errors from swish-e won't be cought and may result in back-end crashes!");                  elog(INFO, "can't open /tmp/pgswish.log -- errors from swish-e won't be cought and may result in back-end crashes!");
371          }          }
372    
373          elog(INFO, "pgswish: SwishInit(%s)", index_path);          elog(DEBUG1, "pgswish: SwishInit(%s)", index_path);
374    
375          swish_handle = SwishInit( index_path );          swish_handle = SwishInit( index_path );
376    
# Line 391  Datum pgswish_arr(PG_FUNCTION_ARGS) Line 387  Datum pgswish_arr(PG_FUNCTION_ARGS)
387          SwishRankScheme( swish_handle, 0 );          SwishRankScheme( swish_handle, 0 );
388          error_or_abort( swish_handle );          error_or_abort( swish_handle );
389    
390          elog(INFO, "pgswish: SwishQuery(%s)", query);          elog(DEBUG1, "pgswish: SwishQuery(%s)", query);
391          /* Here's a short-cut to searching that creates a search object          /* Here's a short-cut to searching that creates a search object
392           * and searches at the same time */           * and searches at the same time */
393                    
# Line 435  Datum pgswish_arr(PG_FUNCTION_ARGS) Line 431  Datum pgswish_arr(PG_FUNCTION_ARGS)
431                  if (! ( SwishErrorString( swish_handle ) ) ) {                  if (! ( SwishErrorString( swish_handle ) ) ) {
432                          elog(INFO, "can't find result %d", i + offset);                          elog(INFO, "can't find result %d", i + offset);
433                  } else {                  } else {
434                          elog(INFO, "Path: %s\n  Rank: %lu\n  Size: %lu\n  Title: %s\n  Index: %s\n  Modified: %s\n  Record #: %lu\n  File   #: %lu\n\n",                          elog(DEBUG1, "Path: %s\n  Rank: %lu\n  Size: %lu\n  Title: %s\n  Index: %s\n  Modified: %s\n  Record #: %lu\n  File   #: %lu\n\n",
435                                  SwishResultPropertyStr   ( sw_res, "swishdocpath" ),                                  SwishResultPropertyStr   ( sw_res, "swishdocpath" ),
436                                  SwishResultPropertyULong ( sw_res, "swishrank" ),                                  SwishResultPropertyULong ( sw_res, "swishrank" ),
437                                  SwishResultPropertyULong ( sw_res, "swishdocsize" ),                                  SwishResultPropertyULong ( sw_res, "swishdocsize" ),

Legend:
Removed from v.22  
changed lines
  Added in v.23

  ViewVC Help
Powered by ViewVC 1.1.26