declare stuff record;
begin
select into stuff host from hostnames;
return stuff;
end;
And that ought to work. Unfortunately, a 'record' is not really what it seems to be. You might return a 'cursor', but that's a similar can of worms. Barrel of monkeys, whatever. Unfortunately, you have to declare a 'type', and so doing declare how your 'record' will look, and then return a 'setof' your type. This, if you ask me (and nobody did) is just retarded. Now this is postgres, and postgres has arrays. I could just return an array, but it wouldn't be portable, and probably the developer I'm supporting here wouldn't know how to handle it. So we wind up with fifteen lines of sql for what is one line of select statement. Whatever.
It's been an interesting week already (and it's only wednesday even) in coding; I've both been breaking code and finding new holes in my own code. Some particularly strange bugs have been found, some of which are reproducible, some of which aren't. Maddening, that, finding bugs that aren't reproducible.
Published my first module to the cpan yesterday, too. Something that I needed both for work stuff and home stuff. Wound up coding it on my own time so that I could use it away from work. After uploading it, I realized that there was another module which was similar to mine. However, the difference is substantial. His is kind of coded poorly and is a derivative work, mine is more flexible, less code, and has inherent error checking (design-by-contract via Params::Validate). And it requires 5.6.0 for no good reason.
Kind of ironic that I've written so much interesting and useful code and what winds up finally being publish worthy (a few friends asked me for the module) was something like 120 lines of perl and 150 lines of documentation. But, the world needs more thin, fast code. There's so much bloat out there that something that's less than 300 lines of code and documentation is awful refreshing.
Also bumped into a coworker from a previous employer. Unfortunately, he had almost nothing nice to say about them, or the people still there (who I mostly keep in touch with). I suppose his life experience (being laid off from said employer, congestive heart failure last year, among other things) has colored his perspective on things. It's too bad that somebody could leave a place so bitter.
No comments:
Post a Comment