WordPress / sqlite-database-integration

Feature Plugin to add SQLite support to WordPress. Under Development.
GNU General Public License v2.0
223 stars 37 forks source link

Identifiers for keys are too long in `show create` output #124

Closed jeroenpf closed 2 months ago

jeroenpf commented 2 months ago

When running show create queries, the output returns a create statement that has new key names that exceed the 64-character limit for key identifiers in MySQL.

Here is an example of such a table:

CREATE TABLE wp_woocommerce_downloadable_product_permissions (
    `permission_id` bigint(20) unsigned PRIMARY KEY AUTO_INCREMENT NOT NULL,
    ...
    `download_count` bigint(20) unsigned NOT NULL,
    KEY wp_woocommerce_downloadable_product_permissions__user_order_remaining_expires (user_id, order_id, downloads_remaining, access_expires),
    KEY wp_woocommerce_downloadable_product_permissions__order_id (order_id),
    KEY wp_woocommerce_downloadable_product_permissions__download_order_product (download_id, order_id, product_id),
    KEY wp_woocommerce_downloadable_product_permissions__download_order_key_product (product_id, order_id, order_key, download_id)
);

Additionally, the key names do not match those of the original MySQL table:

CREATE TABLE `wp_woocommerce_downloadable_product_permissions` (
   `permission_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   ...
   `download_count` bigint(20) unsigned NOT NULL DEFAULT 0,
   PRIMARY KEY (`permission_id`),
   KEY `download_order_key_product` (`product_id`,`order_id`,`order_key`(16),`download_id`),
   KEY `download_order_product` (`download_id`,`order_id`,`product_id`),
   KEY `order_id` (`order_id`),
   KEY `user_order_remaining_expires` (`user_id`,`order_id`,`downloads_remaining`,`access_expires`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

We should either use the original key names or generate names that are no longer than 64 characters.