Skip to content

Add BLB_write function to allow modification of data in a BLOB#9066

Open
Noremos wants to merge 9 commits into
FirebirdSQL:masterfrom
Noremos:blob_data_modification_function
Open

Add BLB_write function to allow modification of data in a BLOB#9066
Noremos wants to merge 9 commits into
FirebirdSQL:masterfrom
Noremos:blob_data_modification_function

Conversation

@Noremos

@Noremos Noremos commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This PR is part of the JSON implementation. Efficiently writing binary JSON requires modifying a blob. Otherwise, TempSpace is required to use it and convert the data to a blob, significantly increasing overhead.

Additions:

  1. New blob functions: BLB_write. It works the same as TempSpace::write
  2. New blob functions: BLB_read. It works the same as BLB_seek + BLB_get_data
  3. BLB_lseek now works with BLB_put_data (to modify and append data)
  4. BLB_lseek now works with BLB_put_segment (to modify and append data)

@hvlad

hvlad commented Jun 17, 2026

Copy link
Copy Markdown
Member

Whats wrong or not enough with seek + putSegment ?

@Noremos

Noremos commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Whats wrong or not enough with seek + putSegment ?

BLB_lseek works only for BLB_get_segment

@hvlad

hvlad commented Jun 17, 2026

Copy link
Copy Markdown
Member

Whats wrong or not enough with seek + putSegment ?

BLB_lseek works only for BLB_get_segment

So why not make it work with put too? I suppose it's been done in your PR anyway.

@Noremos

Noremos commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Whats wrong or not enough with seek + putSegment ?

BLB_lseek works only for BLB_get_segment

So why not make it work with put too? I suppose it's been done in your PR anyway.

Initially, I wanted to implement the same read/write interface as for TempSpace. But I can do this within the BLB_get_segment function.

@hvlad

hvlad commented Jun 17, 2026

Copy link
Copy Markdown
Member

Whats wrong or not enough with seek + putSegment ?

BLB_lseek works only for BLB_get_segment

So why not make it work with put too? I suppose it's been done in your PR anyway.

Initially, I wanted to implement the same read/write interface as for TempSpace.

You still speak about blobs here ?

But I can do this within the BLB_get_segment function.

I'm lost your point here, sorry. How it answers on my question ?

@hvlad

hvlad commented Jun 17, 2026

Copy link
Copy Markdown
Member

BTW, code in blb.cpp (at least) requires comments. It have none too small useful comments, imo.

@sim1984

sim1984 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Why is JsonTempParsingTests.cpp needed in this PR?

@Noremos

Noremos commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Whats wrong or not enough with seek + putSegment ?

BLB_lseek works only for BLB_get_segment

So why not make it work with put too? I suppose it's been done in your PR anyway.

Initially, I wanted to implement the same read/write interface as for TempSpace.

You still speak about blobs here ?

But I can do this within the BLB_get_segment function.

I'm lost your point here, sorry. How it answers on my question ?

I meant that the TempSpace class has convenient read/write functions with the ability to specify a position, so it would be great to have the same function for blobs at some point.

As for BLB_put_data and BLB_put_segment, I initially didn't want to change them, as the code in them is quite complex and modifying it would be quite difficult. But now I see that the integration is quite simple, so I did it.

So now BLB_write works the same as BLB_lseek + BLB_put_data (or BLB_lseek + BLB_put_segment).

@Noremos

Noremos commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Why is JsonTempParsingTests.cpp needed in this PR?

Sorry, forgot to delete this file after the branch checkout.

@dyemanov

Copy link
Copy Markdown
Member

If you say BLB_write() is convenient, I'd also expect BLB_read() to be added for symmetry.

@aafemt

aafemt commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Do new methods of blb really need this ancient BLB_ prefix?..

@Noremos

Noremos commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

BTW, code in blb.cpp (at least) requires comments. It have none too small useful comments, imo.

Added description of modification algorithm:
https://github.com/FirebirdSQL/firebird/pull/9066/changes#diff-b38a2d18c3f2097dc3697386a2d4d4cb6c708408ac2cdad4169aca72bdf2479dR2051-R2079

@Noremos

Noremos commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

If you say BLB_write() is convenient, I'd also expect BLB_read() to be added for symmetry.

Added as suggested

Comment thread src/jrd/blb.h Outdated
Comment thread src/jrd/blb.h Outdated
Comment thread src/jrd/blb.h Outdated
Comment thread src/jrd/blb.cpp Outdated
Comment thread src/jrd/blb.cpp Outdated
Comment thread src/jrd/blb.cpp Outdated
Comment thread src/jrd/blb.cpp
Comment thread src/jrd/blb.cpp Outdated
Comment thread src/jrd/blb.cpp Outdated
Comment thread src/include/firebird/impl/msg/jrd.h Outdated
@hvlad

hvlad commented Jun 18, 2026

Copy link
Copy Markdown
Member

Don't get me wrong - the code itself is not bad, but it is very hard to read, understand and verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants