Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Jiří Činčura
On Thu, Aug 11, 2022, at 17:58, Vlad Khorsun wrote:
>The answer is the same - for user convenience. When I want to append 
> something to the
> already existing blob, I doesn't expect to destroy my blob just because 
> nothing is
> appended to it.

How is that different from `update foo set bar = bar || 'foo'` where `bar` is 
null?

-- 
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/





Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Jiří Činčura
On Thu, Aug 11, 2022, at 18:56, Vlad Khorsun wrote:
>I replied to Jiří who definitely read that discussion ;)

But I read it like last week, completely, because I discovered it as part of 
reading RN. I wasn't in the discussion as it was unfolding.

-- 
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Adriano dos Santos Fernandes
 Em 11/08/2022 12:58, Vlad Khorsun escreveu:

11.08.2022 17:26, Mark Rotteveel wrote:

On 11-08-2022 16:21, Vlad Khorsun wrote:

11.08.2022 17:10, Mark Rotteveel wrote:

Why was this NULL behaviour chosen?


   To make BLOB_APPEND more convenient for users.


I don't understand how using a different NULL behaviour then standard for
operations in SQL/Firebird is convenient.


  There is no standard defined operation for appending blobs, afaik.

To me it sounds like something that will result in confusion because of the
difference with normal concatenation, but OK.


  The BLOB_APPEND is not CONCATENATION, it is non-standard function with
custom semantics.


As well many of our system functions, and we choose to implement the
standard behavior on them.

This remember-me JavaScript:

> null + null
0
> 'null' + null
'nullnull'


  The answer is the same - for user convenience. When I want to append
something to the
already existing blob, I doesn't expect to destroy my blob just because
nothing is
appended to it.


It's is inconsistent, and I do not see that as convenience.

Some user would think the convenience would be to treat it as strings
('null', 'NULL', 'Null').


Adriano
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread James Starkey
While I’m hardly entitled to a vote, it is almost impossible to find a use
case where making a concatenation with a NULL a NULL is useful.  NULL
should be interpreted as “there ain’t nothing there” rather than a poison
pill for other contexts.

In Amorphous, concatenation of a NULL treats the NULL as an empty string,
but then in Amorphous I am king and dictator.

But, for the record, Ann and I disagree on this.

On Thu, Aug 11, 2022 at 11:58 AM Vlad Khorsun  wrote:

> 11.08.2022 17:26, Mark Rotteveel wrote:
> > On 11-08-2022 16:21, Vlad Khorsun wrote:
> >> 11.08.2022 17:10, Mark Rotteveel wrote:
> >>> Why was this NULL behaviour chosen?
> >>
> >>To make BLOB_APPEND more convenient for users.
> >
> > I don't understand how using a different NULL behaviour then standard
> for operations in SQL/Firebird is convenient.
>
>There is no standard defined operation for appending blobs, afaik.
>
> > To me it sounds
> > like something that will result in confusion because of the difference
> with normal concatenation, but OK.
>
>The BLOB_APPEND is not CONCATENATION, it is non-standard function with
> custom semantics.
>
> > I had hoped for something more solid, so I could add that as an
> explanation when documenting it in the language reference.
>
>The answer is the same - for user convenience. When I want to append
> something to the
> already existing blob, I doesn't expect to destroy my blob just because
> nothing is
> appended to it.
>
> > PS You mailed this to me privately instead of to the list.
>
>Sorry, hope you are not suffer too much because of it ;)
>
> Regards,
> Vlad
>
>
>
> Firebird-Devel mailing list, web interface at
> https://lists.sourceforge.net/lists/listinfo/firebird-devel
>
-- 
Jim Starkey
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Vlad Khorsun

11.08.2022 19:31, Mark Rotteveel wrote:

On 11-08-2022 18:04, Vlad Khorsun wrote:

11.08.2022 17:46, Jiří Činčura wrote:
I was thinking the same when reading the discussion on GH. 


   There was a LOT of time to write something at that discussion.
Nobody asked about NULL's there, while it was documented since a very beginning.


Unfortunately I don't always have time or energy to monitor all GitHub updates, and there was no previous discussion on this list 
about BLOB_APPEND, so I simply had not noticed its existence before.


  I replied to Jiří who definitely read that discussion ;)

  It is always very sad to get such comments two month after the code was
merged and release is almost out.

Regards,
Vlad


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Mark Rotteveel

On 11-08-2022 18:09, Alex Peshkoff via Firebird-devel wrote:

On 8/11/22 19:04, Vlad Khorsun wrote:


  So far I don't see it as mistake.



+1
Function is anyway damned non-standard.
And as soon as we have documented behavior - no problems at all.


Time will tell. I think deviating NULL behaviour can lead to confusion, 
even if it is documented.


In any case, I updated the language reference (I used the release notes 
as a starting point):


https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref40/firebird-40-language-reference.html#fblangref40-scalarfuncs-blob-append

Mark
--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Mark Rotteveel

On 11-08-2022 18:04, Vlad Khorsun wrote:

11.08.2022 17:46, Jiří Činčura wrote:
I was thinking the same when reading the discussion on GH. 


   There was a LOT of time to write something at that discussion.
Nobody asked about NULL's there, while it was documented since a very 
beginning.


Unfortunately I don't always have time or energy to monitor all GitHub 
updates, and there was no previous discussion on this list about 
BLOB_APPEND, so I simply had not noticed its existence before.


Mark
--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Mark Rotteveel

On 11-08-2022 17:58, Vlad Khorsun wrote:

11.08.2022 17:26, Mark Rotteveel wrote:

On 11-08-2022 16:21, Vlad Khorsun wrote:

11.08.2022 17:10, Mark Rotteveel wrote:

Why was this NULL behaviour chosen?


   To make BLOB_APPEND more convenient for users.


I don't understand how using a different NULL behaviour then standard 
for operations in SQL/Firebird is convenient. 


   There is no standard defined operation for appending blobs, afaik.


I am talking about the general expectations raised by the SQL standard 
(and Firebird itself) regarding behaviour when faced with NULL, and that 
is, in general, that when one of the inputs of a function, operation, or 
other expression is NULL, the result is NULL.


And given concatenation is defined for BLOBs in the standard, with the 
normal NULL behaviour, I would expect this appending to follow the same 
basic rules.


To me it sounds like something that will result in confusion because 
of the difference with normal concatenation, but OK.


   The BLOB_APPEND is not CONCATENATION, it is non-standard function 
with custom semantics.


It is a non-standard function that is intended to be used in places 
where you'd otherwise use concatenation. To me that means semantics of 
concatenation should be applied.


Mark

--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Alex Peshkoff via Firebird-devel

On 8/11/22 19:04, Vlad Khorsun wrote:


  So far I don't see it as mistake.



+1
Function is anyway damned non-standard.
And as soon as we have documented behavior - no problems at all.





Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and returned SUB_TYPE

2022-08-11 Thread Vlad Khorsun

11.08.2022 17:40, Mark Rotteveel wrote:
I noticed that BLOB_APPEND always returns a blob of SUB_TYPE TEXT, even if the first blob is binary or other type of blob. Is that 
expected?


  No, the intention was to use type\charset of first arg (if not NULL).
I'll check and fix it, thanks.

Regards,
Vlad


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Vlad Khorsun

11.08.2022 17:46, Jiří Činčura wrote:
I was thinking the same when reading the discussion on GH. 


  There was a LOT of time to write something at that discussion.
Nobody asked about NULL's there, while it was documented since a very beginning.


I believe it's not late to make correction (hey, we all make mistakes) and have 
consistent behavior.


  So far I don't see it as mistake.

Regards,
Vlad


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Vlad Khorsun

11.08.2022 17:26, Mark Rotteveel wrote:

On 11-08-2022 16:21, Vlad Khorsun wrote:

11.08.2022 17:10, Mark Rotteveel wrote:

Why was this NULL behaviour chosen?


   To make BLOB_APPEND more convenient for users.


I don't understand how using a different NULL behaviour then standard for operations in SQL/Firebird is convenient. 


  There is no standard defined operation for appending blobs, afaik.

To me it sounds 
like something that will result in confusion because of the difference with normal concatenation, but OK.


  The BLOB_APPEND is not CONCATENATION, it is non-standard function with custom 
semantics.


I had hoped for something more solid, so I could add that as an explanation 
when documenting it in the language reference.


  The answer is the same - for user convenience. When I want to append 
something to the
already existing blob, I doesn't expect to destroy my blob just because nothing 
is
appended to it.


PS You mailed this to me privately instead of to the list.


  Sorry, hope you are not suffer too much because of it ;)

Regards,
Vlad



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Omacht András
+1

András

Feladó: Jiří Činčura 
Elküldve: 2022. augusztus 11. 16:46
Címzett: For discussion among Firebird Developers
Tárgy: Re: [Firebird-devel] BLOB_APPEND and NULL

I was thinking the same when reading the discussion on GH. I believe it's not 
late to make correction (hey, we all make mistakes) and have consistent 
behavior.

--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Jiří Činčura
I was thinking the same when reading the discussion on GH. I believe it's not 
late to make correction (hey, we all make mistakes) and have consistent 
behavior.

-- 
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


[Firebird-devel] BLOB_APPEND and returned SUB_TYPE

2022-08-11 Thread Mark Rotteveel
I noticed that BLOB_APPEND always returns a blob of SUB_TYPE TEXT, even 
if the first blob is binary or other type of blob. Is that expected?


Mark
--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Mark Rotteveel

On 11-08-2022 16:21, Vlad Khorsun wrote:

11.08.2022 17:10, Mark Rotteveel wrote:

Why was this NULL behaviour chosen?


   To make BLOB_APPEND more convenient for users.


I don't understand how using a different NULL behaviour then standard 
for operations in SQL/Firebird is convenient. To me it sounds like 
something that will result in confusion because of the difference with 
normal concatenation, but OK.


I had hoped for something more solid, so I could add that as an 
explanation when documenting it in the language reference.


PS You mailed this to me privately instead of to the list.

--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


[Firebird-devel] BLOB_APPEND and NULL

2022-08-11 Thread Mark Rotteveel
The new BLOB_APPEND function has a NULL behaviour that is not consistent 
with the normal NULL behaviour. Using NULL in BLOB_APPEND behaves as an 
empty string, while the normal behaviour for functions and operations 
involving NULL is to result in NULL.


For example, normal concatenation:

select cast(null as blob sub_type text) || cast('a' as blob sub_type 
text) || cast(null as blob sub_type text) || cast('b' as blob sub_type 
text)  from rdb$database;


results in NULL, while BLOB_APPEND:

select blob_append(null, 'a', null, 'b') from rdb$database;

results in 'ab'.

If the "normal" NULL-behaviour had been used, it would be possible to 
easily rewrite normal concatenation involving blobs to BLOB_APPEND, but 
now that requires careful consideration. In addition, this closes an 
avenue for the engine to - at some point in the future, as an engine 
optimization - rewrite concatenation to BLOB_APPEND internally.


Why was this NULL behaviour chosen?

Mark
--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel