Recent

Author Topic: [SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?  (Read 589 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?
« on: April 30, 2026, 10:38:14 pm »
I just was testing an application that I'm working on at the moment, in the Contacts table I have a CLOB or tried changing it to a MEMO field for the Notes/Profile field.  After about 150-200 characters, it's truncating or cutting off the rest when I save the record. It's supposed to have a limit of 1GB I read somewhere.  200 characters is no where that large. Changing it from CLOB to MEMO didn't cure the issue.

« Last Edit: May 07, 2026, 11:53:32 pm by 1HuntnMan »

paweld

  • Hero Member
  • *****
  • Posts: 1617
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #1 on: May 01, 2026, 06:34:13 am »
Whether using the SQLdb or Zeos components, I have no trouble saving long text (I tested it with over 1,000 characters) or a file (an image of ~100 KB) to the database.
Perhaps when defining the dataset, you set a limit on that column yourself (the Size property for the field), and in that case, the dataset ensures that you do not exceed that size.
Best regards / Pozdrawiam
paweld

Zvoni

  • Hero Member
  • *****
  • Posts: 3376
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #2 on: May 04, 2026, 08:33:23 am »
Is this happening only from your Frontend, or is it the same, when you use a different client (e.g. DB Browser for SQlite)?
Maybe the Limit is in your frontend code and not on the backend
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

cdbc

  • Hero Member
  • *****
  • Posts: 2787
    • http://www.cdbc.dk
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #3 on: May 04, 2026, 08:43:27 am »
Hi
I have no trouble saving several megabytes of pictures or text into SQLite3's BLOB-fields  8)
Mind you -- I don't use "DBAware-gui-stuff"  8-)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Zvoni

  • Hero Member
  • *****
  • Posts: 3376
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #4 on: May 04, 2026, 09:18:42 am »
Hi
I have no trouble saving several megabytes of pictures or text into SQLite3's BLOB-fields  8)
Mind you -- I don't use "DBAware-gui-stuff"  8-)
Regards Benny
Note that TS says "CLOB" which gets TEXT-Affinity (Basically the same as VARCHAR)
BLOB is no Datatype at all
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

cdbc

  • Hero Member
  • *****
  • Posts: 2787
    • http://www.cdbc.dk
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #5 on: May 04, 2026, 09:33:53 am »
Aaaaha, haven't I read somtin' about, at least, varchars limits at 1024?
I dunno... %)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Khrys

  • Sr. Member
  • ****
  • Posts: 439
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #6 on: May 04, 2026, 09:36:53 am »
[...] when I save the record.

Are you using  TParam.AsString  or  TParam.AsMemo?
The former is intended for short strings only (another devious footgun, if you ask me).

Zvoni

  • Hero Member
  • *****
  • Posts: 3376
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #7 on: May 04, 2026, 09:52:35 am »
[...] when I save the record.

Are you using  TParam.AsString  or  TParam.AsMemo?
The former is intended for short strings only (another devious footgun, if you ask me).
That's why i asked if it just happens from his Frontend-code, or also with a different client
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #8 on: May 07, 2026, 11:30:05 pm »
I'll do some testing with DB Browser just to cross-check. I just have a TDBMemo component on the forms for edit/adding.
Thanks...

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 448
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #9 on: May 07, 2026, 11:50:34 pm »
There's no real limit for text or memo according what I'm reading online. So, did some testing with copy/paste of a large amount of text into a Memo field in one of my tables via DB Browser. Saved just fine. Then open my app. and it's all there so. When testing I was copying test data from a website but when I saved it was cutting off the test data.  So, probably hidden characters or whatever.  Not an issue, thanks...

Khrys

  • Sr. Member
  • ****
  • Posts: 439
Re: [SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #10 on: May 08, 2026, 07:12:14 am »
Somewhat off-topic, but has anyone else encountered issues when querying long text fields when using the ODBC  Microsoft Access Driver (*.mdb, *.accdb)? I've consistently gotten strings longer than 2 KiB being padded with large amounts of garbage data at the end.

I've had to override a method in  TODBCConnection  to resolve this (but as far as I can remember this bug isn't caused by Lazarus's ODBC code itself, so I didn't report it).

Code: Pascal  [Select][+][-]
  1. // +-------------------------------------+
  2. // |          TAccessConnection          |
  3. // +-------------------------------------+
  4.  
  5. /// `TODBCConnection` descendant providing patches for the hopeless mess known as the Microsoft Access driver.
  6.  
  7. /// Fixes an issue whereby the length of long text (aka `SQL_LONGVARCHAR`) fields is inflated by a factor of two
  8. /// when the contained data is longer than 2 KiB (e.g. possible length values: 2047, 2048, 4098, 4100, 4102, etc.).
  9. ///
  10. /// There is no rational explanation for this (we're talking about Microsoft Access, after all).
  11. procedure TAccessConnection.LoadBlobIntoBuffer(FieldDef: TFieldDef; FieldBuf: PBufBlobField;
  12.                                                Cursor: TSQLCursor; Trans: TSQLTransaction);
  13. begin
  14.  
  15.   inherited LoadBlobIntoBuffer(FieldDef, FieldBuf, Cursor, Trans);
  16.  
  17.   with FieldBuf^.BlobBuffer^ do if (FieldDef.DataType = ftMemo) and (Size > $800) then begin
  18.     Size := Size div 2;
  19.     ReAllocMem(Buffer, Size);
  20.   end;
  21. end;

Thaddy

  • Hero Member
  • *****
  • Posts: 19165
  • Glad to be alive.
Re: [SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #11 on: May 08, 2026, 07:51:33 am »
Although I first answered relating terminators we saw, it is a documented known bug in Microsoft's Access odbc driver for lengths over ~2k.
objects are fine constructs. You can even initialize them with constructors.

Khrys

  • Sr. Member
  • ****
  • Posts: 439
Re: [SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #12 on: May 08, 2026, 08:14:40 am »
Although I first answered relating terminators we saw, it is a documented known bug in Microsoft's Access odbc driver for lengths over ~2k.

It's documented? Where?  :)

Thaddy

  • Hero Member
  • *****
  • Posts: 19165
  • Glad to be alive.
Re: [SOLVED] Is there a limit to a SQLite3 Memo/CLOB field?
« Reply #13 on: May 08, 2026, 12:30:17 pm »
The only official mention is KB293653 in which you should ignore the unicode focus. But it is a known issue across languages and your solution is the correct one.
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018