Debian Codegraph @

src/main/org/h2/table/DualTable.java

raw
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.table;
7
8 import org.h2.engine.Database;
9 import org.h2.engine.SessionLocal;
10 import org.h2.index.DualIndex;
11 import org.h2.index.Index;
12
13 /**
14 * The DUAL table for selects without a FROM clause.
15 */
16 public class DualTable extends VirtualTable {
17
18 /**
19 * The name of the range table.
20 */
21 public static final String NAME = "DUAL";
22
23 /**
24 * Create a new range with the given start and end expressions.
25 *
26 * @param database
27 * the database
28 */
29 public DualTable(Database database) {
30 super(database.getMainSchema(), 0, NAME);
31 setColumns(new Column[0]);
32 }
33
34 @Override
35 public StringBuilder getSQL(StringBuilder builder, int sqlFlags) {
36 return builder.append(NAME);
37 }
38
39 @Override
40 public boolean canGetRowCount(SessionLocal session) {
41 return true;
42 }
43
44 @Override
45 public long getRowCount(SessionLocal session) {
46 return 1L;
47 }
48
49 @Override
50 public TableType getTableType() {
51 return TableType.SYSTEM_TABLE;
52 }
53
54 @Override
55 public Index getScanIndex(SessionLocal session) {
56 return new DualIndex(this);
57 }
58
59 @Override
60 public long getMaxDataModificationId() {
61 return 0L;
62 }
63
64 @Override
65 public long getRowCountApproximation(SessionLocal session) {
66 return 1L;
67 }
68
69 @Override
70 public boolean isDeterministic() {
71 return true;
72 }
73
74 }