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 |
|
|
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 */ |
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; |
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 */ |
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 |
|
|
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); |