{"record":{"id":"b0b3d535bca4e918","repo":"vitessio/vitess","slug":"invalid-database-name-s","errorCode":null,"errorMessage":"invalid database name: %s","messagePattern":"invalid database name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/controller_plan.go","lineNumber":176,"sourceCode":"\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tplan.query = query\n\treturn plan, nil\n}\n\nfunc buildInsertPlan(ins *sqlparser.Insert) (*controllerPlan, error) {\n\t// This should never happen.\n\tif ins == nil {\n\t\treturn nil, errors.New(\"BUG: invalid nil INSERT statement found when building VReplication plan\")\n\t}\n\ttableName, err := ins.Table.TableName()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif tableName.Qualifier.String() != sidecar.GetName() && tableName.Qualifier.String() != sidecar.DefaultName {\n\t\treturn nil, fmt.Errorf(\"invalid database name: %s\", tableName.Qualifier.String())\n\t}\n\tswitch tableName.Name.String() {\n\tcase reshardingJournalTableName:\n\t\treturn &controllerPlan{\n\t\t\topcode: reshardingJournalQuery,\n\t\t}, nil\n\tcase vreplicationTableName:\n\t\t// no-op\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid table name: %s\", tableName.Name.String())\n\t}\n\tif ins.Action != sqlparser.InsertAct {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tif ins.Ignore {\n\t\treturn nil, fmt.Errorf(\"unsupported construct: %v\", sqlparser.String(ins))\n\t}\n\tif ins.Partitions != nil {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/controller_plan.go#L158-L194","documentation":"buildInsertPlan validates that an INSERT statement targets the sidecar database (the configured sidecar name or the default `_vt`). An INSERT qualified with any other database name is rejected with `invalid database name: <qualifier>`.","triggerScenarios":"An INSERT whose table qualifier is neither the configured sidecar identifier nor sidecar.DefaultName — e.g. `INSERT INTO myschema.vreplication VALUES ...` issued through the vreplication engine's exec path.","commonSituations":"Typing the unqualified/wrongly qualified sidecar table name in a VExec statement; sidecar table renamed via --sidecar-db-name-identifier while scripts still use the old name; copying queries written for a different schema.","solutions":["Qualify the insert with the correct sidecar name: `insert into _vt.vreplication ...` (default).","If a custom sidecar identifier is configured, use that identifier in the qualifier.","Omit the database qualifier and target the sidecar table by name through the engine's own connection.","Check the tablet's --sidecar-db-name-identifier flag to learn the expected qualifier."],"exampleFix":"// before\ninsert into commerce.vreplication(id, workflow) values (1, 'w')\n// after\ninsert into _vt.vreplication(id, workflow) values (1, 'w')","handlingStrategy":"validation","validationCode":"func validSidecarQualifier(q string, sidecar string) bool {\n    return q == sidecar || q == \"_vt\" || q == \"\"\n}\n// check before issuing: validSidecarQualifier(qualifierFromSQL(stmt), sidecar.GetName())","typeGuard":null,"tryCatchPattern":"plan, err := buildInsertPlan(ins, sidecar)\nif err != nil && strings.Contains(err.Error(), \"invalid database name\") {\n    return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, \"qualify inserts with the sidecar db (%s), not another schema\", sidecar.GetName())\n}","preventionTips":["Always qualify sidecar tables with `_vt` or the configured --sidecar-db-name-identifier.","Grep scripts for schema-qualified vreplication references after sidecar renames.","Keep generated SQL unqualified or generated from sidecar.GetName() at runtime."],"tags":["sql","vreplication","validation"],"backgroundTag":"invalid-database-name","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}