Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed issue joining two federated queries to the same host

  • Loading branch information...
commit 64d19aec73f86c086596da455dd7009bedefa8c2 1 parent a130788
VOS Maintainer authored
View
40 libsrc/Wi/sparql2sql.c
@@ -581,6 +581,44 @@ sparp_gp_trav_cu_out_triples_1 (sparp_t *sparp, SPART *curr, sparp_trav_state_t
}
int
+sparp_gp_trav_cu_out_triples_1_merge_recvs (sparp_t *sparp, SPART *curr, sparp_trav_state_t *sts_this, void *common_env)
+{
+ int eq_ctr;
+ sparp_gp_trav_cu_out_triples_1 (sparp, curr, sts_this, common_env);
+ if (SPAR_GP != SPART_TYPE(curr))
+ return 0;
+ if (OPTIONAL_L == curr->_.gp.subtype)
+ return 0;
+ SPARP_FOREACH_GP_EQUIV (sparp, curr, eq_ctr, eq)
+ {
+ int ctr_r1;
+ DO_BOX_FAST_REV (ptrlong, recv1_idx, ctr_r1, eq->e_receiver_idxs)
+ {
+ int ctr_r2;
+ for (ctr_r2 = BOX_ELEMENTS (eq->e_receiver_idxs); --ctr_r2 > ctr_r1; /* no step */)
+ {
+ int recv2_idx = eq->e_receiver_idxs[ctr_r2];
+ SPART *recv_gp;
+ sparp_equiv_t *recv1_eq = SPARP_EQUIV(sparp,recv1_idx);
+ sparp_equiv_t *recv2_eq = SPARP_EQUIV(sparp,recv2_idx);
+ if (recv1_eq == recv2_eq)
+ spar_internal_error (sparp, "sparp_" "gp_trav_cu_out_triples_1_merge_recvs (): duplicate receiver");
+ recv_gp = recv1_eq->e_gp;
+ if (recv_gp != recv2_eq->e_gp)
+ spar_internal_error (sparp, "sparp_" "gp_trav_cu_out_triples_1_merge_recvs (): receivers in different gps");
+ if (UNION_L == recv_gp->_.gp.subtype)
+ return 0;
+ sparp_equiv_merge (sparp, recv1_eq, recv2_eq);
+ }
+ }
+ END_DO_BOX_FAST;
+ }
+ END_SPARP_FOREACH_GP_EQUIV;
+ return 0;
+}
+
+
+int
sparp_gp_trav_cu_out_triples_2 (sparp_t *sparp, SPART *curr, sparp_trav_state_t *sts_this, void *common_env)
{
if (SPAR_GP == SPART_TYPE(curr))
@@ -1648,7 +1686,7 @@ sparp_make_aliases (sparp_t *sparp)
NULL, NULL, NULL,
NULL );
sparp_gp_trav (sparp, top_pattern, NULL,
- sparp_gp_trav_make_common_aliases_gp_in, sparp_gp_trav_cu_out_triples_1,
+ sparp_gp_trav_make_common_aliases_gp_in, sparp_gp_trav_cu_out_triples_1_merge_recvs,
NULL, NULL, sparp_gp_trav_make_aliases_expn_subq,
NULL );
sparp_gp_trav (sparp, top_pattern, NULL,
View
28 libsrc/Wi/sparql2sqltext.c
@@ -5053,15 +5053,33 @@ ssg_print_service_rset_item (spar_sqlgen_t *ssg, SPART *service_gp, caddr_t seli
{
int pos = -1;
char buf[50];
+ sparp_equiv_t *e_eq;
SPART *sinv = sparp_get_option (ssg->ssg_sparp, service_gp->_.gp.options, SPAR_SERVICE_INV);
- DO_BOX_FAST_REV (caddr_t, vname, pos, sinv->_.sinv.rset_varnames)
+/* An optimistic search first: */
+ DO_BOX_FAST_REV (caddr_t, ret_vname, pos, sinv->_.sinv.rset_varnames)
{
- if (!strcmp (e_varname, vname))
-break;
+ if (!strcmp (e_varname, ret_vname))
+ goto rset_pos_found; /* see below */
}
END_DO_BOX_FAST_REV;
- if (0 > pos)
- spar_internal_error (ssg->ssg_sparp, "ssg_" "print_service_rset_item(): service retval not in rset_varnames");
+/* In order to avoid bug 14730, now it's time to check for appropriate synonyms */
+ e_eq = sparp_equiv_get (ssg->ssg_sparp, service_gp, (SPART *)e_varname, SPARP_EQUIV_GET_NAMESAKES);
+ if (NULL != e_eq)
+ {
+ int vnamectr;
+ DO_BOX_FAST_REV (caddr_t, e_eq_varname, vnamectr, e_eq->e_varnames)
+ {
+ DO_BOX_FAST_REV (caddr_t, ret_vname, pos, sinv->_.sinv.rset_varnames)
+ {
+ if (!strcmp (e_eq_varname, ret_vname))
+ goto rset_pos_found; /* see below */
+ }
+ END_DO_BOX_FAST_REV;
+ }
+ END_DO_BOX_FAST_REV;
+ }
+ spar_internal_error (ssg->ssg_sparp, "ssg_" "print_service_rset_item(): service retval not in rset_varnames");
+rset_pos_found:
#ifdef NDEBUG
ssg_putchar (' ');
#else
View
2  libsrc/Wi/sparql_core.c
@@ -4029,7 +4029,7 @@ spar_var_cmp (caddr_t p_data1, caddr_t p_data2)
if (0 != res) return res;
res = strcmp (v1->_.var.vname, v2->_.var.vname);
if (0 != res) return res;
- return strcmp (v1->_.var.tabid, v2->_.var.tabid);
+ return strcmp ((NULL != v1->_.var.tabid) ? v1->_.var.tabid : "", (NULL != v2->_.var.tabid) ? v2->_.var.tabid : "");
}
caddr_t
View
4 libsrc/Wi/sparql_tree.c
@@ -1675,10 +1675,12 @@ sparp_equiv_merge (sparp_t *sparp, sparp_equiv_t *pri, sparp_equiv_t *sec)
}
}
#endif
+#if 0 /* I can't recall why did I add these restrictions, probably to cut the amount of testing. Now they're preventing from a bugfixing, but related situations are still not tested entirely */
if ((pri->e_rvr.rvrRestrictions & SPART_VARR_EXPORTED) && (sec->e_rvr.rvrRestrictions & SPART_VARR_EXPORTED))
return SPARP_EQUIV_MERGE_ROLLBACK;
if ((0 != pri->e_subquery_uses) || (0 != sec->e_subquery_uses))
return SPARP_EQUIV_MERGE_ROLLBACK;
+#endif
ret = sparp_equiv_restrict_by_constant (sparp, pri, sec->e_rvr.rvrDatatype, (SPART *)(sec->e_rvr.rvrFixedValue));
if (SPARP_EQUIV_MERGE_ROLLBACK == ret)
return ret;
@@ -2744,6 +2746,8 @@ sparp_gp_detach_member_int (sparp_t *sparp, SPART *parent_gp, int member_idx, dk
for (var_ctr = eq->e_var_count; var_ctr--; /* no step */) /* The order is important due to sparp_equiv_remove_var() */
{
SPART *var = eq->e_vars[var_ctr];
+ if (NULL == var->_.var.tabid)
+ continue;
if (strcmp (var->_.var.tabid, memb->_.triple.tabid))
continue;
sparp_equiv_remove_var (sparp, eq, var);
Please sign in to comment.
Something went wrong with that request. Please try again.