Common SQL Errors

MySQL Error 2035: CR_INVALID_BUFFER_USE - Complete Fix & Prevention Guide

Galaxy Team
August 5, 2025

MySQL client error raised when mysql_stmt_send_long_data is used on a parameter that is not declared as a string or binary type.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 2035 (CR_INVALID_BUFFER_USE)?

MySQL Error 2035: CR_INVALID_BUFFER_USE occurs when you call mysql_stmt_send_long_data on a placeholder bound to a non-string or non-binary column. Rebind the parameter with a BLOB, TEXT, or VARBINARY type or avoid mysql_stmt_send_long_data entirely to resolve the issue.

Error Highlights

Typical Error Message

Can't send long data for non-string/non-binary data types (parameter: %d)

Error Type

Client Error

Language

MySQL

Symbol

CR_INVALID_BUFFER_USE

Error Code

2035

SQL State

Explanation

Table of Contents

What does "Can't send long data for non-string/non-binary data types" mean?

The MySQL client library raises error 2035 when mysql_stmt_send_long_data attempts to stream data into a prepared-statement placeholder that is bound to an integer, date, or other fixed-length type. Only placeholders bound as string or binary types can accept long data chunks.

Because the wire protocol expects a fixed number of bytes for non-string data, the client stops the transmission and surfaces CR_INVALID_BUFFER_USE.

The server never receives the packet, so the failure is purely client side.

When does MySQL Error 2035 usually appear?

The error shows up during bulk loads, file uploads, or blob inserts where developers split payloads into chunks via mysql_stmt_send_long_data.

It can surface in C, C++, PHP (mysqli_stmt_send_long_data), Go, and any language that wraps the native C API.

Developers often encounter the issue after changing a column from TEXT to INT but forgetting to update the binding code, or when copy-pasting sample code that uses long-data streaming for every parameter.

Why is fixing CR_INVALID_BUFFER_USE important?

Leaving the bug unfixed stops data from reaching the database, breaks ETL pipelines, and may cause silent data loss if the error is swallowed by retry logic.

Correct binding protects data integrity and boosts application stability.

What Causes This Error?

Using mysql_stmt_send_long_data on a parameter bound as MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, DATE, or any non-string type triggers the error immediately.

Mismatched bind type declarations due to schema changes are another driver.

Altering a column without updating the client binding creates an implicit mismatch.

How to Fix MySQL Error 2035

First, call mysql_stmt_bind_param with the correct MYSQL_TYPE_STRING, MYSQL_TYPE_VAR_STRING, or MYSQL_TYPE_BLOB buffer_type for the placeholder that will receive long data.

If the column must remain numeric, stop using mysql_stmt_send_long_data and instead place the entire numeric value in the input buffer before mysql_stmt_execute.

Common Scenarios and Solutions

Uploading a CSV where a numeric column is mistakenly streamed as long data - change the bind type to string or send the number in one piece.

Storing a large JSON document in a TEXT column renamed to JSON but keeping the old INT bind - switch buffer_type to MYSQL_TYPE_JSON or MYSQL_TYPE_STRING.

Best Practices to Avoid This Error

Keep bind code in one module and regenerate it automatically when the schema changes.

Use descriptive enums rather than hard-coded integers for buffer types.

Write unit tests that prepare statements and assert successful mysql_stmt_send_long_data calls to catch type mismatches early.

Related Errors and Solutions

Error 2034 (CR_MALFORMED_PACKET) occurs when packet sizes are incorrect - often the next error after fixing buffer types.

Error 2055 (CR_SERVER_LOST) indicates network loss during long-data streaming - adjust net_write_timeout and retry logic.

.

Common Causes

Related Errors

FAQs

Does this error come from the server or client?

Error 2035 originates in the MySQL client library before any packet reaches the server.

Can I stream integers with mysql_stmt_send_long_data?

No. Only string and binary types accept streamed chunks. Send numeric values in a single buffer.

Will changing max_allowed_packet fix the error?

No. The error is independent of packet size. It is solely about buffer type mismatch.

How does Galaxy help prevent this error?

Galaxy’s AI copilot detects mismatched bind types while you write C or Go snippets, suggesting the correct MYSQL_TYPE_ constant and avoiding CR_INVALID_BUFFER_USE.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo