Skip to content

Commit

Permalink
Fix NPE occurs when execute DML without use database #28918 (#29123)
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoFly authored Nov 25, 2023
1 parent 525d1d3 commit 75f48c2
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.shardingsphere.infra.database.postgresql.type.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.exception.TableNotExistsException;
import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
import org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
Expand Down Expand Up @@ -79,6 +80,7 @@ public static SimpleTableSegment bind(final SimpleTableSegment segment, final SQ
fillPivotColumnNamesInBinderContext(segment, statementBinderContext);
IdentifierValue originalDatabase = getDatabaseName(segment, statementBinderContext);
IdentifierValue originalSchema = getSchemaName(segment, statementBinderContext);
ShardingSpherePreconditions.checkNotNull(originalDatabase.getValue(), NoDatabaseSelectedException::new);
checkTableExists(segment.getTableName().getIdentifier().getValue(), statementBinderContext, originalDatabase.getValue(), originalSchema.getValue());
ShardingSphereSchema schema = statementBinderContext.getMetaData().getDatabase(originalDatabase.getValue()).getSchema(originalSchema.getValue());
tableBinderContexts.put((segment.getAliasName().orElseGet(() -> segment.getTableName().getIdentifier().getValue())).toLowerCase(),
Expand Down

0 comments on commit 75f48c2

Please sign in to comment.