message: complete reorganization
diff: # name: test/sql/storage/catalog/test_table_macro_storage.test
  -# description: Create and drop a table macro over different runs
  +# description: Test storage of table macros
  # group: [catalog]
  # load the DB from disk
  load __TEST_DIR__/macro_storage.db
  -statement ok
  -PRAGMA wal_autocheckpoint='1TB';
  statement ok
  CREATE TABLE test_tbl (id INT, name string, height double);
  @@ -19,81 +17,69 @@ INSERT INTO test_tbl values (1,'tom', 1.1), (2,'dick',1.2),(3,'harry', 1.2),
  statement ok
  CREATE MACRO xt(a, _name) as TABLE SELECT * FROM test_tbl WHERE id<=a or name = _name;
  -
  # use the macro
  query III
  SELECT * FROM xt(10, '*') ORDER BY height limit 1;
  ----
  6 midge 0.5
  -
  statement ok
  -DROP MACRO TABLE xt;
  +CREATE TEMPORARY MACRO my_seq(start , finish, stride:=3) as TABLE SELECT * FROM generate_series(start , finish , stride);
  -loop i 0 2
  +query I
  +SELECT * FROM my_seq(0,6);
  +----
  +0
  +3
  +6
  -# restart the system
  -restart
  -statement error
  -SELECT * FROM xt(10, 'midge');
  +restart
  -# after recreating the macro we can use it again
  statement ok
  -CREATE MACRO xt(a, _name) as TABLE SELECT * FROM test_tbl WHERE id<=a or name = _name;
  +PRAGMA disable_checkpoint_on_shutdown
  +statement ok
  +PRAGMA wal_autocheckpoint='1TB';
  -query T
  -SELECT max(height) from xt(20,'*');
  -----
  -1.2
  +statement ok
  +SELECT * FROM xt(100, 'joe');
  -# drop the macro again
  statement ok
  DROP MACRO TABLE xt;
  -endloop
  -
  -#create a macro but dont drop
  +statement error
  +SELECT * from my_seq(0,10,2);
  +# create another macro to check the WAL
  statement ok
  -CREATE MACRO yt(a) as TABLE SELECT * FROM test_tbl WHERE id<=a;
  +CREATE MACRO my_range(rend) AS TABLE SELECT * FROM range(rend);
  -loop i 0 1
  -
  -query T
  -SELECT min(height) FROM yt(10);
  +query I
  +SELECT * from my_range(2);
  ----
  -0.5
  -
  -restart
  +0
  +1
  -query III
  -SELECT * FROM yt(2) ORDER BY id limit 1;
  -----
  -1 tom 1.1
  -endloop
  -
  -# check the wal - TableMacro Deserialize works
  +# check the WAL
  restart
  -statement ok
  -PRAGMA disable_checkpoint_on_shutdown
  +statement error
  +SELECT * FROM xt(100, 'joe');
  -statement ok
  -PRAGMA wal_autocheckpoint='1TB';
  +statement error
  +SELECT * FROM my_seq(0,3,2);
  +
  +query I
  +SELECT * from my_range(2);
  +----
  +0
  +1
  -statement ok
  -CREATE MACRO zt(a) as TABLE SELECT * FROM test_tbl WHERE id<=a;
  -restart
  -query T
  -SELECT min(height) FROM zt(10);
  -----
  -0.5
  