emotionbug edited a comment on issue #162: URL: https://github.com/apache/incubator-age/issues/162#issuecomment-998462127
I tested again. it works. ```sh git clone -b binary_io --single-branch https://github.com/emotionbug/incubator-age.git cd incubator-age make -j16 && make install -j16 ``` ```psql update pg_type set typsend = 'ag_catalog.agtype_send', typreceive = 'ag_catalog.agtype_recv' where typname = 'agtype'; ``` ```rust use postgres::{Client, Error, NoTls}; use postgres::types::{FromSql, Type}; struct AgType<'a>(&'a str); impl<'a> FromSql<'a> for AgType<'a> { fn from_sql(_: &Type, raw: &'a [u8]) -> Result<AgType<'a>, Box<dyn std::error::Error + Sync + Send>> { let t = postgres_protocol::types::text_from_sql(raw)?; Ok(AgType(t)) } fn accepts(ty: &Type) -> bool { ty.name() == "agtype" } } pub fn graph_list() -> Result<(), Error> { let conn_string = "host=172.17.0.2 port=5432 dbname=postgres user=postgres password=postgres"; let mut client = Client::connect(conn_string, NoTls)?; &client.batch_execute("LOAD \'age\'")?; &client.batch_execute("SET search_path = ag_catalog, \"$user\", public")?; // &client.batch_execute("SELECT * from create_graph('text_test')")?; // &client.batch_execute("SELECT * from cypher('text_test', $$ CREATE (V:node{id:1}) $$) as (V agtype)")?; for types in &client.query("SELECT count(*) FROM ag_graph WHERE name= 'text_test'", &[])? { println!("{:?}", types) } for row in client.query("SELECT * from cypher('text_test', $$ MATCH (V:node) RETURN V $$) as (V agtype)", &[])? { let path: AgType = row.get(0); println!("{:?}", path.0); } Ok(()) } fn main() { match graph_list() { Ok(r) => { println!("Succeeded! {:?} ", r); } Err(e) => { println!("Error: {}!", e); } } } ``` if you are not working, check `pg_type` record. ``` postgres=# select typreceive, typsend from pg_type where typname = 'agtype'; typreceive | typsend ------------------------+------------------------ ag_catalog.agtype_recv | ag_catalog.agtype_send (1 row) ``` ``` warning: unused borrow that must be used --> src/main.rs:23:5 | 23 | &client.batch_execute("LOAD \'age\'")?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the borrow produces a value | = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 23 | let _ = &client.batch_execute("LOAD \'age\'")?; | +++++++ warning: unused borrow that must be used --> src/main.rs:24:5 | 24 | &client.batch_execute("SET search_path = ag_catalog, \"$user\", public")?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the borrow produces a value | help: use `let _ = ...` to ignore the resulting value | 24 | let _ = &client.batch_execute("SET search_path = ag_catalog, \"$user\", public")?; | +++++++ warning: `rust_age` (bin "rust_age") generated 2 warnings Finished dev [unoptimized + debuginfo] target(s) in 0.03s Running `target/debug/rust_age` Row { columns: [Column { name: "count", type: Int8 }] } "{\"id\": 844424930131969, \"label\": \"node\", \"properties\": {\"id\": 1}}::vertex" Succeeded! () Process finished with exit code 0 ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
