Skip to content

Commit

Permalink
make opts public
Browse files Browse the repository at this point in the history
  • Loading branch information
rebasedming authored and kysshsy committed Jan 12, 2025
1 parent 15d5437 commit 91ea206
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 0 additions & 2 deletions supabase-wrappers/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::ffi::CStr;
use crate::prelude::*;
use pgrx::pg_sys::panic::ErrorReport;
use pgrx::prelude::*;
use std::collections::HashMap;
use std::panic::{catch_unwind, AssertUnwindSafe};

pub struct ForeignServer {
pub server_name: String,
Expand Down
4 changes: 4 additions & 0 deletions supabase-wrappers/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub const FOREIGN_SERVER_RELATION_ID: Oid = BuiltinOid::ForeignServerRelationId.
/// Constant can be used in [validator](ForeignDataWrapper::validator)
pub const FOREIGN_TABLE_RELATION_ID: Oid = BuiltinOid::ForeignTableRelationId.value();

pub const OPTS_DATABASE_KEY: &str = "database_oid";
pub const OPTS_NAMESPACE_KEY: &str = "namespace_oid";
pub const OPTS_TABLE_KEY: &str = "table_oid";

/// A data cell in a data row
#[derive(Debug)]
pub enum Cell {
Expand Down
15 changes: 7 additions & 8 deletions supabase-wrappers/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use std::os::raw::c_int;
use std::ptr;

use crate::instance;
use crate::interface::{Cell, Column, Limit, Qual, Row, Sort, Value};
use crate::interface::{
Cell, Column, Limit, Qual, Row, Sort, Value, OPTS_DATABASE_KEY, OPTS_NAMESPACE_KEY,
OPTS_TABLE_KEY,
};
use crate::limit::*;
use crate::memctx;
use crate::options::options_to_hashmap;
Expand All @@ -22,10 +25,6 @@ use crate::qual::*;
use crate::sort::*;
use crate::utils::{self, report_error, ReportableError, SerdeList};

pub const OPTS_DATABASE_KEY: &str = "database_oid";
pub const OPTS_NAMESPACE_KEY: &str = "namespace_oid";
pub const OPTS_TABLE_KEY: &str = "table_oid";

// Fdw private state for scan
struct FdwState<E: Into<ErrorReport>, W: ForeignDataWrapper<E>> {
// foreign data wrapper instance
Expand Down Expand Up @@ -321,9 +320,9 @@ pub(super) extern "C" fn begin_foreign_scan<E: Into<ErrorReport>, W: ForeignData

// pass begin_scan OID values for the table, schema, and database
let pg_rel = PgRelation::from_pg(rel);
let database_oid = pg_sys::MyDatabaseId.to_string();
let namespace_oid = pg_rel.namespace_oid().to_string();
let table_oid = pg_rel.oid().to_string();
let database_oid = pg_sys::MyDatabaseId.as_u32().to_string();
let namespace_oid = pg_rel.namespace_oid().as_u32().to_string();
let table_oid = pg_rel.oid().as_u32().to_string();
let extra_opts = HashMap::from([
(OPTS_DATABASE_KEY.into(), database_oid),
(OPTS_NAMESPACE_KEY.into(), namespace_oid),
Expand Down

0 comments on commit 91ea206

Please sign in to comment.