mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-16 10:12:58 +00:00
feat: add optional schema for Postgres metadata tables (#6764)
* feat(meta): add optional schema for Postgres metadata tables - Add `schema` option to specify a custom schema for metadata tables - Update `PgStore` and `PgElection` to support optional schema - Modify SQL templates to use schema when provided - Add tests for schema support in Postgres backend Signed-off-by: Logic <zqr10159@dromara.org> * refactor(meta): remove unused `create_schema_statement` and simplify `PgSqlTemplateFactory` - Remove `create_schema_statement` from `PgSqlTemplateSet` struct - Simplify `PgSqlTemplateFactory` by removing `new` method and merging it with `with_schema` - Update related tests to reflect these changes Signed-off-by: Logic <zqr10159@dromara.org> * refactor(meta-srv): remove unused imports - Remove unused import of BoxedError from common_error::ext- Remove unused import of TlsOption from servers::tls Signed-off-by: Logic <zqr10159@dromara.org> * build(meta): update Postgres version and add error handling imports - Update Postgres version to 17 in docker-compose.yml - Add BoxedError import for error handling in meta-srv Signed-off-by: Logic <zqr10159@dromara.org> * feat(postgres): add support for optional schema in PgElection and related components Signed-off-by: Logic <zqr10159@dromara.org> * feat(postgres): add support for optional schema in PgElection and related components Signed-off-by: Logic <zqr10159@dromara.org> * fix(develop): update Postgres schema commands to specify host Signed-off-by: Logic <zqr10159@dromara.org> * refactor(postgres): simplify plugin options handling and update SQL examples Signed-off-by: Logic <zqr10159@dromara.org> * refactor(postgres): simplify plugin options handling and update SQL examples Signed-off-by: Logic <zqr10159@dromara.org> * fix(postgres): update meta_election_lock_id description for optional schema support Signed-off-by: Logic <zqr10159@dromara.org> * fix(postgres): add health check and fallback wait for Postgres in CI setup * fix(postgres): update Docker setup for Postgres and add support for Postgres 15 * fix(postgres): remove redundant Postgres setup step in CI configuration * Update tests-integration/fixtures/postgres/init.sql Co-authored-by: Weny Xu <wenymedia@gmail.com> * Update .github/workflows/develop.yml * Update tests-integration/fixtures/docker-compose.yml * Update src/common/meta/src/kv_backend/rds/postgres.rs Co-authored-by: Weny Xu <wenymedia@gmail.com> * Update src/common/meta/src/kv_backend/rds/postgres.rs Co-authored-by: Weny Xu <wenymedia@gmail.com> * Update src/common/meta/src/kv_backend/rds/postgres.rs Co-authored-by: Weny Xu <wenymedia@gmail.com> * Update src/common/meta/src/kv_backend/rds/postgres.rs Co-authored-by: Weny Xu <wenymedia@gmail.com> * fix: Refactor PostgreSQL backend to support optional schema in PgStore and related SQL templates * feat: Update PostgreSQL configuration and add PG15 specific integration tests * feat: Update PostgreSQL configuration and add PG15 specific integration tests * refactor(postgres): update test schemas from 'greptime_schema' to 'test_schema' * Update .github/workflows/develop.yml * refactor: minor factor Signed-off-by: WenyXu <wenymedia@gmail.com> * chore: apply suggestions Signed-off-by: WenyXu <wenymedia@gmail.com> * fix: fix unit test Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: Logic <zqr10159@dromara.org> Signed-off-by: WenyXu <wenymedia@gmail.com> Co-authored-by: Weny Xu <wenymedia@gmail.com>
This commit is contained in:
@@ -66,6 +66,9 @@ pub struct BenchTableMetadataCommand {
|
||||
#[cfg(feature = "pg_kvbackend")]
|
||||
#[clap(long)]
|
||||
postgres_addr: Option<String>,
|
||||
#[cfg(feature = "pg_kvbackend")]
|
||||
#[clap(long)]
|
||||
postgres_schema: Option<String>,
|
||||
#[cfg(feature = "mysql_kvbackend")]
|
||||
#[clap(long)]
|
||||
mysql_addr: Option<String>,
|
||||
|
||||
@@ -57,6 +57,10 @@ pub(crate) struct StoreConfig {
|
||||
#[clap(long, default_value = common_meta::kv_backend::DEFAULT_META_TABLE_NAME)]
|
||||
meta_table_name: String,
|
||||
|
||||
/// Optional PostgreSQL schema for metadata table (defaults to current search_path if unset).
|
||||
#[cfg(feature = "pg_kvbackend")]
|
||||
#[clap(long)]
|
||||
meta_schema_name: Option<String>,
|
||||
/// TLS mode for backend store connections (etcd, PostgreSQL, MySQL)
|
||||
#[clap(long = "backend-tls-mode", value_enum, default_value = "disable")]
|
||||
backend_tls_mode: TlsMode,
|
||||
@@ -110,8 +114,10 @@ impl StoreConfig {
|
||||
let pool = meta_srv::bootstrap::create_postgres_pool(store_addrs, None)
|
||||
.await
|
||||
.map_err(BoxedError::new)?;
|
||||
let schema_name = self.meta_schema_name.as_deref();
|
||||
Ok(common_meta::kv_backend::rds::PgStore::with_pg_pool(
|
||||
pool,
|
||||
schema_name,
|
||||
table_name,
|
||||
max_txn_ops,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user