Details

    • New Feature
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None

    Description

      Arrays, like in Postgresql

      This MDEV is about adding ARRAY support as table columns.

      ARRAY for SP variables will be added first by a separate blocker task MDEV-32380.

      Attachments

        Issue Links

          Activity

            maybe we could use dynamic columns and add a "natural sql interface"?

            rspadim roberto spadim added a comment - maybe we could use dynamic columns and add a "natural sql interface"?

            The PostgreSQL implementation looks like this:

            postgres=# CREATE TABLE t1 (id serial, myarray int[]);
            CREATE TABLE
            postgres=# INSERT INTO t1(myarray) VALUES('{1, 2, 4}');
            INSERT 0 1
            postgres=# SELECT * FROM t1;
             id | myarray 
            ----+---------
              1 | {1,2,4}
            (1 row)
            postgres=# SELECT id, myarray[1], myarray[2], myarray[3] FROM t1;
             id | myarray | myarray | myarray 
            ----+---------+---------+---------
              1 |       1 |       2 |       4
            (1 row)

            Docs: http://www.postgresql.org/docs/9.5/static/arrays.html

            It looks like array's are a SQL:2008 feature. It is mentioned as feature S091, “Basic array support” in SQL:2011

            dveeden Daniël van Eeden added a comment - The PostgreSQL implementation looks like this: postgres=# CREATE TABLE t1 (id serial, myarray int[]); CREATE TABLE postgres=# INSERT INTO t1(myarray) VALUES('{1, 2, 4}'); INSERT 0 1 postgres=# SELECT * FROM t1; id | myarray ----+--------- 1 | {1,2,4} (1 row) postgres=# SELECT id, myarray[1], myarray[2], myarray[3] FROM t1; id | myarray | myarray | myarray ----+---------+---------+--------- 1 | 1 | 2 | 4 (1 row) Docs: http://www.postgresql.org/docs/9.5/static/arrays.html It looks like array's are a SQL:2008 feature. It is mentioned as feature S091, “Basic array support” in SQL:2011

            When implementing arrays, we should provide both dynamic and static size arrays.
            Static size arrays would be good for MariaDB Vector where all arrays are always on the same size and we do not need a prefix to store the number of element in the stored data.

            monty Michael Widenius added a comment - When implementing arrays, we should provide both dynamic and static size arrays. Static size arrays would be good for MariaDB Vector where all arrays are always on the same size and we do not need a prefix to store the number of element in the stored data.
            PavelCibulka Pavel Cibulka added a comment - - edited

            Does this enable using array as parameter in "IN()" clause?

            1st example JAVA:

            PreparedStatement preparedSt = connection.prepareStatement("SELECT * FROM customer WHERE id IN(?)"));
            int[] ids = {1, 2, 3, 4, 5};
            preparedSt.setObject(0, ids);
            ResultSet result = preparedStatement.executeQuery();
            

            2nd example SQL:

            SET @ids = {1, 2, 4};
            SELECT * FROM customer WHERE id IN(@ids);
            

            3rd example JAVA:

            PreparedStatement preparedSt = connection.prepareStatement("SELECT * FROM customer WHERE lastname IN(?)"));
            String[] lastnames =  {"Smith", "Johnson"};
            preparedSt.setObject(0, lastnames);
            ResultSet result = preparedStatement.executeQuery();
            

            4th example SQL:

            SET @lastnames = {'Smith', 'Johnson'};
            SELECT * FROM customer WHERE lastname IN(@lastnames);
            

            PavelCibulka Pavel Cibulka added a comment - - edited Does this enable using array as parameter in "IN()" clause? 1st example JAVA: PreparedStatement preparedSt = connection.prepareStatement( "SELECT * FROM customer WHERE id IN(?)" )); int [] ids = { 1 , 2 , 3 , 4 , 5 }; preparedSt.setObject( 0 , ids); ResultSet result = preparedStatement.executeQuery(); 2nd example SQL: SET @ids = {1, 2, 4}; SELECT * FROM customer WHERE id IN (@ids); 3rd example JAVA: PreparedStatement preparedSt = connection.prepareStatement( "SELECT * FROM customer WHERE lastname IN(?)" )); String[] lastnames = { "Smith" , "Johnson" }; preparedSt.setObject( 0 , lastnames); ResultSet result = preparedStatement.executeQuery(); 4th example SQL: SET @lastnames = { 'Smith' , 'Johnson' }; SELECT * FROM customer WHERE lastname IN (@lastnames);

            People

              bar Alexander Barkov
              serg Sergei Golubchik
              Votes:
              15 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.