Quadcap Embeddable Database

com.quadcap.sql.Table Class Reference

Inheritance diagram for com.quadcap.sql.Table:

com.quadcap.sql.TupleImpl com.quadcap.sql.Relation Externalizable com.quadcap.sql.Tuple Externalizable com.quadcap.sql.Tuple List of all members.

Detailed Description

A single SQL base table.

Author:
Stan Bailes

Definition at line 88 of file Table.java.

Public Member Functions

 Table ()
 Default constructor (required for deserialization).

 Table (String tableName, int modifiers)
 Explicit constructor.

boolean isUnderConstruction ()
 Get/Set the value of the 'is under construction' flag.

void setUnderConstruction (boolean v)
 Set the value of the 'is under construction' flag.

int getModifiers ()
 Return the modifier bits for this table.

boolean hasBlobs () throws SQLException
 Are any of this table's columns BLOB (or CLOB) types?

void readExternal (ObjectInput in) throws IOException, ClassNotFoundException
 Read me from a stream.

void writeExternal (ObjectOutput out) throws IOException
 Write me to a stream.

void addColumn (Column col) throws SQLException
 Add a column to the table; called during initial table construction only.

final Constraint getConstraint (int num)
 Return the specified table constraint (zero-based).

final int getNumConstraints ()
 Return the number of table constraints.

Constraint getConstraint (String name)
 Get the constraint with the specified name.

UniqueConstraint getPrimaryKey ()
 Return the table's primary key constraint, if it is defined, otherwise return null.

void nameConstraint (Constraint c)
 Generate a unique, semi-meaningful, name for this constratint, in case the user didn't specify one.

void addConstraint (Constraint c) throws SQLException
 Add a table constraint.

void deleteConstraint (String name) throws SQLException, IOException
 Delete the specified table constraint.

void deleteColumn (int c) throws SQLException, IOException
 Delete a column from this table, and reset any column-constraint mappings.

void resetColumnConstraints () throws SQLException
 Reset any constraint-column mapping (typically after a column has been added or dropped).

Cursor getCursor (Session session, Expression where, String asName, Cursor outer) throws SQLException
 Return a cursor on this table.

Cursor getCursor (Session session, Expression where, String asName) throws SQLException
IndexCursor getCursor (Session session, IndexConstraint notMe) throws SQLException
String getType ()
 My SQL type.

boolean isUpdatable ()
 (haiku-comment) I am a table and therefore updateable

String toString ()
 String representation for debugging.

void insertRow (Session session, Row row) throws SQLException, IOException

Static Public Member Functions

final long putRow (Session session, Tuple t, Row row) throws SQLException, IOException
 Convenience method to write a new row to the database.


Static Public Attributes

final int TEMPORARY = 1
 Table modifiers, bit fields.

final int LOCAL = 2
final int GLOBAL = 4
final int STATEMENT_TEMP = 8

Package Functions

Row getRow (Database db, long rowId) throws IOException, SQLException
Hashtable getNames (Expression ex)
final IndexConstraint getAnyIndex (Session session) throws IOException, SQLException
final IndexConstraint getIndexForNames (Session session, Hashtable names) throws IOException, SQLException
final IndexConstraint getAnyIndexBut (Session session, IndexConstraint notMe) throws IOException, SQLException
IndexConstraint getIndexConstraint (Session session, Hashtable names, IndexConstraint notMe) throws IOException, SQLException
UniqueConstraint getIndexForColumns (int[] cols) throws SQLException

Static Package Functions

final String strip (String s)
 Write (an already serialized) row to the database.


Package Attributes

int modifiers = 0
Constraint[] constraints = new Constraint[0]
transient boolean underConstruction = false
transient int hasBlobs = 0
long tableIdentity = 1
 For in-memory mode, the table identity.


Constructor & Destructor Documentation

com.quadcap.sql.Table.Table  ) 
 

Default constructor (required for deserialization).

Definition at line 115 of file Table.java.

com.quadcap.sql.Table.Table String  tableName,
int  modifiers
 

Explicit constructor.

Definition at line 120 of file Table.java.


Member Function Documentation

void com.quadcap.sql.Table.addColumn Column  col  )  throws SQLException
 

Add a column to the table; called during initial table construction only.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 191 of file Table.java.

References com.quadcap.sql.Table.addColumn(), and com.quadcap.sql.Constraint.setColumn().

Referenced by com.quadcap.sql.Table.addColumn(), com.quadcap.sql.SQLParser.createTableStmt(), com.quadcap.sql.AddColumn.redo(), and com.quadcap.sql.DropColumn.undo().

void com.quadcap.sql.Table.addConstraint Constraint  c  )  throws SQLException
 

Add a table constraint.

Definition at line 267 of file Table.java.

References com.quadcap.sql.Table.addConstraint(), com.quadcap.sql.Table.constraints, com.quadcap.sql.Constraint.getPriority(), com.quadcap.sql.Column.setNullable(), and com.quadcap.sql.Constraint.setTable().

Referenced by com.quadcap.sql.Table.addConstraint(), com.quadcap.sql.AddConstraint.redo(), and com.quadcap.sql.DeleteConstraint.undo().

void com.quadcap.sql.Table.deleteColumn int  c  )  throws SQLException, IOException
 

Delete a column from this table, and reset any column-constraint mappings.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 326 of file Table.java.

References com.quadcap.sql.Table.deleteColumn(), and com.quadcap.sql.Table.resetColumnConstraints().

Referenced by com.quadcap.sql.Table.deleteColumn(), com.quadcap.sql.DropColumn.redo(), and com.quadcap.sql.AddColumn.undo().

void com.quadcap.sql.Table.deleteConstraint String  name  )  throws SQLException, IOException
 

Delete the specified table constraint.

Definition at line 301 of file Table.java.

References com.quadcap.sql.Table.constraints, com.quadcap.sql.Table.deleteConstraint(), com.quadcap.sql.TupleImpl.getName(), and com.quadcap.sql.Constraint.getName().

Referenced by com.quadcap.sql.Table.deleteConstraint(), com.quadcap.sql.DeleteConstraint.redo(), and com.quadcap.sql.AddConstraint.undo().

final IndexConstraint com.quadcap.sql.Table.getAnyIndex Session  session  )  throws IOException, SQLException [package]
 

Definition at line 449 of file Table.java.

References com.quadcap.sql.Table.getAnyIndex(), and com.quadcap.sql.Table.getIndexConstraint().

Referenced by com.quadcap.sql.StmtDropTable.execute(), com.quadcap.sql.StmtDropColumn.execute(), com.quadcap.sql.StmtAddColumn.execute(), and com.quadcap.sql.Table.getAnyIndex().

final IndexConstraint com.quadcap.sql.Table.getAnyIndexBut Session  session,
IndexConstraint  notMe
throws IOException, SQLException [package]
 

Definition at line 461 of file Table.java.

References com.quadcap.sql.Table.getAnyIndexBut(), and com.quadcap.sql.Table.getIndexConstraint().

Referenced by com.quadcap.sql.Table.getAnyIndexBut(), and com.quadcap.sql.Table.getCursor().

Constraint com.quadcap.sql.Table.getConstraint String  name  ) 
 

Get the constraint with the specified name.

XXX Maybe we should profile this sucker. A hashtable?

Definition at line 221 of file Table.java.

References com.quadcap.sql.Table.constraints, and com.quadcap.sql.Constraint.getName().

final Constraint com.quadcap.sql.Table.getConstraint int  num  ) 
 

Return the specified table constraint (zero-based).

Definition at line 205 of file Table.java.

References com.quadcap.sql.Table.constraints, and com.quadcap.sql.Table.getConstraint().

Referenced by com.quadcap.sql.ExportedKeyConstraint.delete(), com.quadcap.sql.StmtDropTable.execute(), com.quadcap.sql.StmtDropIndex.execute(), com.quadcap.sql.StmtDropConstraint.execute(), com.quadcap.sql.StmtAddConstraint.execute(), com.quadcap.sql.ImportedKeyConstraint.findExportedKeyConstraint(), com.quadcap.sql.JoinInnerCursor.findIndex(), com.quadcap.sql.Table.getConstraint(), com.quadcap.sql.ExportedKeyConstraint.getImportedKeyConstraint(), com.quadcap.sql.ModIndexEntry.getIndex(), com.quadcap.sql.meta.MetaBestRowId.MetaBestRowId(), com.quadcap.sql.meta.MetaCrossReference.MetaCrossReference(), com.quadcap.sql.meta.MetaIndexInfo.MetaIndexInfo(), com.quadcap.sql.meta.MetaPrimaryKeys.MetaPrimaryKeys(), com.quadcap.sql.StmtRenameTable.rename(), com.quadcap.sql.StmtRenameTable.renameForeignKeys(), and com.quadcap.sql.AddConstraint.undo().

IndexCursor com.quadcap.sql.Table.getCursor Session  session,
IndexConstraint  notMe
throws SQLException
 

Definition at line 418 of file Table.java.

References com.quadcap.sql.Table.getAnyIndexBut(), and com.quadcap.sql.TupleImpl.getName().

Cursor com.quadcap.sql.Table.getCursor Session  session,
Expression  where,
String  asName
throws SQLException
 

Definition at line 411 of file Table.java.

Cursor com.quadcap.sql.Table.getCursor Session  session,
Expression  where,
String  asName,
Cursor  outer
throws SQLException
 

Return a cursor on this table.

Implements com.quadcap.sql.Relation.

Definition at line 393 of file Table.java.

References com.quadcap.sql.Table.getCursor(), com.quadcap.sql.Table.getIndexForNames(), com.quadcap.sql.TupleImpl.getName(), and com.quadcap.sql.Table.getNames().

Referenced by com.quadcap.sql.IndexConstraint.add(), com.quadcap.sql.ImportedKeyConstraint.add(), com.quadcap.sql.CheckConstraint.add(), and com.quadcap.sql.Table.getCursor().

IndexConstraint com.quadcap.sql.Table.getIndexConstraint Session  session,
Hashtable  names,
IndexConstraint  notMe
throws IOException, SQLException [package]
 

Definition at line 467 of file Table.java.

References com.quadcap.sql.Table.constraints, com.quadcap.sql.Constraint.getColumnNames(), com.quadcap.sql.Table.getIndexConstraint(), and com.quadcap.sql.TupleImpl.getName().

Referenced by com.quadcap.sql.Table.getAnyIndex(), com.quadcap.sql.Table.getAnyIndexBut(), com.quadcap.sql.Table.getIndexConstraint(), and com.quadcap.sql.Table.getIndexForNames().

UniqueConstraint com.quadcap.sql.Table.getIndexForColumns int[]  cols  )  throws SQLException [package]
 

Definition at line 543 of file Table.java.

References com.quadcap.sql.Table.constraints, com.quadcap.sql.Constraint.getColumns(), and com.quadcap.sql.Table.getIndexForColumns().

Referenced by com.quadcap.sql.ImportedKeyConstraint.checkInsert(), com.quadcap.sql.ForeignKeyConstraint.getFCols(), and com.quadcap.sql.Table.getIndexForColumns().

final IndexConstraint com.quadcap.sql.Table.getIndexForNames Session  session,
Hashtable  names
throws IOException, SQLException [package]
 

Definition at line 455 of file Table.java.

References com.quadcap.sql.Table.getIndexConstraint(), and com.quadcap.sql.Table.getIndexForNames().

Referenced by com.quadcap.sql.Table.getCursor(), and com.quadcap.sql.Table.getIndexForNames().

int com.quadcap.sql.Table.getModifiers  ) 
 

Return the modifier bits for this table.

Definition at line 139 of file Table.java.

References com.quadcap.sql.Table.modifiers.

Referenced by com.quadcap.sql.Database.checkViewDependency().

Hashtable com.quadcap.sql.Table.getNames Expression  ex  )  [package]
 

Definition at line 443 of file Table.java.

References com.quadcap.sql.Table.getNames(), com.quadcap.sql.Table.GetNames.t, and com.quadcap.sql.Table.GetNames.visit().

Referenced by com.quadcap.sql.Table.getCursor(), and com.quadcap.sql.Table.getNames().

final int com.quadcap.sql.Table.getNumConstraints  ) 
 

Return the number of table constraints.

Definition at line 212 of file Table.java.

References com.quadcap.sql.Table.constraints.

Referenced by com.quadcap.sql.StmtDropTable.execute(), com.quadcap.sql.StmtDropConstraint.execute(), com.quadcap.sql.JoinInnerCursor.findIndex(), com.quadcap.sql.meta.MetaBestRowId.MetaBestRowId(), com.quadcap.sql.meta.MetaCrossReference.MetaCrossReference(), com.quadcap.sql.meta.MetaIndexInfo.MetaIndexInfo(), com.quadcap.sql.meta.MetaPrimaryKeys.MetaPrimaryKeys(), com.quadcap.sql.StmtRenameTable.rename(), com.quadcap.sql.StmtRenameTable.renameForeignKeys(), and com.quadcap.sql.Table.resetColumnConstraints().

UniqueConstraint com.quadcap.sql.Table.getPrimaryKey  ) 
 

Return the table's primary key constraint, if it is defined, otherwise return null.

Definition at line 235 of file Table.java.

References com.quadcap.sql.Table.constraints.

Referenced by com.quadcap.sql.ForeignKeyConstraint.getFCols().

Row com.quadcap.sql.Table.getRow Database  db,
long  rowId
throws IOException, SQLException [package]
 

Definition at line 384 of file Table.java.

References com.quadcap.sql.TupleImpl.getColumnCount(), and com.quadcap.sql.Table.getRow().

Referenced by com.quadcap.sql.Table.getRow(), and com.quadcap.sql.UpdateRow.prepare().

String com.quadcap.sql.Table.getType  ) 
 

My SQL type.

Implements com.quadcap.sql.Relation.

Definition at line 565 of file Table.java.

References com.quadcap.sql.Table.GLOBAL, com.quadcap.sql.Table.LOCAL, com.quadcap.sql.Table.modifiers, and com.quadcap.sql.Table.TEMPORARY.

boolean com.quadcap.sql.Table.hasBlobs  )  throws SQLException
 

Are any of this table's columns BLOB (or CLOB) types?

Implements com.quadcap.sql.Relation.

Definition at line 144 of file Table.java.

References com.quadcap.sql.TupleImpl.getColumnCount(), and com.quadcap.sql.Column.getType().

void com.quadcap.sql.Table.insertRow Session  session,
Row  row
throws SQLException, IOException
 

Implements com.quadcap.sql.Relation.

Definition at line 601 of file Table.java.

References com.quadcap.sql.Table.insertRow().

Referenced by com.quadcap.sql.Table.insertRow().

boolean com.quadcap.sql.Table.isUnderConstruction  ) 
 

Get/Set the value of the 'is under construction' flag.

This is used to determine when ADD CONSTRAINT really has work to do ;-)

Definition at line 129 of file Table.java.

References com.quadcap.sql.Table.underConstruction.

Referenced by com.quadcap.sql.ImportedKeyConstraint.add(), com.quadcap.sql.CheckConstraint.add(), and com.quadcap.sql.AutoNumberConstraint.add().

boolean com.quadcap.sql.Table.isUpdatable  ) 
 

(haiku-comment) I am a table and therefore updateable

Returns:
true not false

Implements com.quadcap.sql.Relation.

Definition at line 582 of file Table.java.

void com.quadcap.sql.Table.nameConstraint Constraint  c  ) 
 

Generate a unique, semi-meaningful, name for this constratint, in case the user didn't specify one.

Definition at line 252 of file Table.java.

References com.quadcap.sql.Table.constraints, com.quadcap.sql.Constraint.getName(), com.quadcap.sql.Table.nameConstraint(), and com.quadcap.sql.Constraint.setName().

Referenced by com.quadcap.sql.AddConstraint.AddConstraint(), com.quadcap.sql.StmtDropConstraint.execute(), com.quadcap.sql.StmtCreateIndex.execute(), and com.quadcap.sql.Table.nameConstraint().

final long com.quadcap.sql.Table.putRow Session  session,
Tuple  t,
Row  row
throws SQLException, IOException [static]
 

Convenience method to write a new row to the database.

Definition at line 346 of file Table.java.

References com.quadcap.sql.Table.putRow().

Referenced by com.quadcap.sql.Table.putRow().

void com.quadcap.sql.Table.readExternal ObjectInput  in  )  throws IOException, ClassNotFoundException
 

Read me from a stream.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 161 of file Table.java.

References com.quadcap.sql.Table.constraints, com.quadcap.sql.Table.readExternal(), and com.quadcap.sql.Constraint.setTable().

Referenced by com.quadcap.sql.Table.readExternal().

void com.quadcap.sql.Table.resetColumnConstraints  )  throws SQLException
 

Reset any constraint-column mapping (typically after a column has been added or dropped).

Definition at line 335 of file Table.java.

References com.quadcap.sql.Table.getNumConstraints(), and com.quadcap.sql.Constraint.resetColumns().

Referenced by com.quadcap.sql.Table.deleteColumn(), and com.quadcap.sql.StmtAddColumn.execute().

void com.quadcap.sql.Table.setUnderConstruction boolean  v  ) 
 

Set the value of the 'is under construction' flag.

Definition at line 134 of file Table.java.

References com.quadcap.sql.Table.setUnderConstruction(), and com.quadcap.sql.Table.underConstruction.

Referenced by com.quadcap.sql.StmtCreateTable.execute(), and com.quadcap.sql.Table.setUnderConstruction().

final String com.quadcap.sql.Table.strip String  s  )  [static, package]
 

Write (an already serialized) row to the database.

Definition at line 378 of file Table.java.

References com.quadcap.sql.Table.strip().

Referenced by com.quadcap.sql.Table.strip().

String com.quadcap.sql.Table.toString  ) 
 

String representation for debugging.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 588 of file Table.java.

References com.quadcap.sql.Table.constraints.

void com.quadcap.sql.Table.writeExternal ObjectOutput  out  )  throws IOException
 

Write me to a stream.

Reimplemented from com.quadcap.sql.TupleImpl.

Definition at line 179 of file Table.java.

References com.quadcap.sql.Table.constraints, and com.quadcap.sql.Table.writeExternal().

Referenced by com.quadcap.sql.Table.writeExternal().


Member Data Documentation

Constraint [] com.quadcap.sql.Table.constraints = new Constraint[0] [package]
 

Definition at line 92 of file Table.java.

Referenced by com.quadcap.sql.Table.addConstraint(), com.quadcap.sql.Table.deleteConstraint(), com.quadcap.sql.Table.getConstraint(), com.quadcap.sql.Table.getIndexConstraint(), com.quadcap.sql.Table.getIndexForColumns(), com.quadcap.sql.Table.getNumConstraints(), com.quadcap.sql.Table.getPrimaryKey(), com.quadcap.sql.Table.nameConstraint(), com.quadcap.sql.Table.readExternal(), com.quadcap.sql.StmtCreateTable.StmtCreateTable(), com.quadcap.sql.Table.toString(), and com.quadcap.sql.Table.writeExternal().

final int com.quadcap.sql.Table.GLOBAL = 4 [static]
 

Definition at line 104 of file Table.java.

Referenced by com.quadcap.sql.Table.getType().

transient int com.quadcap.sql.Table.hasBlobs = 0 [package]
 

Definition at line 96 of file Table.java.

Referenced by com.quadcap.sql.DeletedRows.finish(), com.quadcap.sql.UpdateRow.redo(), and com.quadcap.sql.InsertRow.redo().

final int com.quadcap.sql.Table.LOCAL = 2 [static]
 

Definition at line 103 of file Table.java.

Referenced by com.quadcap.sql.Table.getType().

int com.quadcap.sql.Table.modifiers = 0 [package]
 

Definition at line 91 of file Table.java.

Referenced by com.quadcap.sql.Table.getModifiers(), and com.quadcap.sql.Table.getType().

final int com.quadcap.sql.Table.STATEMENT_TEMP = 8 [static]
 

Definition at line 105 of file Table.java.

long com.quadcap.sql.Table.tableIdentity = 1 [package]
 

For in-memory mode, the table identity.

Definition at line 110 of file Table.java.

Referenced by com.quadcap.sql.Database.getTableIdentity(), and com.quadcap.sql.Database.updateTableIdentity().

final int com.quadcap.sql.Table.TEMPORARY = 1 [static]
 

Table modifiers, bit fields.

If temporary, either global or local must be specified.

Definition at line 102 of file Table.java.

Referenced by com.quadcap.sql.Table.getType().

transient boolean com.quadcap.sql.Table.underConstruction = false [package]
 

Definition at line 93 of file Table.java.

Referenced by com.quadcap.sql.Table.isUnderConstruction(), and com.quadcap.sql.Table.setUnderConstruction().