| 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 java.util.ArrayList; |
| 9 |
|
| 10 |
import org.h2.engine.SessionLocal; |
| 11 |
import org.h2.index.Index; |
| 12 |
import org.h2.index.IndexType; |
| 13 |
import org.h2.message.DbException; |
| 14 |
import org.h2.result.Row; |
| 15 |
import org.h2.schema.Schema; |
| 16 |
|
| 17 |
/** |
| 18 |
* A base class for virtual tables. |
| 19 |
*/ |
| 20 |
public abstract class VirtualTable extends Table { |
| 21 |
|
| 22 |
protected VirtualTable(Schema schema, int id, String name) { |
| 23 |
super(schema, id, name, false, true); |
| 24 |
} |
| 25 |
|
| 26 |
@Override |
| 27 |
public void close(SessionLocal session) { |
| 28 |
// Nothing to do |
| 29 |
} |
| 30 |
|
| 31 |
@Override |
| 32 |
public Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, |
| 33 |
int uniqueColumnCount, IndexType indexType, boolean create, String indexComment) { |
| 34 |
throw DbException.getUnsupportedException("Virtual table"); |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public boolean isInsertable() { |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
public void removeRow(SessionLocal session, Row row) { |
| 44 |
throw DbException.getUnsupportedException("Virtual table"); |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public long truncate(SessionLocal session) { |
| 50 |
throw DbException.getUnsupportedException("Virtual table"); |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public void addRow(SessionLocal session, Row row) { |
| 55 |
throw DbException.getUnsupportedException("Virtual table"); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public void checkSupportAlter() { |
| 60 |
throw DbException.getUnsupportedException("Virtual table"); |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public TableType getTableType() { |
| 65 |
return null; |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
public ArrayList<Index> getIndexes() { |
| 70 |
return null; |
| 71 |
} |
| 72 |
|
| 73 |
@Override |
| 74 |
public boolean canReference() { |
| 75 |
return false; |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
public boolean canDrop() { |
| 80 |
throw DbException.getInternalError(toString()); |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
public String getCreateSQL() { |
| 85 |
return null; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public void checkRename() { |
| 90 |
throw DbException.getUnsupportedException("Virtual table"); |
| 91 |
} |
| 92 |
|
| 93 |
} |