/[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 27 by dpavlin, Thu Jun 30 20:01:36 2005 UTC revision 31 by dpavlin, Wed Jul 6 14:47:56 2005 UTC
# Line 47  char *attr2text(ESTDOC *doc, char *attr) Line 47  char *attr2text(ESTDOC *doc, char *attr)
47  PG_FUNCTION_INFO_V1(pgest_attr);  PG_FUNCTION_INFO_V1(pgest_attr);
48  Datum pgest_attr(PG_FUNCTION_ARGS)  Datum pgest_attr(PG_FUNCTION_ARGS)
49  {  {
50          ArrayType       *attr_arr = PG_GETARG_ARRAYTYPE_P(5);          ArrayType       *attr_arr = PG_GETARG_ARRAYTYPE_P(6);
51          Oid             attr_element_type = ARR_ELEMTYPE(attr_arr);          Oid             attr_element_type = ARR_ELEMTYPE(attr_arr);
52          int             attr_ndims = ARR_NDIM(attr_arr);          int             attr_ndims = ARR_NDIM(attr_arr);
53          int             *attr_dim_counts = ARR_DIMS(attr_arr);          int             *attr_dim_counts = ARR_DIMS(attr_arr);
# Line 81  Datum pgest_attr(PG_FUNCTION_ARGS) Line 81  Datum pgest_attr(PG_FUNCTION_ARGS)
81          char            *index_path;          char            *index_path;
82          char            *query;          char            *query;
83          char            *attr;          char            *attr;
84            char            *order;
85    
86    
87          /* only allow 1D input array */          /* only allow 1D input array */
# Line 143  Datum pgest_attr(PG_FUNCTION_ARGS) Line 144  Datum pgest_attr(PG_FUNCTION_ARGS)
144          index_path = _textout(PG_GETARG_TEXT_P(0));          index_path = _textout(PG_GETARG_TEXT_P(0));
145    
146          /* query string */          /* query string */
147          if (PG_ARGISNULL(0)) {          if (PG_ARGISNULL(1)) {
148                  query = "";                  query = "";
149          } else {          } else {
150                  query = _textout(PG_GETARG_TEXT_P(1));                  query = _textout(PG_GETARG_TEXT_P(1));
# Line 155  Datum pgest_attr(PG_FUNCTION_ARGS) Line 156  Datum pgest_attr(PG_FUNCTION_ARGS)
156          } else {          } else {
157                  attr = _textout(PG_GETARG_TEXT_P(2));                  attr = _textout(PG_GETARG_TEXT_P(2));
158          }          }
159            
160            /* sort order */
161            if (PG_ARGISNULL(3)) {
162                    order = "";
163            } else {
164                    order = _textout(PG_GETARG_TEXT_P(3));
165            }
166    
167    
168          /* limit */          /* limit */
169          if (PG_ARGISNULL(3)) {          if (PG_ARGISNULL(4)) {
170                  limit = 0;                  limit = 0;
171          } else {          } else {
172                  limit = PG_GETARG_INT32(3);                  limit = PG_GETARG_INT32(4);
173          }          }
174    
175          /* offset */          /* offset */
176          if (PG_ARGISNULL(4)) {          if (PG_ARGISNULL(5)) {
177                  offset = 0;                  offset = 0;
178          } else {          } else {
179                  offset = PG_GETARG_INT32(4);                  offset = PG_GETARG_INT32(5);
180          }          }
181    
182    
# Line 198  Datum pgest_attr(PG_FUNCTION_ARGS) Line 207  Datum pgest_attr(PG_FUNCTION_ARGS)
207                  est_cond_add_attr(cond, attr);                  est_cond_add_attr(cond, attr);
208          }          }
209    
210            /* set the search phrase to the search condition object */
211            if (! PG_ARGISNULL(3) && strlen(order) > 0) {
212                    elog(DEBUG1,"est_cond_set_order(%s)", order);
213                    est_cond_set_order(cond, order);
214            }
215    
216          /* get the result of search */          /* get the result of search */
217          est_result = est_db_search(db, cond, &resnum, NULL);          est_result = est_db_search(db, cond, &resnum, NULL);
218    
# Line 208  Datum pgest_attr(PG_FUNCTION_ARGS) Line 223  Datum pgest_attr(PG_FUNCTION_ARGS)
223    
224          /* total number of tuples to be returned */          /* total number of tuples to be returned */
225          if (limit && limit < resnum) {          if (limit && limit < resnum) {
226                  nrows = limit - offset;                  nrows = limit;
227          } else {          } else {
228                  nrows = resnum - offset;                  nrows = resnum - offset;
229          }          }
# Line 274  Datum pgest_attr(PG_FUNCTION_ARGS) Line 289  Datum pgest_attr(PG_FUNCTION_ARGS)
289          rsinfo->setDesc = tupdesc;          rsinfo->setDesc = tupdesc;
290          MemoryContextSwitchTo(oldcontext);          MemoryContextSwitchTo(oldcontext);
291    
292            est_cond_delete(cond);
293    
294          if(!est_db_close(db, &ecode)){          if(!est_db_close(db, &ecode)){
295                  ereport(ERROR, (errcode(ERRCODE_IO_ERROR),                  ereport(ERROR, (errcode(ERRCODE_IO_ERROR),
296                          errmsg("est_db_close: %d", ecode),                          errmsg("est_db_close: %d", ecode),

Legend:
Removed from v.27  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26