The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Monday, Debtember 17, 2007

WTF? And I do mean, seriously, WTF?

I've been looking into The Error From Hell, and seeing how I'm given the exact line number where the error occurs, I thought I'd start there.

So, line 136 from include/database/pgsqlManager.php:

$result = pg_query($sql);

Nice.

So, to see the full query that's failing, I decide to print out the query just before it's made. And that's when I realize that the function this line appears in is called several times throughout the program (not all SQL calls are funneled through this function, just enough to make it painful).

Nice.

Okay, approach the problem from a different angle. What's the function that this piece of code is in? Oh, that's easy—query().

Okay, try a different approach.

The error complains about a syntax error near contact_name_owner, so let's try looking for that. Thirty-one loations where it's used, but none of them appear to construct a 3,544 character long SQL statement, and the one place where such a statement might be constructed, isn't called.

Head?

Meet Mr. Desk.

Mr. Desk? Meet my head.

Ouch.

I think I see the problem:

' ' AS contact_name , ' ' AS contact_id , ' ' contact_name_owner

It seems as if there's a few missing ASes in the SQL Statement From Hell, but not knowing where it's constructed (or even how), it's not that easy to fix.

Or rather … there is a way …

Just before I call pg_query(), scan the string, looking for missing ASes and add them as required, maybe using some form of regular expression search and replace funct—[at this point, Sean's head exploded from even entertaining such a notion and was pronounced “mostly dead” at the scene. Further updates as they arrive. —Editor]

Obligatory Picture

[It's the most wonderful time of the year!]

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: http://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

http://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2019 by Sean Conner. All Rights Reserved.