ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Иван Федотов <ivanan...@gmail.com>
Subject Wrong SQL statement
Date Tue, 17 Oct 2017 08:16:39 GMT
Hello, Igniters!


Currently, if one try to execute `INSERT INTO t1 VALUES(...);` it will be
“IgniteSQLException: Failed to parse query: INSERT INTO Person VALUES(?,?)

…

Caused by: class
org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to
parse query: INSERT INTO Person VALUES(?,?)

…

Caused by: org.h2.jdbc.JdbcSQLException: Неверное количество столбцов”

It looks like a bug, because:


         1.H2 supports format “Insert into t1 values()” [1]

         2.SQL-92 tells us it is a correct query. Paragraph 13.8 - insert
statement, syntax rules[2].


So, I want to create ticket to fix it, what do you think?


Reproducer:


public class IgniteSqlAllColumnsInsertTest extends GridCommonAbstractTest {

   public void testSqlInsert() throws Exception {

       try (Ignite ignite = startGrid(0)) {

           CacheConfiguration<Integer, Integer> cacheCfg = new
CacheConfiguration<Integer, Integer>("CachePerson").setSqlSchema("PUBLIC");


           IgniteCache<Integer, Integer> cache =
ignite.getOrCreateCache(cacheCfg);


           cache.query(new SqlFieldsQuery("CREATE TABLE Person (Name
varchar, Age int, primary key (Name))"));


           // Good query

           QueryCursor<List<?>> cursor = cache.query(

               new SqlFieldsQuery("INSERT INTO Person (Name, Age) VALUES
(?,?)")

                   .setArgs("Alice", 23)

           );


           assertEquals(1L, cursor.getAll().get(0).<Long>get(0));


           // Bad query

           cursor = cache.query(

               new SqlFieldsQuery("INSERT INTO Person VALUES(?,?)")

                   .setArgs("Bob", 25)

           );


           assertEquals(1L, cursor.getAll().get(0).<Long>get(0));

       }

   }

}




[1] http://www.h2database.com/html/history.html


[2]http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt


-- 
Ivan Fedotov.

ivanan639@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message