/[pgestraier]/trunk/pgest.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/pgest.c

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

revision 2 by dpavlin, Fri May 20 13:00:46 2005 UTC revision 3 by dpavlin, Fri May 20 16:11:38 2005 UTC
# Line 40  ESTCOND *cond; Line 40  ESTCOND *cond;
40  ESTDOC *doc;  ESTDOC *doc;
41  const CBLIST *texts;  const CBLIST *texts;
42  int ecode, *est_result, resnum, i, j;  int ecode, *est_result, resnum, i, j;
43    int limit = 0;
44    int offset = 0;
45    
46  /* define PostgreSQL v1 function */  /* define PostgreSQL v1 function */
47  PG_FUNCTION_INFO_V1(pgest);  PG_FUNCTION_INFO_V1(pgest);
# Line 62  Datum pgest(PG_FUNCTION_ARGS) { Line 64  Datum pgest(PG_FUNCTION_ARGS) {
64                  //index_path = _textout(PG_GETARG_TEXT_P(0));                  //index_path = _textout(PG_GETARG_TEXT_P(0));
65                  index_path = _textout(PG_GETARG_TEXT_P(0));                  index_path = _textout(PG_GETARG_TEXT_P(0));
66                  query = _textout(PG_GETARG_TEXT_P(1));                  query = _textout(PG_GETARG_TEXT_P(1));
67                    limit = PG_GETARG_INT32(2);
68                    offset = PG_GETARG_INT32(3);
69    
70                  /* create a function context for cross-call persistence */                  /* create a function context for cross-call persistence */
71                  funcctx = SRF_FIRSTCALL_INIT();                  funcctx = SRF_FIRSTCALL_INIT();
# Line 77  Datum pgest(PG_FUNCTION_ARGS) { Line 81  Datum pgest(PG_FUNCTION_ARGS) {
81                          SRF_RETURN_DONE(funcctx);                          SRF_RETURN_DONE(funcctx);
82                  }                  }
83                                    
84                  elog(DEBUG2, "pgest: query=%s", query);                  elog(INFO, "pgest: query=%s limit %d offset %d", query, limit, offset);
85                                    
86                  /* create a search condition object */                  /* create a search condition object */
87                  if (!(cond = est_cond_new())) {                  if (!(cond = est_cond_new())) {
# Line 128  Datum pgest(PG_FUNCTION_ARGS) { Line 132  Datum pgest(PG_FUNCTION_ARGS) {
132          max_calls = funcctx->max_calls;          max_calls = funcctx->max_calls;
133          slot = funcctx->slot;          slot = funcctx->slot;
134          attinmeta = funcctx->attinmeta;          attinmeta = funcctx->attinmeta;
135    
136            if (limit && call_cntr > limit - 1) {
137                    elog(INFO, "call_cntr: %d limit: %d", call_cntr, limit);
138                    SRF_RETURN_DONE(funcctx);
139            }
140    
141          if (call_cntr < max_calls) {          if (call_cntr < max_calls) {
142                  char            **values;                  char            **values;
143                  HeapTuple       tuple;                  HeapTuple       tuple;
# Line 147  Datum pgest(PG_FUNCTION_ARGS) { Line 156  Datum pgest(PG_FUNCTION_ARGS) {
156                   * be processed later by the type input functions.                   * be processed later by the type input functions.
157                   */                   */
158    
159                  if (doc = est_db_get_doc(db, est_result[call_cntr], 0)) {                  if (doc = est_db_get_doc(db, est_result[call_cntr + offset], 0)) {
160                                    
161                          elog(DEBUG1, "URI: %s\n Title: %s\n",                          elog(DEBUG1, "URI: %s\n Title: %s\n",
162                                  est_doc_attr(doc, "@uri"),                                  est_doc_attr(doc, "@uri"),

Legend:
Removed from v.2  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26