What type of bug is this?
Incorrect result, User Experience
What subsystems are affected?
Frontend, Query Engine, Write Protocols
Minimal reproduce step
Run logically equivalent SQL through the HTTP SQL API and through the MySQL protocol/client, using double quotes for identifiers.
For example, HTTP/UI SQL commonly accepts PostgreSQL-style quoted identifiers:
SELECT *
FROM k8s_resources."kube_pod_container_resource_limits_cpu_cores:sum"
WHERE "namespace" >= 'y'
ORDER BY "greptime_timestamp" DESC
LIMIT 1;
Then run the same or similar SQL through a MySQL client/protocol connection:
SELECT *
FROM k8s_resources."kube_pod_container_resource_limits_cpu_cores:sum"
WHERE namespace >= 'y'
ORDER BY "greptime_timestamp" DESC
LIMIT 1;
In the MySQL dialect/protocol, double quotes may be parsed as string literals unless ANSI_QUOTES-style behavior is enabled. As a result, ORDER BY "greptime_timestamp" can be planned as ordering by a constant string, e.g. Utf8("greptime_timestamp"), rather than ordering by the greptime_timestamp column.
This is easy to hit when users copy SQL from HTTP/UI output or examples into a MySQL client.
What did you expect to see?
The same SQL text should not silently change semantics across GreptimeDB protocols without an obvious warning/error.
Possible acceptable behaviors:
- MySQL protocol supports/documented
ANSI_QUOTES behavior for double-quoted identifiers;
- or MySQL protocol rejects/warns on suspicious double-quoted identifiers like
"greptime_timestamp" when they look like column names;
- or documentation clearly states that MySQL clients must use backticks or unquoted identifiers, for example:
ORDER BY `greptime_timestamp` DESC
WHERE `namespace` >= 'y'
What did you see instead?
The HTTP SQL interface and MySQL protocol can interpret double quotes differently:
- HTTP SQL:
"greptime_timestamp" is treated as an identifier.
- MySQL protocol/client:
"greptime_timestamp" can be treated as a string literal.
This can silently produce a different logical/physical plan. In the observed case, the MySQL plan sorted by a constant Utf8("greptime_timestamp") instead of the timestamp column. That changes optimizer behavior for ORDER BY ... LIMIT, TopK, dynamic filters, and scan planning, and is very misleading during performance investigation.
What operating system did you use?
Linux x86_64
What version of GreptimeDB did you use?
Observed against a GreptimeDB server reporting 8.4.2 GreptimeDB via MySQL protocol.
Relevant log output and stack trace
Relevant plan symptom from MySQL protocol investigation:
ORDER BY "greptime_timestamp" was planned as sorting by a constant Utf8("greptime_timestamp") instead of column greptime_timestamp.
The issue is not limited to this specific table/query; it is a protocol/dialect consistency and UX problem.
What type of bug is this?
Incorrect result, User Experience
What subsystems are affected?
Frontend, Query Engine, Write Protocols
Minimal reproduce step
Run logically equivalent SQL through the HTTP SQL API and through the MySQL protocol/client, using double quotes for identifiers.
For example, HTTP/UI SQL commonly accepts PostgreSQL-style quoted identifiers:
Then run the same or similar SQL through a MySQL client/protocol connection:
In the MySQL dialect/protocol, double quotes may be parsed as string literals unless
ANSI_QUOTES-style behavior is enabled. As a result,ORDER BY "greptime_timestamp"can be planned as ordering by a constant string, e.g.Utf8("greptime_timestamp"), rather than ordering by thegreptime_timestampcolumn.This is easy to hit when users copy SQL from HTTP/UI output or examples into a MySQL client.
What did you expect to see?
The same SQL text should not silently change semantics across GreptimeDB protocols without an obvious warning/error.
Possible acceptable behaviors:
ANSI_QUOTESbehavior for double-quoted identifiers;"greptime_timestamp"when they look like column names;What did you see instead?
The HTTP SQL interface and MySQL protocol can interpret double quotes differently:
"greptime_timestamp"is treated as an identifier."greptime_timestamp"can be treated as a string literal.This can silently produce a different logical/physical plan. In the observed case, the MySQL plan sorted by a constant
Utf8("greptime_timestamp")instead of the timestamp column. That changes optimizer behavior forORDER BY ... LIMIT, TopK, dynamic filters, and scan planning, and is very misleading during performance investigation.What operating system did you use?
Linux x86_64
What version of GreptimeDB did you use?
Observed against a GreptimeDB server reporting
8.4.2 GreptimeDBvia MySQL protocol.Relevant log output and stack trace
Relevant plan symptom from MySQL protocol investigation:
The issue is not limited to this specific table/query; it is a protocol/dialect consistency and UX problem.