Permalink
Browse files

patch for issue #62: not all variables bound in resultset when vars f…

…orm a triangle
  • Loading branch information...
1 parent ca1329e commit 09c4c157175cd1a23489fe2881934b3242038c80 @msalvadores msalvadores committed Feb 27, 2012
Showing with 18 additions and 16 deletions.
  1. +18 −16 src/frontend/query-datatypes.c
@@ -759,7 +759,6 @@ void fs_binding_merge(fs_query *q, int block, fs_binding *from, fs_binding *to)
for (int d=0; d<length_t; d++) {
to[i].vals->data[d] = FS_RID_NULL;
}
- if (q->opt_level == 0)
rep_list = g_list_append(rep_list, GINT_TO_POINTER(i));
}
}
@@ -867,41 +866,44 @@ if (fp < DEBUG_CUTOFF) {
to[0].vals->length = 0;
/* ms8: INIT code to clean up rows that where not replaced */
- if (q->opt_level == 0 && rep_list) {
- GList *del_list = NULL;
+ if (rep_list) {
+ unsigned char *to_del = fs_new_bit_array(length_t);
+ int to_del_count = 0;
while(rep_list) {
int col_r = GPOINTER_TO_INT(rep_list->data);
rep_list = g_list_next(rep_list);
for (int d=0; d<length_t; d++) {
if (to[col_r].vals->data[d] == FS_RID_NULL) {
- del_list = g_list_append(del_list,GINT_TO_POINTER(d));
+ fs_bit_array_set(to_del, d, 0);
+ to_del_count++;
}
}
}
g_list_free(rep_list);
- if (del_list) {
+ if (to_del_count) {
int vars = 0;
for (int i=1; to[i].name; i++)
vars++;
fs_rid_vector **clean = calloc(vars, sizeof(fs_rid_vector *));
- for (int i=1;i<=vars;i++)
+ for (int i=0;i<vars;i++)
clean[i] = fs_rid_vector_new(0);
for (int d = 0;d<length_t;d++) {
- if (!g_list_find(del_list,GINT_TO_POINTER(d))) {
- for (int i=1;i<=vars;i++)
- fs_rid_vector_append(clean[i],to[i].vals->data[d]);
+ if (fs_bit_array_get(to_del,d)) {
+ for (int i=0;i<vars;i++) {
+ fs_rid_vector_append(clean[i],to[i+1].vals->data[d]);
+ }
}
- }
-
+ }
for (int i=1;i<=vars;i++) {
free(to[i].vals->data);
- to[i].vals->data = clean[i]->data;
- to[i].vals->length = clean[i]->length;
- to[i].vals->size = clean[i]->size;
+ to[i].vals->data = clean[i-1]->data;
+ to[i].vals->length = clean[i-1]->length;
+ to[i].vals->size = clean[i-1]->size;
+ free(clean[i-1]);
}
- for (int i=0;i<=vars;i++)
- g_list_free(del_list);
+ free(clean);
}
+ fs_bit_array_destroy(to_del);
}
/* ms8: END code to clean up rows that where not replaced */

0 comments on commit 09c4c15

Please sign in to comment.