{"record":{"id":"f5e64053ce721be7","repo":"risingwavelabs/risingwave","slug":"postgresql-schema-schema-does-not-exist","errorCode":null,"errorMessage":"PostgreSQL schema `{schema}` does not exist","messagePattern":"PostgreSQL schema `(.+?)` does not exist","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/connector/src/connector_common/postgres.rs","lineNumber":339,"sourceCode":"        let row = sqlx::query(CHECK_TABLE_PRIVILEGE_QUERY)\n            .bind(schema)\n            .bind(table)\n            .bind(required_privilege)\n            .fetch_one(connection)\n            .await\n            .context(\"Failed to check PostgreSQL table privileges\")?;\n\n        let privilege_status = PostgresTablePrivilege {\n            user_name: row.get(\"user_name\"),\n            schema_exists: row.get(\"schema_exists\"),\n            table_exists: row.get(\"table_exists\"),\n            has_schema_usage: row.get(\"has_schema_usage\"),\n            has_table_privilege: row.get(\"has_table_privilege\"),\n            has_any_column_privilege: row.get(\"has_any_column_privilege\"),\n        };\n\n        if !privilege_status.schema_exists {\n            return Err(anyhow!(\"PostgreSQL schema `{schema}` does not exist\").into());\n        }\n\n        if !privilege_status.table_exists {\n            return Err(anyhow!(\"PostgreSQL table `{schema}`.`{table}` does not exist\").into());\n        }\n\n        if !privilege_status.has_schema_usage {\n            return Err(anyhow!(\n                \"PostgreSQL table {} exists, but the connection user `{}` does not have USAGE privilege on schema `{}`. Grant privileges on the upstream PostgreSQL database: {}\",\n                format_pg_table_name(schema, table),\n                privilege_status.user_name,\n                schema,\n                format_grant_usage(schema, &privilege_status.user_name),\n            )\n            .into());\n        }\n\n        if !privilege_status.has_table_privilege {","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/connector_common/postgres.rs#L321-L357","documentation":"ensure_table_privilege validates that the configured PostgreSQL user can read the source table. This error is returned when the catalog query reports the schema itself does not exist on the upstream PostgreSQL server, so privilege checks cannot proceed.","triggerScenarios":"Creating a CDC/table source where the `schema.name` setting names a schema absent from the configured database: typo in schema name, wrong database in connection string, case-sensitive quoted schema names, schema dropped before source creation.","commonSituations":"Connecting to the wrong database (schema exists in `prod` but connection points at `staging`); schema names with uppercase letters needing quoting; multi-tenant setups where search_path differs; schema renamed or dropped by migrations.","solutions":["Verify the schema exists: `SELECT 1 FROM information_schema.schemata WHERE schema_name = '<schema>';` on the configured database.","Check the connection string/`database.name` option points at the intended database.","Correct the schema name in the source configuration, honoring case sensitivity (quote if created quoted).","Ensure the connection user has permission to see the schema (USAGE/grant visibility)."],"exampleFix":"// before\nCREATE TABLE t (...) WITH (connector = 'postgres-cdc', schema.name = 'Public', table.name = 'users')\n// after: match actual schema case\nschema.name = 'public'","handlingStrategy":"validation","validationCode":"// check upstream schema before creating the source\nSELECT 1 FROM information_schema.schemata WHERE schema_name = 'public';","typeGuard":null,"tryCatchPattern":"// surface a clear config error when the schema is absent\nif err.to_string().contains(\"does not exist\") && err.to_string().contains(\"schema\") {\n    return Err(anyhow!(\"fix schema.name in the source config; schema not found in the configured database\"));\n}","preventionTips":["Verify schema existence in the exact database from the connection string","Match schema name case exactly (quote-aware)","Run preflight privilege/existence checks before creating sources"],"tags":["postgresql","cdc","schema","validation"],"backgroundTag":"entity-not-found","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"}