42 |
#endif |
#endif |
43 |
|
|
44 |
#define ATTR_DELIMITER "{{!}}" |
#define ATTR_DELIMITER "{{!}}" |
45 |
|
#define HINTS_PREFIX "HINTS." |
46 |
|
|
47 |
/* prototype */ |
/* prototype */ |
48 |
char *attr2text(ESTDOC *doc, char *attr); |
char *attr2text(ESTDOC *doc, char *attr); |
395 |
ESTCOND *cond; |
ESTCOND *cond; |
396 |
ESTNODERES *nres; |
ESTNODERES *nres; |
397 |
ESTRESDOC *rdoc; |
ESTRESDOC *rdoc; |
398 |
|
CBMAP *hints; |
399 |
int resnum = 0; |
int resnum = 0; |
400 |
int limit = 0; |
int limit = 0; |
401 |
int offset = 0; |
int offset = 0; |
592 |
nrows = resnum - offset; |
nrows = resnum - offset; |
593 |
} |
} |
594 |
|
|
595 |
|
/* get hints */ |
596 |
|
hints = est_noderes_hints(nres); |
597 |
|
|
598 |
elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query); |
elog(DEBUG1, "pgest_node: found %d hits for %s", resnum, query); |
599 |
|
|
600 |
|
|
617 |
for (j = 0; j < ncols; j++) |
for (j = 0; j < ncols; j++) |
618 |
{ |
{ |
619 |
bool isnull; |
bool isnull; |
620 |
|
char *attr; /* current attribute name */ |
621 |
|
char *hint; /* position of current hint in attribute */ |
622 |
|
char *hint_val; |
623 |
|
|
624 |
/* array value of this position */ |
/* array value of this position */ |
625 |
indx[0] = j + attr_dim_lower_bounds[0]; |
indx[0] = j + attr_dim_lower_bounds[0]; |
626 |
|
|
627 |
dvalue = array_ref(attr_arr, attr_ndims, indx, -1, attr_len, attr_byval, attr_align, &isnull); |
dvalue = array_ref(attr_arr, attr_ndims, indx, -1, attr_len, attr_byval, attr_align, &isnull); |
628 |
|
attr = (char *)DirectFunctionCall1(textout, dvalue); |
629 |
|
|
630 |
if (!isnull && rdoc) |
if (!isnull && (hint = strstr(attr, HINTS_PREFIX)) != NULL) { |
631 |
values[j] = DatumGetCString( |
/* skip HINTS. prefix */ |
632 |
node_attr2text(rdoc, |
hint += strlen(HINTS_PREFIX); |
633 |
(char *)DirectFunctionCall1(textout, dvalue) |
|
634 |
)); |
hint_val = cbmapget(hints, hint, -1, NULL); |
635 |
|
elog(DEBUG2, "hint %s = %s", hint, hint_val); |
636 |
|
|
637 |
|
if (hint_val != NULL) { |
638 |
|
values[j] = DatumGetCString( hint_val ); |
639 |
|
} else { |
640 |
|
elog(INFO, "can't get hint in results: %s", hint); |
641 |
|
values[j] = NULL; |
642 |
|
} |
643 |
|
} else if (!isnull && rdoc) |
644 |
|
values[j] = DatumGetCString( node_attr2text(rdoc, attr) ); |
645 |
else |
else |
646 |
values[j] = NULL; |
values[j] = NULL; |
647 |
} |
} |