1 package com.quadcap.sql; 2 3 40 41 import java.io.ByteArrayOutputStream ; 42 import java.io.Externalizable ; 43 import java.io.IOException ; 44 import java.io.ObjectInput ; 45 import java.io.ObjectOutput ; 46 47 import java.util.Vector ; 48 49 import java.sql.ResultSet ; 50 import java.sql.ResultSetMetaData ; 51 import java.sql.SQLException ; 52 53 import com.quadcap.sql.types.Value; 54 55 import com.quadcap.sql.io.ObjectInputStream; 56 import com.quadcap.sql.io.ObjectOutputStream; 57 58 import com.quadcap.sql.index.Btree; 59 60 import com.quadcap.sql.file.BlockFile; 61 62 import com.quadcap.util.Debug; 63 import com.quadcap.util.Util; 64 65 70 public class PrimaryKeyConstraint extends UniqueConstraint 71 implements Externalizable { 72 75 public PrimaryKeyConstraint() {} 76 77 80 public PrimaryKeyConstraint(String name) { 81 super(name); 82 } 83 84 88 public PrimaryKeyConstraint(String name, Vector names) { 89 super(name, names); 90 } 91 92 97 public void readExternal(ObjectInput in) 98 throws IOException , ClassNotFoundException 99 { 100 super.readExternal(in); 101 } 102 103 108 public void writeExternal(ObjectOutput out) throws IOException { 109 super.writeExternal(out); 110 } 111 112 115 public int getIndexColumnCount() { 116 return getColumnCount(); 117 } 118 119 122 public byte[] makeKey(Session session, Row row, long rowId) 123 throws SQLException 124 { 125 return Key.makeKey(table, row, getColumns(), 0, false); 126 } 127 128 131 public String constraintType() { return "primary key"; } 132 133 136 public void setTable(Table t) throws SQLException { 137 super.setTable(t); 138 int[] cols = getColumns(); 139 final int notnull = ResultSetMetaData.columnNoNulls; 140 for (int i = 0; i < cols.length; i++) { 141 t.getColumn(cols[i]).setNullable(notnull); 142 } 143 } 144 } 145 | Popular Tags |