Skip to main content

risingwave_connector/source/cdc/
mariadb.rs

1// Copyright 2026 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::collections::BTreeMap;
16
17use risingwave_pb::secret::PbSecretRef;
18
19use crate::error::ConnectorResult;
20use crate::source::cdc::{
21    CdcSourceDdlValidator, CdcSourceExternalTableIdentifier, CdcSourceRuntimeFlags,
22    CdcSourceTypeTrait, Mariadb, Mysql, check_alter_with_options_inner, check_common_with_options,
23};
24
25// ------- Runtime flags -------
26
27impl CdcSourceRuntimeFlags for Mariadb {
28    const CAN_AUTO_SCHEMA_CHANGE: bool = true;
29    const CAN_BACKFILL: bool = true;
30    const CAN_USE_TRANSACTION_METADATA: bool = true;
31    const NEEDS_NON_EMPTY_INITIAL_OFFSET: bool = true;
32}
33
34// ------- DDL validation -------
35
36impl CdcSourceDdlValidator for Mariadb {
37    fn check_and_fill_create_with_options(
38        props: &mut BTreeMap<String, String>,
39        secret_refs: &BTreeMap<String, PbSecretRef>,
40    ) -> ConnectorResult<()> {
41        // MariaDB replication needs a unique `server.id` just like MySQL.
42        Mysql::check_and_fill_create_with_options(props, secret_refs)
43    }
44
45    fn check_alter_with_options(
46        props: &BTreeMap<String, String>,
47        secret_refs: &BTreeMap<String, PbSecretRef>,
48    ) -> ConnectorResult<()> {
49        check_common_with_options::<Self>(props, secret_refs)?;
50        check_alter_with_options_inner(
51            Self::CDC_CONNECTOR_NAME,
52            props,
53            secret_refs,
54            &[
55                "cdc.source.wait.streaming.start.timeout",
56                "debezium.max.queue.size",
57                "debezium.queue.memory.ratio",
58                "hostname",
59                "port",
60                "password",
61            ],
62        )
63    }
64}
65
66// ------- External table identifier -------
67
68impl CdcSourceExternalTableIdentifier for Mariadb {}