diff --git a/crates/glaredb/src/commands.rs b/crates/glaredb/src/commands.rs index f8528dd7a..c514acecf 100644 --- a/crates/glaredb/src/commands.rs +++ b/crates/glaredb/src/commands.rs @@ -316,7 +316,22 @@ impl RunCommand for SltArgs { } fn build_runtime(thread_label: &'static str) -> Result { - let runtime = Builder::new_multi_thread() + let mut builder = Builder::new_multi_thread(); + + // Bump the stack from the default 2MB. + // + // We reach the limit when planning a query + // with nested views. + // + // Note that Sean observed the stack size only reaching ~300KB when + // running in release mode, and so we don't need to bump this + // everywhere. However there's definitely improvements to stack + // usage that we can make. + // see + #[cfg(not(release))] + builder.thread_stack_size(4 * 1024 * 1024); + + let runtime = builder .thread_name_fn(move || { static THREAD_ID: AtomicU64 = AtomicU64::new(0); let id = THREAD_ID.fetch_add(1, Ordering::Relaxed); diff --git a/crates/sqlbuiltins/src/builtins.rs b/crates/sqlbuiltins/src/builtins.rs index b8e25680e..0ef3a3120 100644 --- a/crates/sqlbuiltins/src/builtins.rs +++ b/crates/sqlbuiltins/src/builtins.rs @@ -494,32 +494,32 @@ pub static PG_ATTRIBUTE: Lazy = Lazy::new(|| BuiltinView { name: "pg_attribute", sql: " SELECT - c.table_oid AS attrelid, - c.column_name AS attname, - null AS atttypeid, - null AS attstattarget, - null AS attlen, - null AS attnum, - null AS attndims, - null AS attcacheoff, - null AS atttypmod, - null AS attbyval, - null AS attalign, - null AS attstorage, - null AS attcompression, - null AS attnotnull, - null AS atthasdef, - null AS atthasmissing, - null AS attidentity, - null AS attgenerated, - null AS attisdropped, - null AS attislocal, - null AS attinhcount, - null AS attcollation, - null AS attacl, - null AS attoptions, - null AS attfdwoptions, - null AS attmissingval + null as attacl, + ' ' as attalign, + false as attbyval, + 0 as attcacheoff, + 0 as attcollation, + ' ' as attcompression, + null as attfdwoptions, + ' ' as attgenerated, + false as atthasdef, + false as atthasmissing, + ' ' as attidentity, + 0 as attinhcount, + false as attisdropped, + false as attislocal, + 0::smallint as attlen, + null as attmissingval, + '' as attname, + 0 as attndims, + false as attnotnull, + 0::smallint as attnum, + null as attoptions, + 0 as attrelid, + 0 as attstattarget, + ' ' as attstorage, + 0 as atttypid, + 0 as atttypmod FROM glare_catalog.columns c", }); @@ -642,7 +642,51 @@ SELECT FROM glare_catalog.views; ", }); - +pub static PG_TYPE: Lazy = Lazy::new(|| BuiltinView { + schema: POSTGRES_SCHEMA, + name: "pg_type", + sql: " +SELECT + +null as typacl, +0 as typndims, +0 as typcollation, +0 as oid, +0 as typnamespace, +0 as typowner, +0 as typlen, +false as typbyval, +'r' as typtype, +'r' as typcategory, +false as typispreferred, +false as typisdefined, +'r' as typdelim, +0 as typrelid, +0 as typsubscript, +0 as typelem, +0 as typarray, +0 as typinput, +0 as typoutput, +0 as typreceive, +0 as typsend, +0 as typmodin, +0 as typmodout, +0 as typanalyze, +'r' as typalign, +'r' as typstorage, +false as typnotnull, +0 as typbasetype, +0 as typtypmod, +'r' as typname, +null as typdefault, +null as typdefaultbin +FROM (VALUES (NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL)) WHERE false", +}); impl BuiltinView { pub fn builtins() -> Vec<&'static BuiltinView> { vec![ @@ -658,6 +702,7 @@ impl BuiltinView { &PG_DATABASE, &PG_TABLE, &PG_VIEWS, + &PG_TYPE, ] } } diff --git a/crates/sqlexec/src/dispatch/mod.rs b/crates/sqlexec/src/dispatch/mod.rs index baf39fd22..c554f0624 100644 --- a/crates/sqlexec/src/dispatch/mod.rs +++ b/crates/sqlexec/src/dispatch/mod.rs @@ -161,7 +161,6 @@ impl ViewPlanner for LocalSessionContext { }))? .build()?; } - Ok(df_plan) } } diff --git a/testdata/sqllogictests/pg_catalog.slt b/testdata/sqllogictests/pg_catalog.slt index ef6f76237..c0593542e 100644 --- a/testdata/sqllogictests/pg_catalog.slt +++ b/testdata/sqllogictests/pg_catalog.slt @@ -80,3 +80,7 @@ query TT select schema_name, table_name from glare_catalog.tables where table_name = 'pg_description' and schema_name = 'pg_catalog_test'; ---- pg_catalog_test pg_description + + +statement ok +select * from pg_catalog.pg_type; \ No newline at end of file