Repository navigation
Description
SEVERITY: MEDIUM
Summary
The class SQLFunctionFactoryTemplate registers every name lowercased and resolves getFunctionInstance
lowercased, but its hasFunction is a raw containsKey and its unregister is a raw remove. CallStep
gates the CALL path on hasFunction with the name exactly as the query wrote it, so a CALL of any built-in
SQL function whose canonical name contains a capital letter is rejected as "Unknown procedure/function",
while the same name works in a Cypher RETURN, in SQL SELECT, and in CALL if the caller happens to lowercase
it.
More than fifty registered built-ins are affected, because camelCase is the house style for the namespaced
families. From the NAME constants under function/sql/: vector.l2Distance, vector.l1Distance,
vector.cosineSimilarity, vector.dotProduct, vector.hasNaN, vector.lInfNorm, vector.stdDev,
vector.quantizeInt8, vector.sparseCreate, vector.toString, geo.asText, geo.asGeoJson, geo.geomFromText,
geo.lineString, geo.dWithin, ts.movingAvg, ts.timeBucket, ts.rowNumber, bellmanFord, shortestPath,
cchShortestPath, duanSSSP, bothE, inV, unionAll, symmetricDifference, randomInt, the four fulltext.search*
names, and the rest.
The two sides of the same decision disagree inside one statement. In SimpleCypherStatement, the method
named isConfirmedPureFunctionName lowercases before it asks the same factory, so CALL
vector.Dimension(...) is classified as a confirmed-pure read, admitted, and then fails at execution; a name
the purity check does not clear is instead refused earlier as QueryNotIdempotentException. So the parse-time
classifier and the runtime resolver read the same registry through two different case rules.
The same raw-key bug makes unregister a silent no-op for any caller that unregisters under the name it
registered with, if that name is not already lowercase. Every in-tree caller happens to use a lowercase name
("bigger", "acme9768.twice"), which is why no test catches it.
Where (HEAD 4e6cd88)
- engine/src/main/java/com/arcadedb/function/sql/SQLFunctionFactoryTemplate.java:123-125, where
hasFunctiondoesfunctions.containsKey(name)with no lowercasing - engine/src/main/java/com/arcadedb/function/sql/SQLFunctionFactoryTemplate.java:142-143, where
getFunctionInstancedoes lowercase, which is the asymmetry - engine/src/main/java/com/arcadedb/function/sql/SQLFunctionFactoryTemplate.java:64-65, where
unregister
doesfunctions.remove(name)with no lowercasing - engine/src/main/java/com/arcadedb/function/sql/SQLFunctionFactoryTemplate.java:56 and :79, the two public
register entry points, both of which lowercase, as does the alias mapping they share - engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/CallStep.java:410, the raw-name gate,
and :412, the fallback to the simple name, which is equally case-sensitive - engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/CallStep.java:597, the same raw gate
insidecallSQLFunction - engine/src/main/java/com/arcadedb/query/opencypher/ast/SimpleCypherStatement.java:353-357, where
isConfirmedPureFunctionNamelowercases before asking the same factory - engine/src/main/java/com/arcadedb/function/sql/DefaultSQLFunctionFactory.java:420, where
hasNamespacedFunctionalso lowercases before asking
Repro
SQL is case-insensitive, and so is Cypher in expression position:
OK | SELECT vector.magnitude([3,4]) as v
=> {"v":5.0}
OK | SELECT VECTOR.MAGNITUDE([3,4]) as v
=> {"v":5.0}
OK | SELECT Vector.Magnitude([3,4]) as v
=> {"v":5.0}
OK | cypher:RETURN vector.Magnitude([3,4]) AS v
=> {"v":5.0}
OK | cypher:RETURN VECTOR.MAGNITUDE([3,4]) AS v
=> {"v":5.0}
CALL is not, and the name that fails is the function's own canonical spelling:
OK | cypher:CALL vector.magnitude([3,4]) YIELD value RETURN value
=> {"value":5.0}
ERR | cypher:CALL vector.Magnitude([3,4]) YIELD value RETURN value
=> CommandExecutionException: Unknown procedure/function: vector.Magnitude
ERR | cypher:CALL vector.l2Distance([1,0],[0,1]) YIELD value RETURN value
=> CommandExecutionException: Unknown procedure/function: vector.l2Distance
OK | cypher:CALL vector.l2distance([1,0],[0,1]) YIELD value RETURN value
=> {"value":1.4142135}
ERR | cypher:CALL geo.asText(geo.point(1,2)) YIELD value RETURN value
=> CommandExecutionException: Unknown procedure/function: geo.asText
OK | cypher:CALL geo.astext(geo.point(1,2)) YIELD value RETURN value
=> {"value":"POINT (1 2)"}
ERR | cypher:CALL vector.Dimension([1,2,3]) YIELD value RETURN value
=> CommandExecutionException: Unknown procedure/function: vector.Dimension
OK | cypher:CALL vector.dimension([1,2,3]) YIELD value RETURN value
=> {"value":3}
The registry-level asymmetry, and the silent unregister, from a standalone main() against
engine/target/classes:
hasFunction('vector.l2Distance') = false
hasFunction('vector.l2distance') = true
getFunctionInstance('vector.l2Distance') = vector.l2Distance(<vector1>, <vector2>)
isSharedInstance('vector.l2Distance') = false
isSharedInstance('vector.l2distance') = true
isBuiltIn('vector.l2Distance') = false
isBuiltIn('vector.l2distance') = true
hasNamespacedFunction('vector.l2Distance') = true
after register, instance = true
after unregister('Acme.Twice'), still resolvable = true
after unregister('acme.twice'), still resolvable = false
The last three lines register a function under the string "Acme.Twice" and then unregister it under the same
string.
A function registered as a namespaced CALL target that is not in the Cypher registry (every vector.* and
geo.* built-in) reaches the raw gate; the text., coll., agg., map. and date.* families do not, because
CallStep resolves them one line earlier through CypherFunctionRegistry.get, which normalises. So CALL
text.Format('a %s','b') works while CALL vector.Magnitude(...) does not, which is the shape that makes this
hard to notice.
Refutation attempted
- Is
hasFunctiondocumented as taking a lowercase name? No. The interface it implements,
function/sql/SQLFunctionFactory.java, declaresboolean hasFunction(String iName)with no javadoc at all.
The neighbouringisSharedInstancein the same file does carry a "(lower case)" note, which makes the
silence onhasFunctionlook like an omission rather than a contract. - Is CallStep supposed to be case-sensitive because Cypher procedure names are? Neo4j procedure names are
case-sensitive, but these are not procedures: the chain CallStep falls through reaches the SQL function
factory, whose resolver is case-insensitive, and the Cypher function registry one line earlier is also
case-insensitive. The CALL path is the only one of the three that is not. - Could the fallback to the simple name mask the failure with a wrong answer instead of an error? CALL
vector.Sum(...) falls through to callSQLFunction("Sum"), which hits the same case-sensitive gate and
errors, so no. I looked for a silently-wrong resolution and did not find one; the symptom is a refusal,
not a wrong value. - Is the unregister leak already accepted? The method carries a note that it deliberately does not
unregister from FunctionRegistry. That note is about the other registry. It says nothing about failing to
remove the entry from its own map.
Suggested fix
Lowercase in hasFunction and unregister the way register and getFunctionInstance already do, so the
map's key rule is applied on every side of it rather than at four of six call sites.
The guarantee to ask for: make the key normalisation a property of the map and not of each method, by
holding the entries in a map that normalises on the way in and out, or by routing every access through one
private key(String) helper; then add a test that asserts, for each name in getBuiltInFunctionNames(),
that hasFunction, isBuiltIn, isSharedInstance, getFunctionInstance and a CALL of it all agree for the name
as the function itself spells it in its NAME constant, not only for its lowercase form. The present
tests all use already-lowercase names, which is exactly why a registry whose canonical names are camelCase
passed them.
Scope / confidence
Executed: all of it. The SQL and Cypher statements ran against an embedded database; the registry lines came
from a standalone main() against engine/target/classes.
Dedup
Grepped alltitles.txt in full for "case-sensit", "case sensit", "lowercas", "camelCase", "unregister",
"registry", "hasFunction", "factory", "Unknown procedure". Nearest neighbours: #9768 (CLOSED, the dotted
name is not a function call in the AST so dotted vector aggregates never aggregate) is about the same
resolution chain but about aggregation planning, not case; #10524 (CLOSED) is about the text.camelCase
function, not camelCase names; #10590 (CLOSED) is an unrelated unregister ordering bug in DROP MATERIALIZED
VIEW. No overlap.
Activity
fix(#11145, #11146, #11051, #11029): labelpropagation seeds, personal…
lvca commentedon Nov 2, 2026
Fixed in #11148, available from 26.11.1.
Function names are now case-insensitive on every lookup, so
CALL vector.l2Distance(...),CALL geo.asText(...)and every other camelCase built-in work from CypherCALLunder their own spelling, like they already did inSELECTandRETURN. Unregistering a function also works under any case now, and removes its aliases too.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix(#11145, #11146, #11051, #11029): labelpropagation seeds, personal…