1pub const FIRST_NORMAL_OBJECT_ID: u32 = 16_384;
11
12pub fn stable_oid(kind: &str, name: &str) -> i64 {
13 let mut hash = 14_695_981_039_346_656_037_u64;
14 for byte in kind.bytes().chain(*b":").chain(name.bytes()) {
15 hash ^= u64::from(byte);
16 hash = hash.wrapping_mul(1_099_511_628_211);
17 }
18 10_000 + i64::try_from(hash % 2_000_000_000).unwrap_or(0)
19}
20
21pub fn stable_object_oid(kind: &str, object_id: &[u8; 16]) -> i64 {
22 let mut hash = 14_695_981_039_346_656_037_u64;
23 for byte in kind.bytes().chain(*b":").chain(object_id.iter().copied()) {
24 hash ^= u64::from(byte);
25 hash = hash.wrapping_mul(1_099_511_628_211);
26 }
27 10_000 + i64::try_from(hash % 2_000_000_000).unwrap_or(0)
28}
29
30pub fn schema_oid(schema: &str) -> i64 {
31 match schema {
32 "pg_catalog" => 11,
33 "public" => 2200,
34 "information_schema" => 13_293,
35 other => stable_oid("namespace", other),
36 }
37}
38
39pub fn relation_oid(kind: &str, schema: &str, name: &str) -> i64 {
40 stable_oid(kind, &format!("{schema}.{name}"))
41}
42
43pub fn current_user_oid() -> i64 {
44 10
45}
46
47pub fn current_user_name() -> &'static str {
48 "uqa"
49}