{"record":{"id":"25e4644b30097f44","repo":"risingwavelabs/risingwave","slug":"the-database-name-in-the-from-clause-is-not-i","errorCode":null,"errorMessage":"The database name `{}` in the FROM clause is not included in the database name `{}` in source definition","messagePattern":"The database name `(.+?)` in the FROM clause is not included in the database name `(.+?)` in source definition","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/handler/create_table.rs","lineNumber":1017,"sourceCode":"        .get(\"database.name\")\n        .ok_or_else(|| anyhow!(\"The source with properties does not contain 'database.name'\"))?\n        .as_str();\n    let mut with_options = source_with_properties.clone();\n    if let Some(connector) = source_with_properties.get(UPSTREAM_SOURCE_KEY) {\n        match connector.as_str() {\n            MYSQL_CDC_CONNECTOR => {\n                // MySQL doesn't allow '.' in database name and table name, so we can split the\n                // external table name by '.' to get the table name\n                let (db_name, table_name) = external_table_name.split_once('.').ok_or_else(|| {\n                    anyhow!(\"The upstream table name must contain database name prefix, e.g. 'database.table'\")\n                })?;\n                // We allow multiple database names in the source definition\n                if !source_database_name\n                    .split(',')\n                    .map(|s| s.trim())\n                    .any(|name| name == db_name)\n                {\n                    return Err(anyhow!(\n                        \"The database name `{}` in the FROM clause is not included in the database name `{}` in source definition\",\n                        db_name,\n                        source_database_name\n                    ).into());\n                }\n                with_options.insert(DATABASE_NAME_KEY.into(), db_name.into());\n                with_options.insert(TABLE_NAME_KEY.into(), table_name.into());\n                // Return original external_table_name unchanged for MySQL\n                return Ok((with_options, external_table_name));\n            }\n            POSTGRES_CDC_CONNECTOR => {\n                let (schema_name, table_name) =\n                    parse_postgres_cdc_external_table_name(&external_table_name)?;\n\n                // insert 'schema.name' into connect properties\n                with_options.insert(SCHEMA_NAME_KEY.into(), schema_name);\n                with_options.insert(TABLE_NAME_KEY.into(), table_name);\n                // Return original external_table_name unchanged for Postgres","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/handler/create_table.rs#L999-L1035","documentation":"After splitting the FROM-clause table name into `db.table` for a MySQL CDC source, the code verifies that the database prefix appears among the (comma-separated) names declared in the source's `database.name` option. A mismatch means the FROM clause references a database the source is not configured to read, and the error names both values.","triggerScenarios":"`CREATE TABLE ... FROM mysql_src TABLE 'dbB.orders'` where the source was defined with `'database.name' = 'dbA'` (or a list not containing dbB); also triggered during table replacement.","commonSituations":"Typos in the database prefix; sources declared with multiple databases (`'dbA,dbB'`) where the user references a database omitted from the list; renamed databases on the upstream.","solutions":["Change the FROM-clause prefix to a database listed in the source's `database.name`, e.g. `TABLE 'dbA.orders'`.","Or recreate the source with `database.name` including the desired database (comma-separated for several).","Confirm the exact upstream database name case-sensitively (MySQL is case-sensitive depending on platform)."],"exampleFix":"-- before (source has database.name='dbA')\nCREATE TABLE t FROM mysql_src TABLE 'dbB.orders';\n-- after\nCREATE TABLE t FROM mysql_src TABLE 'dbA.orders';","handlingStrategy":"validation","validationCode":"fn db_in_source(from_db: &str, source_db: &str) -> bool {\n    source_db.split(',').map(|s| s.trim()).any(|n| n == from_db)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the FROM-clause database prefix in sync with the source's database.name","When using multi-database sources, confirm the target db is in the comma list","Re-check names after renaming upstream databases"],"tags":["rust","cdc","mysql","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}