634 |
/* skip HINTS. prefix */ |
/* skip HINTS. prefix */ |
635 |
hint += strlen(HINTS_PREFIX); |
hint += strlen(HINTS_PREFIX); |
636 |
|
|
637 |
hint_val = cbmapget(hints, hint, -1, NULL); |
hint_val = (char *)cbmapget(hints, hint, -1, NULL); |
638 |
elog(DEBUG2, "hint %s = %s", hint, hint_val); |
elog(DEBUG2, "hint %s = %s", hint, hint_val); |
639 |
|
|
640 |
if (hint_val != NULL) { |
if (hint_val != NULL) { |
724 |
char *next; |
char *next; |
725 |
char *curr_attr; |
char *curr_attr; |
726 |
while ( strlen(attr) > 0 ) { |
while ( strlen(attr) > 0 ) { |
727 |
printf("len [%s] = %d\n", attr, strlen(attr)); |
printf("len [%s] = %zd\n", attr, strlen(attr)); |
728 |
if ((next = strstr(attr, ATTR_DELIMITER)) != NULL) { |
if ((next = strstr(attr, ATTR_DELIMITER)) != NULL) { |
729 |
curr_attr = palloc( next - attr + 1 ); |
curr_attr = palloc( next - attr + 1 ); |
730 |
memcpy(curr_attr, attr, next-attr); |
memcpy(curr_attr, attr, next-attr); |
768 |
int knumber; |
int knumber; |
769 |
int i; |
int i; |
770 |
int create_doc = 0; |
int create_doc = 0; |
771 |
|
int edit_doc = 0; |
772 |
|
|
773 |
ESTNODE *node; |
ESTNODE *node; |
774 |
ESTDOC *doc; |
ESTDOC *doc; |
811 |
} else if (TRIGGER_FIRED_BY_UPDATE(data->tg_event)) { |
} else if (TRIGGER_FIRED_BY_UPDATE(data->tg_event)) { |
812 |
ret = data->tg_newtuple; |
ret = data->tg_newtuple; |
813 |
|
|
814 |
create_doc++; |
edit_doc++; |
815 |
|
|
816 |
} else if (TRIGGER_FIRED_BY_DELETE(data->tg_event)) { |
} else if (TRIGGER_FIRED_BY_DELETE(data->tg_event)) { |
817 |
/* There is no new data */ |
/* There is no new data */ |
824 |
elog(ERROR, "pgest_trigger() not called from INSERT/UPDATE/DELETE"); |
elog(ERROR, "pgest_trigger() not called from INSERT/UPDATE/DELETE"); |
825 |
} |
} |
826 |
|
|
827 |
if ( create_doc ) { |
if ( create_doc || edit_doc ) { |
828 |
|
|
829 |
/* create a document object */ |
if ( create_doc ) { |
830 |
doc = est_doc_new(); |
/* create a document object */ |
831 |
est_doc_add_attr(doc, "@uri", key); |
doc = est_doc_new(); |
832 |
|
est_doc_add_attr(doc, "@uri", key); |
833 |
|
|
834 |
elog(DEBUG1, "est_doc_new @uri=%s", key); |
elog(DEBUG1, "est_doc_new @uri=%s", key); |
835 |
|
} else { |
836 |
|
/* edit existing document */ |
837 |
|
doc = est_node_get_doc_by_uri(node, key); |
838 |
|
if (doc == NULL) |
839 |
|
elog(ERROR, "est_node_get_doc_by_uri(%s): %d\n", key, est_node_status(node)); |
840 |
|
elog(DEBUG1, "est_node_get_doc_by_uri(%s)", key); |
841 |
|
} |
842 |
|
|
843 |
for( i = 4; i < data->tg_trigger->tgnargs; i++ ) { |
for( i = 4; i < data->tg_trigger->tgnargs; i++ ) { |
844 |
|
|
852 |
|
|
853 |
} |
} |
854 |
|
|
855 |
/* register the document object to the node */ |
if ( edit_doc ) { |
856 |
if( ! est_node_put_doc(node, doc) ) |
/* update existing document */ |
857 |
elog(ERROR, "est_node_put_doc: %d\n", est_node_status(node)); |
if( ! est_node_edit_doc(node, doc) ) |
858 |
|
elog(ERROR, "est_node_edit_doc: %d\n", est_node_status(node)); |
859 |
|
} else { |
860 |
|
/* register the document object to the node */ |
861 |
|
if( ! est_node_put_doc(node, doc) ) |
862 |
|
elog(ERROR, "est_node_put_doc: %d\n", est_node_status(node)); |
863 |
|
} |
864 |
|
|
865 |
/* destroy the document object */ |
/* destroy the document object */ |
866 |
est_doc_delete(doc); |
est_doc_delete(doc); |