Live data from Hacker News

Time for a WTF MySQL Moment

gbl08ma.com

41–50 of 121 posts

Re: Time for a WTF MySQL Moment

#41

Earlier quoted context omitted.

The author had no specific expectations. The author received a report of an error, investigated, found that MySQL's TIME did not match EF Core's expectations for a timespan (hence causing the error): > for a brief moment I assumed the incorrection in this value was the hundreds of hours, as one could reasonably assume that maybe TIME values were capped at 24 hours, or that a different syntax was needed for values spa…

> I prefer PostgreSQL for reasons that will soon become self-evident This outlines his expectations, and his biases, quite clearly. Also see: the title of the article.

> This outlines his expectations, and his biases

No, it does not. What it does is explain why they are admittedly "not too experienced with MySQL" and didn't straight remember that obviously the range of MySQL's TIME type is '-838:59:59' to '838:59:59' so 960 would be out of range.

Also please don't staple dicks onto people, the author's gender is irrelevant to the article and it's very disturbing.

> Also see: the title of the article.

The title of the article, and the introduction you're quoting, follow from the article itself. Unless you're calling the author a liar and think they made up the entire thing just to bash mysql.

That the author ultimately considers the behaviour of MySQL's TIME type and its bounds "a WTF"… is entirely defensible.

Re: Time for a WTF MySQL Moment

#42

A list of MySQL WTFs: https://grinnz.com/stuff/lolmysql.txt

Nice

These three points has made me raving mad from working with mysql:

- The default 'latin1' character set is in fact cp1252, not ISO-8859-1, meaning it contains the extra characters in the Windows codepage. 'latin2', however, is ISO-8859-2. - The 'utf8' character set is limited to unicode characters that encode to 1-3 bytes in UTF-8. 'utf8mb4' was added in MySQL 5.5.3 and supports up to 4-byte encoded characters. UTF-8 has been defined to encode characters to up to 4 bytes since 2003. - Neither the 'utf8' nor 'utf8mb4' character sets have any case sensitive collation other than 'utf8_bin' and 'utf8mb4_bin', which sort characters by their numeric codepoint.

utf8 being effectively alias of utf8mb3 has cost us so much work its not even funny.

Re: Time for a WTF MySQL Moment

#43
post #19

I'm a big fan of Postgres too for a number of reasons, but this issue is pretty clearly documented so I'd like to counter with an issue I hit in Postgres recently that is terribly documented. UNNEST works a bit funky, and in particular it works super funky if you have multiple calls in the same select statement (or any set expanded function calls it turns out). There's a bit of a dive into here[1] (though that is out…

> I'm a big fan of Postgres too for a number of reasons, but this issue is pretty clearly documented

Of course it is, the documentation is where TFAA got the information in the 4th paragraph of the story, out of 15 or so.

The range itself is what nerd-sniped the author and led them to try and find out why mysql had such an odd yet specific range.

Re: Time for a WTF MySQL Moment

#44
post #19

I'm a big fan of Postgres too for a number of reasons, but this issue is pretty clearly documented so I'd like to counter with an issue I hit in Postgres recently that is terribly documented. UNNEST works a bit funky, and in particular it works super funky if you have multiple calls in the same select statement (or any set expanded function calls it turns out). There's a bit of a dive into here[1] (though that is out…

> I hit in Postgres recently that is terribly documented.

I'm going to have to disagree with you there. This issue is quite well documented in the "SQL Functions Returning Sets" section [0]. The relevant bit starts thusly:

> ...Set-returning functions can be nested in a select list, although that is not allowed in FROM-clause items. In such cases, each level of nesting is treated separately, as though it were a separate LATERAL ROWS FROM( ... ) item...

And there's even a note about the crazy behavior pre-PostgreSQL 10:

> Before PostgreSQL 10, putting more than one set-returning function in the same select list did not behave very sensibly unless they always produced equal numbers of rows. Otherwise, what you got was a number of output rows equal to the least common multiple of the numbers of rows produced by the set-returning functions. Also, nested set-returning functions did not work as described above; instead, a set-returning function could have at most one set-returning argument, and each nest of set-returning functions was run independently. Also, conditional execution (set-returning functions inside CASE etc) was previously allowed, complicating things even more. Use of the LATERAL syntax is recommended when writing queries that need to work in older PostgreSQL versions, because that will give consistent results across different versions.

I agree that allowing SRFs in the SELECT clause is a wart that should never have been permitted, but I think the PostgreSQL docs do a pretty great job describing both the old behavior and the new behavior that has to balance backwards compatibility with sensibility.

(And, indeed, the 9.6 docs have this to say on the behavior of SRFs in the SELECT list: "The key problem with using set-returning functions in the select list, rather than the FROM clause, is that putting more than one set-returning function in the same select list does not behave very sensibly.")

I do think one notable defect with the PostgreSQL docs is that they were designed in a time before modern search engines. They are better understood as a written manual in electronic form. Almost always the information you need is there, but possibly not in the chapter that Google will surface. But there are all sorts of tricks you can use if you update your mental model of how to read the PostgreSQL docs. For example, there's an old-style index! [1]

[0]: https://www.postgresql.org/docs/current/xfunc-sql.html#XFUNC... [1]: https://www.postgresql.org/docs/current/bookindex.html

Re: Time for a WTF MySQL Moment

#45
post #37
post #6

Edit. Fuck HN.

"If we want to complain that MySQL has an utterly useless TIME datatype, and separately they really should have an INTERVAL datatype, then let's do that." Uhh, done? "The issue" is that MySQL has a TIME type that is goofy as all get-out, and this guy's friend had a bug that prompted him to look into the TIME type and find out how goofy it is. I don't recall him complaining that it's not in the docs (since that's wher…

Edit. Fuck HN.

Re: Time for a WTF MySQL Moment

#46
post #6

Edit. Fuck HN.

>If we want to complain that MySQL has an utterly useless TIME datatype, and separately they really should have an INTERVAL datatype, then let's do that.

Well isn't this complaint basically the last paragraph of TFA verbatim?

Re: Time for a WTF MySQL Moment

#47
post #34
post #6

Edit. Fuck HN.

The MySQL documentation suggests using it to store a time interval: "The hours part may be so large because the TIME type can be used not only to represent a time of day (which must be less than 24 hours), but also elapsed time or a time interval between two events (which may be much greater than 24 hours, or even negative)." [1] How is the author's usage incorrect? Sure there's a documented allowed range, but it see…

[deleted]

Re: Time for a WTF MySQL Moment

#48
post #45
post #37

Earlier quoted context omitted.

"If we want to complain that MySQL has an utterly useless TIME datatype, and separately they really should have an INTERVAL datatype, then let's do that." Uhh, done? "The issue" is that MySQL has a TIME type that is goofy as all get-out, and this guy's friend had a bug that prompted him to look into the TIME type and find out how goofy it is. I don't recall him complaining that it's not in the docs (since that's wher…

Edit. Fuck HN.

> Maybe you should take a moment to review the etiquette you're trying to hypocritically enforce.

Although they did breach it, they did not invoke the etiquette, they only made a more general recommendation of calming down (however snarkily).

You, however, are invoking the etiquette while breaching multiple items from it in your original comment.

Re: Time for a WTF MySQL Moment

#49
post #34
post #6

Edit. Fuck HN.

The MySQL documentation suggests using it to store a time interval: "The hours part may be so large because the TIME type can be used not only to represent a time of day (which must be less than 24 hours), but also elapsed time or a time interval between two events (which may be much greater than 24 hours, or even negative)." [1] How is the author's usage incorrect? Sure there's a documented allowed range, but it see…

The documentation is valuable in the following way: based on almost every aspect of the documentation, the datatype is not something I would use.

Those who use it and get burned didn't get the main message.

Re: Time for a WTF MySQL Moment

#50
post #45

Earlier quoted context omitted.

Edit. Fuck HN.

> Maybe you should take a moment to review the etiquette you're trying to hypocritically enforce. Although they did breach it, they did not invoke the etiquette, they only made a more general recommendation of calming down (however snarkily). You, however, are invoking the etiquette while breaching multiple items from it in your original comment.

[deleted]
Post reply on HN