-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE FUNCTION create_table() | ||
RETURNS VOID AS 'MODULE_PATHNAME', 'create_table' | ||
LANGUAGE C STRICT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use pgrx::prelude::*; | ||
use pgrx::spi::Spi; | ||
use std::error::Error; | ||
|
||
#[pg_extern] | ||
fn create_table() -> Result<(), Box<dyn Error>> { | ||
let queries = r#" | ||
CREATE TABLE IF NOT EXISTS metric_labels ( | ||
id SERIAL PRIMARY KEY, | ||
name TEXT NOT NULL, | ||
labels jsonb NOT NULL | ||
); | ||
CREATE TABLE IF NOT EXISTS metric_values ( | ||
label_id INTEGER REFERENCES metric_labels (id), | ||
time TIMESTAMP NOT NULL, | ||
value DOUBLE PRECISION NOT NULL | ||
) PARTITION BY RANGE (time); | ||
"#; | ||
|
||
Spi::run(queries); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn index_tables() { | ||
// Implement indexing logic | ||
} | ||
|
||
fn create_partitions(){ | ||
// Implement partitioning logic | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mod init; | ||
|
||
use pgrx::warning; | ||
use pgrx::{pg_sys, prelude::*, JsonB}; | ||
use reqwest::{self, Client}; | ||
|