The function works on MySQL server well but it can not create a table on the MariaDB server. What could be the problem?

    public function create_table() {
    $current_version = get_option('wpsm_db_table_version');
    if($current_version && $current_version == $this->db_version && $this->db->get_var("SHOW TABLES LIKE '$this->table_name'") == $this->table_name){

    $sql = "CREATE TABLE ". $this->table_name ." (
            id bigint(20) unsigned NOT NULL auto_increment,
            name varchar(255) NOT NULL default '',
            rows int(11) NOT NULL default 0,
            cols int(11) NOT NULL default 0,
            subs varchar(255) NOT NULL default '',
            color varchar(255) NOT NULL default '',
            responsive tinyint(1) DEFAULT '0',
            tvalues longtext NOT NULL,
            UNIQUE KEY id (id)
            ) $this->charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );

    // since v.1.1
    if($this->db->get_var("SHOW TABLES LIKE '$this->old_table_name'") == $this->old_table_name){

    update_option('wpsm_db_table_version', $this->db_version);

This is a record from the log file:

WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'rows int(11) NOT NULL default 0,
            cols int(11) NOT NULL default 0,
            subs v' at line 4 for query CREATE TABLE...
  • Have a problem that is probably the same with WordPress's dbDelta() on recent MariaDB; it has worked with no problem on MySQL for years, and I can't see any comments or otherwise obvious strangeness in the table declaration. Any ideas appreciated! – Brian C Sep 15 '19 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.