1 /* 2 * This file belongs to the XQuark distribution. 3 * Copyright (C) 2003 Universite de Versailles Saint-Quentin. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307. 18 * You can also get it at http://www.gnu.org/licenses/lgpl.html 19 * 20 * For more information on this software, see http://www.xquark.org. 21 */ 22 23 package org.xquark.extractor.algebra; 24 25 import java.util.List; 26 27 import org.xquark.extractor.common.SqlWrapperException; 28 import org.xquark.extractor.sql.SqlExpression; 29 30 /** 31 * 32 * A Temporary table used for intermediate result storage. This object may be 33 * created with or without table specification. If missing table specification 34 * will be deduced from operand relation. 35 * 36 * NOTE: Not used up to now : the problem is fixed during generation. 37 */ 38 39 // TODO: Reset temp table counter at every query (No drop needed 4 MySQL but a least a truncate) 40 // TODO: Remove ? 41 public final class TempTable extends UnaryAlgebra 42 { 43 44 private static final String RCSRevision = "$Revision: 1.3 $"; 45 private static final String RCSName = "$Name: $"; 46 47 protected org.xquark.extractor.metadata.Table _table; 48 49 50 public TempTable(org.xquark.extractor.metadata.Table mTable) { 51 _table = mTable; 52 } 53 54 public TempTable(String name) { 55 // TODO: build a metadata object from the operand: not necessary for DBMS 56 // supporting CREATE TABLE AS... But not so easy to realize: should add a 57 // method to Relation interface to retrieve item list 58 this(new org.xquark.extractor.metadata.Table(name)); 59 } 60 61 public SqlExpression accept (GenSqlVisitor visitor) throws SqlWrapperException 62 { 63 return visitor.visit(this); 64 } 65 66 public void accept (AlgebraVisitor visitor) throws SqlWrapperException 67 { 68 visitor.visit(this); 69 } 70 71 public String getName() 72 { 73 return _table.getName(); 74 } 75 76 public List getKeys() { 77 return _keys; 78 } 79 } 80