From b5d381ea112079faf91a4b663ad2323e3252ef2b Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Sun, 30 Oct 2022 21:32:21 +0800 Subject: [PATCH] access_level can take multiple relations; fix bad dependency version --- Cargo.lock | 271 ++++++++++++++++++++++++++++--------------- Cargo.toml | 9 +- cozorocks/Cargo.toml | 3 +- src/algo/csv.rs | 3 +- src/algo/jlines.rs | 16 ++- src/cozoscript.pest | 2 +- src/parse/sys.rs | 11 +- src/runtime/db.rs | 6 +- 8 files changed, 213 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a595b5a5..a5c409fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,9 +216,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" dependencies = [ "jobserver", ] @@ -327,6 +327,16 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -587,9 +597,24 @@ dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.42.0", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", ] +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -847,9 +872,9 @@ dependencies = [ [[package]] name = "miette" -version = "5.4.1" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a24c4b4063c21e037dffb4de388ee85e400bff299803aba9513d9c52de8116b" +checksum = "a28d6092d7e94a90bb9ea8e6c26c99d5d112d49dda2afdb4f7ea8cf09e1a5a6d" dependencies = [ "atty", "backtrace", @@ -867,9 +892,9 @@ dependencies = [ [[package]] name = "miette-derive" -version = "5.4.1" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827d18edee5d43dc309eb0ac565f2b8e2fdc89b986b2d929e924a0f6e7f23835" +checksum = "4f2485ed7d1fe80704928e3eb86387439609bd0c6bb96db8208daa364cfd1e09" dependencies = [ "proc-macro2", "quote", @@ -907,11 +932,8 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c785bc6027fd359756e538541c8624012ba3776d3d3fe123885643092ed4132" dependencies = [ - "lazy_static", "log", - "rustls", - "webpki", - "webpki-roots", + "native-tls", ] [[package]] @@ -959,6 +981,24 @@ dependencies = [ "syn", ] +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num-complex" version = "0.4.2" @@ -1028,9 +1068,54 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "openssl" +version = "0.10.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] [[package]] name = "ordered-float" @@ -1328,21 +1413,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin", - "untrusted", - "web-sys", - "winapi", -] - [[package]] name = "rmp" version = "0.8.11" @@ -1406,18 +1476,6 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustls" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" -dependencies = [ - "log", - "ring", - "sct", - "webpki", -] - [[package]] name = "ryu" version = "1.0.11" @@ -1439,6 +1497,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -1452,13 +1520,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" [[package]] -name = "sct" -version = "0.7.0" +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ - "ring", - "untrusted", + "core-foundation-sys", + "libc", ] [[package]] @@ -1555,12 +1636,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "static_assertions" version = "1.1.0" @@ -1854,12 +1929,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "url" version = "2.3.1" @@ -1882,6 +1951,12 @@ dependencies = [ "serde", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -1954,35 +2029,6 @@ version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" -[[package]] -name = "web-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" -dependencies = [ - "webpki", -] - [[package]] name = "wide" version = "0.7.5" @@ -2024,6 +2070,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -2031,12 +2090,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_x86_64_msvc 0.42.0", ] [[package]] @@ -2045,24 +2104,48 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + [[package]] name = "windows_x86_64_gnu" version = "0.42.0" @@ -2075,6 +2158,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "windows_x86_64_msvc" version = "0.42.0" diff --git a/Cargo.toml b/Cargo.toml index ba59184c..b631cf8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cozo" version = "0.1.0" edition = "2021" -description = "A database in development" +description = "A general-purpose, transactional, relational database that uses Datalog and focuses on graph data" authors = ["Ziyang Hu"] license = "AGPL-3.0-or-later" @@ -16,7 +16,7 @@ io-uring = ["cozorocks/io-uring"] casey = "0.3.3" either = "1.7.0" rand = "0.8.5" -miette = { version = "5.3.0", features = ["fancy"] } +miette = { version = "=5.3.0", features = ["fancy"] } lazy_static = "1.4.0" log = "0.4.16" env_logger = "0.9.0" @@ -42,7 +42,7 @@ pest = "2.2.1" pest_derive = "2.2.1" rayon = "1.5.3" nalgebra = "0.31.1" -minreq = { version = "2.6.0", features = ["https-rustls"] } +minreq = { version = "2.6.0", features = ["https-native"] } approx = "0.5.1" unicode-normalization = "0.1.21" thiserror = "1.0.34" @@ -54,9 +54,6 @@ cozorocks = { path = "cozorocks" } clap = { version = "3.2.8", features = ["derive"] } rouille = "3.5.0" -#[target.'cfg(not(target_env = "msvc"))'.dependencies] -#tikv-jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] } - #[profile.release] #lto = true diff --git a/cozorocks/Cargo.toml b/cozorocks/Cargo.toml index c171439f..12ad27f6 100644 --- a/cozorocks/Cargo.toml +++ b/cozorocks/Cargo.toml @@ -3,12 +3,13 @@ name = "cozorocks" version = "0.1.0" edition = "2021" license = "MIT/Apache-2.0/BSD-3-Clause" +authors = ["Ziyang Hu"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] cxx = "1.0.69" -miette = "5.3.0" +miette = "=5.3.0" libc = "0.2" tikv-jemalloc-sys = { version = "0.5", features = ["unprefixed_malloc_on_supported_platforms"], optional = true } lz4-sys = { version = "1.9" } diff --git a/src/algo/csv.rs b/src/algo/csv.rs index 8c35a91b..cd96b47c 100644 --- a/src/algo/csv.rs +++ b/src/algo/csv.rs @@ -9,6 +9,7 @@ use miette::{bail, ensure, IntoDiagnostic, Result}; use smartstring::{LazyCompact, SmartString}; use crate::algo::{AlgoImpl, CannotDetermineArity}; +use crate::algo::jlines::get_file_content_from_url; use crate::data::expr::Expr; use crate::data::functions::{op_to_float, op_to_uuid}; use crate::data::program::{ @@ -157,7 +158,7 @@ impl AlgoImpl for CsvReader { } } None => { - let content = minreq::get(&url as &str).send().into_diagnostic()?; + let content = get_file_content_from_url(&url)?; let mut rdr = rdr_builder.from_reader(content.as_bytes()); for record in rdr.records() { let record = record.into_diagnostic()?; diff --git a/src/algo/jlines.rs b/src/algo/jlines.rs index 43b7850c..bc32e2f4 100644 --- a/src/algo/jlines.rs +++ b/src/algo/jlines.rs @@ -8,7 +8,9 @@ use std::io::BufRead; use std::{fs, io}; use itertools::Itertools; -use miette::{bail, miette, Diagnostic, IntoDiagnostic, Result}; +use log::error; +use miette::{bail, miette, Diagnostic, IntoDiagnostic, Result, WrapErr}; +use minreq::Response; use smartstring::{LazyCompact, SmartString}; use thiserror::Error; @@ -105,7 +107,7 @@ impl AlgoImpl for JsonReader { } } None => { - let content = minreq::get(&url as &str).send().into_diagnostic()?; + let content = get_file_content_from_url(&url)?; let content = content.as_str().into_diagnostic()?; if json_lines { for line in content.lines() { @@ -168,3 +170,13 @@ impl AlgoImpl for JsonReader { }) } } + +pub(crate) fn get_file_content_from_url(url: &str) -> Result { + minreq::get(&url as &str) + .send() + .map_err(|e| { + error!("{:?}", e); + miette!(e) + }) + .wrap_err_with(|| format!("when requesting URL {}", url)) +} diff --git a/src/cozoscript.pest b/src/cozoscript.pest index 0b85629b..a029b198 100644 --- a/src/cozoscript.pest +++ b/src/cozoscript.pest @@ -17,7 +17,7 @@ list_relations_op = {"relations"} list_relation_op = {"columns" ~ compound_ident} remove_relations_op = {"remove" ~ (compound_ident ~ ",")* ~ compound_ident } rename_relations_op = {"rename" ~ (rename_pair ~ ",")* ~ rename_pair } -access_level_op = {"access_level" ~ access_level ~ compound_ident} +access_level_op = {"access_level" ~ access_level ~ (compound_ident ~ ",")* ~ compound_ident} access_level = {("normal" | "protected" | "read_only" | "hidden")} trigger_relation_show_op = {"show_triggers" ~ compound_ident } trigger_relation_op = {"set_triggers" ~ compound_ident ~ trigger_clause* } diff --git a/src/parse/sys.rs b/src/parse/sys.rs index debe6723..3d1c1b04 100644 --- a/src/parse/sys.rs +++ b/src/parse/sys.rs @@ -26,7 +26,7 @@ pub(crate) enum SysOp { RenameRelation(Vec<(Symbol, Symbol)>), ShowTrigger(Symbol), SetTriggers(Symbol, Vec, Vec, Vec), - SetAccessLevel(Symbol, AccessLevel), + SetAccessLevel(Vec, AccessLevel), } #[derive(Debug, Diagnostic, Error)] @@ -91,9 +91,12 @@ pub(crate) fn parse_sys( "hidden" => AccessLevel::Hidden, _ => unreachable!() }; - let rel_p = ps.next().unwrap(); - let rel = Symbol::new(rel_p.as_str(), rel_p.extract_span()); - SysOp::SetAccessLevel(rel, access_level) + let mut rels = vec![]; + for rel_p in ps { + let rel = Symbol::new(rel_p.as_str(), rel_p.extract_span()); + rels.push(rel) + } + SysOp::SetAccessLevel(rels, access_level) } Rule::trigger_relation_show_op => { let rels_p = inner.into_inner().next().unwrap(); diff --git a/src/runtime/db.rs b/src/runtime/db.rs index b8a193e1..f69a35db 100644 --- a/src/runtime/db.rs +++ b/src/runtime/db.rs @@ -484,9 +484,11 @@ impl Db { tx.commit_tx()?; Ok(json!({"headers": ["status"], "rows": [["OK"]]})) } - SysOp::SetAccessLevel(name, level) => { + SysOp::SetAccessLevel(names, level) => { let mut tx = self.transact_write()?; - tx.set_access_level(name, level)?; + for name in names { + tx.set_access_level(name, level)?; + } tx.commit_tx()?; Ok(json!({"headers": ["status"], "rows": [["OK"]]})) }