{"record":{"id":"a4a6005498bacc5c","repo":"MyCATApache/Mycat-Server","slug":"partition-table-insert-must-provide-columnlist","errorCode":null,"errorMessage":"partition table, insert must provide ColumnList","messagePattern":"partition table, insert must provide ColumnList","errorType":"exception","errorClass":"SQLSyntaxErrorException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java","lineNumber":77,"sourceCode":"\t\tTableConfig tc = schema.getTables().get(tableName);\n\t\tif(tc == null) {\n\t\t\tString msg = \"can't find table define in schema \"\n\t\t\t\t\t+ tableName + \" schema:\" + schema.getName();\n\t\t\tLOGGER.warn(msg);\n\t\t\tthrow new SQLNonTransientException(msg);\n\t\t} else {\n\t\t\t//childTable的insert直接在解析过程中完成路由\n\t\t\tif (tc.isChildTable()) {\n\t\t\t\tparserChildTable(schema, rrs, tableName, insert);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tString partitionColumn = tc.getPartitionColumn();\n\t\t\t\n\t\t\tif(partitionColumn != null) {//分片表\n\t\t\t\t//拆分表必须给出column list,否则无法寻找分片字段的值\n\t\t\t\tif(insert.getColumns() == null || insert.getColumns().size() == 0) {\n\t\t\t\t\tthrow new SQLSyntaxErrorException(\"partition table, insert must provide ColumnList\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//批量insert\n\t\t\t\tif(isMultiInsert(insert)) {\n//\t\t\t\t\tString msg = \"multi insert not provided\" ;\n//\t\t\t\t\tLOGGER.warn(msg);\n//\t\t\t\t\tthrow new SQLNonTransientException(msg);\n\t\t\t\t\tparserBatchInsert(schema, rrs, partitionColumn, tableName, insert);\n\t\t\t\t} else {\n\t\t\t\t\tparserSingleInsert(schema, rrs, partitionColumn, tableName, insert);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/**\n\t * 寻找joinKey的索引","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java#L59-L95","documentation":"For a sharded (partitioned) table with a configured partitionColumn, Mycat needs the sharding column's value to compute the target node. If the INSERT statement has no column list (INSERT INTO t VALUES (...) or empty columns), the partition column value cannot be located, so SQLSyntaxErrorException is thrown.","triggerScenarios":"INSERT INTO sharded_table VALUES (...) without an explicit column list on a table whose <table> config defines a partitionColumn; insert.getColumns() null or empty in statementParse.","commonSituations":"ORMs generating column-less INSERTs; scripts copied from single-node MySQL usage; tables whose partitionColumn was recently added to config while old SQL lacked the column list.","solutions":["Always write an explicit column list in INSERTs to sharded tables: INSERT INTO t (id, name, sharding_col) VALUES (...).","If the column list is intentionally omitted, remove partitionColumn from the table config or switch to a non-sharded/global table.","Ensure the partition column itself is included in the column list."],"exampleFix":"// before\nINSERT INTO orders VALUES (1, 'x', 100);\n// after\nINSERT INTO orders (id, name, customer_id) VALUES (1, 'x', 100);","handlingStrategy":"validation","validationCode":"// Ensure INSERTs to sharded tables carry an explicit column list\nfunction validateInsert(sql, shardedTables) {\n  const m = /^\\s*INSERT\\s+INTO\\s+[`\\\"]?(\\w+)[`\\\"]?\\s*VALUES/i.exec(sql);\n  if (m && shardedTables.includes(m[1].toUpperCase())) {\n    throw new Error(\"INSERT into sharded table \" + m[1] + \" requires an explicit column list\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ban column-less INSERT syntax in coding standards for sharded tables.","Configure ORMs to always emit explicit column lists."],"tags":["insert","sharding","missing-column-list"],"backgroundTag":"missing-required-argument","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}