Commit 4390b0bf authored by Bruce Momjian's avatar Bruce Momjian

Add TEMP tables/indexes. Add COPY pfree(). Other cleanups.

parent 7fc75517
...@@ -248,7 +248,7 @@ Specifies that output goes to a pipe or terminal. ...@@ -248,7 +248,7 @@ Specifies that output goes to a pipe or terminal.
</para> </para>
<para> <para>
The backslash character has other special meanings. NULL attributes are The backslash character has other special meanings. NULL attributes are
output as "\N". A literal backslash character is output as two represented as "\N". A literal backslash character is represented as two
consecutive backslashes ("\\"). A literal tab character is represented consecutive backslashes ("\\"). A literal tab character is represented
as a backslash and a tab. A literal newline character is as a backslash and a tab. A literal newline character is
represented as a backslash and a newline. When loading text data represented as a backslash and a newline. When loading text data
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<DATE>1998-09-11</DATE> <DATE>1998-09-11</DATE>
</REFSYNOPSISDIVINFO> </REFSYNOPSISDIVINFO>
<SYNOPSIS> <SYNOPSIS>
CREATE TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ( CREATE [TEMP] TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> (
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE>
[ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ] [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ]
[<REPLACEABLE>column_constraint_clause</REPLACEABLE> | PRIMARY KEY } [ ... ] ] [<REPLACEABLE>column_constraint_clause</REPLACEABLE> | PRIMARY KEY } [ ... ] ]
...@@ -38,6 +38,18 @@ CREATE TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ( ...@@ -38,6 +38,18 @@ CREATE TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> (
</TITLE> </TITLE>
<PARA> <PARA>
<VARLISTENTRY>
<TERM>
TEMP
</TERM>
<LISTITEM>
<PARA>
The table is created unique to this session, and is
automatically dropped on session exit.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARIABLELIST> <VARIABLELIST>
<VARLISTENTRY> <VARLISTENTRY>
<TERM> <TERM>
......
...@@ -19,7 +19,7 @@ SELECT ...@@ -19,7 +19,7 @@ SELECT
<synopsis> <synopsis>
SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
<replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
[ INTO [TABLE] <replaceable class="PARAMETER">new_table</replaceable> ] [ INTO [TEMP] [TABLE] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable> ] [, ...] ] [ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ] [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
...@@ -64,6 +64,18 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -64,6 +64,18 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY>
<TERM>
TEMP
</TERM>
<LISTITEM>
<PARA>
The table is created unique to this session, and is
automatically dropped on session exit.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<varlistentry> <varlistentry>
<term> <term>
<replaceable class="PARAMETER">new_table</replaceable> <replaceable class="PARAMETER">new_table</replaceable>
...@@ -599,7 +611,7 @@ Create a new table from an existing table or view ...@@ -599,7 +611,7 @@ Create a new table from an existing table or view
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...] SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
INTO [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ] INTO [TEMP] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable>] [, ...] ] [ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable>] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ] [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
......
...@@ -363,7 +363,7 @@ SET TIME ZONE { '<REPLACEABLE CLASS="PARAMETER">timezone</REPLACEABLE>' | LOCAL ...@@ -363,7 +363,7 @@ SET TIME ZONE { '<REPLACEABLE CLASS="PARAMETER">timezone</REPLACEABLE>' | LOCAL
<listitem> <listitem>
<para> <para>
enables the genetic optimizer algorithm enables the genetic optimizer algorithm
for statements with 8 or more tables. for statements with 6 or more tables.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -406,7 +406,7 @@ SET TIME ZONE { '<REPLACEABLE CLASS="PARAMETER">timezone</REPLACEABLE>' | LOCAL ...@@ -406,7 +406,7 @@ SET TIME ZONE { '<REPLACEABLE CLASS="PARAMETER">timezone</REPLACEABLE>' | LOCAL
</para> </para>
<para> <para>
This algorithm is on by default, which used GEQO for This algorithm is on by default, which used GEQO for
statements of eight or more tables. statements of six or more tables.
(See the chapter on GEQO in the Programmer's Guide (See the chapter on GEQO in the Programmer's Guide
for more information). for more information).
</para> </para>
......
...@@ -7,31 +7,31 @@ ...@@ -7,31 +7,31 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.54 1998/11/29 05:30:14 tgl Exp $ # $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.55 1999/02/02 03:43:56 momjian Exp $
# #
# NOTES # NOTES
# Essentially all Postgres make files include this file and use the # Essentially all Postgres make files include this file and use the
# variables it sets. # variables it sets.
# #
# To override the default setting, create a Makefile.custom in this # To override the default setting, create a Makefile.custom in this
# directory and put your defines there. (Makefile.custom is included # directory and put your defines there. (Makefile.custom is included
# near the end of this file). Sometimes, a variable gets set in # near the end of this file). Sometimes, a variable gets set in
# Makefile.global after Makefile.custom has been included, so you can't # Makefile.global after Makefile.custom has been included, so you can't
# simply set that variable in Makefile.custom. In those cases, there is # simply set that variable in Makefile.custom. In those cases, there is
# often another variable (like CUSTOM_COPT) that you can set in # often another variable (like CUSTOM_COPT) that you can set in
# Makefile.custom that influences the later setting of the true variable # Makefile.custom that influences the later setting of the true variable
# of interest (like CFLAGS) by Makefile.global. # of interest (like CFLAGS) by Makefile.global.
# #
# #
# If you change any of these defines you probably have to # If you change any of these defines you probably have to
# make clean; make # make clean; make
# since no dependencies are created for these. (of course you can # since no dependencies are created for these. (of course you can
# be crafty and check what files really depend on them and just remake # be crafty and check what files really depend on them and just remake
# those). # those).
# #
# Before including this file, you must set the SRCDIR variable to the # Before including this file, you must set the SRCDIR variable to the
# path of the top of the Postgres source tree (the directory that # path of the top of the Postgres source tree (the directory that
# contains this file). # contains this file).
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
# #
# CONFIGURATION SECTION # CONFIGURATION SECTION
# #
# Following are settings pertaining to the postgres build and # Following are settings pertaining to the postgres build and
# installation. # installation.
# of the port. # of the port.
# #
# Ignore BSD_SHLIB if you're not using one of the BSD ports. But if you # Ignore BSD_SHLIB if you're not using one of the BSD ports. But if you
...@@ -55,8 +55,8 @@ ELF_SYSTEM= @ELF_SYS@ ...@@ -55,8 +55,8 @@ ELF_SYSTEM= @ELF_SYS@
LIBPQDIR:= $(SRCDIR)/interfaces/libpq LIBPQDIR:= $(SRCDIR)/interfaces/libpq
# For convenience, POSTGRESDIR is where BINDIR, and LIBDIR # For convenience, POSTGRESDIR is where BINDIR, and LIBDIR
# and other target destinations are rooted. Of course, each of these is # and other target destinations are rooted. Of course, each of these is
# changable separately. # changable separately.
POSTGRESDIR= @prefix@ POSTGRESDIR= @prefix@
...@@ -73,7 +73,7 @@ LIBDIR= $(POSTGRESDIR)/lib ...@@ -73,7 +73,7 @@ LIBDIR= $(POSTGRESDIR)/lib
# This is the directory where IPC utilities ipcs and ipcrm are located # This is the directory where IPC utilities ipcs and ipcrm are located
# #
IPCS=@ipcs@ IPCS=@ipcs@
IPCRM=@ipcrm@ IPCRM=@ipcrm@
# Where the man pages (suitable for use with "man") get installed. # Where the man pages (suitable for use with "man") get installed.
POSTMANDIR= $(POSTGRESDIR)/man POSTMANDIR= $(POSTGRESDIR)/man
...@@ -91,7 +91,7 @@ ODBCINST= $(POSTGRESDIR) ...@@ -91,7 +91,7 @@ ODBCINST= $(POSTGRESDIR)
############################################################################## ##############################################################################
# #
# FEATURES # FEATURES
# #
# To disable a feature, comment out the entire definition # To disable a feature, comment out the entire definition
# (that is, prepend '#', don't set it to "0" or "no"). # (that is, prepend '#', don't set it to "0" or "no").
...@@ -167,7 +167,7 @@ endif ...@@ -167,7 +167,7 @@ endif
############################################################################## ##############################################################################
# #
# Installation. # Installation.
# #
# For many ports, INSTALL is overridden below. # For many ports, INSTALL is overridden below.
INSTALL= @INSTALL@ INSTALL= @INSTALL@
...@@ -181,7 +181,7 @@ INSTL_SHLIB_OPTS= @INSTL_SHLIB_OPTS@ ...@@ -181,7 +181,7 @@ INSTL_SHLIB_OPTS= @INSTL_SHLIB_OPTS@
############################################################################## ##############################################################################
# #
# For building shell scripts: # For building shell scripts:
# #
# For many ports, these are overridden below. # For many ports, these are overridden below.
# DASH_N is what we put before the text on an echo command when we don't # DASH_N is what we put before the text on an echo command when we don't
...@@ -191,7 +191,7 @@ INSTL_SHLIB_OPTS= @INSTL_SHLIB_OPTS@ ...@@ -191,7 +191,7 @@ INSTL_SHLIB_OPTS= @INSTL_SHLIB_OPTS@
# you do echo "no newline after this\c". # you do echo "no newline after this\c".
DASH_N= @DASH_N@ DASH_N= @DASH_N@
BACKSLASH_C= @BACKSLASH_C@ BACKSLASH_C= @BACKSLASH_C@
...@@ -204,7 +204,7 @@ YFLAGS= @YFLAGS@ ...@@ -204,7 +204,7 @@ YFLAGS= @YFLAGS@
YACC= @YACC@ YACC= @YACC@
LEX= @LEX@ LEX= @LEX@
AROPT= @AROPT@ AROPT= @AROPT@
CFLAGS= -I$(SRCDIR)/include -I$(SRCDIR)/backend @CPPFLAGS@ @CFLAGS@ CFLAGS= -I$(SRCDIR)/include -I$(SRCDIR)/backend @CPPFLAGS@ @CFLAGS@
CFLAGS_SL= @SHARED_LIB@ CFLAGS_SL= @SHARED_LIB@
LDFLAGS= @LDFLAGS@ @LIBS@ LDFLAGS= @LDFLAGS@ @LIBS@
DLSUFFIX= @DLSUFFIX@ DLSUFFIX= @DLSUFFIX@
...@@ -245,25 +245,25 @@ INSTALL= $(CUSTOM_INSTALL) ...@@ -245,25 +245,25 @@ INSTALL= $(CUSTOM_INSTALL)
endif endif
# #
# Flags for CC and LD. # Flags for CC and LD.
############################################################################## ##############################################################################
# COPT # COPT
# #
# COPT is for options that the sophisticated builder might want to vary # COPT is for options that the sophisticated builder might want to vary
# from one build to the next, like options to build Postgres with debugging # from one build to the next, like options to build Postgres with debugging
# information included. COPT is meant to be set on the make command line, # information included. COPT is meant to be set on the make command line,
# for example with the command "make COPT=-g". The value you see set here # for example with the command "make COPT=-g". The value you see set here
# is the default that gets used if the builder does not give a value for # is the default that gets used if the builder does not give a value for
# COPT on his make command. # COPT on his make command.
# #
# There is a nonobvious relationship between -O (optimization) and # There is a nonobvious relationship between -O (optimization) and
# -Werror (consider all warnings fatal). On some systems, if you don't # -Werror (consider all warnings fatal). On some systems, if you don't
# optimize, you will always get some warnings because the system header # optimize, you will always get some warnings because the system header
# files will include some unreferenced functions in the code. These are # files will include some unreferenced functions in the code. These are
# functions that are supposed to be inline, so there wouldn't ordinarily # functions that are supposed to be inline, so there wouldn't ordinarily
# be an "unreferenced" problem, but if you don't enable optimization, no # be an "unreferenced" problem, but if you don't enable optimization, no
# inlining can happen, and hence the problem. Therefore, we include # inlining can happen, and hence the problem. Therefore, we include
# if you override -O, you override -Werror as well. # if you override -O, you override -Werror as well.
# #
# CUSTOM_COPT is something the user may set in Makefile.custom # CUSTOM_COPT is something the user may set in Makefile.custom
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Id: hio.c,v 1.15 1998/12/15 12:45:14 vadim Exp $ * $Id: hio.c,v 1.16 1999/02/02 03:43:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -110,7 +110,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) ...@@ -110,7 +110,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
ItemId itemId; ItemId itemId;
Item item; Item item;
if (!relation->rd_islocal) if (!relation->rd_myxactonly)
LockRelation(relation, ExtendLock); LockRelation(relation, ExtendLock);
/* /*
...@@ -158,7 +158,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) ...@@ -158,7 +158,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
elog(ERROR, "Tuple is too big: size %d", len); elog(ERROR, "Tuple is too big: size %d", len);
} }
if (!relation->rd_islocal) if (!relation->rd_myxactonly)
UnlockRelation(relation, ExtendLock); UnlockRelation(relation, ExtendLock);
offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data, offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.29 1999/01/29 09:22:53 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.30 1999/02/02 03:44:00 momjian Exp $
* *
* NOTES * NOTES
* Transaction aborts can now occur two ways: * Transaction aborts can now occur two ways:
...@@ -850,7 +850,7 @@ StartTransaction() ...@@ -850,7 +850,7 @@ StartTransaction()
are created in the course of the transactions are created in the course of the transactions
they need to be destroyed properly at the end of the transactions they need to be destroyed properly at the end of the transactions
*/ */
InitTempRelList(); InitNoNameRelList();
/* ---------------- /* ----------------
* done with start processing, set current transaction * done with start processing, set current transaction
...@@ -917,7 +917,7 @@ CommitTransaction() ...@@ -917,7 +917,7 @@ CommitTransaction()
AtCommit_Notify(); AtCommit_Notify();
CloseSequences(); CloseSequences();
DestroyTempRels(); DestroyNoNameRels();
AtEOXact_portals(); AtEOXact_portals();
RecordTransactionCommit(); RecordTransactionCommit();
RelationPurgeLocalRelation(true); RelationPurgeLocalRelation(true);
...@@ -984,7 +984,7 @@ AbortTransaction() ...@@ -984,7 +984,7 @@ AbortTransaction()
AtEOXact_portals(); AtEOXact_portals();
RecordTransactionAbort(); RecordTransactionAbort();
RelationPurgeLocalRelation(false); RelationPurgeLocalRelation(false);
DestroyTempRels(); DestroyNoNameRels();
AtAbort_Cache(); AtAbort_Cache();
AtAbort_Locks(); AtAbort_Locks();
AtAbort_Memory(); AtAbort_Memory();
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.22 1999/01/21 22:48:04 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.23 1999/02/02 03:44:03 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -164,7 +164,8 @@ Boot_CreateStmt: ...@@ -164,7 +164,8 @@ Boot_CreateStmt:
if (DebugMode) if (DebugMode)
puts("creating bootstrap relation"); puts("creating bootstrap relation");
tupdesc = CreateTupleDesc(numattr,attrtypes); tupdesc = CreateTupleDesc(numattr,attrtypes);
reldesc = heap_create(LexIDStr($3), tupdesc); reldesc = heap_create(LexIDStr($3), tupdesc,
false, false);
if (DebugMode) if (DebugMode)
puts("bootstrap relation created ok"); puts("bootstrap relation created ok");
} }
...@@ -175,7 +176,7 @@ Boot_CreateStmt: ...@@ -175,7 +176,7 @@ Boot_CreateStmt:
tupdesc = CreateTupleDesc(numattr,attrtypes); tupdesc = CreateTupleDesc(numattr,attrtypes);
id = heap_create_with_catalog(LexIDStr($3), id = heap_create_with_catalog(LexIDStr($3),
tupdesc, RELKIND_RELATION); tupdesc, RELKIND_RELATION, false);
if (!Quiet) if (!Quiet)
printf("CREATED relation %s with OID %d\n", printf("CREATED relation %s with OID %d\n",
LexIDStr($3), id); LexIDStr($3), id);
......
This diff is collapsed.
...@@ -7,19 +7,13 @@ ...@@ -7,19 +7,13 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.67 1999/01/21 22:48:05 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.68 1999/02/02 03:44:13 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* index_create() - Create a cataloged index relation * index_create() - Create a cataloged index relation
* index_destroy() - Removes index relation from catalogs * index_destroy() - Removes index relation from catalogs
* *
* NOTES
* Much of this code uses hardcoded sequential heap relation scans
* to fetch information from the catalogs. These should all be
* rewritten to use the system caches lookup routines like
* SearchSysCacheTuple, which can do efficient lookup and
* caching.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,10 +40,12 @@ ...@@ -46,10 +40,12 @@
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "storage/smgr.h" #include "storage/smgr.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/mcxt.h" #include "utils/mcxt.h"
#include "utils/relcache.h" #include "utils/relcache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/tqual.h" #include "utils/tqual.h"
#include "utils/temprel.h"
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
#include <regex/utils.h> #include <regex/utils.h>
...@@ -64,16 +60,15 @@ ...@@ -64,16 +60,15 @@
#define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE)) #define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
/* non-export function prototypes */ /* non-export function prototypes */
static Oid static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName,
RelationNameGetObjectId(char *relationName, Relation pg_class); bool istemp);
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo); static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
List *attributeList, List *attributeList,
int numatts, AttrNumber *attNums); int numatts, AttrNumber *attNums);
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
static Oid UpdateRelationRelation(Relation indexRelation); static Oid UpdateRelationRelation(Relation indexRelation, char *temp_relname);
static void InitializeAttributeOids(Relation indexRelation, static void InitializeAttributeOids(Relation indexRelation,
int numatts, int numatts,
Oid indexoid); Oid indexoid);
...@@ -121,105 +116,30 @@ static FormData_pg_attribute sysatts[] = { ...@@ -121,105 +116,30 @@ static FormData_pg_attribute sysatts[] = {
{0, {"cmax"}, CIDOID, 0, 4, -6, 0, -1, -1, '\001', '\0', 'i', '\0', '\0'}, {0, {"cmax"}, CIDOID, 0, 4, -6, 0, -1, -1, '\001', '\0', 'i', '\0', '\0'},
}; };
/* ----------------------------------------------------------------
* RelationNameGetObjectId --
* Returns the object identifier for a relation given its name.
*
* ----------------------------------------------------------------
*/
static Oid
RelationNameGetObjectId(char *relationName,
Relation pg_class)
{
HeapScanDesc pg_class_scan;
HeapTuple pg_class_tuple;
Oid relationObjectId;
ScanKeyData key;
/*
* If this isn't bootstrap time, we can use the system catalogs to
* speed this up.
*/
if (!IsBootstrapProcessingMode())
{
HeapTuple tuple;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(relationName),
0, 0, 0);
if (HeapTupleIsValid(tuple))
return tuple->t_data->t_oid;
else
return InvalidOid;
}
/* ----------------
* BOOTSTRAP TIME, do this the hard way.
* begin a scan of pg_class for the named relation
* ----------------
*/
ScanKeyEntryInitialize(&key, 0, Anum_pg_class_relname,
F_NAMEEQ,
PointerGetDatum(relationName));
pg_class_scan = heap_beginscan(pg_class, 0, SnapshotNow, 1, &key);
/* ----------------
* if we find the named relation, fetch its relation id
* (the oid of the tuple we found).
* ----------------
*/
pg_class_tuple = heap_getnext(pg_class_scan, 0);
if (!HeapTupleIsValid(pg_class_tuple))
relationObjectId = InvalidOid;
else
relationObjectId = pg_class_tuple->t_data->t_oid;
/* ----------------
* cleanup and return results
* ----------------
*/
heap_endscan(pg_class_scan);
return relationObjectId;
}
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* GetHeapRelationOid * GetHeapRelationOid
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static Oid static Oid
GetHeapRelationOid(char *heapRelationName, char *indexRelationName) GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp)
{ {
Relation pg_class;
Oid indoid; Oid indoid;
Oid heapoid; Oid heapoid;
/* ----------------
* open pg_class and get the oid of the relation indoid = RelnameFindRelid(indexRelationName);
* corresponding to the name of the index relation.
* ----------------
*/
pg_class = heap_openr(RelationRelationName);
indoid = RelationNameGetObjectId(indexRelationName, pg_class);
if (OidIsValid(indoid)) if ((!istemp && OidIsValid(indoid)) ||
(istemp && get_temp_rel_by_name(indexRelationName) != NULL))
elog(ERROR, "Cannot create index: '%s' already exists", elog(ERROR, "Cannot create index: '%s' already exists",
indexRelationName); indexRelationName);
heapoid = RelationNameGetObjectId(heapRelationName, pg_class); heapoid = RelnameFindRelid(heapRelationName);
if (!OidIsValid(heapoid)) if (!OidIsValid(heapoid))
elog(ERROR, "Cannot create index on '%s': relation does not exist", elog(ERROR, "Cannot create index on '%s': relation does not exist",
heapRelationName); heapRelationName);
heap_close(pg_class);
return heapoid; return heapoid;
} }
...@@ -538,7 +458,7 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid) ...@@ -538,7 +458,7 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
static Oid static Oid
UpdateRelationRelation(Relation indexRelation) UpdateRelationRelation(Relation indexRelation, char *temp_relname)
{ {
Relation pg_class; Relation pg_class;
HeapTuple tuple; HeapTuple tuple;
...@@ -561,6 +481,9 @@ UpdateRelationRelation(Relation indexRelation) ...@@ -561,6 +481,9 @@ UpdateRelationRelation(Relation indexRelation)
tuple->t_data->t_oid = RelationGetRelid(indexRelation); tuple->t_data->t_oid = RelationGetRelid(indexRelation);
heap_insert(pg_class, tuple); heap_insert(pg_class, tuple);
if (temp_relname)
create_temp_relation(temp_relname, tuple);
/* /*
* During normal processing, we need to make sure that the system * During normal processing, we need to make sure that the system
* catalog indices are correct. Bootstrap (initdb) time doesn't * catalog indices are correct. Bootstrap (initdb) time doesn't
...@@ -760,6 +683,7 @@ UpdateIndexRelation(Oid indexoid, ...@@ -760,6 +683,7 @@ UpdateIndexRelation(Oid indexoid,
} }
else else
predText = (text *) fmgr(F_TEXTIN, ""); predText = (text *) fmgr(F_TEXTIN, "");
predLen = VARSIZE(predText); predLen = VARSIZE(predText);
itupLen = predLen + sizeof(FormData_pg_index); itupLen = predLen + sizeof(FormData_pg_index);
indexForm = (Form_pg_index) palloc(itupLen); indexForm = (Form_pg_index) palloc(itupLen);
...@@ -1025,27 +949,28 @@ index_create(char *heapRelationName, ...@@ -1025,27 +949,28 @@ index_create(char *heapRelationName,
Oid heapoid; Oid heapoid;
Oid indexoid; Oid indexoid;
PredInfo *predInfo; PredInfo *predInfo;
bool istemp = (get_temp_rel_by_name(heapRelationName) != NULL);
char *temp_relname = NULL;
/* ---------------- /* ----------------
* check parameters * check parameters
* ---------------- * ----------------
*/ */
if (numatts < 1) if (numatts < 1)
elog(ERROR, "must index at least one attribute"); elog(ERROR, "must index at least one attribute");
/* ---------------- /* ----------------
* get heap relation oid and open the heap relation * get heap relation oid and open the heap relation
* XXX ADD INDEXING * XXX ADD INDEXING
* ---------------- * ----------------
*/ */
heapoid = GetHeapRelationOid(heapRelationName, indexRelationName); heapoid = GetHeapRelationOid(heapRelationName, indexRelationName, istemp);
heapRelation = heap_open(heapoid); heapRelation = heap_open(heapoid);
/* /*
* Only SELECT ... FOR UPDATE are allowed * Only SELECT ... FOR UPDATE are allowed
*/ */
LockRelation(heapRelation, ShareLock); LockRelation(heapRelation, ShareLock);
/* ---------------- /* ----------------
...@@ -1061,12 +986,36 @@ index_create(char *heapRelationName, ...@@ -1061,12 +986,36 @@ index_create(char *heapRelationName,
numatts, numatts,
attNums); attNums);
/* invalidate cache so possible non-temp index is masked by temp */
if (istemp)
{
Oid relid = RelnameFindRelid(indexRelationName);
if (relid != InvalidOid)
{
/*
* This is heavy-handed, but appears necessary bjm 1999/02/01
* SystemCacheRelationFlushed(relid) is not enough either.
*/
RelationForgetRelation(relid);
ResetSystemCache();
}
}
/* save user relation name because heap_create changes it */
if (istemp)
{
temp_relname = pstrdup(indexRelationName); /* save original value */
indexRelationName = palloc(NAMEDATALEN);
strcpy(indexRelationName, temp_relname); /* heap_create will change this */
}
/* ---------------- /* ----------------
* create the index relation * create the index relation
* ---------------- * ----------------
*/ */
indexRelation = heap_create(indexRelationName, indexRelation = heap_create(indexRelationName,
indexTupDesc); indexTupDesc, false, istemp);
/* ---------------- /* ----------------
* construct the index relation descriptor * construct the index relation descriptor
...@@ -1081,7 +1030,7 @@ index_create(char *heapRelationName, ...@@ -1081,7 +1030,7 @@ index_create(char *heapRelationName,
* (append RELATION tuple) * (append RELATION tuple)
* ---------------- * ----------------
*/ */
indexoid = UpdateRelationRelation(indexRelation); indexoid = UpdateRelationRelation(indexRelation, temp_relname);
/* ---------------- /* ----------------
* Now get the index procedure (only relevant for functional indices). * Now get the index procedure (only relevant for functional indices).
...@@ -1162,9 +1111,9 @@ index_create(char *heapRelationName, ...@@ -1162,9 +1111,9 @@ index_create(char *heapRelationName,
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
*
* index_destroy * index_destroy
* *
* XXX break into modules like index_create
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
void void
...@@ -1175,11 +1124,11 @@ index_destroy(Oid indexId) ...@@ -1175,11 +1124,11 @@ index_destroy(Oid indexId)
Relation relationRelation; Relation relationRelation;
Relation attributeRelation; Relation attributeRelation;
HeapTuple tuple; HeapTuple tuple;
int16 attnum; int16 attnum;
Assert(OidIsValid(indexId)); Assert(OidIsValid(indexId));
/* why open it here? bjm 1998/08/20 */ /* Open now to obtain lock by referencing table? bjm */
userindexRelation = index_open(indexId); userindexRelation = index_open(indexId);
/* ---------------- /* ----------------
...@@ -1192,7 +1141,7 @@ index_destroy(Oid indexId) ...@@ -1192,7 +1141,7 @@ index_destroy(Oid indexId)
ObjectIdGetDatum(indexId), ObjectIdGetDatum(indexId),
0, 0, 0); 0, 0, 0);
AssertState(HeapTupleIsValid(tuple)); Assert(HeapTupleIsValid(tuple));
heap_delete(relationRelation, &tuple->t_self, NULL); heap_delete(relationRelation, &tuple->t_self, NULL);
pfree(tuple); pfree(tuple);
...@@ -1217,6 +1166,9 @@ index_destroy(Oid indexId) ...@@ -1217,6 +1166,9 @@ index_destroy(Oid indexId)
} }
heap_close(attributeRelation); heap_close(attributeRelation);
/* does something only if it is a temp index */
remove_temp_relation(indexId);
/* ---------------- /* ----------------
* fix INDEX relation * fix INDEX relation
* ---------------- * ----------------
...@@ -1224,10 +1176,7 @@ index_destroy(Oid indexId) ...@@ -1224,10 +1176,7 @@ index_destroy(Oid indexId)
tuple = SearchSysCacheTupleCopy(INDEXRELID, tuple = SearchSysCacheTupleCopy(INDEXRELID,
ObjectIdGetDatum(indexId), ObjectIdGetDatum(indexId),
0, 0, 0); 0, 0, 0);
Assert(HeapTupleIsValid(tuple));
if (!HeapTupleIsValid(tuple))
elog(NOTICE, "IndexRelationDestroy: %s's INDEX tuple missing",
RelationGetRelationName(userindexRelation));
indexRelation = heap_openr(IndexRelationName); indexRelation = heap_openr(IndexRelationName);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.34 1998/11/27 19:51:50 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.35 1999/02/02 03:44:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "storage/bufmgr.h" #include "storage/bufmgr.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/temprel.h"
/* /*
* Names of indices on the following system catalogs: * Names of indices on the following system catalogs:
...@@ -455,6 +456,13 @@ ClassNameIndexScan(Relation heapRelation, char *relName) ...@@ -455,6 +456,13 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
ScanKeyData skey[1]; ScanKeyData skey[1];
HeapTuple tuple; HeapTuple tuple;
/*
* we have to do this before looking in system tables because temp
* table namespace takes precedence
*/
if ((tuple = get_temp_rel_by_name(relName)) != NULL)
return heap_copytuple(tuple);
ScanKeyEntryInitialize(&skey[0], ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0, (bits16) 0x0,
(AttrNumber) 1, (AttrNumber) 1,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.35 1999/01/21 22:48:06 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.36 1999/02/02 03:44:17 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -219,7 +219,8 @@ copy_heap(Oid OIDOldHeap) ...@@ -219,7 +219,8 @@ copy_heap(Oid OIDOldHeap)
tupdesc = CreateTupleDescCopy(OldHeapDesc); tupdesc = CreateTupleDescCopy(OldHeapDesc);
OIDNewHeap = heap_create_with_catalog(NewName, tupdesc, RELKIND_RELATION); OIDNewHeap = heap_create_with_catalog(NewName, tupdesc,
RELKIND_RELATION, false);
if (!OidIsValid(OIDNewHeap)) if (!OidIsValid(OIDNewHeap))
elog(ERROR, "clusterheap: cannot create temporary heap relation\n"); elog(ERROR, "clusterheap: cannot create temporary heap relation\n");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.69 1999/02/01 20:25:54 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.70 1999/02/02 03:44:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -646,7 +646,6 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -646,7 +646,6 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
index_nulls[i] = ' '; index_nulls[i] = ' ';
byval[i] = (bool) IsTypeByVal(attr[i]->atttypid); byval[i] = (bool) IsTypeByVal(attr[i]->atttypid);
} }
values = (Datum *) palloc(sizeof(Datum) * attr_count);
lineno = 0; lineno = 0;
while (!done) while (!done)
...@@ -873,13 +872,16 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) ...@@ -873,13 +872,16 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
} }
pfree(values); pfree(values);
pfree(nulls); pfree(nulls);
pfree(index_nulls);
pfree(idatum);
pfree(byval);
if (!binary) if (!binary)
{ {
pfree(in_functions); pfree(in_functions);
pfree(elements); pfree(elements);
pfree(typmod); pfree(typmod);
} }
pfree(byval);
/* comments in execUtils.c */ /* comments in execUtils.c */
if (has_index) if (has_index)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.37 1998/12/14 05:18:43 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.38 1999/02/02 03:44:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -138,8 +138,8 @@ DefineRelation(CreateStmt *stmt, char relkind) ...@@ -138,8 +138,8 @@ DefineRelation(CreateStmt *stmt, char relkind)
} }
} }
relationId = heap_create_with_catalog(relname, relationId = heap_create_with_catalog(relname, descriptor,
descriptor, relkind); relkind, stmt->istemp);
StoreCatalogInheritance(relationId, inheritList); StoreCatalogInheritance(relationId, inheritList);
} }
...@@ -279,7 +279,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) ...@@ -279,7 +279,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
SearchSysCacheTuple(TYPOID, SearchSysCacheTuple(TYPOID,
ObjectIdGetDatum(attribute->atttypid), ObjectIdGetDatum(attribute->atttypid),
0, 0, 0); 0, 0, 0);
AssertState(HeapTupleIsValid(tuple)); Assert(HeapTupleIsValid(tuple));
attributeType = attributeType =
(((Form_pg_type) GETSTRUCT(tuple))->typname).data; (((Form_pg_type) GETSTRUCT(tuple))->typname).data;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.30 1999/01/21 22:48:06 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.31 1999/02/02 03:44:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -98,15 +98,11 @@ DefineIndex(char *heapRelationName, ...@@ -98,15 +98,11 @@ DefineIndex(char *heapRelationName,
/* /*
* compute heap relation id * compute heap relation id
*/ */
tuple = SearchSysCacheTuple(RELNAME, if ((relationId = RelnameFindRelid(heapRelationName)) == InvalidOid)
PointerGetDatum(heapRelationName),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
{ {
elog(ERROR, "DefineIndex: %s relation not found", elog(ERROR, "DefineIndex: %s relation not found",
heapRelationName); heapRelationName);
} }
relationId = tuple->t_data->t_oid;
if (unique && strcmp(accessMethodName, "btree") != 0) if (unique && strcmp(accessMethodName, "btree") != 0)
elog(ERROR, "DefineIndex: unique indices are only available with the btree access method"); elog(ERROR, "DefineIndex: unique indices are only available with the btree access method");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.26 1998/12/14 05:18:44 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.27 1999/02/02 03:44:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1025,7 +1025,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) ...@@ -1025,7 +1025,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
relid = heap_create_with_catalog( relid = heap_create_with_catalog(
child->nodeElem->outTypes->val[0], child->nodeElem->outTypes->val[0],
tupdesc, RELKIND_RELATION); tupdesc, RELKIND_RELATION, false);
} }
else else
{ {
...@@ -1049,7 +1049,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) ...@@ -1049,7 +1049,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
{ {
relid = heap_create_with_catalog( relid = heap_create_with_catalog(
child->nodeElem->outTypes->val[0], child->nodeElem->outTypes->val[0],
tupdesc, RELKIND_RELATION); tupdesc, RELKIND_RELATION, false);
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.19 1998/12/15 12:45:58 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.20 1999/02/02 03:44:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <utils/builtins.h> #include <utils/builtins.h>
#include <catalog/catname.h> #include <catalog/catname.h>
#include <utils/syscache.h> #include <utils/syscache.h>
#include <catalog/heap.h>
#include <catalog/indexing.h> #include <catalog/indexing.h>
#include <catalog/catalog.h> #include <catalog/catalog.h>
#include <commands/copy.h> #include <commands/copy.h>
...@@ -106,15 +107,9 @@ renameatt(char *relname, ...@@ -106,15 +107,9 @@ renameatt(char *relname,
List *child, List *child,
*children; *children;
reltup = SearchSysCacheTuple(RELNAME, if ((myrelid = RelnameFindRelid(relname)) == InvalidOid)
PointerGetDatum(relname),
0, 0, 0);
if (!HeapTupleIsValid(reltup))
elog(ERROR, "renameatt: unknown relation: \"%s\"", relname); elog(ERROR, "renameatt: unknown relation: \"%s\"", relname);
myrelid = reltup->t_data->t_oid;
/* this routine is actually in the planner */ /* this routine is actually in the planner */
children = find_all_inheritors(lconsi(myrelid, NIL), NIL); children = find_all_inheritors(lconsi(myrelid, NIL), NIL);
...@@ -147,14 +142,10 @@ renameatt(char *relname, ...@@ -147,14 +142,10 @@ renameatt(char *relname,
} }
} }
reltup = SearchSysCacheTuple(RELNAME,
PointerGetDatum(relname), if ((relid = RelnameFindRelid(relname)) == InvalidOid)
0, 0, 0);
if (!HeapTupleIsValid(reltup))
elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname); elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
relid = reltup->t_data->t_oid;
oldatttup = SearchSysCacheTupleCopy(ATTNAME, oldatttup = SearchSysCacheTupleCopy(ATTNAME,
ObjectIdGetDatum(relid), ObjectIdGetDatum(relid),
PointerGetDatum(oldattname), PointerGetDatum(oldattname),
...@@ -211,8 +202,7 @@ void ...@@ -211,8 +202,7 @@ void
renamerel(char *oldrelname, char *newrelname) renamerel(char *oldrelname, char *newrelname)
{ {
Relation relrelation; /* for RELATION relation */ Relation relrelation; /* for RELATION relation */
HeapTuple oldreltup, HeapTuple oldreltup;
newreltup;
char oldpath[MAXPGPATH], char oldpath[MAXPGPATH],
newpath[MAXPGPATH]; newpath[MAXPGPATH];
Relation irelations[Num_pg_class_indices]; Relation irelations[Num_pg_class_indices];
...@@ -231,10 +221,7 @@ renamerel(char *oldrelname, char *newrelname) ...@@ -231,10 +221,7 @@ renamerel(char *oldrelname, char *newrelname)
if (!HeapTupleIsValid(oldreltup)) if (!HeapTupleIsValid(oldreltup))
elog(ERROR, "renamerel: relation \"%s\" does not exist", oldrelname); elog(ERROR, "renamerel: relation \"%s\" does not exist", oldrelname);
newreltup = SearchSysCacheTuple(RELNAME, if (RelnameFindRelid(newrelname) != InvalidOid)
PointerGetDatum(newrelname),
0, 0, 0);
if (HeapTupleIsValid(newreltup))
elog(ERROR, "renamerel: relation \"%s\" exists", newrelname); elog(ERROR, "renamerel: relation \"%s\" exists", newrelname);
/* rename the path first, so if this fails the rename's not done */ /* rename the path first, so if this fails the rename's not done */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: view.c,v 1.29 1998/12/14 08:11:01 scrappy Exp $ * $Id: view.c,v 1.30 1999/02/02 03:44:20 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -95,6 +95,7 @@ DefineVirtualRelation(char *relname, List *tlist) ...@@ -95,6 +95,7 @@ DefineVirtualRelation(char *relname, List *tlist)
* nil... * nil...
*/ */
createStmt.relname = relname; createStmt.relname = relname;
createStmt.istemp = false;
createStmt.tableElts = attrList; createStmt.tableElts = attrList;
/* createStmt.tableType = NULL;*/ /* createStmt.tableType = NULL;*/
createStmt.inhRelnames = NIL; createStmt.inhRelnames = NIL;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: execAmi.c,v 1.29 1999/01/18 00:09:45 momjian Exp $ * $Id: execAmi.c,v 1.30 1999/02/02 03:44:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -524,7 +524,7 @@ ExecCreatR(TupleDesc tupType, ...@@ -524,7 +524,7 @@ ExecCreatR(TupleDesc tupType,
* heap_create creates a name if the argument to heap_create is * heap_create creates a name if the argument to heap_create is
* '\0 ' * '\0 '
*/ */
relDesc = heap_create("", tupType); relDesc = heap_create(NULL, tupType, true, false);
} }
else else
{ {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.69 1999/01/29 13:24:36 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.70 1999/02/02 03:44:23 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -654,7 +654,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) ...@@ -654,7 +654,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
tupdesc = CreateTupleDescCopy(tupType); tupdesc = CreateTupleDescCopy(tupType);
intoRelationId = heap_create_with_catalog(intoName, intoRelationId = heap_create_with_catalog(intoName,
tupdesc, RELKIND_RELATION); tupdesc, RELKIND_RELATION,parseTree->isTemp);
FreeTupleDesc(tupdesc); FreeTupleDesc(tupdesc);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* ExecInitTee * ExecInitTee
* ExecEndTee * ExecEndTee
* *
* $Id: nodeTee.c,v 1.28 1999/02/01 13:33:27 vadim Exp $ * $Id: nodeTee.c,v 1.29 1999/02/02 03:44:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -167,7 +167,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent) ...@@ -167,7 +167,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
else else
bufferRel = heap_open( bufferRel = heap_open(
heap_create_with_catalog(teeState->tee_bufferRelname, heap_create_with_catalog(teeState->tee_bufferRelname,
tupType, RELKIND_RELATION)); tupType, RELKIND_RELATION, false));
} }
else else
{ {
...@@ -176,7 +176,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent) ...@@ -176,7 +176,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent)
newoid()); newoid());
bufferRel = heap_open( bufferRel = heap_open(
heap_create_with_catalog(teeState->tee_bufferRelname, heap_create_with_catalog(teeState->tee_bufferRelname,
tupType, RELKIND_RELATION)); tupType, RELKIND_RELATION, false));
} }
teeState->tee_bufferRel = bufferRel; teeState->tee_bufferRel = bufferRel;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.56 1999/01/29 09:22:59 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.57 1999/02/02 03:44:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "utils/palloc.h" #include "utils/palloc.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "optimizer/planmain.h"
/* /*
* listCopy-- * listCopy--
...@@ -1572,6 +1573,7 @@ _copyQuery(Query *from) ...@@ -1572,6 +1573,7 @@ _copyQuery(Query *from)
newnode->into = pstrdup(from->into); newnode->into = pstrdup(from->into);
newnode->isPortal = from->isPortal; newnode->isPortal = from->isPortal;
newnode->isBinary = from->isBinary; newnode->isBinary = from->isBinary;
newnode->isTemp = from->isTemp;
newnode->unionall = from->unionall; newnode->unionall = from->unionall;
if (from->uniqueFlag) if (from->uniqueFlag)
newnode->uniqueFlag = pstrdup(from->uniqueFlag); newnode->uniqueFlag = pstrdup(from->uniqueFlag);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: outfuncs.c,v 1.61 1999/01/24 00:28:20 momjian Exp $ * $Id: outfuncs.c,v 1.62 1999/02/02 03:44:26 momjian Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -69,8 +69,13 @@ _outIntList(StringInfo str, List *list) ...@@ -69,8 +69,13 @@ _outIntList(StringInfo str, List *list)
static void static void
_outCreateStmt(StringInfo str, CreateStmt *node) _outCreateStmt(StringInfo str, CreateStmt *node)
{ {
appendStringInfo(str, " CREATE :relname %s :columns ", appendStringInfo(str, " CREATE :relname %s ",
stringStringInfo(node->relname)); stringStringInfo(node->relname));
appendStringInfo(str, " :istemp %s ",
node->istemp ? "true" : "false");
appendStringInfo(str, " :columns ");
_outNode(str, node->tableElts); _outNode(str, node->tableElts);
appendStringInfo(str, " :inhRelnames "); appendStringInfo(str, " :inhRelnames ");
...@@ -197,11 +202,12 @@ _outQuery(StringInfo str, Query *node) ...@@ -197,11 +202,12 @@ _outQuery(StringInfo str, Query *node)
} }
appendStringInfo(str, appendStringInfo(str,
" :resultRelation %d :into %s :isPortal %s :isBinary %s :unionall %s ", " :resultRelation %d :into %s :isPortal %s :isBinary %s :isTemp %s :unionall %s ",
node->resultRelation, node->resultRelation,
stringStringInfo(node->into), stringStringInfo(node->into),
node->isPortal ? "true" : "false", node->isPortal ? "true" : "false",
node->isBinary ? "true" : "false", node->isBinary ? "true" : "false",
node->isTemp ? "true" : "false",
node->unionall ? "true" : "false"); node->unionall ? "true" : "false");
appendStringInfo(str, " :unique %s :sortClause ", appendStringInfo(str, " :unique %s :sortClause ",
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.43 1999/01/24 00:28:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.44 1999/02/02 03:44:27 momjian Exp $
* *
* NOTES * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -120,6 +120,10 @@ _readQuery() ...@@ -120,6 +120,10 @@ _readQuery()
token = lsptok(NULL, &length); /* get isBinary */ token = lsptok(NULL, &length); /* get isBinary */
local_node->isBinary = (token[0] == 't') ? true : false; local_node->isBinary = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip :isTemp */
token = lsptok(NULL, &length); /* get isTemp */
local_node->isTemp = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip :unionall */ token = lsptok(NULL, &length); /* skip :unionall */
token = lsptok(NULL, &length); /* get unionall */ token = lsptok(NULL, &length); /* get unionall */
local_node->unionall = (token[0] == 't') ? true : false; local_node->unionall = (token[0] == 't') ? true : false;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: analyze.c,v 1.96 1999/01/27 01:18:20 scrappy Exp $ * $Id: analyze.c,v 1.97 1999/02/02 03:44:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -924,6 +924,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) ...@@ -924,6 +924,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
qry->uniqueFlag = stmt->unique; qry->uniqueFlag = stmt->unique;
qry->into = stmt->into; qry->into = stmt->into;
qry->isTemp = stmt->istemp;
qry->isPortal = FALSE; qry->isPortal = FALSE;
qry->targetList = transformTargetList(pstate, stmt->targetList); qry->targetList = transformTargetList(pstate, stmt->targetList);
...@@ -1032,6 +1033,7 @@ transformCursorStmt(ParseState *pstate, SelectStmt *stmt) ...@@ -1032,6 +1033,7 @@ transformCursorStmt(ParseState *pstate, SelectStmt *stmt)
qry = transformSelectStmt(pstate, stmt); qry = transformSelectStmt(pstate, stmt);
qry->into = stmt->portalname; qry->into = stmt->portalname;
qry->isTemp = stmt->istemp;
qry->isPortal = TRUE; qry->isPortal = TRUE;
qry->isBinary = stmt->binary; /* internal portal */ qry->isBinary = stmt->binary; /* internal portal */
...@@ -1074,7 +1076,7 @@ create_select_list(Node *ptr, List **select_list, bool *unionall_present) ...@@ -1074,7 +1076,7 @@ create_select_list(Node *ptr, List **select_list, bool *unionall_present)
* hands back 'true' */ * hands back 'true' */
Node *A_Expr_to_Expr(Node *ptr, bool *intersect_present) Node *A_Expr_to_Expr(Node *ptr, bool *intersect_present)
{ {
Node *result; Node *result = NULL;
switch(nodeTag(ptr)) switch(nodeTag(ptr))
{ {
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.49 1999/01/25 12:01:13 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.50 1999/02/02 03:44:42 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -154,13 +154,13 @@ Oid param_type(int t); /* used in parse_expr.c */ ...@@ -154,13 +154,13 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <str> opt_id, opt_portal_name, %type <str> opt_id, opt_portal_name,
all_Op, MathOp, opt_name, opt_unique, all_Op, MathOp, opt_name, opt_unique,
result, OptUseOp, opt_class, SpecialRuleRelation OptUseOp, opt_class, SpecialRuleRelation
%type <str> privileges, operation_commalist, grantee %type <str> privileges, operation_commalist, grantee
%type <chr> operation, TriggerOneEvent %type <chr> operation, TriggerOneEvent
%type <list> stmtblock, stmtmulti, %type <list> stmtblock, stmtmulti,
relation_name_list, OptTableElementList, result, relation_name_list, OptTableElementList,
OptInherit, definition, OptInherit, definition,
opt_with, func_args, func_args_list, opt_with, func_args, func_args_list,
oper_argtypes, OptStmtList, OptStmtBlock, OptStmtMulti, oper_argtypes, OptStmtList, OptStmtBlock, OptStmtMulti,
...@@ -173,7 +173,7 @@ Oid param_type(int t); /* used in parse_expr.c */ ...@@ -173,7 +173,7 @@ Oid param_type(int t); /* used in parse_expr.c */
%type <node> func_return %type <node> func_return
%type <boolean> set_opt %type <boolean> set_opt
%type <boolean> TriggerForOpt, TriggerForType %type <boolean> TriggerForOpt, TriggerForType, OptTemp
%type <list> for_update_clause %type <list> for_update_clause
%type <list> join_list %type <list> join_list
...@@ -283,7 +283,7 @@ Oid param_type(int t); /* used in parse_expr.c */ ...@@ -283,7 +283,7 @@ Oid param_type(int t); /* used in parse_expr.c */
PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC, PARTIAL, POSITION, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PUBLIC,
READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK, READ, REFERENCES, RELATIVE, REVOKE, RIGHT, ROLLBACK,
SCROLL, SECOND_P, SELECT, SET, SUBSTRING, SCROLL, SECOND_P, SELECT, SET, SUBSTRING,
TABLE, THEN, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE, TABLE, TEMP, THEN, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE,
TO, TRAILING, TRANSACTION, TRIM, TRUE_P, TO, TRAILING, TRANSACTION, TRIM, TRUE_P,
UNION, UNIQUE, UPDATE, USER, USING, UNION, UNIQUE, UPDATE, USER, USING,
VALUES, VARCHAR, VARYING, VIEW, VALUES, VARCHAR, VARYING, VIEW,
...@@ -747,18 +747,23 @@ copy_delimiter: USING DELIMITERS Sconst { $$ = $3; } ...@@ -747,18 +747,23 @@ copy_delimiter: USING DELIMITERS Sconst { $$ = $3; }
* *
*****************************************************************************/ *****************************************************************************/
CreateStmt: CREATE TABLE relation_name '(' OptTableElementList ')' CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')'
OptInherit OptInherit
{ {
CreateStmt *n = makeNode(CreateStmt); CreateStmt *n = makeNode(CreateStmt);
n->relname = $3; n->istemp = $2;
n->tableElts = $5; n->relname = $4;
n->inhRelnames = $7; n->tableElts = $6;
n->inhRelnames = $8;
n->constraints = NIL; n->constraints = NIL;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
OptTemp: TEMP { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
OptTableElementList: OptTableElementList ',' OptTableElement OptTableElementList: OptTableElementList ',' OptTableElement
{ {
if ($3 != NULL) if ($3 != NULL)
...@@ -1236,12 +1241,13 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; } ...@@ -1236,12 +1241,13 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
| /*EMPTY*/ { $$ = NIL; } | /*EMPTY*/ { $$ = NIL; }
; ;
CreateAsStmt: CREATE TABLE relation_name OptCreateAs AS SubSelect CreateAsStmt: CREATE OptTemp TABLE relation_name OptCreateAs AS SubSelect
{ {
SelectStmt *n = (SelectStmt *)$6; SelectStmt *n = (SelectStmt *)$7;
if ($4 != NIL) if ($5 != NIL)
mapTargetColumns($4, n->targetList); mapTargetColumns($5, n->targetList);
n->into = $3; n->istemp = $2;
n->into = $4;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -2862,8 +2868,9 @@ SubSelect: SELECT opt_unique res_target_list2 ...@@ -2862,8 +2868,9 @@ SubSelect: SELECT opt_unique res_target_list2
* want to create a new rule 'SubSelect1' including the * want to create a new rule 'SubSelect1' including the
* feature. If it makes troubles we will have to add * feature. If it makes troubles we will have to add
* a new rule and change this to prevent INTOs in * a new rule and change this to prevent INTOs in
* Subselects again */ * Subselects again */
n->into = $4; n->istemp = (bool)((A_Const *)lfirst($4))->val.val.ival;
n->into = (char *)lnext($4);
n->fromClause = $5; n->fromClause = $5;
n->whereClause = $6; n->whereClause = $6;
...@@ -2873,8 +2880,9 @@ SubSelect: SELECT opt_unique res_target_list2 ...@@ -2873,8 +2880,9 @@ SubSelect: SELECT opt_unique res_target_list2
} }
; ;
result: INTO opt_table relation_name { $$= $3; } /* easy way to return two values. Can someone improve this? bjm */
| /*EMPTY*/ { $$ = NULL; } result: INTO OptTemp opt_table relation_name { $$ = lcons(makeInteger($2), (List *)$4); }
| /*EMPTY*/ { $$ = lcons(makeInteger(false), NIL); }
; ;
opt_table: TABLE { $$ = TRUE; } opt_table: TABLE { $$ = TRUE; }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.51 1999/01/18 00:09:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.52 1999/02/02 03:44:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -213,6 +213,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -213,6 +213,7 @@ static ScanKeyword ScanKeywords[] = {
{"stdout", STDOUT}, {"stdout", STDOUT},
{"substring", SUBSTRING}, {"substring", SUBSTRING},
{"table", TABLE}, {"table", TABLE},
{"temp", TEMP},
{"then", THEN}, {"then", THEN},
{"time", TIME}, {"time", TIME},
{"timestamp", TIMESTAMP}, {"timestamp", TIMESTAMP},
......
...@@ -145,110 +145,111 @@ typedef union ...@@ -145,110 +145,111 @@ typedef union
#define SET 371 #define SET 371
#define SUBSTRING 372 #define SUBSTRING 372
#define TABLE 373 #define TABLE 373
#define THEN 374 #define TEMP 374
#define TIME 375 #define THEN 375
#define TIMESTAMP 376 #define TIME 376
#define TIMEZONE_HOUR 377 #define TIMESTAMP 377
#define TIMEZONE_MINUTE 378 #define TIMEZONE_HOUR 378
#define TO 379 #define TIMEZONE_MINUTE 379
#define TRAILING 380 #define TO 380
#define TRANSACTION 381 #define TRAILING 381
#define TRIM 382 #define TRANSACTION 382
#define TRUE_P 383 #define TRIM 383
#define UNION 384 #define TRUE_P 384
#define UNIQUE 385 #define UNION 385
#define UPDATE 386 #define UNIQUE 386
#define USER 387 #define UPDATE 387
#define USING 388 #define USER 388
#define VALUES 389 #define USING 389
#define VARCHAR 390 #define VALUES 390
#define VARYING 391 #define VARCHAR 391
#define VIEW 392 #define VARYING 392
#define WHEN 393 #define VIEW 393
#define WHERE 394 #define WHEN 394
#define WITH 395 #define WHERE 395
#define WORK 396 #define WITH 396
#define YEAR_P 397 #define WORK 397
#define ZONE 398 #define YEAR_P 398
#define TRIGGER 399 #define ZONE 399
#define TYPE_P 400 #define TRIGGER 400
#define ABORT_TRANS 401 #define TYPE_P 401
#define AFTER 402 #define ABORT_TRANS 402
#define AGGREGATE 403 #define AFTER 403
#define ANALYZE 404 #define AGGREGATE 404
#define BACKWARD 405 #define ANALYZE 405
#define BEFORE 406 #define BACKWARD 406
#define BINARY 407 #define BEFORE 407
#define CACHE 408 #define BINARY 408
#define CLUSTER 409 #define CACHE 409
#define COPY 410 #define CLUSTER 410
#define CREATEDB 411 #define COPY 411
#define CREATEUSER 412 #define CREATEDB 412
#define CYCLE 413 #define CREATEUSER 413
#define DATABASE 414 #define CYCLE 414
#define DELIMITERS 415 #define DATABASE 415
#define DO 416 #define DELIMITERS 416
#define EACH 417 #define DO 417
#define ENCODING 418 #define EACH 418
#define EXPLAIN 419 #define ENCODING 419
#define EXTEND 420 #define EXPLAIN 420
#define FORWARD 421 #define EXTEND 421
#define FUNCTION 422 #define FORWARD 422
#define HANDLER 423 #define FUNCTION 423
#define INCREMENT 424 #define HANDLER 424
#define INDEX 425 #define INCREMENT 425
#define INHERITS 426 #define INDEX 426
#define INSTEAD 427 #define INHERITS 427
#define ISNULL 428 #define INSTEAD 428
#define LANCOMPILER 429 #define ISNULL 429
#define LISTEN 430 #define LANCOMPILER 430
#define LOAD 431 #define LISTEN 431
#define LOCATION 432 #define LOAD 432
#define LOCK_P 433 #define LOCATION 433
#define MAXVALUE 434 #define LOCK_P 434
#define MINVALUE 435 #define MAXVALUE 435
#define MOVE 436 #define MINVALUE 436
#define NEW 437 #define MOVE 437
#define NOCREATEDB 438 #define NEW 438
#define NOCREATEUSER 439 #define NOCREATEDB 439
#define NONE 440 #define NOCREATEUSER 440
#define NOTHING 441 #define NONE 441
#define NOTIFY 442 #define NOTHING 442
#define NOTNULL 443 #define NOTIFY 443
#define OIDS 444 #define NOTNULL 444
#define OPERATOR 445 #define OIDS 445
#define PASSWORD 446 #define OPERATOR 446
#define PROCEDURAL 447 #define PASSWORD 447
#define RECIPE 448 #define PROCEDURAL 448
#define RENAME 449 #define RECIPE 449
#define RESET 450 #define RENAME 450
#define RETURNS 451 #define RESET 451
#define ROW 452 #define RETURNS 452
#define RULE 453 #define ROW 453
#define SEQUENCE 454 #define RULE 454
#define SERIAL 455 #define SEQUENCE 455
#define SETOF 456 #define SERIAL 456
#define SHOW 457 #define SETOF 457
#define START 458 #define SHOW 458
#define STATEMENT 459 #define START 459
#define STDIN 460 #define STATEMENT 460
#define STDOUT 461 #define STDIN 461
#define TRUSTED 462 #define STDOUT 462
#define UNLISTEN 463 #define TRUSTED 463
#define UNTIL 464 #define UNLISTEN 464
#define VACUUM 465 #define UNTIL 465
#define VALID 466 #define VACUUM 466
#define VERBOSE 467 #define VALID 467
#define VERSION 468 #define VERBOSE 468
#define IDENT 469 #define VERSION 469
#define SCONST 470 #define IDENT 470
#define Op 471 #define SCONST 471
#define ICONST 472 #define Op 472
#define PARAM 473 #define ICONST 473
#define FCONST 474 #define PARAM 474
#define OP 475 #define FCONST 475
#define UMINUS 476 #define OP 476
#define TYPECAST 477 #define UMINUS 477
#define TYPECAST 478
extern YYSTYPE yylval; extern YYSTYPE yylval;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.32 1999/01/25 18:02:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.33 1999/02/02 03:44:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1135,6 +1135,7 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree) ...@@ -1135,6 +1135,7 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree)
subquery->into = NULL; subquery->into = NULL;
subquery->isPortal = FALSE; subquery->isPortal = FALSE;
subquery->isBinary = FALSE; subquery->isBinary = FALSE;
subquery->isTemp = FALSE;
subquery->unionall = FALSE; subquery->unionall = FALSE;
subquery->uniqueFlag = NULL; subquery->uniqueFlag = NULL;
subquery->sortClause = NULL; subquery->sortClause = NULL;
...@@ -2767,7 +2768,7 @@ Except_Intersect_Rewrite (Query *parsetree) ...@@ -2767,7 +2768,7 @@ Except_Intersect_Rewrite (Query *parsetree)
List *union_list = NIL, *sortClause; List *union_list = NIL, *sortClause;
List *left_expr, *right_expr, *resnames = NIL; List *left_expr, *right_expr, *resnames = NIL;
char *op, *uniqueFlag, *into; char *op, *uniqueFlag, *into;
bool isBinary, isPortal; bool isBinary, isPortal, isTemp;
CmdType commandType = CMD_SELECT; CmdType commandType = CMD_SELECT;
List *rtable_insert = NIL; List *rtable_insert = NIL;
...@@ -2811,7 +2812,8 @@ Except_Intersect_Rewrite (Query *parsetree) ...@@ -2811,7 +2812,8 @@ Except_Intersect_Rewrite (Query *parsetree)
into = parsetree->into; into = parsetree->into;
isBinary = parsetree->isBinary; isBinary = parsetree->isBinary;
isPortal = parsetree->isPortal; isPortal = parsetree->isPortal;
isTemp = parsetree->isTemp;
/* The operator tree attached to parsetree->intersectClause is still 'raw' /* The operator tree attached to parsetree->intersectClause is still 'raw'
* ( = the leaf nodes are still SelectStmt nodes instead of Query nodes) * ( = the leaf nodes are still SelectStmt nodes instead of Query nodes)
* So step through the tree and transform the nodes using parse_analyze(). * So step through the tree and transform the nodes using parse_analyze().
...@@ -2959,6 +2961,8 @@ Except_Intersect_Rewrite (Query *parsetree) ...@@ -2959,6 +2961,8 @@ Except_Intersect_Rewrite (Query *parsetree)
result->into = into; result->into = into;
result->isPortal = isPortal; result->isPortal = isPortal;
result->isBinary = isBinary; result->isBinary = isBinary;
result->isTemp = isTemp;
/* The relation to insert into is attached to the range table /* The relation to insert into is attached to the range table
* of the new top node */ * of the new top node */
if (commandType == CMD_INSERT) if (commandType == CMD_INSERT)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.45 1998/12/15 12:46:19 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.46 1999/02/02 03:44:46 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -231,7 +231,7 @@ ReadBufferWithBufferLock(Relation reln, ...@@ -231,7 +231,7 @@ ReadBufferWithBufferLock(Relation reln,
bool isLocalBuf; bool isLocalBuf;
extend = (blockNum == P_NEW); extend = (blockNum == P_NEW);
isLocalBuf = reln->rd_islocal; isLocalBuf = reln->rd_myxactonly;
if (isLocalBuf) if (isLocalBuf)
{ {
...@@ -1374,7 +1374,7 @@ BlockNumber ...@@ -1374,7 +1374,7 @@ BlockNumber
RelationGetNumberOfBlocks(Relation relation) RelationGetNumberOfBlocks(Relation relation)
{ {
return return
((relation->rd_islocal) ? relation->rd_nblocks : ((relation->rd_myxactonly) ? relation->rd_nblocks :
smgrnblocks(DEFAULT_SMGR, relation)); smgrnblocks(DEFAULT_SMGR, relation));
} }
...@@ -1395,7 +1395,7 @@ ReleaseRelationBuffers(Relation rel) ...@@ -1395,7 +1395,7 @@ ReleaseRelationBuffers(Relation rel)
int holding = 0; int holding = 0;
BufferDesc *buf; BufferDesc *buf;
if (rel->rd_islocal) if (rel->rd_myxactonly)
{ {
for (i = 0; i < NLocBuffer; i++) for (i = 0; i < NLocBuffer; i++)
{ {
...@@ -1564,7 +1564,7 @@ BlowawayRelationBuffers(Relation rel, BlockNumber block) ...@@ -1564,7 +1564,7 @@ BlowawayRelationBuffers(Relation rel, BlockNumber block)
int i; int i;
BufferDesc *buf; BufferDesc *buf;
if (rel->rd_islocal) if (rel->rd_myxactonly)
{ {
for (i = 0; i < NLocBuffer; i++) for (i = 0; i < NLocBuffer; i++)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.45 1999/01/21 22:48:09 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.46 1999/02/02 03:44:50 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "utils/builtins.h" /* for namestrcpy() */ #include "utils/builtins.h" /* for namestrcpy() */
#include "utils/rel.h" #include "utils/rel.h"
#include "utils/relcache.h" #include "utils/relcache.h"
#include "utils/syscache.h"
/* /*
* Warning, Will Robinson... In order to pack data into an inversion * Warning, Will Robinson... In order to pack data into an inversion
...@@ -120,20 +119,16 @@ inv_create(int flags) ...@@ -120,20 +119,16 @@ inv_create(int flags)
sprintf(objname, "xinv%d", file_oid); sprintf(objname, "xinv%d", file_oid);
sprintf(indname, "xinx%d", file_oid); sprintf(indname, "xinx%d", file_oid);
if (SearchSysCacheTuple(RELNAME, if (RelnameFindRelid(objname) != InvalidOid)
PointerGetDatum(objname),
0, 0, 0) != NULL)
{ {
elog(ERROR, elog(ERROR,
"internal error: %s already exists -- cannot create large obj", "internal error: %s already exists -- cannot create large obj",
objname); objname);
} }
if (SearchSysCacheTuple(RELNAME, if (RelnameFindRelid(indname) != InvalidOid)
PointerGetDatum(indname),
0, 0, 0) != NULL)
{ {
elog(ERROR, elog(ERROR,
"internal error: %s already exists -- cannot create large obj", "internal error: %s already exists -- cannot create large obj",
indname); indname);
} }
...@@ -153,7 +148,7 @@ inv_create(int flags) ...@@ -153,7 +148,7 @@ inv_create(int flags)
* be located on whatever storage manager the user requested. * be located on whatever storage manager the user requested.
*/ */
heap_create_with_catalog(objname, tupdesc, RELKIND_LOBJECT); heap_create_with_catalog(objname, tupdesc, RELKIND_LOBJECT, false);
/* make the relation visible in this transaction */ /* make the relation visible in this transaction */
CommandCounterIncrement(); CommandCounterIncrement();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.97 1999/01/18 00:09:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.98 1999/02/02 03:44:51 momjian Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#include "utils/mcxt.h" #include "utils/mcxt.h"
#include "utils/rel.h" #include "utils/rel.h"
#include "utils/ps_status.h" #include "utils/ps_status.h"
#include "utils/temprel.h"
#if FALSE #if FALSE
#include "nodes/relation.h" #include "nodes/relation.h"
...@@ -1502,6 +1503,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1502,6 +1503,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!TransactionFlushEnabled()) if (!TransactionFlushEnabled())
on_shmem_exit(FlushBufferPool, NULL); on_shmem_exit(FlushBufferPool, NULL);
on_shmem_exit(remove_all_temp_relations, NULL);
/* ---------------- /* ----------------
* Set up handler for cancel-request signal, and * Set up handler for cancel-request signal, and
* send this backend's cancellation info to the frontend. * send this backend's cancellation info to the frontend.
...@@ -1535,7 +1538,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) ...@@ -1535,7 +1538,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.97 $ $Date: 1999/01/18 00:09:56 $\n"); puts("$Revision: 1.98 $ $Date: 1999/02/02 03:44:51 $\n");
} }
/* ---------------- /* ----------------
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for utils/cache # Makefile for utils/cache
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.9 1998/08/24 01:13:52 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.10 1999/02/02 03:44:54 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -13,7 +13,8 @@ include ../../../Makefile.global ...@@ -13,7 +13,8 @@ include ../../../Makefile.global
CFLAGS += -I../.. CFLAGS += -I../..
OBJS = catcache.o inval.o rel.o relcache.o syscache.o lsyscache.o fcache.o OBJS = catcache.o inval.o rel.o relcache.o syscache.o lsyscache.o \
fcache.o temprel.o
all: SUBSYS.o all: SUBSYS.o
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.36 1998/11/27 19:52:26 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.37 1999/02/02 03:44:58 momjian Exp $
* *
* Notes: * Notes:
* XXX This needs to use exception.h to handle recovery when * XXX This needs to use exception.h to handle recovery when
...@@ -196,7 +196,6 @@ CatalogCacheInitializeCache(struct catcache * cache, ...@@ -196,7 +196,6 @@ CatalogCacheInitializeCache(struct catcache * cache,
if (cache->cc_key[i] > 0) if (cache->cc_key[i] > 0)
{ {
/* /*
* Yoiks. The implementation of the hashing code and the * Yoiks. The implementation of the hashing code and the
* implementation of int28's are at loggerheads. The right * implementation of int28's are at loggerheads. The right
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.18 1998/11/27 19:52:28 vadim Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.19 1999/02/02 03:45:01 momjian Exp $
* *
* Note - this code is real crufty... * Note - this code is real crufty...
* *
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "access/heapam.h" /* XXX to support hacks below */ #include "access/heapam.h" /* XXX to support hacks below */
#include "access/htup.h" #include "access/htup.h"
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "catalog/heap.h"
#include "storage/bufpage.h" #include "storage/bufpage.h"
#include "storage/buf.h" /* XXX for InvalidBuffer */ #include "storage/buf.h" /* XXX for InvalidBuffer */
#include "storage/ipc.h" #include "storage/ipc.h"
...@@ -244,31 +245,17 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId) ...@@ -244,31 +245,17 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId)
static void static void
getmyrelids() getmyrelids()
{ {
HeapTuple tuple; MyRelationRelationId = RelnameFindRelid(RelationRelationName);
Assert(RelationRelationName != InvalidOid);
tuple = SearchSysCacheTuple(RELNAME, MyAttributeRelationId = RelnameFindRelid(AttributeRelationName);
PointerGetDatum(RelationRelationName), Assert(AttributeRelationName != InvalidOid);
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyRelationRelationId = tuple->t_data->t_oid;
tuple = SearchSysCacheTuple(RELNAME, MyAMRelationId = RelnameFindRelid(AccessMethodRelationName);
PointerGetDatum(AttributeRelationName), Assert(MyAMRelationId != InvalidOid);
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyAttributeRelationId = tuple->t_data->t_oid;
tuple = SearchSysCacheTuple(RELNAME, MyAMOPRelationId = RelnameFindRelid(AccessMethodOperatorRelationName);
PointerGetDatum(AccessMethodRelationName), Assert(MyAMOPRelationId != InvalidOid);
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyAMRelationId = tuple->t_data->t_oid;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(AccessMethodOperatorRelationName),
0, 0, 0);
Assert(HeapTupleIsValid(tuple));
MyAMOPRelationId = tuple->t_data->t_oid;
} }
/* -------------------------------- /* --------------------------------
...@@ -614,10 +601,6 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple) ...@@ -614,10 +601,6 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)
*/ */
RelationInvalidateHeapTuple_DEBUG1; RelationInvalidateHeapTuple_DEBUG1;
/* ----------------
*
* ----------------
*/
RelationInvalidateCatalogCacheTuple(relation, RelationInvalidateCatalogCacheTuple(relation,
tuple, tuple,
CacheIdRegisterLocalInvalid); CacheIdRegisterLocalInvalid);
...@@ -625,12 +608,4 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple) ...@@ -625,12 +608,4 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)
RelationInvalidateRelationCache(relation, RelationInvalidateRelationCache(relation,
tuple, tuple,
RelationIdRegisterLocalInvalid); RelationIdRegisterLocalInvalid);
#ifdef NOT_USED
if (RefreshWhenInvalidate)
/* what does this do? bjm 1998/08/20 */
RelationInvalidateCatalogCacheTuple(relation,
tuple,
(void (*) ()) NULL);
#endif
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.55 1999/01/22 18:47:37 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.56 1999/02/02 03:45:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -404,7 +404,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) ...@@ -404,7 +404,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo)
switch (buildinfo.infotype) switch (buildinfo.infotype)
{ {
case INFO_RELID: case INFO_RELID:
return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id); return_tuple = ClassOidIndexScan(pg_class_desc,buildinfo.i.info_id);
break; break;
case INFO_RELNAME: case INFO_RELNAME:
...@@ -821,7 +821,6 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo) ...@@ -821,7 +821,6 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
*/ */
if (!HeapTupleIsValid(pg_class_tuple)) if (!HeapTupleIsValid(pg_class_tuple))
{ {
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
return NULL; return NULL;
...@@ -867,8 +866,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo) ...@@ -867,8 +866,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
*/ */
if (OidIsValid(relam)) if (OidIsValid(relam))
{ {
relation->rd_am = (Form_pg_am) relation->rd_am = (Form_pg_am) AccessMethodObjectIdGetForm(relam);
AccessMethodObjectIdGetForm(relam);
} }
/* ---------------- /* ----------------
...@@ -927,7 +925,6 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo) ...@@ -927,7 +925,6 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
* restore memory context and return the new reldesc. * restore memory context and return the new reldesc.
* ---------------- * ----------------
*/ */
RelationCacheInsert(relation); RelationCacheInsert(relation);
/* ------------------- /* -------------------
...@@ -1197,8 +1194,7 @@ RelationIdGetRelation(Oid relationId) ...@@ -1197,8 +1194,7 @@ RelationIdGetRelation(Oid relationId)
buildinfo.i.info_id = relationId; buildinfo.i.info_id = relationId;
rd = RelationBuildDesc(buildinfo); rd = RelationBuildDesc(buildinfo);
return return rd;
rd;
} }
/* -------------------------------- /* --------------------------------
...@@ -1332,8 +1328,9 @@ RelationFlushRelation(Relation *relationPtr, ...@@ -1332,8 +1328,9 @@ RelationFlushRelation(Relation *relationPtr,
/* -------------------------------- /* --------------------------------
* RelationForgetRelation - * RelationForgetRelation -
* RelationFlushRelation + if the relation is local then get rid of * RelationFlushRelation + if the relation is myxactonly then
* the relation descriptor from the newly created relation list. * get rid of the relation descriptor from the newly created
* relation list.
* -------------------------------- * --------------------------------
*/ */
void void
...@@ -1342,37 +1339,39 @@ RelationForgetRelation(Oid rid) ...@@ -1342,37 +1339,39 @@ RelationForgetRelation(Oid rid)
Relation relation; Relation relation;
RelationIdCacheLookup(rid, relation); RelationIdCacheLookup(rid, relation);
Assert(PointerIsValid(relation));
if (relation->rd_islocal) if (PointerIsValid(relation))
{ {
MemoryContext oldcxt; if (relation->rd_myxactonly)
List *curr;
List *prev = NIL;
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
foreach(curr, newlyCreatedRelns)
{ {
Relation reln = lfirst(curr); MemoryContext oldcxt;
List *curr;
Assert(reln != NULL && reln->rd_islocal); List *prev = NIL;
if (RelationGetRelid(reln) == rid)
break; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
prev = curr;
foreach(curr, newlyCreatedRelns)
{
Relation reln = lfirst(curr);
Assert(reln != NULL && reln->rd_myxactonly);
if (RelationGetRelid(reln) == rid)
break;
prev = curr;
}
if (curr == NIL)
elog(FATAL, "Local relation %s not found in list",
(RelationGetRelationName(relation))->data);
if (prev == NIL)
newlyCreatedRelns = lnext(newlyCreatedRelns);
else
lnext(prev) = lnext(curr);
pfree(curr);
MemoryContextSwitchTo(oldcxt);
} }
if (curr == NIL)
elog(FATAL, "Local relation %s not found in list", RelationFlushRelation(&relation, false);
(RelationGetRelationName(relation))->data);
if (prev == NIL)
newlyCreatedRelns = lnext(newlyCreatedRelns);
else
lnext(prev) = lnext(curr);
pfree(curr);
MemoryContextSwitchTo(oldcxt);
} }
RelationFlushRelation(&relation, false);
} }
/* -------------------------------- /* --------------------------------
...@@ -1393,9 +1392,8 @@ RelationIdInvalidateRelationCacheByRelationId(Oid relationId) ...@@ -1393,9 +1392,8 @@ RelationIdInvalidateRelationCacheByRelationId(Oid relationId)
* BufferSync also? But I'll leave it for now since I don't want to * BufferSync also? But I'll leave it for now since I don't want to
* break anything.) - ay 3/95 * break anything.) - ay 3/95
*/ */
if (PointerIsValid(relation) && !relation->rd_islocal) if (PointerIsValid(relation) && !relation->rd_myxactonly)
{ {
/* /*
* The boolean onlyFlushReferenceCountZero in RelationFlushReln() * The boolean onlyFlushReferenceCountZero in RelationFlushReln()
* should be set to true when we are incrementing the command * should be set to true when we are incrementing the command
...@@ -1502,13 +1500,13 @@ RelationRegisterRelation(Relation relation) ...@@ -1502,13 +1500,13 @@ RelationRegisterRelation(Relation relation)
/* /*
* we've just created the relation. It is invisible to anyone else * we've just created the relation. It is invisible to anyone else
* before the transaction is committed. Setting rd_islocal allows us * before the transaction is committed. Setting rd_myxactonly allows us
* to use the local buffer manager for select/insert/etc before the * to use the local buffer manager for select/insert/etc before the
* end of transaction. (We also need to keep track of relations * end of transaction. (We also need to keep track of relations
* created during a transaction and does the necessary clean up at the * created during a transaction and does the necessary clean up at the
* end of the transaction.) - ay 3/95 * end of the transaction.) - ay 3/95
*/ */
relation->rd_islocal = TRUE; relation->rd_myxactonly = TRUE;
newlyCreatedRelns = lcons(relation, newlyCreatedRelns); newlyCreatedRelns = lcons(relation, newlyCreatedRelns);
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
...@@ -1516,7 +1514,7 @@ RelationRegisterRelation(Relation relation) ...@@ -1516,7 +1514,7 @@ RelationRegisterRelation(Relation relation)
/* /*
* RelationPurgeLocalRelation - * RelationPurgeLocalRelation -
* find all the Relation descriptors marked rd_islocal and reset them. * find all the Relation descriptors marked rd_myxactonly and reset them.
* This should be called at the end of a transaction (commit/abort) when * This should be called at the end of a transaction (commit/abort) when
* the "local" relations will become visible to others and the multi-user * the "local" relations will become visible to others and the multi-user
* buffer pool should be used. * buffer pool should be used.
...@@ -1536,7 +1534,7 @@ RelationPurgeLocalRelation(bool xactCommitted) ...@@ -1536,7 +1534,7 @@ RelationPurgeLocalRelation(bool xactCommitted)
List *l = newlyCreatedRelns; List *l = newlyCreatedRelns;
Relation reln = lfirst(l); Relation reln = lfirst(l);
Assert(reln != NULL && reln->rd_islocal); Assert(reln != NULL && reln->rd_myxactonly);
if (!xactCommitted) if (!xactCommitted)
{ {
...@@ -1545,18 +1543,18 @@ RelationPurgeLocalRelation(bool xactCommitted) ...@@ -1545,18 +1543,18 @@ RelationPurgeLocalRelation(bool xactCommitted)
* remove the file if we abort. This is so that files for * remove the file if we abort. This is so that files for
* tables created inside a transaction block get removed. * tables created inside a transaction block get removed.
*/ */
if (reln->rd_istemp) if (reln->rd_isnoname)
{ {
if (!(reln->rd_tmpunlinked)) if (!(reln->rd_nonameunlinked))
{ {
smgrunlink(DEFAULT_SMGR, reln); smgrunlink(DEFAULT_SMGR, reln);
reln->rd_tmpunlinked = TRUE; reln->rd_nonameunlinked = TRUE;
} }
} }
else else
smgrunlink(DEFAULT_SMGR, reln); smgrunlink(DEFAULT_SMGR, reln);
} }
else if (!IsBootstrapProcessingMode() && !(reln->rd_istemp)) else if (!IsBootstrapProcessingMode() && !(reln->rd_isnoname))
/* /*
* RelationFlushRelation () below will flush relation * RelationFlushRelation () below will flush relation
...@@ -1568,7 +1566,7 @@ RelationPurgeLocalRelation(bool xactCommitted) ...@@ -1568,7 +1566,7 @@ RelationPurgeLocalRelation(bool xactCommitted)
*/ */
smgrclose(DEFAULT_SMGR, reln); smgrclose(DEFAULT_SMGR, reln);
reln->rd_islocal = FALSE; reln->rd_myxactonly = FALSE;
if (!IsBootstrapProcessingMode()) if (!IsBootstrapProcessingMode())
RelationFlushRelation(&reln, FALSE); RelationFlushRelation(&reln, FALSE);
......
/*-------------------------------------------------------------------------
*
* temprel.c--
* POSTGRES temporary relation handling
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.1 1999/02/02 03:45:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/*
* This implements temp tables by modifying the relname cache lookups
* of pg_class.
* When a temp table is created, a linked list of temp table tuples is
* stored here. When a relname cache lookup is done, references to user-named
* temp tables are converted to the internal temp table names.
*
*/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include "postgres.h"
#include "miscadmin.h"
#include "nodes/pg_list.h"
#include "utils/mcxt.h"
#include "utils/temprel.h"
#include "access/htup.h"
#include "access/heapam.h"
#include "catalog/heap.h"
#include "catalog/index.h"
#include "catalog/pg_class.h"
GlobalMemory CacheCxt;
/* ----------------
* global variables
* ----------------
*/
static List *temp_rels = NIL;
typedef struct TempTable
{
char *user_relname;
HeapTuple pg_class_tuple;
} TempTable;
void
create_temp_relation(char *relname, HeapTuple pg_class_tuple)
{
MemoryContext oldcxt;
TempTable *temp_rel;
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
temp_rel = palloc(sizeof(TempTable));
temp_rel->user_relname = palloc(NAMEDATALEN);
/* save user-supplied name */
strcpy(temp_rel->user_relname, relname);
temp_rel->pg_class_tuple = heap_copytuple(pg_class_tuple);
temp_rels = lcons(temp_rel, temp_rels);
MemoryContextSwitchTo(oldcxt);
}
void
remove_all_temp_relations(void)
{
List *l, *next;
l = temp_rels;
while (l != NIL)
{
TempTable *temp_rel = lfirst(l);
Form_pg_class classtuple;
classtuple = (Form_pg_class)GETSTRUCT(temp_rel->pg_class_tuple);
next = lnext(l); /* do this first, l is deallocated */
if (classtuple->relkind != RELKIND_INDEX)
{
char relname[NAMEDATALEN];
/* safe from deallocation */
strcpy(relname, temp_rel->user_relname);
heap_destroy_with_catalog(relname);
}
else
index_destroy(temp_rel->pg_class_tuple->t_data->t_oid);
l = next;
}
}
/* we don't have the relname for indexes, so we just pass the oid */
void
remove_temp_relation(Oid relid)
{
MemoryContext oldcxt;
List *l, *prev;
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
prev = NIL;
l = temp_rels;
while (l != NIL)
{
TempTable *temp_rel = lfirst(l);
if (temp_rel->pg_class_tuple->t_data->t_oid == relid)
{
pfree(temp_rel->user_relname);
pfree(temp_rel->pg_class_tuple);
pfree(temp_rel);
/* remove from linked list */
if (prev != NIL)
{
lnext(prev) = lnext(l);
pfree(l);
l = lnext(prev);
}
else
{
temp_rels = lnext(l);
pfree(l);
l = temp_rels;
}
}
else
{
prev = l;
l = lnext(l);
}
}
MemoryContextSwitchTo(oldcxt);
}
HeapTuple
get_temp_rel_by_name(char *user_relname)
{
List *l;
foreach(l, temp_rels)
{
TempTable *temp_rel = lfirst(l);
if (strcmp(temp_rel->user_relname, user_relname) == 0)
return temp_rel->pg_class_tuple;
}
return NULL;
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/enbl.c,v 1.4 1998/09/01 03:26:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/enbl.c,v 1.5 1999/02/02 03:45:04 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,7 +38,7 @@ BypassEnable(int *enableCountInOutP, bool on) ...@@ -38,7 +38,7 @@ BypassEnable(int *enableCountInOutP, bool on)
return (bool) (*enableCountInOutP >= 2); return (bool) (*enableCountInOutP >= 2);
} }
AssertState(*enableCountInOutP >= 1); Assert(*enableCountInOutP >= 1);
*enableCountInOutP -= 1; *enableCountInOutP -= 1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: psort.c,v 1.47 1999/01/17 06:19:02 momjian Exp $ * $Id: psort.c,v 1.48 1999/02/02 03:45:12 momjian Exp $
* *
* NOTES * NOTES
* Sorts the first relation into the second relation. * Sorts the first relation into the second relation.
...@@ -1019,9 +1019,8 @@ gettape() ...@@ -1019,9 +1019,8 @@ gettape()
tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst)); tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst));
snprintf(uniqueName, MAXPGPATH - 1, "%spg_psort.%d.%d", snprintf(uniqueName, MAXPGPATH - 1, "%spg_psort.%d.%u",
TEMPDIR, (int) MyProcPid, uniqueFileId); TEMPDIR, (int) MyProcPid, uniqueFileId++);
uniqueFileId++;
tapeinit = 1; tapeinit = 1;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: psqlHelp.h,v 1.54 1998/10/14 05:10:02 momjian Exp $ * $Id: psqlHelp.h,v 1.55 1999/02/02 03:45:15 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -124,7 +124,7 @@ static struct _helpStruct QL_HELP[] = { ...@@ -124,7 +124,7 @@ static struct _helpStruct QL_HELP[] = {
{"create table", {"create table",
"create a new table", "create a new table",
"\ "\
\tCREATE TABLE class_name\n\ \tCREATE [TEMP] TABLE class_name\n\
\t(attr1 type1 [DEFAULT expression] [NOT NULL], ...attrN)\n\ \t(attr1 type1 [DEFAULT expression] [NOT NULL], ...attrN)\n\
\t[INHERITS (class_name1, ...class_nameN)\n\ \t[INHERITS (class_name1, ...class_nameN)\n\
\t[[CONSTRAINT name] CHECK condition1, ...conditionN] ]\n\ \t[[CONSTRAINT name] CHECK condition1, ...conditionN] ]\n\
...@@ -315,7 +315,7 @@ static struct _helpStruct QL_HELP[] = { ...@@ -315,7 +315,7 @@ static struct _helpStruct QL_HELP[] = {
"retrieve tuples", "retrieve tuples",
"\ "\
\tSELECT [DISTINCT [ON attrN]] expr1 [AS attr1], ...exprN\n\ \tSELECT [DISTINCT [ON attrN]] expr1 [AS attr1], ...exprN\n\
\t[INTO [TABLE] class_name]\n\ \t[INTO [TEMP] [TABLE] class_name]\n\
\t[FROM from_list]\n\ \t[FROM from_list]\n\
\t[WHERE qual]\n\ \t[WHERE qual]\n\
\t[GROUP BY group_list]\n\ \t[GROUP BY group_list]\n\
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: heap.h,v 1.16 1998/09/01 04:34:41 momjian Exp $ * $Id: heap.h,v 1.17 1999/02/02 03:45:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -15,15 +15,17 @@ ...@@ -15,15 +15,17 @@
#include <utils/rel.h> #include <utils/rel.h>
extern Relation heap_create(char *relname, TupleDesc att); extern Oid RelnameFindRelid(char *relname);
extern Relation heap_create(char *relname, TupleDesc att,
bool isnoname, bool istemp);
extern Oid heap_create_with_catalog(char *relname, extern Oid heap_create_with_catalog(char *relname,
TupleDesc tupdesc, char relkind); TupleDesc tupdesc, char relkind, bool istemp);
extern void heap_destroy_with_catalog(char *relname); extern void heap_destroy_with_catalog(char *relname);
extern void heap_destroy(Relation rel); extern void heap_destroy(Relation rel);
extern void InitTempRelList(void); extern void InitNoNameRelList(void);
extern void DestroyTempRels(void); extern void DestroyNoNameRels(void);
#endif /* HEAP_H */ #endif /* HEAP_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: parsenodes.h,v 1.68 1999/01/21 22:48:20 momjian Exp $ * $Id: parsenodes.h,v 1.69 1999/02/02 03:45:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -43,6 +43,7 @@ typedef struct Query ...@@ -43,6 +43,7 @@ typedef struct Query
char *into; /* portal (cursor) name */ char *into; /* portal (cursor) name */
bool isPortal; /* is this a retrieve into portal? */ bool isPortal; /* is this a retrieve into portal? */
bool isBinary; /* binary portal? */ bool isBinary; /* binary portal? */
bool isTemp; /* is 'into' a temp table? */
bool unionall; /* union without unique sort */ bool unionall; /* union without unique sort */
bool hasAggs; /* has aggregates in target list */ bool hasAggs; /* has aggregates in target list */
bool hasSubLinks; /* has subquery SubLink */ bool hasSubLinks; /* has subquery SubLink */
...@@ -138,6 +139,7 @@ typedef struct CopyStmt ...@@ -138,6 +139,7 @@ typedef struct CopyStmt
typedef struct CreateStmt typedef struct CreateStmt
{ {
NodeTag type; NodeTag type;
bool istemp; /* is this a temp table? */
char *relname; /* the relation to create */ char *relname; /* the relation to create */
List *tableElts; /* column definitions list of Column */ List *tableElts; /* column definitions list of Column */
List *inhRelnames; /* relations to inherit from list of Value List *inhRelnames; /* relations to inherit from list of Value
...@@ -662,6 +664,7 @@ typedef struct SelectStmt ...@@ -662,6 +664,7 @@ typedef struct SelectStmt
List *sortClause; /* sort clause (a list of SortGroupBy's) */ List *sortClause; /* sort clause (a list of SortGroupBy's) */
char *portalname; /* the portal (cursor) to create */ char *portalname; /* the portal (cursor) to create */
bool binary; /* a binary (internal) portal? */ bool binary; /* a binary (internal) portal? */
bool istemp; /* into is a temp table */
bool unionall; /* union without unique sort */ bool unionall; /* union without unique sort */
Node *limitOffset; /* # of result tuples to skip */ Node *limitOffset; /* # of result tuples to skip */
Node *limitCount; /* # of result tuples to return */ Node *limitCount; /* # of result tuples to return */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: internal.h,v 1.11 1998/09/01 04:37:08 momjian Exp $ * $Id: internal.h,v 1.12 1999/02/02 03:45:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -86,6 +86,6 @@ extern int BushyPlanFlag; ...@@ -86,6 +86,6 @@ extern int BushyPlanFlag;
/*#define joininfo_inactive(joininfo) joininfo->inactive */ /*#define joininfo_inactive(joininfo) joininfo->inactive */
/* GEQO switch according to number of relations in a query */ /* GEQO switch according to number of relations in a query */
#define GEQO_RELS 8 #define GEQO_RELS 6
#endif /* INTERNAL_H */ #endif /* INTERNAL_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: rel.h,v 1.20 1998/09/01 04:39:29 momjian Exp $ * $Id: rel.h,v 1.21 1999/02/02 03:45:28 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,10 +49,10 @@ typedef struct RelationData ...@@ -49,10 +49,10 @@ typedef struct RelationData
File rd_fd; /* open file descriptor */ File rd_fd; /* open file descriptor */
int rd_nblocks; /* number of blocks in rel */ int rd_nblocks; /* number of blocks in rel */
uint16 rd_refcnt; /* reference count */ uint16 rd_refcnt; /* reference count */
bool rd_islocal; /* uses the local buffer mgr */ bool rd_myxactonly; /* uses the local buffer mgr */
bool rd_isnailed; /* rel is nailed in cache */ bool rd_isnailed; /* rel is nailed in cache */
bool rd_istemp; /* rel is a temp rel */ bool rd_isnoname; /* rel has no name */
bool rd_tmpunlinked; /* temp rel already unlinked */ bool rd_nonameunlinked; /* noname rel already unlinked */
Form_pg_am rd_am; /* AM tuple */ Form_pg_am rd_am; /* AM tuple */
Form_pg_class rd_rel; /* RELATION tuple */ Form_pg_class rd_rel; /* RELATION tuple */
Oid rd_id; /* relations's object id */ Oid rd_id; /* relations's object id */
......
/*-------------------------------------------------------------------------
*
* temprel.h--
* Temporary relation functions
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: temprel.h,v 1.1 1999/02/02 03:45:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef TEMPREL_H
#define TEMPREL_H
#include "access/htup.h"
#include "access/attnum.h"
void create_temp_relation(char *relname, HeapTuple pg_class_tuple);
void remove_all_temp_relations(void);
void remove_temp_relation(Oid relid);
HeapTuple get_temp_rel_by_name(char *user_relname);
#endif /* TEMPREL_H */
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/copy.l,v 1.6 1998/06/24 13:21:24 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/copy.l,v 1.7 1999/02/02 03:45:31 momjian Exp $
.TH COPY SQL 11/05/95 PostgreSQL PostgreSQL .TH COPY SQL 11/05/95 PostgreSQL PostgreSQL
.SH NAME .SH NAME
copy - copy data to or from a class from or to a Unix file. copy - copy data to or from a class from or to a Unix file.
...@@ -93,8 +93,8 @@ encountered. ...@@ -93,8 +93,8 @@ encountered.
.PP .PP
The backslash character has special meaning. The backslash character has special meaning.
.BR NULL .BR NULL
attributes are output as \\N. attributes are represented as \\N.
A literal backslash character is output as two consecutive backslashes. A literal backslash character is represented as two consecutive backslashes.
A literal tab character is represented as a backslash and a tab. A literal tab character is represented as a backslash and a tab.
A literal newline character is represented as a backslash and a newline. A literal newline character is represented as a backslash and a newline.
When loading ASCII data not generated by PostgreSQL, you will need to When loading ASCII data not generated by PostgreSQL, you will need to
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_table.l,v 1.22 1998/10/14 02:54:29 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/create_table.l,v 1.23 1999/02/02 03:45:32 momjian Exp $
.TH "CREATE TABLE" SQL 09/25/97 PostgreSQL .TH "CREATE TABLE" SQL 09/25/97 PostgreSQL
.SH NAME .SH NAME
create table - create a new class create table - create a new class
.SH SYNOPSIS .SH SYNOPSIS
.nf .nf
\fBcreate table\fR classname \fBcreate\fR [\fBtemp\fR] \fBtable\fR classname
\fB(\fP \fB(\fP
attname type attname type
[\fBdefault\fP value] [\fBdefault\fP value]
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/select.l,v 1.10 1998/07/12 04:49:47 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/select.l,v 1.11 1999/02/02 03:45:32 momjian Exp $
.TH SELECT SQL 11/05/95 PostgreSQL PostgreSQL .TH SELECT SQL 11/05/95 PostgreSQL PostgreSQL
.SH NAME .SH NAME
select - retrieve instances from a class select - retrieve instances from a class
...@@ -9,7 +9,7 @@ select - retrieve instances from a class ...@@ -9,7 +9,7 @@ select - retrieve instances from a class
\fBselect\fR [distinct [on attr_name]] \fBselect\fR [distinct [on attr_name]]
expression1 [\fBas\fR attr_name-1] expression1 [\fBas\fR attr_name-1]
{, expression-1 [\fBas\fR attr_name-i]} {, expression-1 [\fBas\fR attr_name-i]}
[\fBinto\fR [\fBtable\fR] classname] [\fBinto\fR [\fBtemp\fR] [\fBtable\fR] classname]
[\fBfrom\fR from-list] [\fBfrom\fR from-list]
[\fBwhere\fR where-clause] [\fBwhere\fR where-clause]
[\fBgroup by\fR attr_name1 {, attr_name-i....}] [\fBgroup by\fR attr_name1 {, attr_name-i....}]
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.11 1998/10/14 05:10:12 momjian Exp $ .\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.12 1999/02/02 03:45:33 momjian Exp $
.TH SET SQL 05/14/97 PostgreSQL PostgreSQL .TH SET SQL 05/14/97 PostgreSQL PostgreSQL
.SH NAME .SH NAME
set - set run-time parameters for session set - set run-time parameters for session
...@@ -44,8 +44,10 @@ determines the output format for the date and time data types. ...@@ -44,8 +44,10 @@ determines the output format for the date and time data types.
.IR GEQO .IR GEQO
enables or disables the genetic optimizer algorithm. This algorithm is enables or disables the genetic optimizer algorithm. This algorithm is
.IR on .IR on
by default, which used GEQO for statements of eight or more tables. by default, which used GEQO for statements of six or more tables.
See the GEQO README for more information. Set the
.IR Programmer's Guide
for more information.
.ce 1 .ce 1
\fBGEQO Values\fR \fBGEQO Values\fR
......
/* A lexical scanner generated by flex */ /* A lexical scanner generated by flex */
/* Scanner skeleton version: /* Scanner skeleton version:
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.c,v 1.3 1999/01/28 11:50:42 wieck Exp $ * /master/usr.bin/lex/skel.c,v 1.3 1997/09/25 00:10:23 jch Exp
*/ */
#define FLEX_SCANNER #define FLEX_SCANNER
...@@ -126,6 +126,7 @@ extern FILE *yyin, *yyout; ...@@ -126,6 +126,7 @@ extern FILE *yyin, *yyout;
{ \ { \
/* Undo effects of setting up yytext. */ \ /* Undo effects of setting up yytext. */ \
*yy_cp = yy_hold_char; \ *yy_cp = yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \
yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \ } \
...@@ -235,7 +236,7 @@ void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); ...@@ -235,7 +236,7 @@ void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
...@@ -281,13 +282,15 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); ...@@ -281,13 +282,15 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*/ */
#define YY_DO_BEFORE_ACTION \ #define YY_DO_BEFORE_ACTION \
yytext_ptr = yy_bp; \ yytext_ptr = yy_bp; \
yytext_ptr -= yy_more_len; \ yyleng = (int) (yy_cp - yy_bp); \
yyleng = (int) (yy_cp - yytext_ptr); \
yy_hold_char = *yy_cp; \ yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \ *yy_cp = '\0'; \
if ( yyleng >= YYLMAX ) \ if ( yyleng + yy_more_offset >= YYLMAX ) \
YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
yy_flex_strncpy( yytext, yytext_ptr, yyleng + 1 ); \ yy_flex_strncpy( &yytext[yy_more_offset], yytext_ptr, yyleng + 1 ); \
yyleng += yy_more_offset; \
yy_prev_more_offset = yy_more_offset; \
yy_more_offset = 0; \
yy_c_buf_p = yy_cp; yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 60 #define YY_NUM_RULES 60
...@@ -606,10 +609,16 @@ yy_cp = yy_full_match; /* restore poss. backed-over text */ \ ...@@ -606,10 +609,16 @@ yy_cp = yy_full_match; /* restore poss. backed-over text */ \
++yy_lp; \ ++yy_lp; \
goto find_rule; \ goto find_rule; \
} }
static int yy_more_flag = 0; static int yy_more_offset = 0;
static int yy_more_len = 0; static int yy_prev_more_offset = 0;
#define yymore() (yy_more_flag = 1) #define yymore() (yy_more_offset = yy_flex_strlen( yytext ))
#define YY_MORE_ADJ yy_more_len #define YY_NEED_STRLEN
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET \
{ \
yy_more_offset = yy_prev_more_offset; \
yyleng -= yy_more_offset; \
}
#ifndef YYLMAX #ifndef YYLMAX
#define YYLMAX 8192 #define YYLMAX 8192
#endif #endif
...@@ -624,7 +633,7 @@ char *yytext_ptr; ...@@ -624,7 +633,7 @@ char *yytext_ptr;
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.c,v 1.3 1999/01/28 11:50:42 wieck Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.c,v 1.4 1999/02/02 03:45:33 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -688,6 +697,10 @@ static void yyunput YY_PROTO(( int c, char *buf_ptr )); ...@@ -688,6 +697,10 @@ static void yyunput YY_PROTO(( int c, char *buf_ptr ));
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif #endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#endif
#ifndef YY_NO_INPUT #ifndef YY_NO_INPUT
#ifdef __cplusplus #ifdef __cplusplus
static int yyinput YY_PROTO(( void )); static int yyinput YY_PROTO(( void ));
...@@ -873,12 +886,6 @@ YY_DECL ...@@ -873,12 +886,6 @@ YY_DECL
while ( 1 ) /* loops until end-of-file is reached */ while ( 1 ) /* loops until end-of-file is reached */
{ {
yy_more_len = 0;
if ( yy_more_flag )
{
yy_more_len = yyleng;
yy_more_flag = 0;
}
yy_cp = yy_c_buf_p; yy_cp = yy_c_buf_p;
/* Support of yytext. */ /* Support of yytext. */
...@@ -1291,6 +1298,7 @@ ECHO; ...@@ -1291,6 +1298,7 @@ ECHO;
/* Undo the effects of YY_DO_BEFORE_ACTION. */ /* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yy_hold_char; *yy_cp = yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
{ {
...@@ -1436,7 +1444,7 @@ static int yy_get_next_buffer() ...@@ -1436,7 +1444,7 @@ static int yy_get_next_buffer()
{ /* Don't try to fill the buffer, so this is an EOF. */ { /* Don't try to fill the buffer, so this is an EOF. */
if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
{ {
/* We matched a singled characater, the EOB, so /* We matched a single character, the EOB, so
* treat this as a final EOF. * treat this as a final EOF.
*/ */
return EOB_ACT_END_OF_FILE; return EOB_ACT_END_OF_FILE;
...@@ -1463,7 +1471,7 @@ static int yy_get_next_buffer() ...@@ -1463,7 +1471,7 @@ static int yy_get_next_buffer()
/* don't do the read, it's not guaranteed to return an EOF, /* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF * just force an EOF
*/ */
yy_n_chars = 0; yy_current_buffer->yy_n_chars = yy_n_chars = 0;
else else
{ {
...@@ -1518,6 +1526,8 @@ static int yy_get_next_buffer() ...@@ -1518,6 +1526,8 @@ static int yy_get_next_buffer()
/* Read in more data. */ /* Read in more data. */
YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
yy_n_chars, num_to_read ); yy_n_chars, num_to_read );
yy_current_buffer->yy_n_chars = yy_n_chars;
} }
if ( yy_n_chars == 0 ) if ( yy_n_chars == 0 )
...@@ -1601,8 +1611,9 @@ yy_state_type yy_current_state; ...@@ -1601,8 +1611,9 @@ yy_state_type yy_current_state;
yy_c = yy_meta[(unsigned int) yy_c]; yy_c = yy_meta[(unsigned int) yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
*yy_state_ptr++ = yy_current_state;
yy_is_jam = (yy_current_state == 211); yy_is_jam = (yy_current_state == 211);
if ( ! yy_is_jam )
*yy_state_ptr++ = yy_current_state;
return yy_is_jam ? 0 : yy_current_state; return yy_is_jam ? 0 : yy_current_state;
} }
...@@ -1636,7 +1647,8 @@ register char *yy_bp; ...@@ -1636,7 +1647,8 @@ register char *yy_bp;
yy_cp += (int) (dest - source); yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source); yy_bp += (int) (dest - source);
yy_n_chars = yy_current_buffer->yy_buf_size; yy_current_buffer->yy_n_chars =
yy_n_chars = yy_current_buffer->yy_buf_size;
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" ); YY_FATAL_ERROR( "flex scanner push-back overflow" );
...@@ -1676,19 +1688,31 @@ static int input() ...@@ -1676,19 +1688,31 @@ static int input()
else else
{ /* need more input */ { /* need more input */
yytext_ptr = yy_c_buf_p; int offset = yy_c_buf_p - yytext_ptr;
++yy_c_buf_p; ++yy_c_buf_p;
switch ( yy_get_next_buffer() ) switch ( yy_get_next_buffer() )
{ {
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
yyrestart( yyin );
/* fall through */
case EOB_ACT_END_OF_FILE: case EOB_ACT_END_OF_FILE:
{ {
if ( yywrap() ) if ( yywrap() )
{
yy_c_buf_p =
yytext_ptr + YY_MORE_ADJ;
return EOF; return EOF;
}
if ( ! yy_did_buffer_switch_on_eof ) if ( ! yy_did_buffer_switch_on_eof )
YY_NEW_FILE; YY_NEW_FILE;
...@@ -1700,17 +1724,8 @@ static int input() ...@@ -1700,17 +1724,8 @@ static int input()
} }
case EOB_ACT_CONTINUE_SCAN: case EOB_ACT_CONTINUE_SCAN:
yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_c_buf_p = yytext_ptr + offset;
break; break;
case EOB_ACT_LAST_MATCH:
#ifdef __cplusplus
YY_FATAL_ERROR(
"unexpected last match in yyinput()" );
#else
YY_FATAL_ERROR(
"unexpected last match in input()" );
#endif
} }
} }
} }
...@@ -1877,6 +1892,9 @@ YY_BUFFER_STATE b; ...@@ -1877,6 +1892,9 @@ YY_BUFFER_STATE b;
#endif #endif
{ {
if ( ! b )
return;
b->yy_n_chars = 0; b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes /* We always need two end-of-buffer characters. The first causes
...@@ -1936,17 +1954,17 @@ yy_size_t size; ...@@ -1936,17 +1954,17 @@ yy_size_t size;
#ifndef YY_NO_SCAN_STRING #ifndef YY_NO_SCAN_STRING
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS
YY_BUFFER_STATE yy_scan_string( yyconst char *str ) YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
#else #else
YY_BUFFER_STATE yy_scan_string( str ) YY_BUFFER_STATE yy_scan_string( yy_str )
yyconst char *str; yyconst char *yy_str;
#endif #endif
{ {
int len; int len;
for ( len = 0; str[len]; ++len ) for ( len = 0; yy_str[len]; ++len )
; ;
return yy_scan_bytes( str, len ); return yy_scan_bytes( yy_str, len );
} }
#endif #endif
...@@ -2067,7 +2085,7 @@ char msg[]; ...@@ -2067,7 +2085,7 @@ char msg[];
{ \ { \
/* Undo effects of setting up yytext. */ \ /* Undo effects of setting up yytext. */ \
yytext[yyleng] = yy_hold_char; \ yytext[yyleng] = yy_hold_char; \
yy_c_buf_p = yytext + n - YY_MORE_ADJ; \ yy_c_buf_p = yytext + n; \
yy_hold_char = *yy_c_buf_p; \ yy_hold_char = *yy_c_buf_p; \
*yy_c_buf_p = '\0'; \ *yy_c_buf_p = '\0'; \
yyleng = n; \ yyleng = n; \
...@@ -2093,6 +2111,22 @@ int n; ...@@ -2093,6 +2111,22 @@ int n;
} }
#endif #endif
#ifdef YY_NEED_STRLEN
#ifdef YY_USE_PROTOS
static int yy_flex_strlen( yyconst char *s )
#else
static int yy_flex_strlen( s )
yyconst char *s;
#endif
{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS
static void *yy_flex_alloc( yy_size_t size ) static void *yy_flex_alloc( yy_size_t size )
......
QUERY: CREATE TABLE temp (initial int4); QUERY: CREATE TABLE tmp (initial int4);
QUERY: ALTER TABLE temp ADD COLUMN a int4; QUERY: ALTER TABLE tmp ADD COLUMN a int4;
QUERY: ALTER TABLE temp ADD COLUMN b name; QUERY: ALTER TABLE tmp ADD COLUMN b name;
QUERY: ALTER TABLE temp ADD COLUMN c text; QUERY: ALTER TABLE tmp ADD COLUMN c text;
QUERY: ALTER TABLE temp ADD COLUMN d float8; QUERY: ALTER TABLE tmp ADD COLUMN d float8;
QUERY: ALTER TABLE temp ADD COLUMN e float4; QUERY: ALTER TABLE tmp ADD COLUMN e float4;
QUERY: ALTER TABLE temp ADD COLUMN f int2; QUERY: ALTER TABLE tmp ADD COLUMN f int2;
QUERY: ALTER TABLE temp ADD COLUMN g polygon; QUERY: ALTER TABLE tmp ADD COLUMN g polygon;
QUERY: ALTER TABLE temp ADD COLUMN h abstime; QUERY: ALTER TABLE tmp ADD COLUMN h abstime;
QUERY: ALTER TABLE temp ADD COLUMN i char; QUERY: ALTER TABLE tmp ADD COLUMN i char;
QUERY: ALTER TABLE temp ADD COLUMN j abstime[]; QUERY: ALTER TABLE tmp ADD COLUMN j abstime[];
QUERY: ALTER TABLE temp ADD COLUMN k dt; QUERY: ALTER TABLE tmp ADD COLUMN k dt;
ERROR: type name lookup of dt failed ERROR: type name lookup of dt failed
QUERY: ALTER TABLE temp ADD COLUMN l tid; QUERY: ALTER TABLE tmp ADD COLUMN l tid;
QUERY: ALTER TABLE temp ADD COLUMN m xid; QUERY: ALTER TABLE tmp ADD COLUMN m xid;
QUERY: ALTER TABLE temp ADD COLUMN n oid8; QUERY: ALTER TABLE tmp ADD COLUMN n oid8;
QUERY: ALTER TABLE temp ADD COLUMN p smgr; QUERY: ALTER TABLE tmp ADD COLUMN p smgr;
QUERY: ALTER TABLE temp ADD COLUMN q point; QUERY: ALTER TABLE tmp ADD COLUMN q point;
QUERY: ALTER TABLE temp ADD COLUMN r lseg; QUERY: ALTER TABLE tmp ADD COLUMN r lseg;
QUERY: ALTER TABLE temp ADD COLUMN s path; QUERY: ALTER TABLE tmp ADD COLUMN s path;
QUERY: ALTER TABLE temp ADD COLUMN t box; QUERY: ALTER TABLE tmp ADD COLUMN t box;
QUERY: ALTER TABLE temp ADD COLUMN u tinterval; QUERY: ALTER TABLE tmp ADD COLUMN u tinterval;
QUERY: ALTER TABLE temp ADD COLUMN v datetime; QUERY: ALTER TABLE tmp ADD COLUMN v datetime;
QUERY: ALTER TABLE temp ADD COLUMN w timespan; QUERY: ALTER TABLE tmp ADD COLUMN w timespan;
QUERY: ALTER TABLE temp ADD COLUMN x float8[]; QUERY: ALTER TABLE tmp ADD COLUMN x float8[];
QUERY: ALTER TABLE temp ADD COLUMN y float4[]; QUERY: ALTER TABLE tmp ADD COLUMN y float4[];
QUERY: ALTER TABLE temp ADD COLUMN z int2[]; QUERY: ALTER TABLE tmp ADD COLUMN z int2[];
QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, QUERY: INSERT INTO tmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
v, w, x, y, z) v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}', 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
...@@ -33,43 +33,43 @@ QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t ...@@ -33,43 +33,43 @@ QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', '1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]', '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]',
'1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}'); '1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
ERROR: Relation temp does not have attribute k ERROR: Relation tmp does not have attribute k
QUERY: SELECT * FROM temp; QUERY: SELECT * FROM tmp;
initial|a|b|c|d|e|f|g|h|i|j|l|m|n|p|q|r|s|t|u|v|w|x|y|z initial|a|b|c|d|e|f|g|h|i|j|l|m|n|p|q|r|s|t|u|v|w|x|y|z
-------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
(0 rows) (0 rows)
QUERY: DROP TABLE temp; QUERY: DROP TABLE tmp;
QUERY: CREATE TABLE temp ( QUERY: CREATE TABLE tmp (
initial int4 initial int4
); );
QUERY: ALTER TABLE temp ADD COLUMN a int4; QUERY: ALTER TABLE tmp ADD COLUMN a int4;
QUERY: ALTER TABLE temp ADD COLUMN b name; QUERY: ALTER TABLE tmp ADD COLUMN b name;
QUERY: ALTER TABLE temp ADD COLUMN c text; QUERY: ALTER TABLE tmp ADD COLUMN c text;
QUERY: ALTER TABLE temp ADD COLUMN d float8; QUERY: ALTER TABLE tmp ADD COLUMN d float8;
QUERY: ALTER TABLE temp ADD COLUMN e float4; QUERY: ALTER TABLE tmp ADD COLUMN e float4;
QUERY: ALTER TABLE temp ADD COLUMN f int2; QUERY: ALTER TABLE tmp ADD COLUMN f int2;
QUERY: ALTER TABLE temp ADD COLUMN g polygon; QUERY: ALTER TABLE tmp ADD COLUMN g polygon;
QUERY: ALTER TABLE temp ADD COLUMN h abstime; QUERY: ALTER TABLE tmp ADD COLUMN h abstime;
QUERY: ALTER TABLE temp ADD COLUMN i char; QUERY: ALTER TABLE tmp ADD COLUMN i char;
QUERY: ALTER TABLE temp ADD COLUMN j abstime[]; QUERY: ALTER TABLE tmp ADD COLUMN j abstime[];
QUERY: ALTER TABLE temp ADD COLUMN k dt; QUERY: ALTER TABLE tmp ADD COLUMN k dt;
ERROR: type name lookup of dt failed ERROR: type name lookup of dt failed
QUERY: ALTER TABLE temp ADD COLUMN l tid; QUERY: ALTER TABLE tmp ADD COLUMN l tid;
QUERY: ALTER TABLE temp ADD COLUMN m xid; QUERY: ALTER TABLE tmp ADD COLUMN m xid;
QUERY: ALTER TABLE temp ADD COLUMN n oid8; QUERY: ALTER TABLE tmp ADD COLUMN n oid8;
QUERY: ALTER TABLE temp ADD COLUMN p smgr; QUERY: ALTER TABLE tmp ADD COLUMN p smgr;
QUERY: ALTER TABLE temp ADD COLUMN q point; QUERY: ALTER TABLE tmp ADD COLUMN q point;
QUERY: ALTER TABLE temp ADD COLUMN r lseg; QUERY: ALTER TABLE tmp ADD COLUMN r lseg;
QUERY: ALTER TABLE temp ADD COLUMN s path; QUERY: ALTER TABLE tmp ADD COLUMN s path;
QUERY: ALTER TABLE temp ADD COLUMN t box; QUERY: ALTER TABLE tmp ADD COLUMN t box;
QUERY: ALTER TABLE temp ADD COLUMN u tinterval; QUERY: ALTER TABLE tmp ADD COLUMN u tinterval;
QUERY: ALTER TABLE temp ADD COLUMN v datetime; QUERY: ALTER TABLE tmp ADD COLUMN v datetime;
QUERY: ALTER TABLE temp ADD COLUMN w timespan; QUERY: ALTER TABLE tmp ADD COLUMN w timespan;
QUERY: ALTER TABLE temp ADD COLUMN x float8[]; QUERY: ALTER TABLE tmp ADD COLUMN x float8[];
QUERY: ALTER TABLE temp ADD COLUMN y float4[]; QUERY: ALTER TABLE tmp ADD COLUMN y float4[];
QUERY: ALTER TABLE temp ADD COLUMN z int2[]; QUERY: ALTER TABLE tmp ADD COLUMN z int2[];
QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, QUERY: INSERT INTO tmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
v, w, x, y, z) v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}', 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
...@@ -77,13 +77,13 @@ QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t ...@@ -77,13 +77,13 @@ QUERY: INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t
'1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', '1 2 3 4 5 6 7 8', 'magnetic disk', '(1.1,1.1)', '(4.1,4.1,3.1,3.1)',
'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]', '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]',
'1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}'); '1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
ERROR: Relation temp does not have attribute k ERROR: Relation tmp does not have attribute k
QUERY: SELECT * FROM temp; QUERY: SELECT * FROM tmp;
initial|a|b|c|d|e|f|g|h|i|j|l|m|n|p|q|r|s|t|u|v|w|x|y|z initial|a|b|c|d|e|f|g|h|i|j|l|m|n|p|q|r|s|t|u|v|w|x|y|z
-------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- -------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
(0 rows) (0 rows)
QUERY: DROP TABLE temp; QUERY: DROP TABLE tmp;
QUERY: ALTER TABLE tenk1 RENAME TO ten_k; QUERY: ALTER TABLE tenk1 RENAME TO ten_k;
QUERY: SELECT unique1 FROM ten_k WHERE unique1 < 20; QUERY: SELECT unique1 FROM ten_k WHERE unique1 < 20;
unique1 unique1
......
...@@ -173,7 +173,7 @@ unique1|string4 ...@@ -173,7 +173,7 @@ unique1|string4
(20 rows) (20 rows)
QUERY: SELECT two, stringu1, ten, string4 QUERY: SELECT two, stringu1, ten, string4
INTO TABLE temp INTO TABLE tmp
FROM onek; FROM onek;
QUERY: SELECT p.name, p.age FROM person* p; QUERY: SELECT p.name, p.age FROM person* p;
name |age name |age
......
QUERY: SELECT DISTINCT two FROM temp; QUERY: SELECT DISTINCT two FROM tmp;
two two
--- ---
0 0
1 1
(2 rows) (2 rows)
QUERY: SELECT DISTINCT ten FROM temp; QUERY: SELECT DISTINCT ten FROM tmp;
ten ten
--- ---
0 0
...@@ -20,7 +20,7 @@ ten ...@@ -20,7 +20,7 @@ ten
9 9
(10 rows) (10 rows)
QUERY: SELECT DISTINCT string4 FROM temp; QUERY: SELECT DISTINCT string4 FROM tmp;
string4 string4
------- -------
AAAAxx AAAAxx
...@@ -30,7 +30,7 @@ VVVVxx ...@@ -30,7 +30,7 @@ VVVVxx
(4 rows) (4 rows)
QUERY: SELECT DISTINCT two, string4, ten QUERY: SELECT DISTINCT two, string4, ten
FROM temp FROM tmp
ORDER BY two using <, string4 using <, ten using <; ORDER BY two using <, string4 using <, ten using <;
two|string4|ten two|string4|ten
---+-------+--- ---+-------+---
......
QUERY: SELECT DISTINCT ON string4 two, string4, ten QUERY: SELECT DISTINCT ON string4 two, string4, ten
FROM temp FROM tmp
ORDER BY two using <, string4 using <, ten using <; ORDER BY two using <, string4 using <, ten using <;
two|string4|ten two|string4|ten
---+-------+--- ---+-------+---
......
QUERY: SELECT * QUERY: SELECT *
INTO TABLE temp1 INTO TABLE tmp1
FROM temp FROM tmp
WHERE onek.unique1 < 2; WHERE onek.unique1 < 2;
QUERY: DROP TABLE temp1; QUERY: DROP TABLE tmp1;
QUERY: SELECT * QUERY: SELECT *
INTO TABLE temp1 INTO TABLE tmp1
FROM temp FROM tmp
WHERE onek2.unique1 < 2; WHERE onek2.unique1 < 2;
QUERY: DROP TABLE temp1; QUERY: DROP TABLE tmp1;
QUERY: CREATE TABLE temptest(col int);
QUERY: CREATE INDEX i_temptest ON temptest(col);
QUERY: CREATE TEMP TABLE temptest(col int);
QUERY: CREATE INDEX i_temptest ON temptest(col);
QUERY: DROP INDEX i_temptest;
QUERY: DROP TABLE temptest;
QUERY: DROP INDEX i_temptest;
QUERY: DROP TABLE temptest;
QUERY: CREATE TABLE temptest(col int);
QUERY: INSERT INTO temptest VALUES (1);
QUERY: CREATE TEMP TABLE temptest(col int);
QUERY: INSERT INTO temptest VALUES (2);
QUERY: SELECT * FROM temptest;
col
---
2
(1 row)
QUERY: DROP TABLE temptest;
QUERY: SELECT * FROM temptest;
col
---
1
(1 row)
QUERY: DROP TABLE temptest;
QUERY: CREATE TEMP TABLE temptest(col int);
QUERY: SELECT * FROM temptest;
ERROR: temptest: Table does not exist.
...@@ -122,22 +122,22 @@ DROP SEQUENCE INSERT_SEQ; ...@@ -122,22 +122,22 @@ DROP SEQUENCE INSERT_SEQ;
CREATE SEQUENCE INSERT_SEQ START 4; CREATE SEQUENCE INSERT_SEQ START 4;
CREATE TABLE TEMP (xd INT, yd TEXT, zd INT); CREATE TABLE tmp (xd INT, yd TEXT, zd INT);
INSERT INTO TEMP VALUES (null, 'Y', null); INSERT INTO tmp VALUES (null, 'Y', null);
INSERT INTO TEMP VALUES (5, '!check failed', null); INSERT INTO tmp VALUES (5, '!check failed', null);
INSERT INTO TEMP VALUES (null, 'try again', null); INSERT INTO tmp VALUES (null, 'try again', null);
INSERT INTO INSERT_TBL(y) select yd from TEMP; INSERT INTO INSERT_TBL(y) select yd from tmp;
SELECT '' AS three, * FROM INSERT_TBL; SELECT '' AS three, * FROM INSERT_TBL;
INSERT INTO INSERT_TBL SELECT * FROM TEMP WHERE yd = 'try again'; INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again';
INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM TEMP WHERE yd = 'try again'; INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again';
INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM TEMP WHERE yd = 'try again'; INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again';
SELECT '' AS four, * FROM INSERT_TBL; SELECT '' AS four, * FROM INSERT_TBL;
DROP TABLE TEMP; DROP TABLE tmp;
-- --
-- Check constraints on UPDATE -- Check constraints on UPDATE
......
...@@ -26,17 +26,17 @@ UPDATE onek ...@@ -26,17 +26,17 @@ UPDATE onek
-- systems. This non-func update stuff needs to be examined -- systems. This non-func update stuff needs to be examined
-- more closely. - jolly (2/22/96) -- more closely. - jolly (2/22/96)
-- --
UPDATE temp UPDATE tmp
SET stringu1 = reverse_name(onek.stringu1) SET stringu1 = reverse_name(onek.stringu1)
WHERE onek.stringu1 = 'JBAAAA' and WHERE onek.stringu1 = 'JBAAAA' and
onek.stringu1 = temp.stringu1; onek.stringu1 = tmp.stringu1;
UPDATE temp UPDATE tmp
SET stringu1 = reverse_name(onek2.stringu1) SET stringu1 = reverse_name(onek2.stringu1)
WHERE onek2.stringu1 = 'JCAAAA' and WHERE onek2.stringu1 = 'JCAAAA' and
onek2.stringu1 = temp.stringu1; onek2.stringu1 = tmp.stringu1;
DROP TABLE temp; DROP TABLE tmp;
--UPDATE person* --UPDATE person*
-- SET age = age + 1; -- SET age = age + 1;
......
...@@ -148,11 +148,11 @@ eight| 8 ...@@ -148,11 +148,11 @@ eight| 8
QUERY: DELETE FROM INSERT_TBL; QUERY: DELETE FROM INSERT_TBL;
QUERY: DROP SEQUENCE INSERT_SEQ; QUERY: DROP SEQUENCE INSERT_SEQ;
QUERY: CREATE SEQUENCE INSERT_SEQ START 4; QUERY: CREATE SEQUENCE INSERT_SEQ START 4;
QUERY: CREATE TABLE TEMP (xd INT, yd TEXT, zd INT); QUERY: CREATE TABLE tmp (xd INT, yd TEXT, zd INT);
QUERY: INSERT INTO TEMP VALUES (null, 'Y', null); QUERY: INSERT INTO tmp VALUES (null, 'Y', null);
QUERY: INSERT INTO TEMP VALUES (5, '!check failed', null); QUERY: INSERT INTO tmp VALUES (5, '!check failed', null);
QUERY: INSERT INTO TEMP VALUES (null, 'try again', null); QUERY: INSERT INTO tmp VALUES (null, 'try again', null);
QUERY: INSERT INTO INSERT_TBL(y) select yd from TEMP; QUERY: INSERT INTO INSERT_TBL(y) select yd from tmp;
NOTICE: insert_seq.nextval: sequence was re-created NOTICE: insert_seq.nextval: sequence was re-created
QUERY: SELECT '' AS three, * FROM INSERT_TBL; QUERY: SELECT '' AS three, * FROM INSERT_TBL;
three|x|y | z three|x|y | z
...@@ -162,10 +162,10 @@ three|x|y | z ...@@ -162,10 +162,10 @@ three|x|y | z
|6|try again |-6 |6|try again |-6
(3 rows) (3 rows)
QUERY: INSERT INTO INSERT_TBL SELECT * FROM TEMP WHERE yd = 'try again'; QUERY: INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again';
ERROR: ExecAppend: rejected due to CHECK constraint $2 ERROR: ExecAppend: rejected due to CHECK constraint $2
QUERY: INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM TEMP WHERE yd = 'try again'; QUERY: INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again';
QUERY: INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM TEMP WHERE yd = 'try again'; QUERY: INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again';
ERROR: ExecAppend: rejected due to CHECK constraint insert_con ERROR: ExecAppend: rejected due to CHECK constraint insert_con
QUERY: SELECT '' AS four, * FROM INSERT_TBL; QUERY: SELECT '' AS four, * FROM INSERT_TBL;
four|x|y | z four|x|y | z
...@@ -176,7 +176,7 @@ four|x|y | z ...@@ -176,7 +176,7 @@ four|x|y | z
|7|try again |-7 |7|try again |-7
(4 rows) (4 rows)
QUERY: DROP TABLE TEMP; QUERY: DROP TABLE tmp;
QUERY: UPDATE INSERT_TBL SET x = NULL WHERE x = 6; QUERY: UPDATE INSERT_TBL SET x = NULL WHERE x = 6;
ERROR: ExecReplace: rejected due to CHECK constraint $2 ERROR: ExecReplace: rejected due to CHECK constraint $2
QUERY: UPDATE INSERT_TBL SET x = 6 WHERE x = 6; QUERY: UPDATE INSERT_TBL SET x = 6 WHERE x = 6;
......
...@@ -2,19 +2,19 @@ QUERY: UPDATE onek ...@@ -2,19 +2,19 @@ QUERY: UPDATE onek
SET unique1 = onek.unique1 + 1; SET unique1 = onek.unique1 + 1;
QUERY: UPDATE onek QUERY: UPDATE onek
SET unique1 = onek.unique1 - 1; SET unique1 = onek.unique1 - 1;
QUERY: UPDATE temp QUERY: UPDATE tmp
SET stringu1 = reverse_name(onek.stringu1) SET stringu1 = reverse_name(onek.stringu1)
WHERE onek.stringu1 = 'JBAAAA' and WHERE onek.stringu1 = 'JBAAAA' and
onek.stringu1 = temp.stringu1; onek.stringu1 = tmp.stringu1;
NOTICE: Non-functional update, only first update is performed NOTICE: Non-functional update, only first update is performed
NOTICE: Non-functional update, only first update is performed NOTICE: Non-functional update, only first update is performed
QUERY: UPDATE temp QUERY: UPDATE tmp
SET stringu1 = reverse_name(onek2.stringu1) SET stringu1 = reverse_name(onek2.stringu1)
WHERE onek2.stringu1 = 'JCAAAA' and WHERE onek2.stringu1 = 'JCAAAA' and
onek2.stringu1 = temp.stringu1; onek2.stringu1 = tmp.stringu1;
NOTICE: Non-functional update, only first update is performed NOTICE: Non-functional update, only first update is performed
NOTICE: Non-functional update, only first update is performed NOTICE: Non-functional update, only first update is performed
QUERY: DROP TABLE temp; QUERY: DROP TABLE tmp;
QUERY: COPY onek TO '_OBJWD_/results/onek.data'; QUERY: COPY onek TO '_OBJWD_/results/onek.data';
QUERY: DELETE FROM onek; QUERY: DELETE FROM onek;
QUERY: COPY onek FROM '_OBJWD_/results/onek.data'; QUERY: COPY onek FROM '_OBJWD_/results/onek.data';
......
-- --
-- add attribute -- add attribute
-- --
CREATE TABLE temp (initial int4); CREATE TABLE tmp (initial int4);
ALTER TABLE temp ADD COLUMN a int4; ALTER TABLE tmp ADD COLUMN a int4;
ALTER TABLE temp ADD COLUMN b name; ALTER TABLE tmp ADD COLUMN b name;
ALTER TABLE temp ADD COLUMN c text; ALTER TABLE tmp ADD COLUMN c text;
ALTER TABLE temp ADD COLUMN d float8; ALTER TABLE tmp ADD COLUMN d float8;
ALTER TABLE temp ADD COLUMN e float4; ALTER TABLE tmp ADD COLUMN e float4;
ALTER TABLE temp ADD COLUMN f int2; ALTER TABLE tmp ADD COLUMN f int2;
ALTER TABLE temp ADD COLUMN g polygon; ALTER TABLE tmp ADD COLUMN g polygon;
ALTER TABLE temp ADD COLUMN h abstime; ALTER TABLE tmp ADD COLUMN h abstime;
ALTER TABLE temp ADD COLUMN i char; ALTER TABLE tmp ADD COLUMN i char;
ALTER TABLE temp ADD COLUMN j abstime[]; ALTER TABLE tmp ADD COLUMN j abstime[];
ALTER TABLE temp ADD COLUMN k dt; ALTER TABLE tmp ADD COLUMN k dt;
ALTER TABLE temp ADD COLUMN l tid; ALTER TABLE tmp ADD COLUMN l tid;
ALTER TABLE temp ADD COLUMN m xid; ALTER TABLE tmp ADD COLUMN m xid;
ALTER TABLE temp ADD COLUMN n oid8; ALTER TABLE tmp ADD COLUMN n oid8;
--ALTER TABLE temp ADD COLUMN o lock; --ALTER TABLE tmp ADD COLUMN o lock;
ALTER TABLE temp ADD COLUMN p smgr; ALTER TABLE tmp ADD COLUMN p smgr;
ALTER TABLE temp ADD COLUMN q point; ALTER TABLE tmp ADD COLUMN q point;
ALTER TABLE temp ADD COLUMN r lseg; ALTER TABLE tmp ADD COLUMN r lseg;
ALTER TABLE temp ADD COLUMN s path; ALTER TABLE tmp ADD COLUMN s path;
ALTER TABLE temp ADD COLUMN t box; ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE temp ADD COLUMN u tinterval; ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE temp ADD COLUMN v datetime; ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE temp ADD COLUMN w timespan; ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE temp ADD COLUMN x float8[]; ALTER TABLE tmp ADD COLUMN x float8[];
ALTER TABLE temp ADD COLUMN y float4[]; ALTER TABLE tmp ADD COLUMN y float4[];
ALTER TABLE temp ADD COLUMN z int2[]; ALTER TABLE tmp ADD COLUMN z int2[];
INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, INSERT INTO tmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
v, w, x, y, z) v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}', 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
...@@ -63,67 +63,67 @@ INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, ...@@ -63,67 +63,67 @@ INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]', '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]',
'1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}'); '1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM temp; SELECT * FROM tmp;
DROP TABLE temp; DROP TABLE tmp;
-- the wolf bug - schema mods caused inconsistent row descriptors -- the wolf bug - schema mods caused inconsistent row descriptors
CREATE TABLE temp ( CREATE TABLE tmp (
initial int4 initial int4
); );
ALTER TABLE temp ADD COLUMN a int4; ALTER TABLE tmp ADD COLUMN a int4;
ALTER TABLE temp ADD COLUMN b name; ALTER TABLE tmp ADD COLUMN b name;
ALTER TABLE temp ADD COLUMN c text; ALTER TABLE tmp ADD COLUMN c text;
ALTER TABLE temp ADD COLUMN d float8; ALTER TABLE tmp ADD COLUMN d float8;
ALTER TABLE temp ADD COLUMN e float4; ALTER TABLE tmp ADD COLUMN e float4;
ALTER TABLE temp ADD COLUMN f int2; ALTER TABLE tmp ADD COLUMN f int2;
ALTER TABLE temp ADD COLUMN g polygon; ALTER TABLE tmp ADD COLUMN g polygon;
ALTER TABLE temp ADD COLUMN h abstime; ALTER TABLE tmp ADD COLUMN h abstime;
ALTER TABLE temp ADD COLUMN i char; ALTER TABLE tmp ADD COLUMN i char;
ALTER TABLE temp ADD COLUMN j abstime[]; ALTER TABLE tmp ADD COLUMN j abstime[];
ALTER TABLE temp ADD COLUMN k dt; ALTER TABLE tmp ADD COLUMN k dt;
ALTER TABLE temp ADD COLUMN l tid; ALTER TABLE tmp ADD COLUMN l tid;
ALTER TABLE temp ADD COLUMN m xid; ALTER TABLE tmp ADD COLUMN m xid;
ALTER TABLE temp ADD COLUMN n oid8; ALTER TABLE tmp ADD COLUMN n oid8;
--ALTER TABLE temp ADD COLUMN o lock; --ALTER TABLE tmp ADD COLUMN o lock;
ALTER TABLE temp ADD COLUMN p smgr; ALTER TABLE tmp ADD COLUMN p smgr;
ALTER TABLE temp ADD COLUMN q point; ALTER TABLE tmp ADD COLUMN q point;
ALTER TABLE temp ADD COLUMN r lseg; ALTER TABLE tmp ADD COLUMN r lseg;
ALTER TABLE temp ADD COLUMN s path; ALTER TABLE tmp ADD COLUMN s path;
ALTER TABLE temp ADD COLUMN t box; ALTER TABLE tmp ADD COLUMN t box;
ALTER TABLE temp ADD COLUMN u tinterval; ALTER TABLE tmp ADD COLUMN u tinterval;
ALTER TABLE temp ADD COLUMN v datetime; ALTER TABLE tmp ADD COLUMN v datetime;
ALTER TABLE temp ADD COLUMN w timespan; ALTER TABLE tmp ADD COLUMN w timespan;
ALTER TABLE temp ADD COLUMN x float8[]; ALTER TABLE tmp ADD COLUMN x float8[];
ALTER TABLE temp ADD COLUMN y float4[]; ALTER TABLE tmp ADD COLUMN y float4[];
ALTER TABLE temp ADD COLUMN z int2[]; ALTER TABLE tmp ADD COLUMN z int2[];
INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, INSERT INTO tmp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
v, w, x, y, z) v, w, x, y, z)
VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)',
'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}', 'Mon May 1 00:30:30 1995', 'c', '{Mon May 1 00:30:30 1995, Monday Aug 24 14:43:07 1992, epoch}',
...@@ -132,9 +132,9 @@ INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, ...@@ -132,9 +132,9 @@ INSERT INTO temp (a, b, c, d, e, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u,
'(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]', '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', '["current" "infinity"]',
'1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}'); '1/3', '1,name', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}');
SELECT * FROM temp; SELECT * FROM tmp;
DROP TABLE temp; DROP TABLE tmp;
-- --
......
...@@ -72,7 +72,7 @@ SELECT onek.unique1, onek.string4 ...@@ -72,7 +72,7 @@ SELECT onek.unique1, onek.string4
-- ORDER BY stringu1 using <; -- ORDER BY stringu1 using <;
SELECT two, stringu1, ten, string4 SELECT two, stringu1, ten, string4
INTO TABLE temp INTO TABLE tmp
FROM onek; FROM onek;
-- --
......
-- --
-- awk '{print $3;}' onek.data | sort -n | uniq -- awk '{print $3;}' onek.data | sort -n | uniq
-- --
SELECT DISTINCT two FROM temp; SELECT DISTINCT two FROM tmp;
-- --
-- awk '{print $5;}' onek.data | sort -n | uniq -- awk '{print $5;}' onek.data | sort -n | uniq
-- --
SELECT DISTINCT ten FROM temp; SELECT DISTINCT ten FROM tmp;
-- --
-- awk '{print $16;}' onek.data | sort -d | uniq -- awk '{print $16;}' onek.data | sort -d | uniq
-- --
SELECT DISTINCT string4 FROM temp; SELECT DISTINCT string4 FROM tmp;
-- --
-- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | -- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq |
-- sort +0n -1 +1d -2 +2n -3 -- sort +0n -1 +1d -2 +2n -3
-- --
SELECT DISTINCT two, string4, ten SELECT DISTINCT two, string4, ten
FROM temp FROM tmp
ORDER BY two using <, string4 using <, ten using <; ORDER BY two using <, string4 using <, ten using <;
-- --
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
-- test select distinct on -- test select distinct on
-- --
SELECT DISTINCT ON string4 two, string4, ten SELECT DISTINCT ON string4 two, string4, ten
FROM temp FROM tmp
ORDER BY two using <, string4 using <, ten using <; ORDER BY two using <, string4 using <, ten using <;
SELECT * SELECT *
INTO TABLE temp1 INTO TABLE tmp1
FROM temp FROM tmp
WHERE onek.unique1 < 2; WHERE onek.unique1 < 2;
DROP TABLE temp1; DROP TABLE tmp1;
SELECT * SELECT *
INTO TABLE temp1 INTO TABLE tmp1
FROM temp FROM tmp
WHERE onek2.unique1 < 2; WHERE onek2.unique1 < 2;
DROP TABLE temp1; DROP TABLE tmp1;
--
-- Test temp relations and indexes
--
-- test temp table/index masking
CREATE TABLE temptest(col int);
CREATE INDEX i_temptest ON temptest(col);
CREATE TEMP TABLE temptest(col int);
CREATE INDEX i_temptest ON temptest(col);
DROP INDEX i_temptest;
DROP TABLE temptest;
DROP INDEX i_temptest;
DROP TABLE temptest;
-- test temp table selects
CREATE TABLE temptest(col int);
INSERT INTO temptest VALUES (1);
CREATE TEMP TABLE temptest(col int);
INSERT INTO temptest VALUES (2);
SELECT * FROM temptest;
DROP TABLE temptest;
SELECT * FROM temptest;
DROP TABLE temptest;
CREATE TEMP TABLE temptest(col int);
-- test temp table deletion
\c regression
SELECT * FROM temptest;
...@@ -64,3 +64,4 @@ portals_p2 ...@@ -64,3 +64,4 @@ portals_p2
rules rules
install_plpgsql install_plpgsql
plpgsql plpgsql
temp
#!/bin/sh #!/bin/sh
trap "rm -f /tmp/$$" 0 1 2 3 15 trap "rm -f /tmp/$$" 0 1 2 3 15
rm -f ./tags rm -f ./tags
find `pwd`/ -type f -name '*.[chyl]' -print|xargs ctags -t -a -f tags find `pwd`/ -type f -name '*.[chyl]' -print|xargs ctags -d -t -a -f tags
sort tags >/tmp/$$ && mv /tmp/$$ tags sort tags >/tmp/$$ && mv /tmp/$$ tags
find . -type d -print |while read DIR find . -type d -print |while read DIR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment