I maintain Beekeeper Studio, an open source SQL GUI.
I have a problem with information_schema.columns
in MySQL 5.7.
when running:
select * from information_schema.columns where table_name = ?`
It returns the COLUMN_DEFAULT
, but it doesn't seem to differentiate between variables (eg CURRENT_TIMESTAMP), and a string 'foo'.
Is there a place I can get the 'real' default value with appropriate quoting?
What I expect:
CURRENT_TIMESTAMP
'foo'
Unfortunately, there's no metadata in the INFORMATION_SCHEMA that can tell you this in MySQL 5.7. You just have to know that for a DATETIME or TIMESTAMP column, CURRENT_TIMESTAMP is a special case.
It is treated as a special case in the code, so if you use SHOW CREATE TABLE, it outputs the literal string "CURRENT_TIMESTAMP" instead of a quoted datetime value.
https://github.com/mysql/mysql-server/blob/5.7/sql/sql_show.cc#L1402-L1411