{"record":{"id":"e01cfbdcd2bf002b","repo":"apache/shardingsphere","slug":"unsupported-returning-expression","errorCode":null,"errorMessage":"Unsupported Returning Expression","messagePattern":"Unsupported Returning Expression","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java","lineNumber":1055,"sourceCode":"        }\n        return new ReturningSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), projections);\n    }\n    \n    private ProjectionSegment createReturningProjection(final ExprContext ctx) {\n        ASTNode projection = visit(ctx);\n        if (projection instanceof ProjectionSegment) {\n            return (ProjectionSegment) projection;\n        }\n        if (projection instanceof ComplexExpressionSegment) {\n            return (ProjectionSegment) createProjectionForComplexExpressionSegment(projection, null);\n        }\n        if (projection instanceof SimpleExpressionSegment) {\n            return createExpressionProjectionSegment((ExpressionSegment) projection, null);\n        }\n        if (projection instanceof ExpressionSegment) {\n            return (ProjectionSegment) createProjectionForExpressionSegment(projection, null);\n        }\n        throw new UnsupportedOperationException(\"Unsupported Returning Expression\");\n    }\n    \n    @Override\n    public ASTNode visitSelectList(final SelectListContext ctx) {\n        ProjectionsSegment result = new ProjectionsSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex());\n        Collection<ProjectionSegment> projections = new LinkedList<>();\n        if (null != ctx.unqualifiedShorthand()) {\n            projections.add(new ShorthandProjectionSegment(ctx.unqualifiedShorthand().getStart().getStartIndex(), ctx.unqualifiedShorthand().getStop().getStopIndex()));\n            result.getProjections().addAll(projections);\n            return result;\n        }\n        for (SelectProjectionContext each : ctx.selectProjection()) {\n            projections.add((ProjectionSegment) visit(each));\n        }\n        result.getProjections().addAll(projections);\n        return result;\n    }\n    ","sourceCodeStart":1037,"sourceCodeEnd":1073,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java#L1037-L1073","documentation":"Thrown by OracleDMLStatementVisitor when a RETURNING clause projection cannot be mapped: createProjection handles ProjectionSegment, ComplexExpressionSegment, SimpleExpressionSegment, and generic ExpressionSegment, and throws UnsupportedOperationException('Unsupported Returning Expression') for anything else. It is a visitor coverage gap — the parsed AST node type has no projection mapping rule, not a user syntax error.","triggerScenarios":"Oracle INSERT/UPDATE/DELETE ... RETURNING with an exotic expression whose visited AST node implements none of the four recognized segment interfaces: e.g. special PL/SQL-ish expressions, newly added segment types from newer grammars, or dialect-specific function segments.","commonSituations":"Using RETURNING with unusual expressions in Oracle-sharded tables; ShardingSphere version where the Oracle RETURNING grammar accepts an expression the visitor cannot classify; upgrading adds new segment types not yet wired into this chain.","solutions":["Simplify the RETURNING list to plain columns or simple expressions","Move the complex computation out of RETURNING (e.g. return the column, compute in the app)","Upgrade ShardingSphere — visitor coverage for RETURNING expressions improves across releases","If extending the project, add a branch mapping the missing segment type in createProjection"],"exampleFix":"// before\nINSERT INTO t (id) VALUES (seq.NEXTVAL) RETURNING id*2+1 INTO x\n\n// after\nINSERT INTO t (id) VALUES (seq.NEXTVAL) RETURNING id INTO x","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { parserEngine.parse(sql); }\ncatch (UnsupportedOperationException e) {\n    // coverage gap, not bad syntax: simplify the RETURNING list and retry once with plain columns\n    log.warn(\"Unsupported RETURNING expression, falling back to column-only RETURNING\", e);\n}","preventionTips":["Keep RETURNING lists to plain columns","Test every RETURNING shape you use against the exact ShardingSphere version in CI"],"tags":["oracle","dml","returning-clause","visitor","unsupported"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}