morrySnow commented on code in PR #67885:
URL: https://github.com/apache/doris/pull/67885#discussion_r4011929389
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java:
##########
@@ -117,12 +160,22 @@ public ShortCircuitQueryContext(Planner planner,
Queriable analzyedQuery) throws
this.tableName = this.scanNode.getTableNameInPlan();
this.schemaVersion = this.tbl.getBaseSchemaVersion();
this.partitionTopologyVersion = this.tbl.getPartitionTopologyVersion();
+ this.tableNamespaceSnapshot = TableNamespaceSnapshot.from(this.tbl);
Review Comment:
Fixed in e5c5fbb0ca2. `SecurityDependencyContext` now captures the checked
table plus the catalog/database object identities and names immediately after
the SELECT check succeeds. `snapshotForShortCircuit` rejects a
check-to-snapshot namespace change; reuse checks the namespace before and after
the current row-policy/privilege validation, and a newly built context is
validated before publication. Added
`testNamespaceChangeBeforeSnapshotFailsClosed`.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java:
##########
@@ -152,4 +263,247 @@ public void sanitize() {
Preconditions.checkNotNull(tbl);
Preconditions.checkNotNull(tableName);
}
+
+ /** Build state owned by one execution without modifying the cached plan
or scan conjuncts. */
+ public PointQueryExecutionContext
createPointQueryExecutionContext(StatementContext statementContext) {
+ return pointQueryKeyTemplate.bind(statementContext);
+ }
+
+ private static class PointQueryKeyTemplate {
+ private final List<Column> keyColumns;
+ private final List<PlaceholderKeyBinding> placeholderBindings;
+ private final List<List<Literal>> fixedConstraints;
+ private final boolean complete;
+
+ private PointQueryKeyTemplate(List<Column> keyColumns,
+ List<PlaceholderKeyBinding> placeholderBindings,
+ List<List<Literal>> fixedConstraints, boolean complete) {
+ this.keyColumns = Collections.unmodifiableList(new
ArrayList<>(keyColumns));
+ this.placeholderBindings = Collections.unmodifiableList(new
ArrayList<>(placeholderBindings));
+ List<List<Literal>> immutableConstraints = new
ArrayList<>(fixedConstraints.size());
+ for (List<Literal> constraints : fixedConstraints) {
+ immutableConstraints.add(Collections.unmodifiableList(new
ArrayList<>(constraints)));
+ }
+ this.fixedConstraints =
Collections.unmodifiableList(immutableConstraints);
+ this.complete = complete;
+ }
+
+ private static PointQueryKeyTemplate unsupported() {
+ return new PointQueryKeyTemplate(Collections.emptyList(),
Collections.emptyList(),
+ Collections.emptyList(), false);
+ }
+
+ private static PointQueryKeyTemplate create(OlapScanNode scanNode,
StatementContext statementContext) {
+ if (statementContext == null) {
+ return unsupported();
+ }
+ List<Column> keyColumns =
scanNode.getOlapTable().getBaseSchemaKeyColumns();
+ if (keyColumns.isEmpty()) {
+ return new PointQueryKeyTemplate(keyColumns,
Collections.emptyList(),
+ Collections.emptyList(), true);
+ }
+ if (!statementContext.arePointQueryFixedKeyConstraintsComplete()) {
+ return unsupported();
+ }
+
+ Map<String, Integer> keyOrdinals = new
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ List<List<Literal>> fixedConstraints = new
ArrayList<>(keyColumns.size());
+ for (int ordinal = 0; ordinal < keyColumns.size(); ordinal++) {
+ keyOrdinals.put(keyColumns.get(ordinal).getName(), ordinal);
+ fixedConstraints.add(new ArrayList<>());
+ }
+
+ List<PlaceholderKeyBinding> placeholderBindings = new
ArrayList<>();
+ for (Map.Entry<PlaceholderId, SlotReference> entry
Review Comment:
Fixed in e5c5fbb0ca2. I removed the PR-added statement-wide fixed-key
tracking from `ExpressionAnalyzer`, `PointQueryExecutionContext`, and the lazy
range-location overload. Eligibility now comes from the exact final
`LogicalFilter` shape: one equality per full key and injective casts only.
`ExecuteCommand` detects placeholders outside `LogicalFilter` and keeps those
statements on normal planning. Added a server-prepared projected-placeholder
regression with different projection and lookup values across executions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]