Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supports_index_sort_order? should return false #16

Closed
yahonda opened this issue Aug 30, 2021 · 3 comments · Fixed by #17
Closed

supports_index_sort_order? should return false #16

yahonda opened this issue Aug 30, 2021 · 3 comments · Fixed by #17

Comments

@yahonda
Copy link
Member

yahonda commented Aug 30, 2021

supports_index_sort_order? defines if the database supports ascending and descending index.

Currently it returns true, however tidb does not support descending index yet then this method should return false until pingcap/tidb#2519 is implemented to TiDB.

Refer rails/rails#28773 for Rails pull request.

@hooopo
Copy link
Contributor

hooopo commented Aug 30, 2021

Yes, you are right. In the current state, the sort order syntax is compatible with tidb ddl, but it is actually ineffective.

my:root@127.0.0.1:4000=> create table a (id bigint primary key, name varchar(255));
my:root@127.0.0.1:4000=> CREATE INDEX idx ON a (name desc);
CREATE INDEX
my:root@127.0.0.1:4000=> show create table a;
 Table | Create Table
-------+-------------------------------------------------------------
 a     | CREATE TABLE "a" (                                         +
       |   "id" bigint(20) NOT NULL,                                +
       |   "name" varchar(255) DEFAULT NULL,                        +
       |   PRIMARY KEY ("id") /*T![clustered_index] CLUSTERED */,   +
       |   KEY "idx" ("name")                                       +
       | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

the Collation column should return 'D' for TiDB.

 show keys from a;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | Clustered |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| a     |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | YES     | NULL       | YES       |
| a     |          1 | idx      |            1 | name        | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               | YES     | NULL       | NO        |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+

@yahonda
Copy link
Member Author

yahonda commented Aug 30, 2021

Thanks for the reply. Let me create a pull request to change supports_index_sort_order?.

@yahonda
Copy link
Member Author

yahonda commented Aug 30, 2021

Opened #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants