Included all yacc and lex files into the distribution.

This commit is contained in:
Peter Eisentraut 2000-01-16 20:05:00 +00:00
parent a4e1304ed1
commit 759fba4873
19 changed files with 824 additions and 556 deletions

View File

@ -176,67 +176,6 @@ Ftp file
</Para> </Para>
</Step> </Step>
<Step Performance="required">
<Para>
Some platforms use <application>flex</application>.
If your system uses <application>flex</application> then make sure
you have a good version. To check, type
<programlisting>
$ flex --version
</programlisting>
</Para>
<Para>
If the <application>flex</application> command is not found then you probably do not need it.
If the version is 2.5.2 or 2.5.4 or greater then you are okay. If it
is 2.5.3 or before 2.5.2 then you will have to upgrade <application>flex</application>. You may
get it at
<ulink url="ftp://prep.ai.mit.edu/pub/gnu/flex-2.5.4.tar.gz">ftp://prep.ai.mit.edu/pub/gnu/flex-2.5.4.tar.gz</ulink>.
</Para>
<Para>
If you need <application>flex</application> and don't have it or have the wrong version, then
you will be told so when you attempt to compile the program. Feel
free to skip this step if you aren't sure you need it. If you do
need it then you will be told to install/upgrade <application>flex</application> when you try to
compile <productname>Postgres</productname>.
</Para>
<Para>
You may want to do the entire <application>flex</application> installation from
the root account, though that is not absolutely necessary.
Assuming that you want the installation to place files in the usual default
areas, type the following:
<ProgramListing>
$ su -
$ cd /usr/local/src
ftp prep.ai.mit.edu
ftp> cd /pub/gnu/
ftp> binary
ftp> get flex-2.5.4.tar.gz
ftp> quit
$ gunzip -c flex-2.5.4.tar.gz | tar xvf -
$ cd flex-2.5.4
$ configure --prefix=/usr
$ gmake
$ gmake check
# You must be root when typing the next line:
$ gmake install
$ cd /usr/local/src
$ rm -rf flex-2.5.4
</ProgramListing>
</Para>
<Para>
This will update files <filename>/usr/man/man1/flex.1</filename>,
<filename>/usr/bin/flex</filename>,
<filename>/usr/lib/libfl.a</filename>,
<filename>/usr/include/FlexLexer.h</filename> and will add a link
<filename>/usr/bin/flex++</filename> which points to flex.
</Para>
</Step>
<Step Performance="required"> <Step Performance="required">
<Para> <Para>
If you are not upgrading an existing system then skip to If you are not upgrading an existing system then skip to

View File

@ -7,7 +7,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.47 2000/01/09 07:53:52 tgl Exp $ # $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.48 2000/01/16 20:04:51 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -24,7 +24,6 @@ ETAGS = @etags@
XARGS = @xargs@ XARGS = @xargs@
all: all:
$(MAKE) lexverify
$(MAKE) -C utils all $(MAKE) -C utils all
$(MAKE) -C backend all $(MAKE) -C backend all
$(MAKE) -C interfaces all $(MAKE) -C interfaces all
@ -35,7 +34,6 @@ all:
fi fi
install: install:
$(MAKE) lexverify
$(MAKE) -C utils install $(MAKE) -C utils install
$(MAKE) -C backend install $(MAKE) -C backend install
$(MAKE) -C interfaces install $(MAKE) -C interfaces install
@ -43,19 +41,7 @@ install:
$(MAKE) -C pl install $(MAKE) -C pl install
cat ../register.txt cat ../register.txt
lexverify:
$(MAKE) -C lextest all
@if test ! -f lextest/lextest; then \
echo "";\
echo "You have a buggy version of flex. Read INSTALL and search for flex for a fix.";\
echo "";\
false;\
else \
true;\
fi
clean: clean:
$(MAKE) -C lextest clean
$(MAKE) -C utils clean $(MAKE) -C utils clean
$(MAKE) -C backend clean $(MAKE) -C backend clean
$(MAKE) -C interfaces clean $(MAKE) -C interfaces clean
@ -108,7 +94,6 @@ distclean: clean
test/regress/GNUmakefile test/regress/GNUmakefile
.DEFAULT: .DEFAULT:
$(MAKE) -C lextest $@
$(MAKE) -C utils $@ $(MAKE) -C utils $@
$(MAKE) -C backend $@ $(MAKE) -C backend $@
$(MAKE) -C interfaces $@ $(MAKE) -C interfaces $@

View File

@ -4,7 +4,7 @@
# Makefile for the bootstrap module # Makefile for the bootstrap module
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.19 1999/12/16 16:52:46 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.20 2000/01/16 20:04:53 petere Exp $
# #
# #
# We must build bootparse.c and bootscanner.c with yacc and lex and sed, # We must build bootparse.c and bootscanner.c with yacc and lex and sed,
@ -68,7 +68,7 @@ bootscanner.c: bootscanner.l
rm -f lex.yy.c sedfile rm -f lex.yy.c sedfile
clean: clean:
rm -f SUBSYS.o $(OBJS) bootparse.c bootstrap_tokens.h bootscanner.c rm -f SUBSYS.o $(OBJS)
# And the garbage that might have been left behind by partial build: # And the garbage that might have been left behind by partial build:
rm -f y.tab.h y.tab.c y.output lex.yy.c rm -f y.tab.h y.tab.c y.output lex.yy.c

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.34 2000/01/15 02:59:28 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.35 2000/01/16 20:04:54 petere Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
@ -444,8 +444,8 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
} }
int32 int32
pg_ownercheck(char *usename, pg_ownercheck(const char *usename,
char *value, const char *value,
int cacheid) int cacheid)
{ {
HeapTuple tuple; HeapTuple tuple;

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.27 2000/01/15 02:59:28 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.28 2000/01/16 20:04:54 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -26,7 +26,7 @@
* Perhaps this should be in-line code in relopen(). * Perhaps this should be in-line code in relopen().
*/ */
char * char *
relpath(char *relname) relpath(const char *relname)
{ {
char *path; char *path;
size_t bufsize = 0; size_t bufsize = 0;
@ -52,7 +52,7 @@ relpath(char *relname)
* XXX this is way bogus. -- pma * XXX this is way bogus. -- pma
*/ */
bool bool
IsSystemRelationName(char *relname) IsSystemRelationName(const char *relname)
{ {
if (relname[0] && relname[1] && relname[2]) if (relname[0] && relname[1] && relname[2])
return (relname[0] == 'p' && return (relname[0] == 'p' &&
@ -67,7 +67,7 @@ IsSystemRelationName(char *relname)
* True iff name is the name of a shared system catalog relation. * True iff name is the name of a shared system catalog relation.
*/ */
bool bool
IsSharedSystemRelationName(char *relname) IsSharedSystemRelationName(const char *relname)
{ {
int i; int i;

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.62 1999/12/20 10:40:41 wieck Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.63 2000/01/16 20:04:55 petere Exp $
* *
* NOTES * NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated * The PortalExecutorHeapMemory crap needs to be eliminated
@ -23,13 +23,16 @@
#include "postgres.h" #include "postgres.h"
#include "access/heapam.h" #include "access/heapam.h"
#include "access/skey.h"
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "catalog/catname.h" #include "catalog/catname.h"
#include "catalog/indexing.h" #include "catalog/indexing.h"
#include "catalog/pg_attrdef.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/command.h" #include "commands/command.h"
#include "executor/execdefs.h" #include "executor/execdefs.h"
#include "executor/executor.h" #include "executor/executor.h"
#include "catalog/heap.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "optimizer/prep.h" #include "optimizer/prep.h"
#include "utils/acl.h" #include "utils/acl.h"
@ -37,6 +40,7 @@
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/temprel.h" #include "utils/temprel.h"
/* ---------------- /* ----------------
* PortalExecutorHeapMemory stuff * PortalExecutorHeapMemory stuff
* *
@ -246,7 +250,8 @@ PerformPortalClose(char *name, CommandDest dest)
} }
/* ---------------- /* ----------------
* PerformAddAttribute * AlterTableAddColumn
* (formerly known as PerformAddAttribute)
* *
* adds an additional attribute to a relation * adds an additional attribute to a relation
* *
@ -276,8 +281,7 @@ PerformPortalClose(char *name, CommandDest dest)
* ---------------- * ----------------
*/ */
void void
PerformAddAttribute(char *relationName, AlterTableAddColumn(const char *relationName,
char *userName,
bool inherits, bool inherits,
ColumnDef *colDef) ColumnDef *colDef)
{ {
@ -295,6 +299,7 @@ PerformAddAttribute(char *relationName,
Relation idescs[Num_pg_attr_indices]; Relation idescs[Num_pg_attr_indices];
Relation ridescs[Num_pg_class_indices]; Relation ridescs[Num_pg_class_indices];
bool hasindex; bool hasindex;
List *rawDefaults = NIL;
/* /*
* permissions checking. this would normally be done in utility.c, * permissions checking. this would normally be done in utility.c,
@ -303,19 +308,18 @@ PerformAddAttribute(char *relationName,
* normally, only the owner of a class can change its schema. * normally, only the owner of a class can change its schema.
*/ */
if (!allowSystemTableMods && IsSystemRelationName(relationName)) if (!allowSystemTableMods && IsSystemRelationName(relationName))
elog(ERROR, "PerformAddAttribute: class \"%s\" is a system catalog", elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
relationName); relationName);
#ifndef NO_SECURITY #ifndef NO_SECURITY
if (!pg_ownercheck(userName, relationName, RELNAME)) if (!pg_ownercheck(UserName, relationName, RELNAME))
elog(ERROR, "PerformAddAttribute: you do not own class \"%s\"", elog(ERROR, "ALTER TABLE: permission denied");
relationName);
#endif #endif
/* /*
* Grab an exclusive lock on the target table, which we will NOT release * Grab an exclusive lock on the target table, which we will NOT release
* until end of transaction. * until end of transaction.
*/ */
rel = heap_openr(relationName, AccessExclusiveLock); rel = heap_openr((char *)relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel); myrelid = RelationGetRelid(rel);
heap_close(rel, NoLock); /* close rel but keep lock! */ heap_close(rel, NoLock); /* close rel but keep lock! */
@ -324,8 +328,10 @@ PerformAddAttribute(char *relationName,
*/ */
if (colDef->is_not_null) if (colDef->is_not_null)
elog(ERROR, "Can't add a NOT NULL attribute to an existing relation"); elog(ERROR, "Can't add a NOT NULL attribute to an existing relation");
if (colDef->raw_default || colDef->cooked_default) if (colDef->raw_default || colDef->cooked_default)
elog(ERROR, "ADD ATTRIBUTE: DEFAULT not yet implemented"); elog(ERROR, "Adding columns with defaults is not implemented.");
/* /*
* if the first element in the 'schema' list is a "*" then we are * if the first element in the 'schema' list is a "*" then we are
@ -358,8 +364,8 @@ PerformAddAttribute(char *relationName,
if (childrelid == myrelid) if (childrelid == myrelid)
continue; continue;
rel = heap_open(childrelid, AccessExclusiveLock); rel = heap_open(childrelid, AccessExclusiveLock);
PerformAddAttribute(RelationGetRelationName(rel), AlterTableAddColumn(RelationGetRelationName(rel),
userName, false, colDef); false, colDef);
heap_close(rel, AccessExclusiveLock); heap_close(rel, AccessExclusiveLock);
} }
} }
@ -372,7 +378,7 @@ PerformAddAttribute(char *relationName,
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(reltup)) if (!HeapTupleIsValid(reltup))
elog(ERROR, "PerformAddAttribute: relation \"%s\" not found", elog(ERROR, "ALTER TABLE: relation \"%s\" not found",
relationName); relationName);
/* /*
@ -380,14 +386,14 @@ PerformAddAttribute(char *relationName,
*/ */
if (((Form_pg_class) GETSTRUCT(reltup))->relkind == RELKIND_INDEX) if (((Form_pg_class) GETSTRUCT(reltup))->relkind == RELKIND_INDEX)
{ {
elog(ERROR, "PerformAddAttribute: index relation \"%s\" not changed", elog(ERROR, "ALTER TABLE: index relation \"%s\" not changed",
relationName); relationName);
} }
minattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts; minattnum = ((Form_pg_class) GETSTRUCT(reltup))->relnatts;
maxatts = minattnum + 1; maxatts = minattnum + 1;
if (maxatts > MaxHeapAttributeNumber) if (maxatts > MaxHeapAttributeNumber)
elog(ERROR, "PerformAddAttribute: relations limited to %d attributes", elog(ERROR, "ALTER TABLE: relations limited to %d columns",
MaxHeapAttributeNumber); MaxHeapAttributeNumber);
attrdesc = heap_openr(AttributeRelationName, RowExclusiveLock); attrdesc = heap_openr(AttributeRelationName, RowExclusiveLock);
@ -421,7 +427,7 @@ PerformAddAttribute(char *relationName,
0, 0); 0, 0);
if (HeapTupleIsValid(tup)) if (HeapTupleIsValid(tup))
elog(ERROR, "PerformAddAttribute: attribute \"%s\" already exists in class \"%s\"", elog(ERROR, "ALTER TABLE: column name \"%s\" already exists in relation \"%s\"",
colDef->colname, relationName); colDef->colname, relationName);
/* /*
@ -444,7 +450,7 @@ PerformAddAttribute(char *relationName,
tform = (Form_pg_type) GETSTRUCT(typeTuple); tform = (Form_pg_type) GETSTRUCT(typeTuple);
if (!HeapTupleIsValid(typeTuple)) if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "Add: type \"%s\" nonexistent", typename); elog(ERROR, "ALTER TABLE: type \"%s\" does not exist", typename);
namestrcpy(&(attribute->attname), colDef->colname); namestrcpy(&(attribute->attname), colDef->colname);
attribute->atttypid = typeTuple->t_data->t_oid; attribute->atttypid = typeTuple->t_data->t_oid;
attribute->attlen = tform->typlen; attribute->attlen = tform->typlen;
@ -483,9 +489,223 @@ PerformAddAttribute(char *relationName,
CatalogCloseIndices(Num_pg_class_indices, ridescs); CatalogCloseIndices(Num_pg_class_indices, ridescs);
heap_freetuple(reltup); heap_freetuple(reltup);
heap_close(rel, RowExclusiveLock);
heap_close(rel, NoLock);
} }
static void drop_default(Oid relid, int16 attnum);
/*
* ALTER TABLE ALTER COLUMN SET/DROP DEFAULT
*/
void
AlterTableAlterColumn(const char *relationName,
bool inh, const char *colName,
Node *newDefault)
{
Relation rel;
HeapTuple tuple;
int16 attnum;
Oid myrelid;
if (!allowSystemTableMods && IsSystemRelationName(relationName))
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
relationName);
#ifndef NO_SECURITY
if (!pg_ownercheck(UserName, relationName, RELNAME))
elog(ERROR, "ALTER TABLE: permission denied");
#endif
/* XXX should heap_openr take const char * ? */
rel = heap_openr((char *)relationName, AccessExclusiveLock);
myrelid = RelationGetRelid(rel);
heap_close(rel, NoLock);
/*
* Propagate to children if desired
*/
if (inh)
{
List *child,
*children;
/* this routine is actually in the planner */
children = find_all_inheritors(myrelid);
/*
* find_all_inheritors does the recursive search of the
* inheritance hierarchy, so all we have to do is process all
* of the relids in the list that it returns.
*/
foreach(child, children)
{
Oid childrelid = lfirsti(child);
if (childrelid == myrelid)
continue;
rel = heap_open(childrelid, AccessExclusiveLock);
AlterTableAlterColumn(RelationGetRelationName(rel),
false, colName, newDefault);
heap_close(rel, AccessExclusiveLock);
}
}
/* -= now do the thing on this relation =- */
/* reopen the business */
rel = heap_openr((char *)relationName, AccessExclusiveLock);
/*
* get the number of the attribute
*/
tuple = SearchSysCacheTuple(ATTNAME,
ObjectIdGetDatum(myrelid),
NameGetDatum(namein((char *)colName)),
0, 0);
if (!HeapTupleIsValid(tuple))
{
heap_close(rel, AccessExclusiveLock);
elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"",
relationName, colName);
}
attnum = ((Form_pg_attribute) GETSTRUCT(tuple))->attnum;
if (newDefault) /* SET DEFAULT */
{
List* rawDefaults = NIL;
RawColumnDefault *rawEnt;
/* Get rid of the old one first */
drop_default(myrelid, attnum);
rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
rawEnt->attnum = attnum;
rawEnt->raw_default = newDefault;
rawDefaults = lappend(rawDefaults, rawEnt);
/*
* This function is intended for CREATE TABLE,
* so it processes a _list_ of defaults, but we just do one.
*/
AddRelationRawConstraints(rel, rawDefaults, NIL);
}
else /* DROP DEFAULT */
{
Relation attr_rel;
ScanKeyData scankeys[3];
HeapScanDesc scan;
HeapTuple tuple;
attr_rel = heap_openr(AttributeRelationName, AccessExclusiveLock);
ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attribute_attrelid, F_OIDEQ,
ObjectIdGetDatum(myrelid));
ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attribute_attnum, F_INT2EQ,
Int16GetDatum(attnum));
ScanKeyEntryInitialize(&scankeys[2], 0x0, Anum_pg_attribute_atthasdef, F_BOOLEQ,
TRUE);
scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
AssertState(scan!=NULL);
if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
{
HeapTuple newtuple;
Relation irelations[Num_pg_attr_indices];
/* update to false */
newtuple = heap_copytuple(tuple);
((Form_pg_attribute) GETSTRUCT(newtuple))->atthasdef = FALSE;
heap_update(attr_rel, &tuple->t_self, newtuple, NULL);
/* keep the system catalog indices current */
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
CatalogIndexInsert(irelations, Num_pg_attr_indices, attr_rel, newtuple);
CatalogCloseIndices(Num_pg_class_indices, irelations);
/* get rid of actual default definition */
drop_default(myrelid, attnum);
}
else
elog(NOTICE, "ALTER TABLE: there was no default on column \"%s\" of relation \"%s\"",
colName, relationName);
heap_endscan(scan);
heap_close(attr_rel, NoLock);
}
heap_close(rel, NoLock);
}
static void
drop_default(Oid relid, int16 attnum)
{
ScanKeyData scankeys[2];
HeapScanDesc scan;
Relation attrdef_rel;
HeapTuple tuple;
attrdef_rel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
ObjectIdGetDatum(relid));
ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum, F_INT2EQ,
Int16GetDatum(attnum));
scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
AssertState(scan!=NULL);
if (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
heap_delete(attrdef_rel, &tuple->t_self, NULL);
heap_endscan(scan);
heap_close(attrdef_rel, NoLock);
}
/*
* ALTER TABLE DROP COLUMN
*/
void
AlterTableDropColumn(const char *relationName,
bool inh, const char *colName,
int behavior)
{
elog(NOTICE, "ALTER TABLE / DROP COLUMN is not implemented");
}
void
AlterTableAddConstraint(const char *relationName,
bool inh, Node *newConstraint)
{
elog(NOTICE, "ALTER TABLE / ADD CONSTRAINT is not implemented");
}
void AlterTableDropConstraint(const char *relationName,
bool inh, const char *constrName,
int behavior)
{
elog(NOTICE, "ALTER TABLE / DROP CONSTRAINT is not implemented");
}
/*
*
* LOCK TABLE
*
*/
void void
LockTableCommand(LockStmt *lockstmt) LockTableCommand(LockStmt *lockstmt)
{ {

View File

@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.126 2000/01/15 02:59:32 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.127 2000/01/16 20:04:55 petere Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
@ -114,7 +114,7 @@ static Node *doNegate(Node *n);
} }
%type <node> stmt, %type <node> stmt,
AddAttrStmt, ClosePortalStmt, AlterTableStmt, ClosePortalStmt,
CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DropStmt, CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DropStmt,
TruncateStmt, CommentStmt, TruncateStmt, CommentStmt,
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt, ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
@ -130,6 +130,9 @@ static Node *doNegate(Node *n);
RuleActionStmtOrEmpty, ConstraintsSetStmt, RuleActionStmtOrEmpty, ConstraintsSetStmt,
CreateGroupStmt, AlterGroupStmt, DropGroupStmt CreateGroupStmt, AlterGroupStmt, DropGroupStmt
%type <node> alter_column_action
%type <ival> drop_behavior
%type <str> createdb_opt_location %type <str> createdb_opt_location
%type <ival> createdb_opt_encoding %type <ival> createdb_opt_encoding
@ -210,7 +213,7 @@ static Node *doNegate(Node *n);
%type <astmt> insert_rest %type <astmt> insert_rest
%type <node> OptTableElement, ConstraintElem %type <node> OptTableElement, ConstraintElem
%type <node> columnDef, alter_clause %type <node> columnDef
%type <defelt> def_elem %type <defelt> def_elem
%type <node> def_arg, columnElem, where_clause, %type <node> def_arg, columnElem, where_clause,
a_expr, a_expr_or_null, b_expr, com_expr, AexprConst, a_expr, a_expr_or_null, b_expr, com_expr, AexprConst,
@ -391,7 +394,7 @@ stmtmulti: stmtmulti ';' stmt
} }
; ;
stmt : AddAttrStmt stmt : AlterTableStmt
| AlterGroupStmt | AlterGroupStmt
| AlterUserStmt | AlterUserStmt
| ClosePortalStmt | ClosePortalStmt
@ -797,40 +800,74 @@ constraints_set_mode: DEFERRED
/***************************************************************************** /*****************************************************************************
* *
* QUERY : * ALTER TABLE variations
* addattr ( attr1 = type1 .. attrn = typen ) to <relname> [*]
* *
*****************************************************************************/ *****************************************************************************/
AddAttrStmt: ALTER TABLE relation_name opt_inh_star alter_clause AlterTableStmt:
{ /* ALTER TABLE <name> ADD [COLUMN] <coldef> */
AddAttrStmt *n = makeNode(AddAttrStmt); ALTER TABLE relation_name opt_inh_star ADD opt_column columnDef
n->relname = $3; {
n->inh = $4; AlterTableStmt *n = makeNode(AlterTableStmt);
n->colDef = $5; n->subtype = 'A';
$$ = (Node *)n; n->relname = $3;
} n->inh = $4;
; n->def = $7;
$$ = (Node *)n;
}
/* ALTER TABLE <name> ALTER [COLUMN] <colname> {SET DEFAULT <expr>|DROP DEFAULT} */
| ALTER TABLE relation_name opt_inh_star ALTER opt_column ColId alter_column_action
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'T';
n->relname = $3;
n->inh = $4;
n->name = $7;
n->def = $8;
$$ = (Node *)n;
}
/* ALTER TABLE <name> DROP [COLUMN] <name> {RESTRICT|CASCADE} */
| ALTER TABLE relation_name opt_inh_star DROP opt_column ColId drop_behavior
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->relname = $3;
n->inh = $4;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
}
/* ALTER TABLE <name> ADD CONSTRAINT ... */
| ALTER TABLE relation_name opt_inh_star ADD TableConstraint
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'A';
n->relname = $3;
n->inh = $4;
n->def = $6;
$$ = (Node *)n;
}
/* ALTER TABLE <name> DROP CONSTRAINT <name> {RESTRICT|CASCADE} */
| ALTER TABLE relation_name opt_inh_star DROP CONSTRAINT name drop_behavior
{
AlterTableStmt *n = makeNode(AlterTableStmt);
n->relname = $3;
n->inh = $4;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
}
;
alter_column_action:
SET DEFAULT a_expr_or_null { $$ = $3; }
| DROP DEFAULT { $$ = NULL; }
;
drop_behavior: CASCADE { $$ = CASCADE; }
| RESTRICT { $$ = RESTRICT; }
;
alter_clause: ADD opt_column columnDef
{
$$ = $3;
}
| ADD '(' OptTableElementList ')'
{
if (length($3) != 1)
elog(ERROR,"ALTER TABLE/ADD() allows one column only");
$$ = (Node *) lfirst($3);
}
| DROP opt_column ColId
{ elog(ERROR,"ALTER TABLE/DROP COLUMN not yet implemented"); }
| ALTER opt_column ColId SET DEFAULT a_expr
{ elog(ERROR,"ALTER TABLE/ALTER COLUMN/SET DEFAULT not yet implemented"); }
| ALTER opt_column ColId DROP DEFAULT
{ elog(ERROR,"ALTER TABLE/ALTER COLUMN/DROP DEFAULT not yet implemented"); }
| ADD ConstraintElem
{ elog(ERROR,"ALTER TABLE/ADD CONSTRAINT not yet implemented"); }
;
/***************************************************************************** /*****************************************************************************

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.79 2000/01/15 18:30:30 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.80 2000/01/16 20:04:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -270,24 +270,6 @@ ProcessUtility(Node *parsetree,
} }
break; break;
case T_AddAttrStmt:
{
AddAttrStmt *stmt = (AddAttrStmt *) parsetree;
PS_SET_STATUS(commandTag = "ADD");
CHECK_IF_ABORTED();
/*
* owner checking done in PerformAddAttribute (now
* recursive)
*/
PerformAddAttribute(stmt->relname,
userName,
stmt->inh,
(ColumnDef *) stmt->colDef);
}
break;
/* /*
* schema * schema
*/ */
@ -346,6 +328,44 @@ ProcessUtility(Node *parsetree,
} }
break; break;
/* various Alter Table forms */
case T_AlterTableStmt:
{
AlterTableStmt *stmt = (AlterTableStmt *) parsetree;
PS_SET_STATUS(commandTag = "ALTER TABLE");
CHECK_IF_ABORTED();
/*
* Some or all of these functions are recursive to cover inherited things,
* so permission checks are done there.
*/
switch(stmt->subtype)
{
case 'A': /* ADD COLUMN */
AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def);
break;
case 'T': /* ALTER COLUMN */
AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def);
break;
case 'D': /* ALTER DROP */
AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
break;
case 'C': /* ADD CONSTRAINT */
AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def);
break;
case 'X': /* DROP CONSTRAINT */
AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
break;
default: /* oops */
elog(ERROR, "T_AlterTableStmt: unknown subtype");
break;
}
}
break;
case T_ChangeACLStmt: case T_ChangeACLStmt:
{ {
ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree; ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree;

View File

@ -268,8 +268,9 @@ MainLoop(FILE *source, int encoding)
/* colon -> substitute variable */ /* colon -> substitute variable */
/* we need to be on the watch for the '::' operator */ /* we need to be on the watch for the '::' operator */
else if (line[i] == ':' && !was_bslash && else if (line[i] == ':' && !was_bslash
strspn(line+i+thislen, VALID_VARIABLE_CHARS)>0 && strspn(line+i+thislen, VALID_VARIABLE_CHARS)>0
&& !(prevlen>0 && line[i-prevlen] == ':')
) )
{ {
size_t in_length, size_t in_length,

740
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -545,6 +545,20 @@ AC_SUBST(DASH_N)
AC_SUBST(BACKSLASH_C) AC_SUBST(BACKSLASH_C)
AC_PROG_LEX AC_PROG_LEX
if test "$LEX" = "flex"; then
$LEX --version 2> /dev/null | grep -s '2\.5\.3' >& /dev/null
if test $? -eq 0 ; then
AC_MSG_WARN([
***
You have flex version 2.5.3, which is broken. Get version 2.5.4 or
a different lex.
(If you are using the official distribution of PostgreSQL then you
do not need to worry about this because the lexer files are
pre-generated. However, other software using flex is likely to be
broken as well.)
***])
fi
fi
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_PROG_RANLIB AC_PROG_RANLIB

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: catalog.h,v 1.8 1999/07/15 23:03:41 momjian Exp $ * $Id: catalog.h,v 1.9 2000/01/16 20:04:57 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -15,9 +15,9 @@
#include "access/tupdesc.h" #include "access/tupdesc.h"
extern char *relpath(char *relname); extern char *relpath(const char *relname);
extern bool IsSystemRelationName(char *relname); extern bool IsSystemRelationName(const char *relname);
extern bool IsSharedSystemRelationName(char *relname); extern bool IsSharedSystemRelationName(const char *relname);
extern Oid newoid(void); extern Oid newoid(void);
extern void fillatt(TupleDesc att); extern void fillatt(TupleDesc att);

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: command.h,v 1.15 1999/07/15 23:03:44 momjian Exp $ * $Id: command.h,v 1.16 2000/01/16 20:04:58 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -38,12 +38,29 @@ extern void PerformPortalClose(char *name, CommandDest dest);
extern void PortalCleanup(Portal portal); extern void PortalCleanup(Portal portal);
/* /*
* PerformAddAttribute * ALTER TABLE variants
* Performs the POSTQUEL function ADD.
*/ */
extern void PerformAddAttribute(char *relationName, char *userName, extern void AlterTableAddColumn(const char *relationName,
bool inh, ColumnDef *colDef); bool inh, ColumnDef *colDef);
extern void AlterTableAlterColumn(const char *relationName,
bool inh, const char *colName,
Node *newDefault);
extern void AlterTableDropColumn(const char *relationName,
bool inh, const char *colName,
int behavior);
extern void AlterTableAddConstraint(const char *relationName,
bool inh, Node *newConstraint);
extern void AlterTableDropConstraint(const char *relationName,
bool inh, const char *constrName,
int behavior);
/*
* LOCK
*/
extern void LockTableCommand(LockStmt *lockstmt); extern void LockTableCommand(LockStmt *lockstmt);
#endif /* COMMAND_H */ #endif /* COMMAND_H */

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: nodes.h,v 1.60 2000/01/09 00:26:42 tgl Exp $ * $Id: nodes.h,v 1.61 2000/01/16 20:04:58 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -145,7 +145,7 @@ typedef enum NodeTag
T_DeleteStmt, T_DeleteStmt,
T_UpdateStmt, T_UpdateStmt,
T_SelectStmt, T_SelectStmt,
T_AddAttrStmt, T_AlterTableStmt,
T_AggregateStmt, T_AggregateStmt,
T_ChangeACLStmt, T_ChangeACLStmt,
T_ClosePortalStmt, T_ClosePortalStmt,

View File

@ -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.93 2000/01/14 22:11:38 petere Exp $ * $Id: parsenodes.h,v 1.94 2000/01/16 20:04:58 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -84,16 +84,20 @@ typedef struct Query
*****************************************************************************/ *****************************************************************************/
/* ---------------------- /* ----------------------
* Add Column Statement * Alter Table
* ---------------------- * ----------------------
*/ */
typedef struct AddAttrStmt /* The fields are used in different ways by the different variants of this command */
typedef struct AlterTableStmt
{ {
NodeTag type; NodeTag type;
char *relname; /* the relation to add attr */ char subtype; /* A = add, T = alter, D = drop, C = add constr, X = drop constr */
bool inh; /* add recursively to children? */ char *relname; /* table to work on */
Node *colDef; /* the attribute definition */ bool inh; /* recursively on children? */
} AddAttrStmt; char *name; /* column or constraint name to act on */
Node *def; /* definition of new column or constraint */
int behavior; /* CASCADE or RESTRICT drop behavior */
} AlterTableStmt;
/* ---------------------- /* ----------------------
* Change ACL Statement * Change ACL Statement

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: acl.h,v 1.22 1999/07/15 23:04:19 momjian Exp $ * $Id: acl.h,v 1.23 2000/01/16 20:04:59 petere Exp $
* *
* NOTES * NOTES
* For backward-compatability purposes we have to allow there * For backward-compatability purposes we have to allow there
@ -168,7 +168,7 @@ extern AclId get_grosysid(char *groname);
extern char *get_groname(AclId grosysid); extern char *get_groname(AclId grosysid);
extern int32 pg_aclcheck(char *relname, char *usename, AclMode mode); extern int32 pg_aclcheck(char *relname, char *usename, AclMode mode);
extern int32 pg_ownercheck(char *usename, char *value, int cacheid); extern int32 pg_ownercheck(const char *usename, const char *value, int cacheid);
extern int32 pg_func_ownercheck(char *usename, char *funcname, extern int32 pg_func_ownercheck(char *usename, char *funcname,
int nargs, Oid *arglist); int nargs, Oid *arglist);
extern int32 pg_aggr_ownercheck(char *usename, char *aggname, extern int32 pg_aggr_ownercheck(char *usename, char *aggname,

View File

@ -4,7 +4,7 @@
# Makefile for the plpgsql shared object # Makefile for the plpgsql shared object
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.18 1999/10/13 11:38:40 momjian Exp $ # $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/Makefile.in,v 1.19 2000/01/16 20:04:59 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -79,6 +79,6 @@ pl_scan.c: scan.l
clean: clean-shlib clean: clean-shlib
rm -f lib$(NAME).a rm -f lib$(NAME).a
rm -f *.o pl.tab.h pl_gram.c pl_scan.c rm -f *.o
# And the garbage that might have been left behind by partial build: # And the garbage that might have been left behind by partial build:
rm -f y.tab.c y.tab.h lex.yy.c rm -f y.tab.c y.tab.h lex.yy.c

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.6 2000/01/09 20:54:36 tgl Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.7 2000/01/16 20:05:00 petere Exp $
# ---------- # ----------
# Check call syntax # Check call syntax
@ -37,6 +37,16 @@ export LOGDIR
export TIMDIR export TIMDIR
export PGPORT export PGPORT
# Needed by psql and pg_encoding (if you run multibyte).
# I hope this covers all platforms with shared libraries,
# otherwise feel free to cover your platform here as well.
if [ "$LD_LIBRARY_PATH" ]; then
old_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="$LIBDIR:$LD_LIBARY_PATH"
else
LD_LIBRARY_PATH="$LIBDIR"
fi
export LD_LIBRARY_PATH
# ---------- # ----------
# Get the commandline parameters # Get the commandline parameters
@ -111,6 +121,7 @@ trap ' echo ""
echo "" echo ""
fi fi
echo "" echo ""
LD_LIBRARY_PATH="$old_LD_LIBRARY_PATH"
exit 1 exit 1
' 2 15 ' 2 15
@ -434,5 +445,6 @@ done | tee run_check.out 2>&1
echo "=============== Terminating regression postmaster ================" echo "=============== Terminating regression postmaster ================"
kill -15 $PMPID kill -15 $PMPID
LD_LIBRARY_PATH="$old_LD_LIBRARY_PATH"
exit 0 exit 0

View File

@ -31,34 +31,39 @@ cd src
./configure ./configure
# Generate parser's gram and lex files. # Generate parser's yacc and lex files
cd backend/parser cd backend/parser
rm -f gram.c parse.h scan.c rm -f gram.c parse.h scan.c
$MAKE gram.c parse.h scan.c $MAKE gram.c parse.h scan.c
cd ../.. cd ../..
# Generate ecpg preprocessor's gram and lex files. # Generate bootstrap parser's yacc and lex files
cd backend/bootstrap
rm -f bootstrap_tokens.h bootparse.c bootscanner.c
$MAKE bootstrap_tokens.h bootparse.c bootscanner.c
cd ../..
# Generate ecpg preprocessor's yacc and lex files
cd interfaces/ecpg/preproc cd interfaces/ecpg/preproc
rm -f preproc.c preproc.h pgc.c rm -f preproc.c preproc.h pgc.c
$MAKE preproc.c preproc.h pgc.c $MAKE preproc.c preproc.h pgc.c
cd ../../.. cd ../../..
# Generate plpgsql's yacc and lex files
cd pl/plpgsql
rm -rf pl_scan.c pl.tab.h pl_gram.c
$MAKE pl_scan.c pl.tab.h pl_gram.c
cd ../..
# Generate psql's help on SQL command from the SGML docs # Generate psql's help on SQL command from the SGML docs
cd bin/psql cd bin/psql
rm -f sql_help.h rm -f sql_help.h
$MAKE sql_help.h $MAKE sql_help.h
cd ../.. cd ../..
# Clean up # Clean up