0

In some cases, MariaDB will lose the data of the text field. My table is

create table tt(
     id int(11) AUTO_INCREMENT PRIMARY KEY ,
   info text 
)

My SQL is

update tt join 
    (select 'StringValue' as info , 1 as id ) a using(id)
    set tt.info = a.info

The StringValue is a string data that more than 65535 bytes;

I can execute this SQL successfully using Java JDBC, but only a few bytes can be written.

For example, StringValue is a String data with 65538 bytes, after executing the SQL, tt.info has only 2 bytes.

My MariaDB version is 10.4.7, innodb_page_size is 16kb.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Please provide a [mre]. As an aside, you are not using MySQL, you're using MariaDB. Although MariaDB started as a fork of MySQL, it is not the same database system. – Mark Rotteveel Jan 28 '22 at 10:02
  • Does this answer your question? [Maximum length for MySQL type text](https://stackoverflow.com/questions/6766781/maximum-length-for-mysql-type-text) – P.Salmon Jan 28 '22 at 10:09
  • @P.Salmon - That link does not seem to explain how the first 64KB can be tossed, keeping the next 2 bytes. – Rick James Jan 29 '22 at 02:15

1 Answers1

0

That seems to be simply this:

UPDATE tt
    SET info = 'StringValue'
    WHERE id = 1;

But, if the string is bigger than TEXT can hold, it will either give a warning or an error, depending on some setting. Is that what you are asking about? Does the code check for warnings and errors?

If you change the column definition from TEXT to MEDIUMTEXT, the limit is 16MB instead of 64KB. (Both of those numbers are in bytes, not characters.

You say it has 2 bytes -- do they happen to be the last 2 bytes?

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Yes , that is same with UPDATE tt SET info = 'StringValue' WHERE id = 1 ;But my sql is dynamic created , i can not change the sql . And what strange is there is errors or warinings do they happen to be the last 2 bytes -- no, they happen to be the first 2 bytes. – mj_test Jan 29 '22 at 02:07