Skip to content

Commit

Permalink
Bugfix in the SQL SELECT parser
Browse files Browse the repository at this point in the history
This fixes a bug that led some SPARQL queries to be created without
any variable in the SELECT clause. We now use * in case the planner
cannot identify which nodes should be retrieved, which can be a bit
inefficent if we're dealing with many columns, but it is better than
an error message.
  • Loading branch information
jimjonesbr committed Mar 21, 2024
1 parent 5576392 commit 6b46ead
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rdf_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,7 @@ static void CreateSPARQL(RDFfdwState *state, PlannerInfo *root)
elog(DEBUG1, " %s: SPARQL is valid and contains a DISTINCT modifier > pushing down DISTINCT", __func__);
appendStringInfo(&sparql,"%s\nSELECT DISTINCT %s\n%s%s",
state->sparql_prefixes,
state->sparql_select,
strlen(state->sparql_select) == 0 ? " * " : state->sparql_select,
state->sparql_from,
where_graph.data);
}
Expand All @@ -2728,7 +2728,7 @@ static void CreateSPARQL(RDFfdwState *state, PlannerInfo *root)
elog(DEBUG1, " %s: SPARQL is valid and contains a REDUCED modifier > pushing down REDUCED", __func__);
appendStringInfo(&sparql,"%s\nSELECT REDUCED %s\n%s%s",
state->sparql_prefixes,
state->sparql_select,
strlen(state->sparql_select) == 0 ? " * " : state->sparql_select,
state->sparql_from,
where_graph.data);
}
Expand All @@ -2744,15 +2744,15 @@ static void CreateSPARQL(RDFfdwState *state, PlannerInfo *root)
{
appendStringInfo(&sparql,"%s\nSELECT DISTINCT %s\n%s%s",
state->sparql_prefixes,
state->sparql_select,
strlen(state->sparql_select) == 0 ? " * " : state->sparql_select,
state->sparql_from,
where_graph.data);
}
else
{
appendStringInfo(&sparql,"%s\nSELECT %s\n%s%s",
state->sparql_prefixes,
state->sparql_select,
strlen(state->sparql_select) == 0 ? " * " : state->sparql_select,
state->sparql_from,
where_graph.data);
}
Expand Down

0 comments on commit 6b46ead

Please sign in to comment.