MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_temporary_views

Function test_temporary_views

src/environmentd/tests/sql.rs:1234–1260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1232#[mz_ore::test]
1233#[allow(clippy::disallowed_methods)]
1234fn test_temporary_views() {
1235 let server = test_util::TestHarness::default().start_blocking();
1236 let mut client_a = server.connect(postgres::NoTls).unwrap();
1237 let mut client_b = server.connect(postgres::NoTls).unwrap();
1238 client_a
1239 .batch_execute("CREATE VIEW v AS VALUES (1, 'foo'), (2, 'bar'), (3, 'foo'), (1, 'bar')")
1240 .unwrap();
1241 client_a
1242 .batch_execute("CREATE TEMPORARY VIEW temp_v AS SELECT * FROM v")
1243 .unwrap();
1244
1245 let query_v = "SELECT count(*) FROM v;";
1246 let query_temp_v = "SELECT count(*) FROM temp_v;";
1247
1248 // Ensure that client_a can query v and temp_v.
1249 let count: i64 = client_b.query_one(query_v, &[]).unwrap().get("count");
1250 assert_eq!(4, count);
1251 let count: i64 = client_a.query_one(query_temp_v, &[]).unwrap().get("count");
1252 assert_eq!(4, count);
1253
1254 // Ensure that client_b can query v, but not temp_v.
1255 let count: i64 = client_b.query_one(query_v, &[]).unwrap().get("count");
1256 assert_eq!(4, count);
1257
1258 let err = client_b.query_one(query_temp_v, &[]).unwrap_db_error();
1259 assert_eq!(err.message(), "unknown catalog item \'temp_v\'");
1260}
1261
1262// Test EXPLAIN TIMESTAMP with tables.
1263#[mz_ore::test]

Callers

nothing calls this directly

Calls 7

start_blockingMethod · 0.80
unwrapMethod · 0.80
batch_executeMethod · 0.80
unwrap_db_errorMethod · 0.80
connectMethod · 0.45
getMethod · 0.45
query_oneMethod · 0.45

Tested by

no test coverage detected