You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/10 06:42:24 UTC
[GitHub] [shardingsphere] TeslaCN opened a new issue, #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
TeslaCN opened a new issue, #14686:
URL: https://github.com/apache/shardingsphere/issues/14686
## Bug Report
### Which version of ShardingSphere did you use?
master - b1322174a5659cf6889f8209e01d711b44d16c3a
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
Proxy
### Expected behavior
Preview the following SQL:
```sql
preview insert into sbtest1 (id, k, c, pad) values ($1, $2, $3, $4);
preview insert into sbtest1 (id, k, c, pad) values (?, ?, ?, ?);
```
### Actual behavior
```
sbtest_sharding=> preview insert into sbtest1 (id, k, c, pad) values ($1, $2, $3, $4);
ERROR: toIndex = 4
sbtest_sharding=> preview insert into sbtest1 (id, k, c, pad) values (?, ?, ?, ?);
ERROR: toIndex = 4
```
```
[ERROR] 2022-01-11 16:31:52.826 [Connection-3-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.IndexOutOfBoundsException: toIndex = 4
at java.util.SubList.<init>(AbstractList.java:622)
at java.util.RandomAccessSubList.<init>(AbstractList.java:775)
at java.util.AbstractList.subList(AbstractList.java:484)
at org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext.getParameters(InsertValueContext.java:66)
at org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext.<init>(InsertValueContext.java:52)
at org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext.getInsertValueContexts(InsertStatementContext.java:108)
at org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext.<init>(InsertStatementContext.java:78)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:140)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:114)
at org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.PreviewDistSQLBackendHandler.execute(PreviewDistSQLBackendHandler.java:80)
at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:73)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:96)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:69)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[ERROR] 2022-01-11 16:31:55.660 [Connection-3-ThreadExecutor] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
java.lang.IndexOutOfBoundsException: toIndex = 4
at java.util.SubList.<init>(AbstractList.java:622)
at java.util.RandomAccessSubList.<init>(AbstractList.java:775)
at java.util.AbstractList.subList(AbstractList.java:484)
at org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext.getParameters(InsertValueContext.java:66)
at org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext.<init>(InsertValueContext.java:52)
at org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext.getInsertValueContexts(InsertStatementContext.java:108)
at org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext.<init>(InsertStatementContext.java:78)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.getDMLStatementContext(SQLStatementContextFactory.java:140)
at org.apache.shardingsphere.infra.binder.SQLStatementContextFactory.newInstance(SQLStatementContextFactory.java:114)
at org.apache.shardingsphere.proxy.backend.text.distsql.ral.advanced.PreviewDistSQLBackendHandler.execute(PreviewDistSQLBackendHandler.java:80)
at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:73)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:96)
at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:69)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
```sql
create table sbtest1
(
id integer not null
primary key,
k integer default 0 not null,
c char(120) default ''::bpchar not null,
pad char(60) default ''::bpchar not null
);
create index k_1
on sbtest1 (k);
```
```yaml
schemaName: sbtest_sharding
dataSources:
ds_0:
url: jdbc:postgresql://127.0.0.1:5432/sbtest_0
username: postgres
password: postgres
connectionTimeoutMilliseconds: 3000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 32
minPoolSize: 0
ds_1:
url: jdbc:postgresql://127.0.0.1:5432/sbtest_1
username: postgres
password: postgres
connectionTimeoutMilliseconds: 3000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 32
minPoolSize: 0
rules:
- !SHARDING
tables:
sbtest1:
actualDataNodes: ds_${0..1}.sbtest1_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_1
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest2:
actualDataNodes: ds_${0..1}.sbtest2_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_2
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest3:
actualDataNodes: ds_${0..1}.sbtest3_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_3
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest4:
actualDataNodes: ds_${0..1}.sbtest4_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_4
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest5:
actualDataNodes: ds_${0..1}.sbtest5_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_5
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest6:
actualDataNodes: ds_${0..1}.sbtest6_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_6
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest7:
actualDataNodes: ds_${0..1}.sbtest7_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_7
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest8:
actualDataNodes: ds_${0..1}.sbtest8_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_8
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest9:
actualDataNodes: ds_${0..1}.sbtest9_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_9
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
sbtest10:
actualDataNodes: ds_${0..1}.sbtest10_${0..9}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: table_inline_10
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
defaultDatabaseStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: database_inline
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm-expression: ds_${id % 2}
allow-range-query-with-inline-sharding: true
table_inline_1:
type: INLINE
props:
algorithm-expression: sbtest1_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_2:
type: INLINE
props:
algorithm-expression: sbtest2_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_3:
type: INLINE
props:
algorithm-expression: sbtest3_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_4:
type: INLINE
props:
algorithm-expression: sbtest4_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_5:
type: INLINE
props:
algorithm-expression: sbtest5_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_6:
type: INLINE
props:
algorithm-expression: sbtest6_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_7:
type: INLINE
props:
algorithm-expression: sbtest7_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_8:
type: INLINE
props:
algorithm-expression: sbtest8_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_9:
type: INLINE
props:
algorithm-expression: sbtest9_${id % 10}
allow-range-query-with-inline-sharding: true
table_inline_10:
type: INLINE
props:
algorithm-expression: sbtest10_${id % 10}
allow-range-query-with-inline-sharding: true
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 123
```
--
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] TeslaCN closed issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
Posted by GitBox <gi...@apache.org>.
TeslaCN closed issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
URL: https://github.com/apache/shardingsphere/issues/14686
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] commented on issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #14686:
URL: https://github.com/apache/shardingsphere/issues/14686#issuecomment-1272350456
Hello , this issue has not received a reply for several days.
This issue is supposed to be closed.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] github-actions[bot] closed issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
URL: https://github.com/apache/shardingsphere/issues/14686
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tuichenchuxin commented on issue #14686: `IndexOutOfBoundsException` occurred when previewing insert SQL
Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on issue #14686:
URL: https://github.com/apache/shardingsphere/issues/14686#issuecomment-1179546943
@TeslaCN I found `sbtest1` is sharding table and `id` is sharding column. So we need to get sharding value. but there is no parameter. So error occurs.
use this sql will be ok.
```
sbtest_sharding=> preview insert into sbtest1 (id, k, c, pad) values (1, ?, ?, ?);
data_source_name | actual_sql
------------------+-----------------------------------------------------------
ds_1 | insert into sbtest1_1 (id, k, c, pad) values (1, ?, ?, ?)
(1 row)
```
And I found `PreviewHandler` set parameters is always empty. If we need to support perview with parameter, We need to set parameters for `LogicSQL`
![image](https://user-images.githubusercontent.com/86938616/178108200-28c2ee43-bcdd-44e4-a997-49ad0934a635.png)
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org