Hi,
I assume the problem whether nulls are sorted first or last, right? I mean
the system property "h2.sortNullsHigh". It is currently used as the default
value for SortOrder.DEFAULT_NULL_SORT, which is the default behavior for
"select ... order by x" if "nulls first" or "nulls last" is not specified.
However, it is not currently used for indexes themselves in H2 (see below).
> for data row it always must be ValueNull.INSTANCE
Yes, I think so. It's true, ValueNull.INSTANCE can occur here, and
NULLS_FIRST and NULLS_LAST are ignored in that case. I think H2 indexes
don't currently support explicit NULLS_FIRST / NULLS_LAST (see below).
> then result of this comparison depends on null sorting settings of the
database.
Currently, for H2, Value.compareTypeSave (I will rename it to
"compareTypeSafe" by the way) uses an hardcoded order:
if (this == v) {
return 0;
} else if (this == ValueNull.INSTANCE) {
return -1;
} else if (v == ValueNull.INSTANCE) {
return 1;
}
return compareSecure(v, mode);
This could be changed, but would require some work. Either the system
property "h2.sortNullsHigh" would need to be ignored for that, or the
"nulls first / last" setting would need to be explicitly stored in each
index definition in a database, because the system property could be
changed between two runs, and data in the index itself can not.
Regards,
Thomas
On Thursday, August 20, 2015, Sergi Vladykin <[email protected]
<javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:
> Thomas,
>
> I have a question about BaseIndex.compareValues method.
> It contains the following lines:
>
> boolean aNull = a == null, bNull = b == null;
> if (aNull || bNull) {
> return SortOrder.compareNull(aNull, sortType);
> }
>
> As far as I understand, value can be null only in a SearchRow when it has
> an open bound, for data row it always must be ValueNull.INSTANCE, no?
> Is this comparison correct? May be it must be something like aNull = a ==
> ValueNull.INSTANCE, bNull = b == ValueNull.INSTANCE?
>
> I was not able to exploit this thing in H2 but I have a problem with my
> Index implementation because of this.
> At some point I need to check if the lower bound search row is not greater
> than upper bound search row (which means we need to return empty result),
> and if query condition contains an open bound (null in a search row) then
> result of this comparison depends on null sorting settings of the database.
>
> Could you please comment on this?
>
> Sergi
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.