未验证 提交 208b8192 编写于 作者: Z zjcnb 提交者: GitHub

add sql state and vendor code for this (#4768)

* add sql state and vendor code for this

* modify the variable name.

* update vendor code

* modify the variable name and check reason
上级 3df3a21c
......@@ -27,4 +27,8 @@ import lombok.NoArgsConstructor;
public final class SQLExceptionConstant {
public static final String SQL_STRING_NULL_OR_EMPTY = "SQL String can not be NULL or empty.";
public static final String COLUMN_INDEX_OUT_OF_RANGE = "Column index out of range.";
public static final String OUT_OF_INDEX_SQL_STATE = "S1002";
}
......@@ -19,6 +19,7 @@ package org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.shardingjdbc.jdbc.adapter.WrapperAdapter;
import org.apache.shardingsphere.shardingjdbc.jdbc.core.constant.SQLExceptionConstant;
import org.apache.shardingsphere.sql.parser.binder.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.binder.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
......@@ -89,8 +90,7 @@ public final class EncryptResultSetMetaData extends WrapperAdapter implements Re
if (sqlStatementContext instanceof SelectStatementContext) {
List<Projection> actualProjections = ((SelectStatementContext) sqlStatementContext).getProjectionsContext().getExpandProjections();
if (column > actualProjections.size()) {
// TODO fill correct SQL state
throw new SQLException(String.format("Out of index of projection %s", column));
throw new SQLException(SQLExceptionConstant.COLUMN_INDEX_OUT_OF_RANGE, SQLExceptionConstant.OUT_OF_INDEX_SQL_STATE, 0);
}
Projection projection = ((SelectStatementContext) sqlStatementContext).getProjectionsContext().getExpandProjections().get(column - 1);
if (projection instanceof ColumnProjection) {
......
......@@ -20,6 +20,7 @@ package org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.core.rule.ShardingRule;
import org.apache.shardingsphere.shardingjdbc.jdbc.adapter.WrapperAdapter;
import org.apache.shardingsphere.shardingjdbc.jdbc.core.constant.SQLExceptionConstant;
import org.apache.shardingsphere.sql.parser.binder.segment.select.projection.Projection;
import org.apache.shardingsphere.sql.parser.binder.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
......@@ -92,8 +93,7 @@ public final class ShardingResultSetMetaData extends WrapperAdapter implements R
if (sqlStatementContext instanceof SelectStatementContext) {
List<Projection> actualProjections = ((SelectStatementContext) sqlStatementContext).getProjectionsContext().getExpandProjections();
if (column > actualProjections.size()) {
// TODO fill correct SQL state
throw new SQLException(String.format("Out of index of projection %s", column));
throw new SQLException(SQLExceptionConstant.COLUMN_INDEX_OUT_OF_RANGE, SQLExceptionConstant.OUT_OF_INDEX_SQL_STATE, 0);
}
Projection projection = ((SelectStatementContext) sqlStatementContext).getProjectionsContext().getExpandProjections().get(column - 1);
if (projection instanceof ColumnProjection) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册