[ 
https://issues.apache.org/jira/browse/IGNITE-18492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pavel Pereslegin updated IGNITE-18492:
--------------------------------------
    Description: 
When I create a table with {{CHAR(length)}} column, it's still possible to 
insert character values with length greater than given limit.
{code:sql}
sql-cli> create table xx (pk int primary key, f1 char(5));
Updated 0 rows.
sql-cli> insert into xx values (1, 'abcdefgh');
Updated 1 rows.
sql-cli> select * from xx;
╔════╤══════════╗
║ PK │ F1       ║
╠════╪══════════╣
║ 1  │ abcdefgh ║
╚════╧══════════╝
{code}
In other hand, length limit is applied when I insert non-char value that's 
casted into {{CHAR}} implicitly. With the same table as above:
{code:sql}
sql-cli> insert into xx values (2, 1234567);
Updated 1 rows.
sql-cli> select * from xx;
╔════╤══════════╗
║ PK │ F1       ║
╠════╪══════════╣
║ 2  │ 12345    ║
╟────┼──────────╢
║ 1  │ abcdefgh ║
╚════╧══════════╝
{code}
Behavior should be consistent: ether strip both values down to the given length 
limit, or deny to insert too long values in both cases (like it's done in other 
DBs, like postgresql).

 

Dynamic params can be processed to, check 
IgniteSqlValidator#inferDynamicParamType

NOTE

VARCHAR is also affected
{color:#505f79}^(this note was added so that the ticket would be included in 
the search for the keyword VARCHAR)^{color}

  was:
When I create a table with {{CHAR(length)}} column, it's still possible to 
insert character values with length greater than given limit.
{code:sql}
sql-cli> create table xx (pk int primary key, f1 char(5));
Updated 0 rows.
sql-cli> insert into xx values (1, 'abcdefgh');
Updated 1 rows.
sql-cli> select * from xx;
╔════╤══════════╗
║ PK │ F1       ║
╠════╪══════════╣
║ 1  │ abcdefgh ║
╚════╧══════════╝
{code}
In other hand, length limit is applied when I insert non-char value that's 
casted into {{CHAR}} implicitly. With the same table as above:
{code:sql}
sql-cli> insert into xx values (2, 1234567);
Updated 1 rows.
sql-cli> select * from xx;
╔════╤══════════╗
║ PK │ F1       ║
╠════╪══════════╣
║ 2  │ 12345    ║
╟────┼──────────╢
║ 1  │ abcdefgh ║
╚════╧══════════╝
{code}
Behavior should be consistent: ether strip both values down to the given length 
limit, or deny to insert too long values in both cases (like it's done in other 
DBs, like postgresql).

 

Dynamic params can be processed to, check 
IgniteSqlValidator#inferDynamicParamType

NOTE

VARCHAR is also affected
{color:#505f79}^(the note was added so that the ticket would be included in the 
search for the keyword VARCHAR)^{color}


> SQL: Inconsistent behavior of LENGTH limit for CHAR data type
> -------------------------------------------------------------
>
>                 Key: IGNITE-18492
>                 URL: https://issues.apache.org/jira/browse/IGNITE-18492
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 3.0.0-beta1
>            Reporter: Andrey Khitrin
>            Assignee: Evgeny Stanilovsky
>            Priority: Major
>              Labels: ignite-3, sql
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> When I create a table with {{CHAR(length)}} column, it's still possible to 
> insert character values with length greater than given limit.
> {code:sql}
> sql-cli> create table xx (pk int primary key, f1 char(5));
> Updated 0 rows.
> sql-cli> insert into xx values (1, 'abcdefgh');
> Updated 1 rows.
> sql-cli> select * from xx;
> ╔════╤══════════╗
> ║ PK │ F1       ║
> ╠════╪══════════╣
> ║ 1  │ abcdefgh ║
> ╚════╧══════════╝
> {code}
> In other hand, length limit is applied when I insert non-char value that's 
> casted into {{CHAR}} implicitly. With the same table as above:
> {code:sql}
> sql-cli> insert into xx values (2, 1234567);
> Updated 1 rows.
> sql-cli> select * from xx;
> ╔════╤══════════╗
> ║ PK │ F1       ║
> ╠════╪══════════╣
> ║ 2  │ 12345    ║
> ╟────┼──────────╢
> ║ 1  │ abcdefgh ║
> ╚════╧══════════╝
> {code}
> Behavior should be consistent: ether strip both values down to the given 
> length limit, or deny to insert too long values in both cases (like it's done 
> in other DBs, like postgresql).
>  
> Dynamic params can be processed to, check 
> IgniteSqlValidator#inferDynamicParamType
> NOTE
> VARCHAR is also affected
> {color:#505f79}^(this note was added so that the ticket would be included in 
> the search for the keyword VARCHAR)^{color}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to