| 1 |
/* |
| 2 |
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (https://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.engine; |
| 7 |
|
| 8 |
import org.h2.util.HasSQL; |
| 9 |
|
| 10 |
/** |
| 11 |
* Determines how rows with {@code NULL} values in indexed columns are handled |
| 12 |
* in unique indexes, unique constraints, or by unique predicate. |
| 13 |
*/ |
| 14 |
public enum NullsDistinct implements HasSQL { |
| 15 |
|
| 16 |
/** |
| 17 |
* {@code NULL} values of columns are distinct. |
| 18 |
*/ |
| 19 |
DISTINCT, |
| 20 |
|
| 21 |
/** |
| 22 |
* {@code NULL} values of columns are distinct only if all columns have null values. |
| 23 |
*/ |
| 24 |
ALL_DISTINCT, |
| 25 |
|
| 26 |
/** |
| 27 |
* {@code NULL} values of columns are never distinct. |
| 28 |
*/ |
| 29 |
NOT_DISTINCT; |
| 30 |
|
| 31 |
@Override |
| 32 |
public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { |
| 33 |
builder.append("NULLS "); |
| 34 |
switch (this) { |
| 35 |
case DISTINCT: |
| 36 |
builder.append("DISTINCT"); |
| 37 |
break; |
| 38 |
case ALL_DISTINCT: |
| 39 |
builder.append("ALL DISTINCT"); |
| 40 |
break; |
| 41 |
case NOT_DISTINCT: |
| 42 |
builder.append("NOT DISTINCT"); |
| 43 |
} |
| 44 |
return builder; |
| 45 |
} |
| 46 |
|
| 47 |
} |