BEGIN;

-- First change existing table entries.
CREATE or REPLACE FUNCTION tmp_update_queuelog_maxcallers() RETURNS INTEGER AS '
  DECLARE
    _dflt int;
  BEGIN
    SELECT INTO _dflt column_default FROM information_schema.columns WHERE table_name = ''queuelog'' AND column_name = ''maxcallers'';
    IF _dflt = 0 THEN
      UPDATE queuelog SET maxcallers = ''9999'' WHERE maxcallers = ''0'';
    ELSE
      RAISE INFO ''Default maxcallers is already 9999'';
    END IF;
    RETURN ''0'';
  END;
' LANGUAGE plpgsql;

SELECT tmp_update_queuelog_maxcallers();

DROP FUNCTION tmp_update_queuelog_maxcallers();

-- Then change the default value.
ALTER TABLE queuelog ALTER COLUMN maxcallers SET DEFAULT '9999';

COMMIT;
