/[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 73 by dpavlin, Mon Aug 7 22:47:41 2006 UTC revision 85 by dpavlin, Sat Feb 3 17:13:07 2007 UTC
# Line 44  Line 44 
44   #define SortMem 16 * 1024   #define SortMem 16 * 1024
45  #endif  #endif
46    
47    #ifdef PG_MODULE_MAGIC
48    PG_MODULE_MAGIC;
49    #endif
50    
51  #define ATTR_DELIMITER "{{!}}"  #define ATTR_DELIMITER "{{!}}"
52  #define HINTS_PREFIX "HINTS."  #define HINTS_PREFIX "HINTS."
53    
# Line 592  Datum pgest_node(PG_FUNCTION_ARGS) Line 596  Datum pgest_node(PG_FUNCTION_ARGS)
596          if (limit && limit < resnum) {          if (limit && limit < resnum) {
597                  nrows = limit;                  nrows = limit;
598          } else {          } else {
599                  nrows = resnum - offset;                  nrows = resnum;
600          }          }
601    
602          /* get hints */          /* get hints */
# Line 768  Datum pgest_trigger(PG_FUNCTION_ARGS) { Line 772  Datum pgest_trigger(PG_FUNCTION_ARGS) {
772          int   knumber;          int   knumber;
773          int   i;          int   i;
774          int   create_doc = 0;          int   create_doc = 0;
775            int   edit_doc = 0;
776    
777          ESTNODE *node;          ESTNODE *node;
778          ESTDOC *doc;          ESTDOC *doc;
# Line 810  Datum pgest_trigger(PG_FUNCTION_ARGS) { Line 815  Datum pgest_trigger(PG_FUNCTION_ARGS) {
815          } else if (TRIGGER_FIRED_BY_UPDATE(data->tg_event)) {          } else if (TRIGGER_FIRED_BY_UPDATE(data->tg_event)) {
816                  ret = data->tg_newtuple;                  ret = data->tg_newtuple;
817    
818                  create_doc++;                  edit_doc++;
819    
820          } else if (TRIGGER_FIRED_BY_DELETE(data->tg_event)) {          } else if (TRIGGER_FIRED_BY_DELETE(data->tg_event)) {
821                  /* There is no new data */                  /* There is no new data */
# Line 823  Datum pgest_trigger(PG_FUNCTION_ARGS) { Line 828  Datum pgest_trigger(PG_FUNCTION_ARGS) {
828                  elog(ERROR, "pgest_trigger() not called from INSERT/UPDATE/DELETE");                  elog(ERROR, "pgest_trigger() not called from INSERT/UPDATE/DELETE");
829          }          }
830    
831          if ( create_doc ) {          if ( create_doc || edit_doc ) {
832    
833                  /* create a document object */                  if ( create_doc ) {
834                  doc = est_doc_new();                          /* create a document object */
835                  est_doc_add_attr(doc, "@uri", key);                          doc = est_doc_new();
836                            est_doc_add_attr(doc, "@uri", key);
837    
838                  elog(DEBUG1, "est_doc_new @uri=%s", key);                          elog(DEBUG1, "est_doc_new @uri=%s", key);
839                    } else {
840                            /* edit existing document */
841                            doc = est_node_get_doc_by_uri(node, key);
842                            if (doc == NULL)
843                                    elog(ERROR, "est_node_get_doc_by_uri(%s): %d\n", key, est_node_status(node));
844                            elog(DEBUG1, "est_node_get_doc_by_uri(%s)", key);
845                    }
846    
847                  for( i = 4; i < data->tg_trigger->tgnargs; i++ ) {                  for( i = 4; i < data->tg_trigger->tgnargs; i++ ) {
848    
# Line 843  Datum pgest_trigger(PG_FUNCTION_ARGS) { Line 856  Datum pgest_trigger(PG_FUNCTION_ARGS) {
856    
857                  }                  }
858    
859                  /* register the document object to the node */                  if ( edit_doc ) {
860                  if( ! est_node_put_doc(node, doc) )                          /* update existing document */
861                          elog(ERROR, "est_node_put_doc: %d\n", est_node_status(node));                          if( ! est_node_edit_doc(node, doc) )
862                                    elog(ERROR, "est_node_edit_doc: %d\n", est_node_status(node));
863                    } else {
864                            /* register the document object to the node */
865                            if( ! est_node_put_doc(node, doc) )
866                                    elog(ERROR, "est_node_put_doc: %d\n", est_node_status(node));
867                    }
868    
869                  /* destroy the document object */                  /* destroy the document object */
870                  est_doc_delete(doc);                  est_doc_delete(doc);

Legend:
Removed from v.73  
changed lines
  Added in v.85

  ViewVC Help
Powered by ViewVC 1.1.26