{"record":{"id":"e9487212416a71c0","repo":"databendlabs/databend","slug":"connection-name-can-not-be-used-with-other-connect","errorCode":null,"errorMessage":"connection_name can not be used with other connection options","messagePattern":"connection_name can not be used with other connection options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/sql/src/planner/binder/location.rs","lineNumber":579,"sourceCode":"    let protocol = l.protocol.parse::<Scheme>()?;\n    let proto = conn.storage_type.parse::<Scheme>().map_err(|err| {\n        Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\"input connection is not a valid protocol: {err:?}\"),\n        )\n    })?;\n    if proto != protocol {\n        return Err(Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\n                \"protocol from connection_name={name} ({proto}) not match with uri protocol ({protocol}).\"\n            ),\n        ));\n    }\n    l.connection.check().map_err(|_| {\n        Error::new(\n            ErrorKind::InvalidInput,\n            anyhow!(\"connection_name can not be used with other connection options\"),\n        )\n    })?;\n    l.connection = Connection::new(conn.storage_params);\n\n    Ok(())\n}\n\nasync fn parse_uri_location_resolved(\n    l: &mut UriLocation,\n    parts: ParsedUriLocation,\n) -> Result<(StorageParams, String)> {\n    let ParsedUriLocation {\n        root,\n        path,\n        protocol,\n    } = parts;\n\n    let sp = match protocol {","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/sql/src/planner/binder/location.rs#L561-L597","documentation":"A named connection reference (connection_name) must be used alone: it cannot be combined with additional inline connection options, otherwise Databend could not decide which settings win. apply_uri_connection calls connection.check() and throws this InvalidInput error when connection_name coexists with other options.","triggerScenarios":"STAGE ... URL='s3://bucket/' CONNECTION_NAME='c' CONNECTION=(REGION='us-east-1') or any other option alongside CONNECTION_NAME in the same CONNECTION clause.","commonSituations":"Trying to override one option of a named connection; tooling that appends extra options to a CONNECTION clause that already names a connection.","solutions":["Remove all other options from the CONNECTION clause, keeping only CONNECTION_NAME","If you need overrides, create a new connection with the full set of options and reference it instead","Inline all required options without CONNECTION_NAME if per-stage customization is needed"],"exampleFix":"-- before\nCREATE STAGE s URL='s3://bucket/path/' CONNECTION_NAME='c' CONNECTION=(REGION='us-east-1');\n-- after\nCREATE STAGE s URL='s3://bucket/path/' CONNECTION_NAME='c';","handlingStrategy":"validation","validationCode":"if opts.contains_key(\"connection_name\") && opts.keys().any(|k| k != \"connection_name\") {\n    return Err(\"CONNECTION_NAME cannot be combined with other connection options\".into());\n}","typeGuard":null,"tryCatchPattern":"match err.kind() { ErrorKind::InvalidInput if msg.contains(\"can not be used with other connection options\") => /* drop extra options or create a new connection */, _ => return Err(err) }","preventionTips":["Treat CONNECTION_NAME as exclusive in the CONNECTION clause","To override settings, create a new connection with all options","Have generators emit either all-inline options or a single CONNECTION_NAME, never both"],"tags":["connection","sql","validation","conflicting-options"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}