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); |
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(); |
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())) { |
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; |
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"), |
301 |
char *val; |
char *val; |
302 |
const char *attrval; |
const char *attrval; |
303 |
int len; |
int len; |
304 |
|
int attrlen; |
305 |
|
|
306 |
elog(DEBUG1, "doc: %08x, attr: %s", doc, attr); |
elog(DEBUG1, "doc: %08x, attr: %s", doc, attr); |
307 |
|
|
308 |
if (attrval = est_doc_attr(doc, attr)) { |
if ( (attrval = est_doc_attr(doc, attr)) && (attrlen = strlen(attrval)) ) { |
309 |
val = (char *) palloc(strlen(attrval) * sizeof(char)); |
val = (char *) palloc(attrlen * sizeof(char)); |
310 |
} else { |
} else { |
311 |
return (Datum) NULL; |
return (Datum) NULL; |
312 |
} |
} |