     ELSIF the_id IS NULL THEN
         EXECUTE 'INSERT INTO change ('||prep.keys||') VALUES ('||prep.vals||') RETURNING obj_id' INTO the_id;
     ELSIF prep.sets!='' THEN
-        EXECUTE 'UPDATE change SET '||prep.sets||' WHERE obj_id='||the_id' RETURNING obj_id' INTO the_id;
+        EXECUTE 'UPDATE change SET '||prep.sets||' WHERE obj_id='||the_id||' RETURNING obj_id' INTO the_id;
     END IF;
     IF a?'command' THEN
-        a_params := a_params || ('_command'=>(a->'command'));
+        a_params := a_params || hstore('_command',a->'command');
     END IF;
     PERFORM set_params(the_id,a_params);
     RETURN the_id;

			-- do nothing
	END;
	RETURN coalesce(r,0);
END;
$$ LANGUAGE plpgsql IMMUTABLE CALLED ON NULL INPUT;
CREATE OR REPLACE FUNCTION str2inet (a text) RETURNS inet AS $$
DECLARE
	r inet;
BEGIN
	BEGIN
		SELECT INTO r a::inet;
	EXCEPTION
		WHEN OTHERS THEN
			-- do nothing
	END;
	RETURN r;
END;
$$ LANGUAGE plpgsql IMMUTABLE CALLED ON NULL INPUT;
CREATE OR REPLACE FUNCTION str2time (a text) RETURNS timestamp AS $$

CREATE OR REPLACE FUNCTION cjoin (a_strs text[],a_delimiter text) RETURNS text AS $$
	SELECT array_to_string($1,$2);
$$ LANGUAGE sql IMMUTABLE STRICT;

--- STRING functions
CREATE OR REPLACE FUNCTION collapse_spaces (a text) RETURNS text AS $$
    SELECT regexp_replace($1,E'\\s+',' ','g');
$$ LANGUAGE sql IMMUTABLE CALLED ON NULL INPUT;

-- LANG
CREATE OR REPLACE FUNCTION unlang (a_str text) RETURNS text AS $$
