How to fix ERROR 1210: Incorrect arguments to function in MySQL
ERROR 1210 occurs when a MySQL function, stored procedure, or prepared statement receives arguments that do not match the function definition in type, count, or format. This commonly happens with prepared statements using LIMIT clauses, UNSIGNED parameters with IFNULL, or DATA DIRECTORY options.
Quick fix
Fixes 1210
ERROR 1210 (HY000): Incorrect arguments to EXECUTE
ERROR 1210 (HY000): Incorrect arguments to DATA DIRECTORY- Verify the exact function or procedure name in the error
- Check parameter count in prepared statements
- Verify argument data types match the expected types
- Fix IFNULL with UNSIGNED parameters using CONVERT
ERROR 1210 (HY000): Incorrect arguments to EXECUTEERROR 1210 (HY000): Incorrect arguments to DATA DIRECTORYERROR 1210: Incorrect arguments to function
What this error means
ERROR 1210 (SQLSTATE HY000) is a generic MySQL error that signals incorrect arguments were passed to a function, stored procedure, or prepared statement. MySQL evaluates the arguments against the function signature and rejects the call if the count, data types, or formats do not match. The error message typically includes a placeholder (%s) indicating which function received the incorrect arguments. This error is particularly common in prepared statements where type coercion and validation rules are stricter than in regular SQL queries. Unlike some functions that perform implicit type conversion, prepared statements enforce exact argument matching to maintain type safety.
Typical symptoms
- Prepared statements fail with "ERROR 1210" when executed
- Queries that work in the client fail in application code
- LIMIT clause in prepared statements throws ERROR 1210
- IFNULL with UNSIGNED parameters causes the error
- Batch inserts with many placeholders fail when parameter count nears 65536
- Version incompatibility between libmysqlclient and MySQL server
Common causes
- Prepared statement receives wrong number of arguments (parameter count mismatch)
- Argument data type does not match the function parameter type (e.g., UNSIGNED passed where SIGNED expected)
- Using IFNULL or type coercion functions with UNSIGNED parameters in prepared statements
- LIMIT clause in prepared statement receiving non-integer values
- DATA DIRECTORY option provided with invalid or unsupported arguments
- Prepared statement with empty strings combined with large placeholder count (approaching 65536 limit)
- Version incompatibility between client library (libmysqlclient) and MySQL server versions
How to fix "ERROR 1210: Incorrect arguments to function"
Review the full error message from MySQL. The error should indicate which function or procedure received incorrect arguments. Example:
ERROR 1210 (HY000): Incorrect arguments to EXECUTE
ERROR 1210 (HY000): Incorrect arguments to DATA DIRECTORYThis tells you exactly where the problem is.
If using prepared statements, ensure the number of placeholders (?) matches the number of arguments passed to EXECUTE or the bind parameters:
-- INCORRECT: 3 placeholders but only 2 arguments
PREPARE stmt FROM "SELECT * FROM users WHERE id = ? AND status = ? AND role = ?";
EXECUTE stmt USING @id, @status; -- Only 2 variables
-- CORRECT: 3 placeholders and 3 arguments
PREPARE stmt FROM "SELECT * FROM users WHERE id = ? AND status = ? AND role = ?";
EXECUTE stmt USING @id, @status, @role; -- All 3 variablesCompare the data types of arguments with the function signature. Prepare a simple test:
-- If function expects INT but you pass UNSIGNED INT
SET @unsigned_val = CAST(10 AS UNSIGNED); -- UNSIGNED
PREPARE stmt FROM "SELECT * FROM table LIMIT ?";
EXECUTE stmt USING @unsigned_val; -- May fail
-- Convert to match expected type
SET @signed_val = CAST(10 AS SIGNED); -- SIGNED (default)
EXECUTE stmt USING @signed_val; -- Should workIf using IFNULL with UNSIGNED parameters in a LIMIT clause, the function may fail type checking. Explicitly convert to SIGNED:
-- PROBLEMATIC
SET @u_rows = IFNULL(u_rows, 10); -- May cause ERROR 1210 if u_rows is UNSIGNED
PREPARE stmt FROM "SELECT * FROM table LIMIT ?";
EXECUTE stmt USING @u_rows;
-- SOLUTION: Convert to SIGNED explicitly
SET @u_rows = CONVERT(IFNULL(u_rows, 10), SIGNED);
PREPARE stmt FROM "SELECT * FROM table LIMIT ?";
EXECUTE stmt USING @u_rows; -- Should workFor prepared statements with UNSIGNED parameters, replace IFNULL with explicit IF logic:
-- PROBLEMATIC
SET @u_rows = IFNULL(u_rows, 10);
PREPARE stmt FROM "SELECT * FROM table LIMIT ?";
EXECUTE stmt USING @u_rows;
-- ALTERNATIVE: Use separate SET and IF
SET @u_rows = u_rows;
IF @u_rows IS NULL THEN
SET @u_rows = 10;
END IF;
PREPARE stmt FROM "SELECT * FROM table LIMIT ?";
EXECUTE stmt USING @u_rows; -- More compatibleIf using prepared statements with many placeholders (approaching 65536), reduce the number of placeholders per statement:
-- PROBLEMATIC: Too many placeholders with empty strings
PREPARE stmt FROM "INSERT INTO table VALUES (?, ?, ?, ...)";
-- With 65535 placeholders - may fail
-- SOLUTION: Split into multiple batches
-- Batch 1: First 60000 placeholders
PREPARE stmt1 FROM "INSERT INTO table VALUES (?, ?, ..., ?)";
EXECUTE stmt1 USING @val1, @val2, ..., @val60000;
-- Batch 2: Remaining values
PREPARE stmt2 FROM "INSERT INTO table VALUES (?, ?, ..., ?)";
EXECUTE stmt2 USING @val60001, ..., @valN;If you are experiencing ERROR 1210 with a version mismatch between libmysqlclient and MySQL server:
# For Ubuntu/Debian (version incompatibility between client and server)
sudo apt-get update
sudo apt-get install --only-upgrade libmysqlclient21
# Or for development
sudo apt-get install --only-upgrade libmysqlclient-dev
# Verify versions match
mysql --version
mysqldump --versionEnsure your client library version is compatible with your MySQL server version (ideally within the same major version).
If ERROR 1210 occurs with CREATE TABLE and DATA DIRECTORY:
-- PROBLEMATIC: Invalid path format or unsupported argument
CREATE TABLE users (
id INT PRIMARY KEY
) DATA DIRECTORY = '/invalid/path/';
-- SOLUTION: Use valid paths and ensure table option is supported
-- Check MySQL docs for your version - DATA DIRECTORY may require specific configurations
CREATE TABLE users (
id INT PRIMARY KEY
);Consult MySQL documentation for your specific version regarding DATA DIRECTORY support and requirements.
Advanced notes
ERROR 1210 can be particularly tricky because prepared statements use stricter type validation than regular SQL queries. This is intentional for security and consistency, but it means implicit type conversions that work in regular queries might fail in prepared statements.
The error is version-dependent: MySQL 5.0.45 introduced stricter type checking in prepared statements that would catch these issues. Upgrading to newer MySQL versions (5.7, 8.0) generally has better error messages that help identify the exact argument causing the problem.
When debugging, enable the MySQL query log to see the exact prepared statement and arguments:
SET GLOBAL general_log = ON;
SET GLOBAL log_output = 'TABLE';
SELECT * FROM mysql.general_log;
SET GLOBAL general_log = OFF;For application developers using MySQL drivers (go-sql-driver, node-mysql2, etc.), ensure you are using the latest version of your driver, as many have implemented automatic type handling that works around these issues.
Frequently asked questions
- What does "1210" mean?
- ERROR 1210 (SQLSTATE HY000) is a generic MySQL error that signals incorrect arguments were passed to a function, stored procedure, or prepared statement. MySQL evaluates the arguments against the function signature and rejects the call if the count, data types, or formats do not match. The error message typically includes a placeholder (%s) indicating which function received the incorrect arguments.
- How do I fix "1210"?
- ERROR 1210 occurs when a MySQL function, stored procedure, or prepared statement receives arguments that do not match the function definition in type, count, or format. This commonly happens with prepared statements using LIMIT clauses, UNSIGNED parameters with IFNULL, or DATA DIRECTORY options.
- What causes "1210"?
- Prepared statement receives wrong number of arguments (parameter count mismatch) Argument data type does not match the function parameter type (e.g., UNSIGNED passed where SIGNED expected) Using IFNULL or type coercion functions with UNSIGNED parameters in prepared statements
- Is the "1210" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐MySQL Official Documentation
- ๐MySQL Error Reference 8.0(Official Docs)
- ๐
- ๐