-- @Description Check updating toast values

-- Create a table with toasted values
CREATE TABLE uao_update_toast (a INT, b INT, c VARCHAR) WITH (appendonly=true);
CREATE INDEX uao_update_toast_index ON uao_update_toast(b);
INSERT INTO uao_update_toast SELECT i as a, 1 as b, i::text || '[encoded data, 13336 characters]' as c FROM generate_series(1, 30) AS i;
ANALYZE uao_update_toast;

-- Now perform updates
\set QUIET off

UPDATE uao_update_toast SET c = '' WHERE a <= 10;
UPDATE uao_update_toast SET c = '[encoded data, 13336 characters]' WHERE a > 10 AND a <= 20;
UPDATE uao_update_toast SET b = 50 WHERE a > 20 AND a <= 30;
VACUUM uao_update_toast;
SELECT a, b, md5(c::text) FROM uao_update_toast;
