Permalink
Browse files

Fixed bad compile of filter exp

  • Loading branch information...
1 parent ed86d28 commit 659613fefd1bb509da165f4e4959c339378a23ba VOS Maintainer committed May 9, 2013

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -2919,6 +2919,45 @@ bif_id_to_iri (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
}
caddr_t
+bif_id_to_canonicalized_iri (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
+{
+ query_instance_t * qi = (query_instance_t *) qst;
+ caddr_t iid_box = bif_arg (qst, args, 0, "id_to_canonicalized_iri");
+ switch (DV_TYPE_OF (iid_box))
+ {
+ case DV_DB_NULL:
+ return NEW_DB_NULL;
+ case DV_IRI_ID:
+ {
+ iri_id_t iid = unbox_iri_id (iid_box);
+ caddr_t iri;
+ if (0L == iid)
+ return NEW_DB_NULL;
+ if ((min_bnode_iri_id () <= iid) && (min_named_bnode_iri_id () > iid))
+ iri = BNODE_IID_TO_LABEL(iid);
+ else
+ {
+ iri = key_id_to_canonicalized_iri (qi, iid);
+ if (!iri)
+ return NEW_DB_NULL;
+ }
+ box_flags (iri) = BF_IRI;
+ return iri;
+ }
+ case DV_UNAME:
+ return box_copy (iid_box);
+ case DV_STRING:
+ if (BF_IRI == box_flags (iid_box))
+ return box_copy (iid_box);
+ break;
+ }
+ sqlr_new_error ("22023", "SR008",
+ "Function id_to_canonicalized_iri needs a string or UNAME or IRI_ID or NULL as argument 1, "
+ "not an arg of type %s (%d)", dv_type_title (DV_TYPE_OF (iid_box)), DV_TYPE_OF (iid_box) );
+ return NULL; /* never reached */
+}
+
+caddr_t
bif_id_to_iri_nosignal (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
query_instance_t *qi = (query_instance_t *) qst;
@@ -3494,13 +3533,31 @@ bif_iri_ensure (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
}
caddr_t
+bif_uriqa_iri_is_local (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
+{
+ caddr_t name = bif_string_or_uname_arg (qst, args, 0, "uriqa_iri_is_local");
+ int tail = uriqa_iri_is_local ((query_instance_t *)qst, name);
+ return box_num (tail);
+}
+
+caddr_t
bif_uriqa_dynamic_local_replace (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
{
caddr_t name = box_copy (bif_string_arg (qst, args, 0, "uriqa_dynamic_local_replace"));
name = uriqa_dynamic_local_replace (name, ((query_instance_t *) qst)->qi_client);
return name;
}
+caddr_t
+bif_uriqa_dynamic_local_set (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args)
+{
+ int val = bif_long_range_arg (qst, args, 0, "uriqa_dynamic_local_set", 0, 1);
+ sec_check_dba ((query_instance_t *)qst, "uriqa_dynamic_local_set");
+ if (val != uriqa_dynamic_local)
+ uriqa_dynamic_local = val;
+ return box_num (val);
+}
+
void rdf_inf_init ();
@@ -3611,6 +3668,9 @@ rdf_core_init (void)
bif_define ("id_to_iri", bif_id_to_iri);
bif_set_uses_index (bif_id_to_iri);
bif_set_no_cluster ("id_to_iri");
+ bif_define_typed ("id_to_canonicalized_iri", bif_id_to_canonicalized_iri, &bt_varchar);
+ bif_set_uses_index (bif_id_to_canonicalized_iri);
+ bif_set_no_cluster ("id_to_canonicalized_iri");
bif_define ("id_to_iri_nosignal", bif_id_to_iri_nosignal);
bif_set_uses_index (bif_id_to_iri_nosignal);
bif_set_no_cluster ("id_to_iri_nosignal");
@@ -3642,6 +3702,8 @@ rdf_core_init (void)
bif_set_no_cluster ("__id2in");
bif_define ("rdf_graph_keyword", bif_rdf_graph_keyword);
bif_define ("iri_split", bif_iri_split);
+ bif_define ("uriqa_dynamic_local_set", bif_uriqa_dynamic_local_set);
+ bif_define ("uriqa_iri_is_local", bif_uriqa_iri_is_local);
bif_define ("uriqa_dynamic_local_replace", bif_uriqa_dynamic_local_replace);
#ifdef DEBUG
bif_define ("turtle_lex_test", bif_turtle_lex_test);
View
@@ -15141,7 +15141,7 @@ create procedure DB.DBA.SPARQL_RELOAD_QM_GRAPH ()
{
declare ver varchar;
declare inx int;
- ver := '2012-04-18 0001v6g';
+ ver := '2013-05-07 0002v6g';
if (USER <> 'dba')
signal ('RDFXX', 'Only DBA can reload quad map metadata');
if (not exists (sparql define input:storage "" ask where {
View
@@ -3230,7 +3230,9 @@ sparp_calc_bop_of_fixed_vals (sparp_t *sparp, ptrlong bop_type, rdf_val_range_t
case BOP_EQ: case SPAR_BOP_EQNAMES: case SPAR_BOP_EQ_NONOPT: case BOP_NEQ:
case BOP_LT: case BOP_LTE: case BOP_GT: case BOP_GTE:
{
- int cb = cmp_boxes_safe (left->rvrFixedValue, right->rvrFixedValue, NULL, NULL);
+ caddr_t left_val = SPAR_LIT_OR_QNAME_VAL ((SPART *)(left->rvrFixedValue));
+ caddr_t right_val = SPAR_LIT_OR_QNAME_VAL ((SPART *)(right->rvrFixedValue));
+ int cb = cmp_boxes_safe (left_val, right_val, NULL, NULL);
switch (cb)
{
case DVC_MATCH:
@@ -3245,10 +3247,12 @@ sparp_calc_bop_of_fixed_vals (sparp_t *sparp, ptrlong bop_type, rdf_val_range_t
if ((BOP_NEQ == bop_type) || (BOP_GT == bop_type) || (BOP_GTE == bop_type) || (BOP_NSAME == bop_type))
goto res_bool_true; /* see below */
goto res_bool_false; /* see below */
+ case DVC_NOORDER:
+ return 1;
default:
if ((BOP_NEQ == bop_type) || (BOP_NSAME == bop_type))
goto res_bool_true; /* see below */
- goto res_bool_false; /* see below */
+ return 1; /* was goto res_bool_false; , but it might be unsafe for out of range and BOP_LT / BOP_GT. Let SQL compiler worries about that */
}
}
case BOP_PLUS: case BOP_MINUS: case BOP_TIMES: case BOP_DIV: case BOP_MOD:
@@ -6712,10 +6716,10 @@ restoring filters is a preorder one, the postorder needs a complete stack of thi
parent_gp->_.gp.selid, NULL,
(ptrlong)(0), SPART_BAD_EQUIV_IDX, SPART_RVR_LIST_OF_NULLS, (ptrlong)(0x0) );
memcpy (&(l->_.var.rvr.rvrRestrictions), &(subq_eq->e_rvr), sizeof (rdf_val_range_t));
- if (eq->e_rvr.rvrRestrictions & SPART_VARR_IS_REF)
- r = spartlist (sparp, 2, SPAR_QNAME, eq->e_rvr.rvrFixedValue);
- else if (DV_ARRAY_OF_POINTER == DV_TYPE_OF (eq->e_rvr.rvrFixedValue))
+ if (DV_ARRAY_OF_POINTER == DV_TYPE_OF (eq->e_rvr.rvrFixedValue))
r = (SPART *)eq->e_rvr.rvrFixedValue;
+ else if (eq->e_rvr.rvrRestrictions & SPART_VARR_IS_REF)
+ r = spartlist (sparp, 2, SPAR_QNAME, eq->e_rvr.rvrFixedValue);
else
r = spartlist (sparp, 4, SPAR_LIT, eq->e_rvr.rvrFixedValue, eq->e_rvr.rvrDatatype, eq->e_rvr.rvrLanguage);
filt = spartlist (sparp, 3, BOP_EQ, l, r);
View
@@ -90,7 +90,7 @@ void rdf_ds_load_all (void)
qmf->qmf01uriOfShortTmpl = box_dv_short_string (" (lt (^{tree}^, min_bnode_iri_id ()))");
qmf->qmf01blankOfShortTmpl = box_dv_short_string (" (gte (^{tree}^, min_bnode_iri_id ()))");
qmf->qmfLongOfShortTmpl = box_dv_short_string (" ^{tree}^");
- qmf->qmfDatatypeOfShortTmpl = box_dv_short_string (" 'http://www.w3.org/2001/XMLSchema#anyURI'");
+ qmf->qmfDatatypeOfShortTmpl = box_dv_short_string (" UNAME'http://www.w3.org/2001/XMLSchema#anyURI'");
qmf->qmfLanguageOfShortTmpl = box_dv_short_string (" NULL");
qmf->qmfSqlvalOfShortTmpl = box_dv_short_string (" __id2i (^{tree}^)");
qmf->qmfBoolOfShortTmpl = box_dv_short_string (" NULL");
@@ -2288,7 +2288,7 @@ ssg_print_box_as_sql_atom (spar_sqlgen_t *ssg, ccaddr_t box, int mode)
{
double boxdbl = (double)(unbox_float (box));
if (1.0 > ((2 - 1.41484755040568800000e+16) + 1.41484755040568800000e+16))
- spar_error (ssg->ssg_sparp, "Platform-specific error: this build of Virtuoso does not supports literals of type %s due to rounding errors in math functions", dv_type_title (dtp));
+ spar_error (ssg->ssg_sparp, "Platform-specific error: this build of Virtuoso does not support literals of type %s due to rounding errors in math functions", dv_type_title (dtp));
buffill = sprintf (tmpbuf, "cast (%lg", boxdbl);
if ((NULL == strchr (tmpbuf+6, '.')) && (NULL == strchr (tmpbuf+6, 'E')) && (NULL == strchr (tmpbuf+6, 'e')))
{
@@ -2378,7 +2378,7 @@ ssg_print_box_as_sql_atom (spar_sqlgen_t *ssg, ccaddr_t box, int mode)
break;
}
default:
- spar_error (ssg->ssg_sparp, "Current implementation of SPARQL does not supports literals of type %s", dv_type_title (dtp));
+ spar_error (ssg->ssg_sparp, "Current implementation of SPARQL does not support literals of type %s", dv_type_title (dtp));
}
session_buffered_write (ssg->ssg_out, tmpbuf, buffill);
BOX_DONE (tmpbuf, smallbuf);
@@ -3668,8 +3668,8 @@ ssg_print_builtin_expn (spar_sqlgen_t *ssg, SPART *tree, int top_filter_op, ssg_
goto print_asname;
}
case DATATYPE_L:
- if (SSG_VALMODE_LONG != needed)
- ssg_print_valmoded_scalar_expn (ssg, tree, needed, SSG_VALMODE_LONG, asname);
+ if (SSG_VALMODE_SQLVAL != needed)
+ ssg_print_valmoded_scalar_expn (ssg, tree, needed, SSG_VALMODE_SQLVAL, asname);
else
ssg_print_scalar_expn (ssg, arg1, SSG_VALMODE_DATATYPE, asname);
return;
@@ -3989,7 +3989,7 @@ ssg_print_builtin_expn (spar_sqlgen_t *ssg, SPART *tree, int top_filter_op, ssg_
ssg_print_tmpl (ssg, arg1_native, tmpl, NULL, NULL, arg1, NULL_ASNAME);
}
else if (SSG_VALMODE_DATATYPE == needed)
- ssg_puts (" " XMLSCHEMA_NS_URI "#anyURI");
+ ssg_puts (" UNAME'" XMLSCHEMA_NS_URI "#anyURI'");
else if (SSG_VALMODE_LANGUAGE == needed)
ssg_puts (" NULL");
else
View
@@ -4305,7 +4305,7 @@ const sparp_bif_desc_t sparp_bif_descs[] = {
{ "coalesce" , SPAR_BIF_COALESCE , '-' , SSG_SD_SPARQL11_DRAFT , 0 , 0xFFF , NULL , { SSG_VALMODE_SQLVAL, NULL, NULL} , 0 },
{ "concat" , SPAR_BIF_CONCAT , 'B' , SSG_SD_SPARQL11_DRAFT , 0 , 0xFFF , SSG_VALMODE_SQLVAL , { SSG_VALMODE_SQLVAL, NULL, NULL} , SPART_VARR_IS_LIT | SPART_VARR_NOT_NULL },
{ "contains" , SPAR_BIF_CONTAINS , 'B' , SSG_SD_SPARQL11_DRAFT , 2 , 2 , SSG_VALMODE_BOOL , { SSG_VALMODE_LONG, SSG_VALMODE_LONG, NULL} , SPART_VARR_IS_LIT | SPART_VARR_NOT_NULL | SPART_VARR_LONG_EQ_SQL },
- { "datatype" , DATATYPE_L , '-' , 0 , 1 , 1 , SSG_VALMODE_LONG , { SSG_VALMODE_LONG, NULL, NULL} , SPART_VARR_IS_IRI | SPART_VARR_IS_REF },
+ { "datatype" , DATATYPE_L , '-' , 0 , 1 , 1 , SSG_VALMODE_SQLVAL , { SSG_VALMODE_LONG, NULL, NULL} , SPART_VARR_IS_IRI | SPART_VARR_IS_REF },
{ "day" , SPAR_BIF_DAY , 'B' , SSG_SD_SPARQL11_DRAFT , 1 , 1 , SSG_VALMODE_NUM , { SSG_VALMODE_NUM, NULL, NULL} , SPART_VARR_IS_LIT | SPART_VARR_NOT_NULL | SPART_VARR_LONG_EQ_SQL },
{ "encode_for_uri" , SPAR_BIF_ENCODE_FOR_URI , 'B' , SSG_SD_SPARQL11_DRAFT , 1 , 1 , SSG_VALMODE_SQLVAL , { SSG_VALMODE_SQLVAL, NULL, NULL} , SPART_VARR_IS_LIT | SPART_VARR_NOT_NULL },
{ "floor" , SPAR_BIF_FLOOR , 'B' , SSG_SD_SPARQL11_DRAFT , 1 , 1 , SSG_VALMODE_NUM , { SSG_VALMODE_NUM, NULL, NULL} , SPART_VARR_IS_LIT | SPART_VARR_NOT_NULL | SPART_VARR_LONG_EQ_SQL },
View
@@ -2407,6 +2407,8 @@ sparp_rvr_set_by_constant (sparp_t *sparp, rdf_val_range_t *dest, ccaddr_t datat
if (uname_xmlschema_ns_uri_hash_string == dest->rvrDatatype)
dest->rvrDatatype = NULL;
}
+ if (NULL == dest->rvrDatatype)
+ dest->rvrRestrictions &= ~SPART_VARR_TYPED;
}
}
}
@@ -3757,12 +3759,14 @@ sparp_extract_filters_replaced_by_equiv (sparp_t *sparp, sparp_equiv_t *eq, dk_s
eq->e_rvr.rvrDatatype ) );
if (repl_bits & SPART_VARR_FIXED)
{
- SPART *fval;
- if (eq->e_rvr.rvrRestrictions & SPART_VARR_IS_REF)
- fval = spartlist (sparp, 2, SPAR_QNAME, eq->e_rvr.rvrFixedValue);
+ SPART *r;
+ if (DV_ARRAY_OF_POINTER == DV_TYPE_OF (eq->e_rvr.rvrFixedValue))
+ r = (SPART *)eq->e_rvr.rvrFixedValue;
+ else if (eq->e_rvr.rvrRestrictions & SPART_VARR_IS_REF)
+ r = spartlist (sparp, 2, SPAR_QNAME, eq->e_rvr.rvrFixedValue);
else
- fval = spartlist (sparp, 4, SPAR_LIT, eq->e_rvr.rvrFixedValue, eq->e_rvr.rvrDatatype, eq->e_rvr.rvrLanguage);
- t_set_push (filts_from_equiv_ret, spartlist (sparp, 3, BOP_EQ, spar_make_variable (sparp, sample_varname), fval));
+ r = spartlist (sparp, 4, SPAR_LIT, eq->e_rvr.rvrFixedValue, eq->e_rvr.rvrDatatype, eq->e_rvr.rvrLanguage);
+ t_set_push (filts_from_equiv_ret, spartlist (sparp, 3, BOP_EQ, spar_make_variable (sparp, sample_varname), r));
}
if (repl_bits & SPART_VARR_NOT_NULL)
t_set_push (filts_from_equiv_ret, sparp_make_builtin_call (sparp, BOUND_L, (SPART **)t_list (1, spar_make_variable (sparp, sample_varname))));

0 comments on commit 659613f

Please sign in to comment.