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

Taras Ledkov updated IGNITE-16098:
----------------------------------
    Description: 
There are two cases that breaks consistency between indexes and data and may be 
cause of break index tree.

*1. Put different entities that are logically same for SQL*
{{CREATE TABLE TEST(ID0 INT, ID1 INT, VAL int) WITH 
"KEY_TYPE=MyType,CACHE_NAME=test"}};

then create to keys with hidden field and put to cache test.
{code}
 BinaryObjectBuilder bobKey0 = grid(0).binary().builder("MyType");
            bobKey0.setField("ID0", 0);
            bobKey0.setField("ID1", 0);
            bobKey0.setField("hidden", 0);

 BinaryObjectBuilder bobKey1 = grid(0).binary().builder("MyType");
            bobKey0.setField("ID0", 0);
            bobKey0.setField("ID1", 0);
            bobKey0.setField("hidden", 1);
{code}
These key object are different  by hidden field and cache will contains two 
entries.
But (ID0, ID1) fields are same and sorted PK index will contain only one record.

Now this case is applied only for SQL CREATE TABLE and cannot be reproduced via 
cache API.
Because PK fields are unwrap only for SQL tables. 
Different functions of the cache API and SQL API should be fixed by 
IGNITE-11402.
It should be possible to create identical tables by SQL and cache API.

*2. Object with different key types*
Now the value type is specify the table. If the value type doesn't not equal to 
value type specified by the {{QueryEntity#valueType}} the entity is not indexed 
(not applied fr the table).
But {{QueryEntity#keyType}} isn't used to validate entry on insertion. Only 
fields of inserted entry are validated.
Only {{QueryBinaryProperty#field}} is prevent of insertion the keys with 
different types. Such insertion produce critical error.
But this property is set up on the first insertion. May be it is implemented 

  was:
There are two cases that breaks consistency between indexes and data and may be 
cause of break index tree.

*1. Put different entities that are logically same for SQL*
{{CREATE TABLE TEST(ID0 INT, ID1 INT, VAL int) WITH 
"KEY_TYPE=MyType,CACHE_NAME=test"}};

then create to keys with hidden field and put to cache test.
{code}
 BinaryObjectBuilder bobKey0 = grid(0).binary().builder("MyType");
            bobKey0.setField("ID0", 0);
            bobKey0.setField("ID1", 0);
            bobKey0.setField("hidden", 0);

 BinaryObjectBuilder bobKey1 = grid(0).binary().builder("MyType");
            bobKey0.setField("ID0", 0);
            bobKey0.setField("ID1", 0);
            bobKey0.setField("hidden", 1);
{code}
These key object are different  by hidden field and cache will contains two 
entries.
But (ID0, ID1) fields are same and sorted PK index will contain only one record.

Now this case is applied only for SQL CREATE TABLE and cannot be reproduced via 
cache API.
Because PK fields are unwrap only for SQL tables. 
Different functions of the cache API and SQL API should be fixed by 
IGNITE-11402.
It should be possible to create identical tables by SQL and cache API.

*2. Object with different key types*
Now the value type is specify the table. If the value type doesn't not equal to 
value type specified by the {{QueryEntity#keyType}} the entity is not indexed 
(not applied fr the table).


> Key type and schema must be validated on a data inserttion
> ----------------------------------------------------------
>
>                 Key: IGNITE-16098
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16098
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.11
>            Reporter: Taras Ledkov
>            Assignee: Taras Ledkov
>            Priority: Major
>             Fix For: 2.13
>
>
> There are two cases that breaks consistency between indexes and data and may 
> be cause of break index tree.
> *1. Put different entities that are logically same for SQL*
> {{CREATE TABLE TEST(ID0 INT, ID1 INT, VAL int) WITH 
> "KEY_TYPE=MyType,CACHE_NAME=test"}};
> then create to keys with hidden field and put to cache test.
> {code}
>  BinaryObjectBuilder bobKey0 = grid(0).binary().builder("MyType");
>             bobKey0.setField("ID0", 0);
>             bobKey0.setField("ID1", 0);
>             bobKey0.setField("hidden", 0);
>  BinaryObjectBuilder bobKey1 = grid(0).binary().builder("MyType");
>             bobKey0.setField("ID0", 0);
>             bobKey0.setField("ID1", 0);
>             bobKey0.setField("hidden", 1);
> {code}
> These key object are different  by hidden field and cache will contains two 
> entries.
> But (ID0, ID1) fields are same and sorted PK index will contain only one 
> record.
> Now this case is applied only for SQL CREATE TABLE and cannot be reproduced 
> via cache API.
> Because PK fields are unwrap only for SQL tables. 
> Different functions of the cache API and SQL API should be fixed by 
> IGNITE-11402.
> It should be possible to create identical tables by SQL and cache API.
> *2. Object with different key types*
> Now the value type is specify the table. If the value type doesn't not equal 
> to value type specified by the {{QueryEntity#valueType}} the entity is not 
> indexed (not applied fr the table).
> But {{QueryEntity#keyType}} isn't used to validate entry on insertion. Only 
> fields of inserted entry are validated.
> Only {{QueryBinaryProperty#field}} is prevent of insertion the keys with 
> different types. Such insertion produce critical error.
> But this property is set up on the first insertion. May be it is implemented 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to