Steve Peart

Internet Rambling, Life, Code
RSS icon Email icon Home icon
  • Amavisd-new 2.6.x upgrade headaches

    Posted on April 24th, 2010 admin No comments

    Ok, so I was using amavisd to help me out with scanning for viruses and spam. I wanted MySQL tables for everything, but i was configuring everything so I could prefix those tables to fit into my control panel scheme. (by default their table names are lame, and as far as I know, un-prefix-able). So to use my scheme, I override the default sql used to query for various things, then I can use my own table names.

    The problem I encountered was when I upgraded amavisd to the newest from the repository. Suddenly all of my mail was getting deferred and infinitely queued.

    I was getting a lot of these types of errors:
    sql-enter FAILED: sql exec: err=16, S1000, DBD::mysql::st > bind_param failed: Illegal parameter number at…

    After some googling, I came across this page: http://www.mail-archive.com/amavis-user@lists.sourceforge.net/msg12088.html

    Ok, so apparently they added the partition_tag column to the database schema, which would be nice if they did some kind of a check, to let you know that you need to fix this based on an upgrade, rather than just let your amavisd fail. I suppose you SHOULD read through the README’s, but when you’re doing ‘yum update’ on your server, are you really going to do that for EVERY piece of software that gets upgraded?

    So in my case, the way to fix everything was to go through the README: http://www.ijs.si/software/amavisd/README.sql-pg.txt

    Find all mentions of the new partition_tag column, and update my database to include it, and all CONSTRAINT or FOREIGN KEYS, etc.

    Which of course, didn’t work by itself. You now have to change the amavisd.conf to update the %sql_clause you overrode to include this new column in the check. I first added it at the end thinking that they matched what you were selecting on the backend to see which order the data should be passed to the ?,?,?,? you set up inside those queries. But no, that’s not true either. You have to have them in the exact order in which they expect to send them to you.

    But how do you know that? I couldn’t seem to pull any of that up on google. So since amavisd happens to be just a perl script, I figured I could read through that searching for queries to see how it builds out the defaults.

    Sure enough, they are right there, exactly in the same shape with which you would override them in %sql_clause, so really all that had to be done was to copy those out of that file, paste them into amavisd.conf over the old ones, and re-do the table prefixes I am using.

    I can only hope that someone finds this and doesn’t have to spend the time I did figuring it out.

    /rant

  • Dojo Form Widgets – dijit.form.FilteringSelect

    Posted on April 8th, 2009 admin No comments

    Recently I wrote in some functionality that used the dijit.form.FilteringSelect widget from the dojotoolkit and had a special use-case, not discussed in the documentation.

    EDIT: Use dijit.byId(‘myFilteringSelect’).attr(‘displayedValue’); Instead, the rest can stay for historical purposes (assuming there would be any).

    Let’s say you have a basic FilteringSelect widget. Look at the example below:

    <select id="myFilteringSelect" name="myOptions">
       <option value="1">Something</option>
    </select>

    If you want to grab the current value of a widget, it’s simple:

    var currentSelection = dijit.byId('myFilteringSelect').attr('value');
    console.log('Current Selection: ' + currentSelection);
    // Outputs 'Current Selection: 1'

    What if for some reason, you want the Displayed value of the widget? What this whole post is for:

    var currentSelection = dojo.byId('myFilteringSelect').value;
    console.log('Current Selection: ' + currentSelection);
    // Outputs 'Current Selection: Something'

    See the difference? We used dojo.byId instead of dijit.byId. When using the FilteringSelect widget, the place where the current option value is stored is within the widget, but dojo creates an underlying form input on the page with the id you gave your widget, and pops the display value there, the value you see in the box once you’ve selected something. So by simply using normal javascript to select it’s value via .value, we can grab that for use.

    Not in the docs for FilteringSelect, and maybe there’s other issues with your code if you find yourself here, but for me, i needed the word, not the number, and had no control over how the html select was created. So there you go.

  • First Post!

    Posted on April 7th, 2009 admin No comments

    So I have finally installed this blog, it’s taken some time. If you find yourself here at this moment, I’m sorry. There’s not much here yet. I plan to blog as much as possible pertaining to life and code as either happens. I do a lot of web development and come across things i can’t solve easily frequently. Eventually, I get them down but wanted to have a place to share the same issues, as i saw them and fought them. So look forward to seeing that sort of thing here.