/[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 51 by dpavlin, Tue May 9 22:55:42 2006 UTC revision 56 by dpavlin, Thu May 11 15:52:50 2006 UTC
# Line 25  Line 25 
25  #include "funcapi.h"  #include "funcapi.h"
26  #include "utils/builtins.h"  #include "utils/builtins.h"
27  #include "utils/array.h"  #include "utils/array.h"
28    #include "utils/lsyscache.h"
29  #include "miscadmin.h"  #include "miscadmin.h"
30  #include <estraier.h>  #include <estraier.h>
31  #include <cabin.h>  #include <cabin.h>
# Line 45  Line 46 
46  /* prototype */  /* prototype */
47  char *attr2text(ESTDOC *doc, char *attr);  char *attr2text(ESTDOC *doc, char *attr);
48  char *node_attr2text(ESTRESDOC *rdoc, char *attr);  char *node_attr2text(ESTRESDOC *rdoc, char *attr);
49    void cond_add_attr(ESTCOND *cond, char *attr);
50    
51    
52  /* work in progress */  /* work in progress */
# Line 77  Datum pgest_attr(PG_FUNCTION_ARGS) Line 79  Datum pgest_attr(PG_FUNCTION_ARGS)
79          ESTDB *db;          ESTDB *db;
80          ESTCOND *cond;          ESTCOND *cond;
81          ESTDOC *doc;          ESTDOC *doc;
         const CBLIST *texts;  
82          int ecode, *est_result, resnum;          int ecode, *est_result, resnum;
83          int limit = 0;          int limit = 0;
84          int offset = 0;          int offset = 0;
# Line 208  Datum pgest_attr(PG_FUNCTION_ARGS) Line 209  Datum pgest_attr(PG_FUNCTION_ARGS)
209          /* minimum valid attribute length is 10: @a STREQ a */          /* minimum valid attribute length is 10: @a STREQ a */
210          if (! PG_ARGISNULL(2) && strlen(attr) >= 10) {          if (! PG_ARGISNULL(2) && strlen(attr) >= 10) {
211                  elog(DEBUG1,"attributes: %s", attr);                  elog(DEBUG1,"attributes: %s", attr);
212                  char *curr_attr;                  cond_add_attr(cond, attr);
                 curr_attr = strtok(attr, ATTR_DELIMITER);  
                 while (curr_attr) {  
                         elog(DEBUG1,"est_cond_add_attr(%s)", curr_attr);  
                         est_cond_add_attr(cond, curr_attr);  
                         curr_attr = strtok(NULL, ATTR_DELIMITER);  
                 }  
213          }          }
214    
215          /* set the search phrase to the search condition object */          /* set the search phrase to the search condition object */
# Line 323  char *attr2text(ESTDOC *doc, char *attr) Line 318  char *attr2text(ESTDOC *doc, char *attr)
318    
319          if (! doc) return (Datum) NULL;          if (! doc) return (Datum) NULL;
320    
321          elog(DEBUG1, "doc: %08x, attr: %s", doc, attr);          elog(DEBUG1, "doc: %p, attr: %s", doc, attr);
322    
323          if ( (attrval = est_doc_attr(doc, attr)) && (attrlen = strlen(attrval)) ) {          if ( (attrval = est_doc_attr(doc, attr)) && (attrlen = strlen(attrval)) ) {
324                  val = (char *) palloc(attrlen * sizeof(char));                  val = (char *) palloc(attrlen * sizeof(char));
# Line 399  Datum pgest_node(PG_FUNCTION_ARGS) Line 394  Datum pgest_node(PG_FUNCTION_ARGS)
394          ESTCOND *cond;          ESTCOND *cond;
395          ESTNODERES *nres;          ESTNODERES *nres;
396          ESTRESDOC *rdoc;          ESTRESDOC *rdoc;
         const CBLIST *texts;  
397          int resnum = 0;          int resnum = 0;
398          int limit = 0;          int limit = 0;
399          int offset = 0;          int offset = 0;
# Line 550  Datum pgest_node(PG_FUNCTION_ARGS) Line 544  Datum pgest_node(PG_FUNCTION_ARGS)
544          /* minimum valid attribute length is 10: @a STREQ a */          /* minimum valid attribute length is 10: @a STREQ a */
545          if (! PG_ARGISNULL(_arg_attr) && strlen(attr) >= 10) {          if (! PG_ARGISNULL(_arg_attr) && strlen(attr) >= 10) {
546                  elog(DEBUG1,"attributes: %s", attr);                  elog(DEBUG1,"attributes: %s", attr);
547                  char *curr_attr;                  cond_add_attr(cond, attr);
                 curr_attr = strtok(attr, ATTR_DELIMITER);  
                 while (curr_attr) {  
                         elog(DEBUG1,"est_cond_add_attr(%s)", curr_attr);  
                         est_cond_add_attr(cond, curr_attr);  
                         curr_attr = strtok(NULL, ATTR_DELIMITER);  
                 }  
548          }          }
549    
550          /* set the search phrase to the search condition object */          /* set the search phrase to the search condition object */
# Line 683  char *node_attr2text(ESTRESDOC *rdoc, ch Line 671  char *node_attr2text(ESTRESDOC *rdoc, ch
671    
672          if (! rdoc) return (Datum) NULL;          if (! rdoc) return (Datum) NULL;
673    
674          elog(DEBUG1, "doc: %08x, attr: %s", rdoc, attr);          elog(DEBUG1, "doc: %p, attr: %s", rdoc, attr);
675    
676          if ( (attrval = est_resdoc_attr(rdoc, attr)) && (attrlen = strlen(attrval)) ) {          if ( (attrval = est_resdoc_attr(rdoc, attr)) && (attrlen = strlen(attrval)) ) {
677                  val = (char *) palloc(attrlen * sizeof(char));                  val = (char *) palloc(attrlen * sizeof(char));
# Line 709  char *node_attr2text(ESTRESDOC *rdoc, ch Line 697  char *node_attr2text(ESTRESDOC *rdoc, ch
697          return val;          return val;
698  }  }
699    
700    /* parse attributes and add them to confition */
701    void cond_add_attr(ESTCOND *cond, char *attr) {
702            char *next;
703            char *curr_attr;
704            while ( strlen(attr) > 0 ) {
705                    printf("len [%s] = %d\n", attr, strlen(attr));
706                    if ((next = strstr(attr, ATTR_DELIMITER)) != NULL) {
707                            curr_attr = palloc( next - attr + 1 );
708                            memcpy(curr_attr, attr, next-attr);
709                            curr_attr[next-attr] = '\0';
710                            next += strlen(ATTR_DELIMITER);
711                    } else {
712                            next = "";
713                            curr_attr = attr;
714                    }
715                    elog(DEBUG1, "est_cond_add_attr(%s)", curr_attr);
716                    est_cond_add_attr(cond, curr_attr);
717                    attr = next;
718            }
719    }

Legend:
Removed from v.51  
changed lines
  Added in v.56

  ViewVC Help
Powered by ViewVC 1.1.26