# builtin opt 	gdk_dbpath = /home/monet/testing/2075952d1dc8-6-1-1/install/var/monetdb5/dbfarm/demo
# builtin opt 	mapi_port = 50000
# builtin opt 	sql_optimizer = default_pipe
# builtin opt 	sql_debug = 0
# builtin opt 	raw_strings = false
# cmdline opt 	gdk_nr_threads = 8
# cmdline opt 	mapi_listenaddr = all
# cmdline opt 	mapi_port = 0
# cmdline opt 	mapi_usock = /tmp/mtest-129833/.s.monetdb.${PORT}
# cmdline opt 	gdk_dbpath = /home/monet/testing/2075952d1dc8-6-1-1/tests/sql/dbfarm/mTests_sql_test_emptydb-upgrade-hge
# cmdline opt 	embedded_c = true
# cmdline opt 	gdk_use_strimps = yes
# cmdline opt 	gdk_vm_maxsize = 8589934592
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_6:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_8:bat[:str]);	#[3] (0) MANIFOLDremapMultiplex 13 <- 14 15 1 11 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_34:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_36:bat[:str]);	#[15] (0) MANIFOLDremapMultiplex 51 <- 14 15 1 49 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_65:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_67:bat[:str]);	#[23] (0) MANIFOLDremapMultiplex 78 <- 14 15 1 76 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_92:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_94:bat[:str]);	#[31] (0) MANIFOLDremapMultiplex 101 <- 14 15 1 99 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_115:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_117:bat[:str]);	#[39] (0) MANIFOLDremapMultiplex 126 <- 14 15 1 124 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_140:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_142:bat[:str]);	#[47] (0) MANIFOLDremapMultiplex 147 <- 14 15 1 145 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_8:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_10:bat[:str]);	#[3] (0) MANIFOLDremapMultiplex 21 <- 22 23 1 19 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_39:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_41:bat[:str]);	#[14] (0) MANIFOLDremapMultiplex 48 <- 22 23 1 46 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_11:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_13:bat[:str]);	#[3] (0) MANIFOLDremapMultiplex 13 <- 14 15 1 11 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_50:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_52:bat[:str]);	#[19] (0) MANIFOLDremapMultiplex 64 <- 14 15 1 62 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_86:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_88:bat[:str]);	#[28] (0) MANIFOLDremapMultiplex 96 <- 14 15 1 94 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup aggr.anyequal a bulk operator implementation is needed for     X_118:bat[:bit] := mal.multiplex("aggr":str, "anyequal":str, A1%tpe:str, X_120:bat[:str]);	#[37] (0) MANIFOLDremapMultiplex 124 <- 14 15 1 122 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[49] (0) MANIFOLDremapMultiplex 88 <- 89 90 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[50] (0) MANIFOLDremapMultiplex 91 <- 89 92 80 81 82 83 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[51] (0) MANIFOLDremapMultiplex 93 <- 89 94 84 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[56] (0) MANIFOLDremapMultiplex 103 <- 89 104 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[49] (0) MANIFOLDremapMultiplex 88 <- 89 90 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[50] (0) MANIFOLDremapMultiplex 91 <- 89 92 80 81 82 83 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[51] (0) MANIFOLDremapMultiplex 93 <- 89 94 84 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[56] (0) MANIFOLDremapMultiplex 103 <- 89 104 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[49] (0) MANIFOLDremapMultiplex 88 <- 89 90 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[50] (0) MANIFOLDremapMultiplex 91 <- 89 92 80 81 82 83 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[51] (0) MANIFOLDremapMultiplex 93 <- 89 94 84 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[56] (0) MANIFOLDremapMultiplex 103 <- 89 104 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[49] (0) MANIFOLDremapMultiplex 88 <- 89 90 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[50] (0) MANIFOLDremapMultiplex 91 <- 89 92 80 81 82 83 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[51] (0) MANIFOLDremapMultiplex 93 <- 89 94 84 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[56] (0) MANIFOLDremapMultiplex 103 <- 89 104 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[49] (0) MANIFOLDremapMultiplex 88 <- 89 90 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[50] (0) MANIFOLDremapMultiplex 91 <- 89 92 80 81 82 83 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[51] (0) MANIFOLDremapMultiplex 93 <- 89 94 84 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[56] (0) MANIFOLDremapMultiplex 103 <- 89 104 80 81 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[43] (0) MANIFOLDremapMultiplex 74 <- 75 76 67 68 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[44] (0) MANIFOLDremapMultiplex 77 <- 75 78 67 68 69 70 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[45] (0) MANIFOLDremapMultiplex 79 <- 75 80 71 68 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[50] (0) MANIFOLDremapMultiplex 89 <- 75 90 67 68 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[43] (0) MANIFOLDremapMultiplex 74 <- 75 76 67 68 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[44] (0) MANIFOLDremapMultiplex 77 <- 75 78 67 68 69 70 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[45] (0) MANIFOLDremapMultiplex 79 <- 75 80 71 68 
#2021-11-24 23:49:52: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[50] (0) MANIFOLDremapMultiplex 89 <- 75 90 67 68 
#2021-11-24 23:49:53: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%1columnsize a bulk operator implementation is needed for     X_0:bat[:lng] := mal.multiplex("sql":str, "%1columnsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[43] (0) MANIFOLDremapMultiplex 74 <- 75 76 67 68 
#2021-11-24 23:49:53: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%2heapsize a bulk operator implementation is needed for     X_3:bat[:lng] := mal.multiplex("sql":str, "%2heapsize":str, X_1:bat[:str], X_2:bat[:lng], X_4:bat[:lng], X_5:bat[:int]);	#[44] (0) MANIFOLDremapMultiplex 77 <- 75 78 67 68 69 70 
#2021-11-24 23:49:53: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%3hashsize a bulk operator implementation is needed for     X_6:bat[:lng] := mal.multiplex("sql":str, "%3hashsize":str, X_7:bat[:bit], X_2:bat[:lng]);	#[45] (0) MANIFOLDremapMultiplex 79 <- 75 80 71 68 
#2021-11-24 23:49:53: client4: OPTexpandMultiplex: !WARNING: To speedup sql.%4imprintsize a bulk operator implementation is needed for     X_8:bat[:lng] := mal.multiplex("sql":str, "%4imprintsize":str, X_1:bat[:str], X_2:bat[:lng]);	#[50] (0) MANIFOLDremapMultiplex 89 <- 75 90 67 68 
--- test
+++ check.stable.out.int128
@@ -1044,7 +1044,7 @@
 create view sys.describe_indices as with it (id, idx) as (values (0, 'INDEX'), (4, 'IMPRINTS INDEX'), (5, 'ORDERED INDEX')) select i.name ind, s.name sch, t.name tbl, c.name col, it.idx tpe from sys.idxs as i left join sys.keys as k on i.name = k.name, sys.objects as kc, sys._columns as c, sys.schemas s, sys._tables as t, it where i.table_id = t.id and i.id = kc.id and kc.name = c.name and t.id = c.table_id and t.schema_id = s.id and k.type is null and i.type = it.id order by i.name, kc.nr;
 create view sys.describe_partition_tables as select m_sch, m_tbl, p_sch, p_tbl, case when p_raw_type is null then 'READ ONLY' when (p_raw_type = 'VALUES' and pvalues is null) or (p_raw_type = 'RANGE' and minimum is null and maximum is null and with_nulls) then 'FOR NULLS' else p_raw_type end as tpe, pvalues, minimum, maximum, with_nulls from (with tp("type", table_id) as (select ifthenelse((table_partitions."type" & 2) = 2, 'VALUES', 'RANGE'), table_partitions.table_id from sys.table_partitions), subq(m_tid, p_mid, "type", m_sch, m_tbl, p_sch, p_tbl) as (select m_t.id, p_m.id, m_t."type", m_s.name, m_t.name, p_s.name, p_m.name from sys.schemas m_s, sys._tables m_t, sys.dependencies d, sys.schemas p_s, sys._tables p_m where m_t."type" in (3, 6) and m_t.schema_id = m_s.id and m_s.name <> 'tmp' and m_t.system = false and m_t.id = d.depend_id and d.id = p_m.id and p_m.schema_id = p_s.id order by m_t.id, p_m.id) select subq.m_sch, subq.m_tbl, subq.p_sch, subq.p_tbl, tp."type" as p_raw_type, case when tp."type" = 'VALUES' then (select group_concat(vp.value, ',') from sys.value_partitions vp where vp.table_id = subq.p_mid) else null end as pvalues, case when tp."type" = 'RANGE' then (select minimum from sys.range_partitions rp where rp.table_id = subq.p_mid) else null end as minimum, case when tp."type" = 'RANGE' then (select maximum from sys.range_partitions rp where rp.table_id = subq.p_mid) else null end as maximum, case when tp."type" = 'VALUES' then exists(select vp.value from sys.value_partitions vp where vp.table_id = subq.p_mid and vp.value is null) else (select rp.with_nulls from sys.range_partitions rp where rp.table_id = subq.p_mid) end as with_nulls from subq left outer join tp on subq.m_tid = tp.table_id) as tmp_pi;
 create view sys.describe_privileges as select case when o.tpe is null and pc.privilege_code_name = 'SELECT' then 'COPY FROM' when o.tpe is null and pc.privilege_code_name = 'UPDATE' then 'COPY INTO' else o.nme end o_nme, coalesce(o.tpe, 'GLOBAL') o_tpe, pc.privilege_code_name p_nme, a.name a_nme, g.name g_nme, p.grantable grantable from sys.privileges p left join (select t.id, s.name || '.' || t.name , 'TABLE' from sys.schemas s, sys.tables t where s.id = t.schema_id union all select c.id, s.name || '.' || t.name || '.' || c.name, 'COLUMN' from sys.schemas s, sys.tables t, sys.columns c where s.id = t.schema_id and t.id = c.table_id union all select f.id, f.nme, f.tpe from sys.fully_qualified_functions f) o(id, nme, tpe) on o.id = p.obj_id, sys.privilege_codes pc, auths a, auths g where p.privileges = pc.privilege_code_id and p.auth_id = a.id and p.grantor = g.id;
-create view sys.describe_sequences as select s.name as sch, seq.name as seq, seq."start" s, peak_next_value_for(s.name, seq.name) as rs, seq."minvalue" mi, seq."maxvalue" ma, seq."increment" inc, seq."cacheinc" cache, seq."cycle" cycle from sys.sequences seq, sys.schemas s where s.id = seq.schema_id and s.name <> 'tmp' order by s.name, seq.name;
+create view sys.describe_sequences as select s.name as sch, seq.name as seq, seq."start" s, get_value_for(s.name, seq.name) as rs, seq."minvalue" mi, seq."maxvalue" ma, seq."increment" inc, seq."cacheinc" cache, seq."cycle" cycle from sys.sequences seq, sys.schemas s where s.id = seq.schema_id and s.name <> 'tmp' order by s.name, seq.name;
 create view sys.describe_tables as select t.id o, s.name sch, t.name tab, ts.table_type_name typ, (select ' (' || group_concat(sys.dq(c.name) || ' ' || sys.describe_type(c.type, c.type_digits, c.type_scale) || ifthenelse(c."null" = 'false', ' NOT NULL', '') , ', ') || ')' from sys._columns c where c.table_id = t.id) col, case ts.table_type_name when 'REMOTE TABLE' then sys.get_remote_table_expressions(s.name, t.name) when 'MERGE TABLE' then sys.get_merge_table_partition_expressions(t.id) when 'VIEW' then sys.schema_guard(s.name, t.name, t.query) else '' end opt from sys.schemas s, sys.table_types ts, sys.tables t where ts.table_type_name in ('TABLE', 'VIEW', 'MERGE TABLE', 'REMOTE TABLE', 'REPLICA TABLE') and t.system = false and s.id = t.schema_id and ts.table_type_id = t.type and s.name <> 'tmp';
 create view sys.describe_triggers as select s.name sch, t.name tab, tr.name tri, tr.statement def from sys.schemas s, sys.tables t, sys.triggers tr where s.id = t.schema_id and t.id = tr.table_id and not t.system;
 create view sys.describe_user_defined_types as select s.name sch, t.sqlname sql_tpe, t.systemname ext_tpe from sys.types t join sys.schemas s on t.schema_id = s.id where t.eclass = 18 and ((s.name = 'sys' and t.sqlname not in ('geometrya', 'mbr', 'url', 'inet', 'json', 'uuid', 'xml')) or (s.name <> 'sys'));
@@ -2010,7 +2010,7 @@
 [ "sys._tables",	"sys",	"describe_indices",	"create view sys.describe_indices as with it (id, idx) as (values (0, 'INDEX'), (4, 'IMPRINTS INDEX'), (5, 'ORDERED INDEX')) select i.name ind, s.name sch, t.name tbl, c.name col, it.idx tpe from sys.idxs as i left join sys.keys as k on i.name = k.name, sys.objects as kc, sys._columns as c, sys.schemas s, sys._tables as t, it where i.table_id = t.id and i.id = kc.id and kc.name = c.name and t.id = c.table_id and t.schema_id = s.id and k.type is null and i.type = it.id order by i.name, kc.nr;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
 [ "sys._tables",	"sys",	"describe_partition_tables",	"create view sys.describe_partition_tables as select m_sch, m_tbl, p_sch, p_tbl, case when p_raw_type is null then 'READ ONLY' when (p_raw_type = 'VALUES' and pvalues is null) or (p_raw_type = 'RANGE' and minimum is null and maximum is null and with_nulls) then 'FOR NULLS' else p_raw_type end as tpe, pvalues, minimum, maximum, with_nulls from (with tp(\"type\", table_id) as (select ifthenelse((table_partitions.\"type\" & 2) = 2, 'VALUES', 'RANGE'), table_partitions.table_id from sys.table_partitions), subq(m_tid, p_mid, \"type\", m_sch, m_tbl, p_sch, p_tbl) as (select m_t.id, p_m.id, m_t.\"type\", m_s.name, m_t.name, p_s.name, p_m.name from sys.schemas m_s, sys._tables m_t, sys.dependencies d, sys.schemas p_s, sys._tables p_m where m_t.\"type\" in (3, 6) and m_t.schema_id = m_s.id and m_s.name <> 'tmp' and m_t.system = false and m_t.id = d.depend_id and d.id = p_m.id and p_m.schema_id = p_s.id order by m_t.id, p_m.id) select subq.m_sch, subq.m_tbl, subq.p_sch, subq.p_tbl, tp.\"type\" as p_raw_type, case when tp.\"type\" = 'VALUES' then (select group_concat(vp.value, ',') from sys.value_partitions vp where vp.table_id = subq.p_mid) else null end as pvalues, case when tp.\"type\" = 'RANGE' then (select minimum from sys.range_partitions rp where rp.table_id = subq.p_mid) else null end as minimum, case when tp.\"type\" = 'RANGE' then (select maximum from sys.range_partitions rp where rp.table_id = subq.p_mid) else null end as maximum, case when tp.\"type\" = 'VALUES' then exists(select vp.value from sys.value_partitions vp where vp.table_id = subq.p_mid and vp.value is null) else (select rp.with_nulls from sys.range_partitions rp where rp.table_id = subq.p_mid) end as with_nulls from subq left outer join tp on subq.m_tid = tp.table_id) as tmp_pi;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
 [ "sys._tables",	"sys",	"describe_privileges",	"create view sys.describe_privileges as select case when o.tpe is null and pc.privilege_code_name = 'SELECT' then 'COPY FROM' when o.tpe is null and pc.privilege_code_name = 'UPDATE' then 'COPY INTO' else o.nme end o_nme, coalesce(o.tpe, 'GLOBAL') o_tpe, pc.privilege_code_name p_nme, a.name a_nme, g.name g_nme, p.grantable grantable from sys.privileges p left join (select t.id, s.name || '.' || t.name , 'TABLE' from sys.schemas s, sys.tables t where s.id = t.schema_id union all select c.id, s.name || '.' || t.name || '.' || c.name, 'COLUMN' from sys.schemas s, sys.tables t, sys.columns c where s.id = t.schema_id and t.id = c.table_id union all select f.id, f.nme, f.tpe from sys.fully_qualified_functions f) o(id, nme, tpe) on o.id = p.obj_id, sys.privilege_codes pc, auths a, auths g where p.privileges = pc.privilege_code_id and p.auth_id = a.id and p.grantor = g.id;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
-[ "sys._tables",	"sys",	"describe_sequences",	"create view sys.describe_sequences as select s.name as sch, seq.name as seq, seq.\"start\" s, peak_next_value_for(s.name, seq.name) as rs, seq.\"minvalue\" mi, seq.\"maxvalue\" ma, seq.\"increment\" inc, seq.\"cacheinc\" cache, seq.\"cycle\" cycle from sys.sequences seq, sys.schemas s where s.id = seq.schema_id and s.name <> 'tmp' order by s.name, seq.name;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
+[ "sys._tables",	"sys",	"describe_sequences",	"create view sys.describe_sequences as select s.name as sch, seq.name as seq, seq.\"start\" s, get_value_for(s.name, seq.name) as rs, seq.\"minvalue\" mi, seq.\"maxvalue\" ma, seq.\"increment\" inc, seq.\"cacheinc\" cache, seq.\"cycle\" cycle from sys.sequences seq, sys.schemas s where s.id = seq.schema_id and s.name <> 'tmp' order by s.name, seq.name;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
 [ "sys._tables",	"sys",	"describe_tables",	"create view sys.describe_tables as select t.id o, s.name sch, t.name tab, ts.table_type_name typ, (select ' (' || group_concat(sys.dq(c.name) || ' ' || sys.describe_type(c.type, c.type_digits, c.type_scale) || ifthenelse(c.\"null\" = 'false', ' NOT NULL', '') , ', ') || ')' from sys._columns c where c.table_id = t.id) col, case ts.table_type_name when 'REMOTE TABLE' then sys.get_remote_table_expressions(s.name, t.name) when 'MERGE TABLE' then sys.get_merge_table_partition_expressions(t.id) when 'VIEW' then sys.schema_guard(s.name, t.name, t.query) else '' end opt from sys.schemas s, sys.table_types ts, sys.tables t where ts.table_type_name in ('TABLE', 'VIEW', 'MERGE TABLE', 'REMOTE TABLE', 'REPLICA TABLE') and t.system = false and s.id = t.schema_id and ts.table_type_id = t.type and s.name <> 'tmp';",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
 [ "sys._tables",	"sys",	"describe_triggers",	"create view sys.describe_triggers as select s.name sch, t.name tab, tr.name tri, tr.statement def from sys.schemas s, sys.tables t, sys.triggers tr where s.id = t.schema_id and t.id = tr.table_id and not t.system;",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]
 [ "sys._tables",	"sys",	"describe_user_defined_types",	"create view sys.describe_user_defined_types as select s.name sch, t.sqlname sql_tpe, t.systemname ext_tpe from sys.types t join sys.schemas s on t.schema_id = s.id where t.eclass = 18 and ((s.name = 'sys' and t.sqlname not in ('geometrya', 'mbr', 'url', 'inet', 'json', 'uuid', 'xml')) or (s.name <> 'sys'));",	"VIEW",	true,	"COMMIT",	"WRITABLE"	]