}
}
break;
}
if (clause == null)
throw new UnsupportedSQLException("Unrecognized FULL_TEXT_SEARCH call",
condition.getSQLsource());
if (query == null) {
query = clause;
}
else {
query = fullTextBoolean(Arrays.asList(query, clause),
Arrays.asList(FullTextQueryBuilder.BooleanType.MUST,
FullTextQueryBuilder.BooleanType.MUST));
}
}
if (query == null)
return null;
FullTextIndex foundIndex = null;
TableSource foundTable = null;
find_index:
for (FullTextIndex index : textFields.get(0).getColumn().getColumn().getTable().getFullTextIndexes()) {
TableSource indexTable = null;
for (FullTextField textField : textFields) {
Column column = textField.getColumn().getColumn();
boolean found = false;
for (IndexColumn indexColumn : index.getKeyColumns()) {
if (indexColumn.getColumn() == column) {
if (foundIndex == null) {
textField.setIndexColumn(indexColumn);
}
found = true;
if ((indexTable == null) &&
(indexColumn.getColumn().getTable() == index.getIndexedTable())) {
indexTable = (TableSource)textField.getColumn().getTable();
}
break;
}
}
if (!found) {
continue find_index;
}
}
if (foundIndex == null) {
foundIndex = index;
foundTable = indexTable;
}
else {
throw new UnsupportedSQLException("Ambiguous full text index: " +
foundIndex + " and " + index);
}
}
if (foundIndex == null) {
StringBuilder str = new StringBuilder("No full text index for: ");
boolean first = true;
for (FullTextField textField : textFields) {
if (first)
first = false;
else
str.append(", ");
str.append(textField.getColumn());
}
throw new UnsupportedSQLException(str.toString());
}
if (foundTable == null) {
for (TableGroupJoinNode node : tables) {
if (node.getTable().getTable().getTable() == foundIndex.getIndexedTable()) {
foundTable = node.getTable();