Skip to main content
question in title
Link
Jeff Puckett
  • 589
  • 2
  • 6
  • 15

Why is MySQL MariaDB GREATEST(timestamp,NOW()) padding appending results with zeros?

Source Link
Jeff Puckett
  • 589
  • 2
  • 6
  • 15

MySQL MariaDB GREATEST(timestamp,NOW()) padding appending results with zeros

Everything works as expected on my development machine, but when deploying to quality assurance environment, tests are failing because MariaDB is padding the result set with extra precision zeros after a decimal.

For example, when I run this query:

SELECT GREATEST(  '2016-04-14 15:06:30', NOW() )

On dev, running Ubuntu 14.04.4 LTS (Trusty Tahr) mysql Ver 14.14 Distrib 5.5.47, for debian-linux-gnu (x86_64) using readline 6.3, I get this expected result:

2016-04-18 09:07:42

On test, running Red Hat Enterprise Linux Server 7.2 (Maipo) mysql Ver 15.1 Distrib 5.5.44-MariaDB, for Linux (x86_64) using readline 5.1, I get this unexpected result:

2016-04-18 09:07:42.000000

I don't see anything in the GREATEST() documentation that would explain this behavior, so I think it must be a server configuration setting in my.cnf but I couldn't find anything in online search results.

Even more curiously, when running the following queries, I get the same unpadded results on both machines:

SELECT GREATEST(  '2016-04-14 15:06:30', '2016-04-14 16:06:30' )

2016-04-14 16:06:30

SELECT GREATEST(  NOW(), NOW() )

2016-04-18 09:24:22

SELECT GREATEST(  5, 10 )

10

Why is MariaDB GREATEST() padding/appending my result set with zeros on timestamp comparison with NOW()?