? GNUmakefile
? config.log
? config.status
? contrib/spi/.deps
? src/Makefile.global
? src/backend/postgres
? src/backend/access/common/.deps
? src/backend/access/gist/.deps
? src/backend/access/hash/.deps
? src/backend/access/heap/.deps
? src/backend/access/index/.deps
? src/backend/access/nbtree/.deps
? src/backend/access/rtree/.deps
? src/backend/access/transam/.deps
? src/backend/bootstrap/.deps
? src/backend/catalog/.deps
? src/backend/catalog/postgres.bki
? src/backend/catalog/postgres.description
? src/backend/commands/.deps
? src/backend/executor/.deps
? src/backend/lib/.deps
? src/backend/libpq/.deps
? src/backend/main/.deps
? src/backend/nodes/.deps
? src/backend/optimizer/geqo/.deps
? src/backend/optimizer/path/.deps
? src/backend/optimizer/plan/.deps
? src/backend/optimizer/prep/.deps
? src/backend/optimizer/util/.deps
? src/backend/parser/.deps
? src/backend/port/.deps
? src/backend/postmaster/.deps
? src/backend/regex/.deps
? src/backend/rewrite/.deps
? src/backend/storage/buffer/.deps
? src/backend/storage/file/.deps
? src/backend/storage/freespace/.deps
? src/backend/storage/ipc/.deps
? src/backend/storage/large_object/.deps
? src/backend/storage/lmgr/.deps
? src/backend/storage/page/.deps
? src/backend/storage/smgr/.deps
? src/backend/tcop/.deps
? src/backend/utils/.deps
? src/backend/utils/adt/.deps
? src/backend/utils/cache/.deps
? src/backend/utils/error/.deps
? src/backend/utils/fmgr/.deps
? src/backend/utils/hash/.deps
? src/backend/utils/init/.deps
? src/backend/utils/mb/.deps
? src/backend/utils/mb/conversion_procs/conversion_create.sql
? src/backend/utils/mb/conversion_procs/ascii_and_mic/.deps
? src/backend/utils/mb/conversion_procs/ascii_and_mic/libascii_and_mic.so.0
? src/backend/utils/mb/conversion_procs/cyrillic_and_mic/.deps
? src/backend/utils/mb/conversion_procs/cyrillic_and_mic/libcyrillic_and_mic.so.0
? src/backend/utils/mb/conversion_procs/euc_cn_and_mic/.deps
? src/backend/utils/mb/conversion_procs/euc_cn_and_mic/libeuc_cn_and_mic.so.0
? src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/.deps
? src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/libeuc_jp_and_sjis.so.0
? src/backend/utils/mb/conversion_procs/euc_kr_and_mic/.deps
? src/backend/utils/mb/conversion_procs/euc_kr_and_mic/libeuc_kr_and_mic.so.0
? src/backend/utils/mb/conversion_procs/euc_tw_and_big5/.deps
? src/backend/utils/mb/conversion_procs/euc_tw_and_big5/libeuc_tw_and_big5.so.0
? src/backend/utils/mb/conversion_procs/latin2_and_win1250/.deps
? src/backend/utils/mb/conversion_procs/latin2_and_win1250/liblatin2_and_win1250.so.0
? src/backend/utils/mb/conversion_procs/latin_and_mic/.deps
? src/backend/utils/mb/conversion_procs/latin_and_mic/liblatin_and_mic.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_ascii/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_ascii/libutf8_and_ascii.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_big5/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_big5/libutf8_and_big5.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/libutf8_and_cyrillic.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/libutf8_and_euc_cn.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/libutf8_and_euc_jp.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/libutf8_and_euc_kr.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/libutf8_and_euc_tw.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_gb18030/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_gb18030/libutf8_and_gb18030.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_gbk/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_gbk/libutf8_and_gbk.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859/libutf8_and_iso8859.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/libutf8_and_iso8859_1.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_johab/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_johab/libutf8_and_johab.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_sjis/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_sjis/libutf8_and_sjis.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_tcvn/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_tcvn/libutf8_and_tcvn.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_uhc/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_uhc/libutf8_and_uhc.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_win1250/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_win1250/libutf8_and_win1250.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_win1256/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_win1256/libutf8_and_win1256.so.0
? src/backend/utils/mb/conversion_procs/utf8_and_win874/.deps
? src/backend/utils/mb/conversion_procs/utf8_and_win874/libutf8_and_win874.so.0
? src/backend/utils/misc/.deps
? src/backend/utils/mmgr/.deps
? src/backend/utils/sort/.deps
? src/backend/utils/time/.deps
? src/bin/initdb/initdb
? src/bin/initlocation/initlocation
? src/bin/ipcclean/ipcclean
? src/bin/pg_config/pg_config
? src/bin/pg_controldata/.deps
? src/bin/pg_controldata/pg_controldata
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/.deps
? src/bin/pg_dump/pg_dump
? src/bin/pg_dump/pg_dumpall
? src/bin/pg_dump/pg_restore
? src/bin/pg_encoding/.deps
? src/bin/pg_encoding/pg_encoding
? src/bin/pg_id/.deps
? src/bin/pg_id/pg_id
? src/bin/pg_resetxlog/.deps
? src/bin/pg_resetxlog/pg_resetxlog
? src/bin/psql/.deps
? src/bin/psql/psql
? src/bin/scripts/createlang
? src/include/pg_config.h
? src/include/stamp-h
? src/interfaces/ecpg/lib/.deps
? src/interfaces/ecpg/lib/libecpg.so.3
? src/interfaces/ecpg/preproc/.deps
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/libpq/.deps
? src/interfaces/libpq/libpq.so.3
? src/pl/plpgsql/src/.deps
? src/pl/plpgsql/src/libplpgsql.so.1
? src/port/.deps
? src/test/regress/.deps
? src/test/regress/log
? src/test/regress/pg_regress
? src/test/regress/results
? src/test/regress/tmp_check
? src/test/regress/expected/constraints.out
? src/test/regress/expected/copy.out
? src/test/regress/expected/create_function_1.out
? src/test/regress/expected/create_function_2.out
? src/test/regress/expected/misc.out
? src/test/regress/sql/constraints.sql
? src/test/regress/sql/copy.sql
? src/test/regress/sql/create_function_1.sql
? src/test/regress/sql/create_function_2.sql
? src/test/regress/sql/misc.sql
Index: doc/src/sgml/ref/alter_table.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/ref/alter_table.sgml,v
retrieving revision 1.53
diff -c -r1.53 alter_table.sgml
*** doc/src/sgml/ref/alter_table.sgml 2002/12/16 19:08:25 1.53
--- doc/src/sgml/ref/alter_table.sgml 2003/01/15 20:24:48
***************
*** 34,39 ****
--- 34,41 ----
ALTER TABLE [ ONLY ] table [ * ]
ALTER [ COLUMN ] column SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
ALTER TABLE [ ONLY ] table [ * ]
+ SET WITHOUT OIDS
+ ALTER TABLE [ ONLY ] table [ * ]
RENAME [ COLUMN ] column TO new_column
ALTER TABLE table
***************
*** 287,296 ****
RENAME
! The RENAME forms change the name of a table
(or an index, sequence, or view) or the name of an individual column in
a table. There is no effect on the stored data.
--- 289,311 ----
+ SET WITHOUT OIDS
+
+
+ Removes the OID column from the the table. Removing (setting without)
+ oids from a table also do not occur immediately. The space an OID
+ uses will be reclaimed when the tuple is updated. Without updating the tuple, both the
+ space and the value of the OID are maintained indefinitely. This is
+ semantically similar to the DROP COLUMN process.
+
+
+
+
+
RENAME
! The RENAME forms change the name of a table
(or an index, sequence, or view) or the name of an individual column in
a table. There is no effect on the stored data.
Index: src/backend/commands/tablecmds.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/tablecmds.c,v
retrieving revision 1.65
diff -c -r1.65 tablecmds.c
*** src/backend/commands/tablecmds.c 2003/01/08 22:06:23 1.65
--- src/backend/commands/tablecmds.c 2003/01/15 20:24:48
***************
*** 2136,2142 ****
heap_close(rel, NoLock);
}
-
/*
* ALTER TABLE ALTER COLUMN SET/DROP DEFAULT
*/
--- 2136,2141 ----
***************
*** 2386,2391 ****
--- 2385,2506 ----
heap_close(rel, NoLock); /* close rel, but keep lock! */
}
+ /*
+ * ALTER TABLE SET {WITHOUT} OIDS
+ */
+ void
+ AlterTableAlterOids(Oid myrelid, bool recurse, bool setOid)
+ {
+ Relation rel;
+ Relation class_rel;
+ HeapTuple tuple;
+ Form_pg_class tuple_class;
+
+ rel = heap_open(myrelid, AccessExclusiveLock);
+
+ if (rel->rd_rel->relkind != RELKIND_RELATION)
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table",
+ RelationGetRelationName(rel));
+
+ if (!allowSystemTableMods
+ && IsSystemRelation(rel))
+ elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
+ RelationGetRelationName(rel));
+
+ if (!pg_class_ownercheck(myrelid, GetUserId()))
+ aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(rel));
+
+
+ /* Get its pg_class tuple, too */
+ class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
+
+ tuple = SearchSysCacheCopy(RELOID,
+ ObjectIdGetDatum(myrelid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "ALTER TABLE: relation %u not found", myrelid);
+ tuple_class = (Form_pg_class) GETSTRUCT(tuple);
+
+ /* Can we change the ownership of this tuple? */
+ CheckTupleType(tuple_class);
+
+ /*
+ * Okay, this is a valid tuple: check it's hasoids flag
+ * to see if we actually need to change anything
+ */
+ if (tuple_class->relhasoids == setOid)
+ elog(ERROR, "ALTER TABLE: Table is already %s",
+ setOid ? "WITH OIDS" : "WITHOUT OIDS");
+
+ /*
+ * Propagate to children if desired
+ */
+ if (recurse)
+ {
+ 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;
+
+ AlterTableAlterOids(childrelid, false, setOid);
+ }
+ }
+
+
+ tuple_class->relhasoids = setOid;
+ simple_heap_update(class_rel, &tuple->t_self, tuple);
+
+ /* Keep the catalog indexes up to date */
+ CatalogUpdateIndexes(class_rel, tuple);
+
+
+
+ if (setOid)
+ /*
+ * TODO: Generate the now required OID pg_attribute entry
+ */
+ elog(ERROR, "ALTER TABLE WITH OIDS is unsupported");
+ else
+ {
+ HeapTuple atttup;
+ Relation attrel;
+
+ /* Add / Remove the oid record from pg_attribute */
+ attrel = heap_open(RelOid_pg_attribute, RowExclusiveLock);
+
+ /*
+ * Oids are being removed from the relation, so we need
+ * to remove the oid pg_attribute record relating.
+ */
+ atttup = SearchSysCache(ATTNUM,
+ ObjectIdGetDatum(myrelid),
+ ObjectIdAttributeNumber, 0, 0);
+ if (!HeapTupleIsValid(atttup))
+ elog(ERROR, "ALTER TABLE: relation %u doesn't have an Oid column to remove", myrelid);
+
+ simple_heap_delete(attrel, &atttup->t_self);
+
+ ReleaseSysCache(atttup);
+
+ heap_close(attrel, NoLock); /* close rel, but keep lock! */
+ }
+
+ heap_close(rel, NoLock); /* close rel, but keep lock! */
+ heap_close(class_rel, NoLock); /* close rel, but keep lock! */
+ }
/*
* ALTER TABLE DROP COLUMN
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/parser/gram.y,v
retrieving revision 2.395
diff -c -r2.395 gram.y
*** src/backend/parser/gram.y 2003/01/10 22:03:27 2.395
--- src/backend/parser/gram.y 2003/01/15 20:24:49
***************
*** 1134,1140 ****
| ALTER TABLE relation_expr ALTER opt_column ColId SET NOT NULL_P
{
AlterTableStmt *n = makeNode(AlterTableStmt);
! n->subtype = 'O';
n->relation = $3;
n->name = $6;
$$ = (Node *)n;
--- 1134,1140 ----
| ALTER TABLE relation_expr ALTER opt_column ColId SET NOT NULL_P
{
AlterTableStmt *n = makeNode(AlterTableStmt);
! n->subtype = 'n';
n->relation = $3;
n->name = $6;
$$ = (Node *)n;
***************
*** 1187,1192 ****
--- 1187,1200 ----
n->relation = $3;
n->name = $6;
n->behavior = $7;
+ $$ = (Node *)n;
+ }
+ /* ALTER TABLE SET WITHOUT OIDS */
+ | ALTER TABLE relation_expr SET WITHOUT OIDS
+ {
+ AlterTableStmt *n = makeNode(AlterTableStmt);
+ n->relation = $3;
+ n->subtype = 'o';
$$ = (Node *)n;
}
/* ALTER TABLE CREATE TOAST TABLE */
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.189
diff -c -r1.189 utility.c
*** src/backend/tcop/utility.c 2003/01/10 22:03:28 1.189
--- src/backend/tcop/utility.c 2003/01/15 20:24:50
***************
*** 557,563 ****
interpretInhOption(stmt->relation->inhOpt),
stmt->name);
break;
! case 'O': /* ALTER COLUMN SET NOT NULL */
AlterTableAlterColumnSetNotNull(relid,
interpretInhOption(stmt->relation->inhOpt),
stmt->name);
--- 557,563 ----
interpretInhOption(stmt->relation->inhOpt),
stmt->name);
break;
! case 'n': /* ALTER COLUMN SET NOT NULL */
AlterTableAlterColumnSetNotNull(relid,
interpretInhOption(stmt->relation->inhOpt),
stmt->name);
***************
*** 618,623 ****
--- 618,628 ----
/* get_usesysid raises an error if no such user */
AlterTableOwner(relid,
get_usesysid(stmt->name));
+ break;
+ case 'o': /* ADD OIDS */
+ AlterTableAlterOids(relid,
+ interpretInhOption(stmt->relation->inhOpt),
+ false);
break;
default: /* oops */
elog(ERROR, "ProcessUtility: Invalid type for AlterTableStmt: %d",
Index: src/include/commands/tablecmds.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/commands/tablecmds.h,v
retrieving revision 1.10
diff -c -r1.10 tablecmds.h
*** src/include/commands/tablecmds.h 2002/11/11 22:19:24 1.10
--- src/include/commands/tablecmds.h 2003/01/15 20:24:51
***************
*** 47,52 ****
--- 47,54 ----
extern void AlterTableOwner(Oid relationOid, int32 newOwnerSysId);
+ extern void AlterTableAlterOids(Oid myrelid, bool recurse, bool setOid);
+
extern Oid DefineRelation(CreateStmt *stmt, char relkind);
extern void RemoveRelation(const RangeVar *relation, DropBehavior behavior);
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/nodes/parsenodes.h,v
retrieving revision 1.225
diff -c -r1.225 parsenodes.h
*** src/include/nodes/parsenodes.h 2003/01/06 00:31:45 1.225
--- src/include/nodes/parsenodes.h 2003/01/15 20:24:52
***************
*** 688,694 ****
* A = add column
* T = alter column default
* N = alter column drop not null
! * O = alter column set not null
* S = alter column statistics
* M = alter column storage
* D = drop column
--- 688,694 ----
* A = add column
* T = alter column default
* N = alter column drop not null
! * n = alter column set not null
* S = alter column statistics
* M = alter column storage
* D = drop column
***************
*** 698,703 ****
--- 698,704 ----
* X = drop constraint
* E = create toast table
* U = change owner
+ * o = DROP OIDS
*------------
*/
RangeVar *relation; /* table to work on */
Index: src/test/regress/expected/alter_table.out
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/expected/alter_table.out,v
retrieving revision 1.55
diff -c -r1.55 alter_table.out
*** src/test/regress/expected/alter_table.out 2003/01/05 00:56:40 1.55
--- src/test/regress/expected/alter_table.out 2003/01/15 20:24:53
***************
*** 1179,1184 ****
--- 1179,1240 ----
drop table p1, p2 cascade;
NOTICE: Drop cascades to table c1
NOTICE: Drop cascades to table gc1
+ --
+ -- Test the ALTER TABLE WITHOUT OIDS command
+ --
+ create table altstartwith (col integer) with oids;
+ insert into altstartwith values (1);
+ select oid > 0, * from altstartwith;
+ ?column? | col
+ ----------+-----
+ t | 1
+ (1 row)
+
+ alter table altstartwith set without oids;
+ select oid > 0, * from altstartwith; -- fails
+ ERROR: Attribute "oid" not found
+ select * from altstartwith;
+ col
+ -----
+ 1
+ (1 row)
+
+ -- Run inheritance tests
+ create table altwithoid (col integer) with oids;
+ -- Inherits parents oid column
+ create table altinhoid () inherits (altwithoid) without oids;
+ insert into altinhoid values (1);
+ select oid > 0, * from altwithoid;
+ ?column? | col
+ ----------+-----
+ t | 1
+ (1 row)
+
+ select oid > 0, * from altinhoid;
+ ?column? | col
+ ----------+-----
+ t | 1
+ (1 row)
+
+ alter table altwithoid set without oids;
+ alter table altinhoid set without oids; -- fails
+ ERROR: ALTER TABLE: Table is already WITHOUT OIDS
+ select oid > 0, * from altwithoid; -- fails
+ ERROR: Attribute "oid" not found
+ select oid > 0, * from altinhoid; -- fails
+ ERROR: Attribute "oid" not found
+ select * from altwithoid;
+ col
+ -----
+ 1
+ (1 row)
+
+ select * from altinhoid;
+ col
+ -----
+ 1
+ (1 row)
+
-- test renumbering of child-table columns in inherited operations
create table p1 (f1 int);
create table c1 (f2 text, f3 int) inherits (p1);
Index: src/test/regress/sql/alter_table.sql
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/test/regress/sql/alter_table.sql,v
retrieving revision 1.36
diff -c -r1.36 alter_table.sql
*** src/test/regress/sql/alter_table.sql 2003/01/05 00:56:40 1.36
--- src/test/regress/sql/alter_table.sql 2003/01/15 20:24:53
***************
*** 850,855 ****
--- 850,888 ----
drop table p1, p2 cascade;
+ --
+ -- Test the ALTER TABLE WITHOUT OIDS command
+ --
+ create table altstartwith (col integer) with oids;
+
+ insert into altstartwith values (1);
+
+ select oid > 0, * from altstartwith;
+
+ alter table altstartwith set without oids;
+
+ select oid > 0, * from altstartwith; -- fails
+ select * from altstartwith;
+
+ -- Run inheritance tests
+ create table altwithoid (col integer) with oids;
+
+ -- Inherits parents oid column
+ create table altinhoid () inherits (altwithoid) without oids;
+
+ insert into altinhoid values (1);
+
+ select oid > 0, * from altwithoid;
+ select oid > 0, * from altinhoid;
+
+ alter table altwithoid set without oids;
+ alter table altinhoid set without oids; -- fails
+
+ select oid > 0, * from altwithoid; -- fails
+ select oid > 0, * from altinhoid; -- fails
+ select * from altwithoid;
+ select * from altinhoid;
+
-- test renumbering of child-table columns in inherited operations
create table p1 (f1 int);