Skip to content

When checking current timestamps, make audit replace mysql function usage with preferred CURRENT_TIMESTAMP variable #4079

@yingbaiibm

Description

@yingbaiibm

When running audit_database.php under mariadb 10.3.17 found below error
current_timestamp

Reproduce steps:

  1. Prepare two env, mariadb 5.5 and mariadb 10.3.17 with both collation_server = utf8mb4_unicode_ci set in my.cnf
  2. create a table in cacti DB
    [root@lsf1x200 ~]# mysql cacti -e "desc disku_groups;"
    +-----------+------------------+------+-----+---------------------+-------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    +-----------+------------------+------+-----+---------------------+-------------------------------+
    | domain | varchar(20) | NO | PRI | | |
    | name | varchar(64) | NO | PRI | | |
    | groupid | int(10) unsigned | NO | PRI | 0 | |
    | firstSeen | timestamp | NO | | 0000-00-00 00:00:00 | |
    | lastSeen | timestamp | NO | | current_timestamp() | on update current_timestamp() |
    +-----------+------------------+------+-----+---------------------+-------------------------------+
  3. Check audit_schema.sql
    INSERT INTO table_columns VALUES ('disku_groups',5,'lastSeen','timestamp','NO','','CURRENT_TIMESTAMP','on update CURRENT_TIMESTAMP');
  4. Run audit_database.php under mariadb 5.5 env, no error exist
  5. Run audit_database.php under mariadb 10 env, error exist as show in screenshot.
  6. Run mysql cacti -e "show table status" to check table collection value, on mariadb 5.5, collection value for this table is utf8mb4_unicode_ci, but on mariadb 10, collection value for this table is utf8mb4_general_ci.
  7. The audit_database.php does not deal with utf8mb4_general_ci to cause this error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions