Index: doc/src/sgml/datatype.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/datatype.sgml,v retrieving revision 1.126 diff -c -r1.126 datatype.sgml *** doc/src/sgml/datatype.sgml 16 Oct 2003 04:52:21 -0000 1.126 --- doc/src/sgml/datatype.sgml 17 Oct 2003 19:03:44 -0000 *************** *** 2891,2913 **** Object identifiers (OIDs) are used internally by ! PostgreSQL as primary keys for various system ! tables. Also, an OID system column is added to user-created tables ! (unless WITHOUT OIDS is specified at table creation time). ! Type oid represents an object identifier. There are also ! several alias types for oid: regproc, regprocedure, ! regoper, regoperator, regclass, ! and regtype. shows an overview. ! The oid type is currently implemented as an unsigned four-byte ! integer. ! Therefore, it is not large enough to provide database-wide uniqueness ! in large databases, or even in large individual tables. So, using a ! user-created table's OID column as a primary key is discouraged. ! OIDs are best used only for references to system tables. ! The oid type itself has few operations beyond comparison. --- 2891,2932 ---- Object identifiers (OIDs) are used internally by ! PostgreSQL as primary keys for various ! system tables. An OID system column is also added to user-created ! tables, unless WITHOUT OIDS is specified when ! the table is created, or the default_use_oids ! configuration variable is set to false. Type oid ! represents an object identifier. There are also several alias ! types for oid: regproc, regprocedure, ! regoper, regoperator, regclass, and ! regtype. shows an ! overview. ! The oid type is currently implemented as an unsigned ! four-byte integer. Therefore, it is not large enough to provide ! database-wide uniqueness in large databases, or even in large ! individual tables. So, using a user-created table's OID column as ! a primary key is discouraged. OIDs are best used only for ! references to system tables. ! ! ! ! ! OIDs are included by default in user-created tables in ! PostgreSQL &version;. However, this ! behavior is likely to change in a future version of ! PostgreSQL. Eventually, user-created ! tables will not include an OID system column unless WITH ! OIDS is specified when the table is created, or the ! default_use_oids configuration variable is set ! to true. If your application requires the presence of an OID ! system column in a table, it should specify WITH ! OIDS when that table is created to ensure compatibility ! with future releases of PostgreSQL. ! ! The oid type itself has few operations beyond comparison. Index: doc/src/sgml/runtime.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/runtime.sgml,v retrieving revision 1.213 diff -c -r1.213 runtime.sgml *** doc/src/sgml/runtime.sgml 10 Oct 2003 02:08:42 -0000 1.213 --- doc/src/sgml/runtime.sgml 17 Oct 2003 20:02:18 -0000 *************** *** 2494,2500 **** ! Platform and Client Compatibility --- 2494,2531 ---- ! ! default_use_oids (boolean) ! ! ! This controls whether CREATE TABLE will ! include OIDs in newly-created tables, if neither WITH ! OIDS or WITHOUT OIDS have been ! specified. It also determines whether OIDs will be included in ! the table generated by SELECT INTO and ! CREATE TABLE AS. In ! PostgreSQL &version; ! default_use_oids defaults to true. This is ! also the behavior of previous versions of ! PostgreSQL. However, assuming that ! tables will contain OIDs by default is not ! encouraged. Therefore, this option will default to false in a ! future release of PostgreSQL. ! ! ! ! To ease compatibility with applications that make use of OIDs, ! this option should left enabled. To ease compatibility with ! future versions of PostgreSQL, this ! option should be disabled, and applications that require OIDs ! on certain tables should explictely specify WITH ! OIDS when issuing the CREATE ! TABLE statements for the tables in question. ! ! ! ! ! Platform and Client Compatibility Index: doc/src/sgml/spi.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/spi.sgml,v retrieving revision 1.27 diff -c -r1.27 spi.sgml *** doc/src/sgml/spi.sgml 31 Aug 2003 17:32:20 -0000 1.27 --- doc/src/sgml/spi.sgml 17 Oct 2003 20:08:42 -0000 *************** *** 319,325 **** if a SELECT (but not SELECT ! ... INTO) was executed --- 319,325 ---- if a SELECT (but not SELECT ! INTO) was executed *************** *** 328,334 **** SPI_OK_SELINTO ! if a SELECT ... INTO was executed --- 328,334 ---- SPI_OK_SELINTO ! if a SELECT INTO was executed Index: doc/src/sgml/ref/alter_table.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/alter_table.sgml,v retrieving revision 1.62 diff -c -r1.62 alter_table.sgml *** doc/src/sgml/ref/alter_table.sgml 22 Sep 2003 00:16:57 -0000 1.62 --- doc/src/sgml/ref/alter_table.sgml 17 Oct 2003 19:03:44 -0000 *************** *** 149,154 **** --- 149,160 ---- of the OID are kept indefinitely. This is semantically similar to the DROP COLUMN process. + + + Note that there is no variant of ALTER TABLE + that allows OIDs to be restored to a table once they have been + removed. + Index: doc/src/sgml/ref/create_table.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/create_table.sgml,v retrieving revision 1.72 diff -c -r1.72 create_table.sgml *** doc/src/sgml/ref/create_table.sgml 9 Sep 2003 18:28:52 -0000 1.72 --- doc/src/sgml/ref/create_table.sgml 17 Oct 2003 19:10:56 -0000 *************** *** 111,122 **** If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a ! session, or optionally at the end of the current transaction ! (see ON COMMIT below). Existing permanent tables with the same ! name are not visible to the current session while the temporary ! table exists, unless they are referenced with schema-qualified ! names. Any indexes created on a temporary table are automatically ! temporary as well. --- 111,122 ---- If specified, the table is created as a temporary table. Temporary tables are automatically dropped at the end of a ! session, or optionally at the end of the current transaction ! (see ON COMMIT below). Existing permanent ! tables with the same name are not visible to the current session ! while the temporary table exists, unless they are referenced ! with schema-qualified names. Any indexes created on a temporary ! table are automatically temporary as well. *************** *** 243,264 **** This optional clause specifies whether rows of the new table ! should have OIDs (object identifiers) assigned to them. The ! default is to have OIDs. (If the new table inherits from any ! tables that have OIDs, then WITH OIDS is forced even ! if the command says WITHOUT OIDS.) ! Specifying WITHOUT OIDS allows the user to suppress ! generation of OIDs for rows of a table. This may be worthwhile ! for large tables, since it will reduce OID consumption and ! thereby postpone wraparound of the 32-bit OID counter. Once the ! counter wraps around, uniqueness of OIDs can no longer be ! assumed, which considerably reduces their usefulness. Specifying ! WITHOUT OIDS also reduces the space required ! to store the table on disk by 4 bytes per row of the table, ! thereby improving performance. --- 243,272 ---- This optional clause specifies whether rows of the new table ! should have OIDs (object identifiers) assigned to them. If ! neither WITH OIDS nor WITHOUT ! OIDS is specified, the default value depends upon the ! default_use_oids configuration parameter. (If ! the new table inherits from any tables that have OIDs, then ! WITH OIDS is forced even if the command says ! WITHOUT OIDS.) ! If WITHOUT OIDS is specified or implied, this ! means that the generation of OIDs for this table will be ! supressed. This is generally considered worthwhile, since it ! will reduce OID consumption and thereby postpone the wraparound ! of the 32-bit OID counter. Once the counter wraps around, OIDs ! can no longer be assumed to be unique, which makes them ! considerably less useful. In addition, excluding OIDs from a ! table reduces the space required on disk to storage the table by ! 4 bytes per row, leading to increased performance. ! ! ! ! To remove OIDs from a table after it has been created, use . *************** *** 570,587 **** ! Whenever an application makes use of OIDs to identify specific rows of a table, it is recommended to create a unique constraint on the oid column of that table, to ensure that OIDs in the table will indeed uniquely identify rows even after counter wraparound. Avoid assuming that OIDs are unique across tables; if you need a database-wide unique identifier, use the combination of tableoid and row OID for the ! purpose. (It is likely that future PostgreSQL ! releases will use a separate OID counter for each table, so that ! it will be necessary, not optional, to include ! tableoid to have a unique identifier ! database-wide.) --- 578,594 ---- ! Using OIDs in new applications is not recommended: where ! possible, using a SERIAL or other sequence ! generator as the table's primary key is preferred. However, if ! your application does make use of OIDs to identify specific rows rows of a table, it is recommended to create a unique constraint on the oid column of that table, to ensure that OIDs in the table will indeed uniquely identify rows even after counter wraparound. Avoid assuming that OIDs are unique across tables; if you need a database-wide unique identifier, use the combination of tableoid and row OID for the ! purpose. Index: doc/src/sgml/ref/create_table_as.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v retrieving revision 1.16 diff -c -r1.16 create_table_as.sgml *** doc/src/sgml/ref/create_table_as.sgml 9 Sep 2003 18:28:53 -0000 1.16 --- doc/src/sgml/ref/create_table_as.sgml 17 Oct 2003 20:34:50 -0000 *************** *** 51,57 **** Parameters ! TEMPORARY or TEMP --- 51,70 ---- Parameters ! ! ! ! GLOBAL or LOCAL ! ! ! Ignored for compatibility. Refer to for ! details. ! ! ! ! ! TEMPORARY or TEMP *************** *** 105,114 **** Notes ! This command is functionally equivalent to , but it is preferred since it is less ! likely to be confused with other uses of the SELECT ! ... INTO syntax. --- 118,141 ---- Notes ! This command is functionally similar to , but it is ! preferred since it is less likely to be confused with other uses of ! the SELECT INTO syntax. ! ! ! ! Prior to PostgreSQL 7.5, CREATE TABLE AS always ! included OIDs in the table it produced. Furthermore, these OIDs ! were newly generated: they were distinct from the OIDs of any of ! the rows in the source tables of the SELECT or ! EXECUTE statement. Therefore, if CREATE ! TABLE AS was frequently executed, the OID counter would ! be rapidly incremented. As of PostgreSQL 7.5, the inclusion of OIDs ! in the table generated by CREATE TABLE AS is ! controlled by the default_use_oids configuration ! variable. This variable currently defaults to true, but will likely ! default to false in a future release of PostgreSQL. *************** *** 129,135 **** - --- 156,161 ---- Index: doc/src/sgml/ref/pg_dump.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/pg_dump.sgml,v retrieving revision 1.65 diff -c -r1.65 pg_dump.sgml *** doc/src/sgml/ref/pg_dump.sgml 23 Sep 2003 22:48:53 -0000 1.65 --- doc/src/sgml/ref/pg_dump.sgml 17 Oct 2003 19:03:44 -0000 *************** *** 611,618 **** ! Once restored, it is wise to run ANALYZE on each ! restored table so the optimizer has useful statistics. --- 611,621 ---- ! The dump file produced by pg_dump does ! not contain the statistics used by the optimizer to make query ! planning decisions. Therefore, it is wise to run ! ANALYZE after restoring from a dump file to ! ensure good performance. Index: doc/src/sgml/ref/prepare.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/prepare.sgml,v retrieving revision 1.7 diff -c -r1.7 prepare.sgml *** doc/src/sgml/ref/prepare.sgml 9 Sep 2003 18:28:53 -0000 1.7 --- doc/src/sgml/ref/prepare.sgml 17 Oct 2003 20:15:49 -0000 *************** *** 52,64 **** ! Prepared statements are only stored in and for the duration of ! the current database session. When ! the session ends, the prepared statement is forgotten, and so it must be ! recreated before being used again. This also means that a single ! prepared statement cannot be used by multiple simultaneous database ! clients; however, each client can create their own prepared statement ! to use. --- 52,63 ---- ! Prepared statements are only for the duration of the current ! database session. When the session ends, the prepared statement is ! forgotten, so it must be recreated before being used again. This ! also means that a single prepared statement cannot be used by ! multiple simultaneous database clients; however, each client can ! create their own prepared statement to use. Index: doc/src/sgml/ref/select_into.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/select_into.sgml,v retrieving revision 1.24 diff -c -r1.24 select_into.sgml *** doc/src/sgml/ref/select_into.sgml 9 Sep 2003 18:28:53 -0000 1.24 --- doc/src/sgml/ref/select_into.sgml 17 Oct 2003 20:21:11 -0000 *************** *** 82,94 **** Notes ! ! is functionally equivalent to SELECT INTO. ! CREATE TABLE AS is the recommended syntax, since ! this form of SELECT INTO is not available in ! ECPG or ! PL/pgSQL, because they interpret the ! INTO clause differently. --- 82,110 ---- Notes ! is functionally similar to ! SELECT INTO. CREATE TABLE AS ! is the recommended syntax, since this form of SELECT ! INTO is not available in ECPG ! or PL/pgSQL, because they interpret the ! INTO clause differently. Furthermore, ! CREATE TABLE AS offers a superset of the ! functionality provided by SELECT INTO. ! ! ! ! Prior to PostgreSQL 7.5, the table created by SELECT ! INTO always included OIDs. Furthermore, these OIDs were ! newly generated: they were distinct from the OIDs of any of the ! rows in the source tables of the SELECT INTO ! statement. Therefore, if SELECT INTO was ! frequently executed, the OID counter would be rapidly ! incremented. As of PostgreSQL 7.5, the inclusion of OIDs in the ! table created by SELECT INTO is controlled by ! the default_use_oids configuration ! variable. This variable currently defaults to true, but will likely ! default to false in a future release of PostgreSQL. *************** *** 96,102 **** Compatibility ! The SQL standard uses SELECT ... INTO to represent selecting values into scalar variables of a host program, rather than creating a new table. This indeed is the usage found in ECPG (see ) and --- 112,118 ---- Compatibility ! The SQL standard uses SELECT INTO to represent selecting values into scalar variables of a host program, rather than creating a new table. This indeed is the usage found in ECPG (see ) and Index: src/backend/executor/execMain.c =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/execMain.c,v retrieving revision 1.220 diff -c -r1.220 execMain.c *** src/backend/executor/execMain.c 1 Oct 2003 21:30:52 -0000 1.220 --- src/backend/executor/execMain.c 17 Oct 2003 19:45:13 -0000 *************** *** 43,48 **** --- 43,49 ---- #include "optimizer/var.h" #include "parser/parsetree.h" #include "utils/acl.h" + #include "utils/guc.h" #include "utils/lsyscache.h" *************** *** 593,603 **** do_select_into = true; /* ! * For now, always create OIDs in SELECT INTO; this is for ! * backwards compatibility with pre-7.3 behavior. Eventually we ! * might want to allow the user to choose. */ ! estate->es_force_oids = true; } /* --- 594,605 ---- do_select_into = true; /* ! * The presence of OIDs in the result set of SELECT INTO is ! * controlled by the default_use_oids GUC parameter. The ! * behavior in versions of PostgreSQL prior to 7.5 is to ! * always include OIDs. */ ! estate->es_force_oids = default_use_oids; } /* Index: src/backend/parser/gram.y =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/backend/parser/gram.y,v retrieving revision 2.436 diff -c -r2.436 gram.y *** src/backend/parser/gram.y 2 Oct 2003 06:34:04 -0000 2.436 --- src/backend/parser/gram.y 17 Oct 2003 19:03:44 -0000 *************** *** 63,68 **** --- 63,69 ---- #include "utils/numeric.h" #include "utils/datetime.h" #include "utils/date.h" + #include "utils/guc.h" extern List *parsetree; /* final parse result is delivered here */ *************** *** 1820,1826 **** OptWithOids: WITH OIDS { $$ = TRUE; } | WITHOUT OIDS { $$ = FALSE; } ! | /*EMPTY*/ { $$ = TRUE; } ; OnCommitOption: ON COMMIT DROP { $$ = ONCOMMIT_DROP; } --- 1821,1832 ---- OptWithOids: WITH OIDS { $$ = TRUE; } | WITHOUT OIDS { $$ = FALSE; } ! /* ! * If the user didn't explicitely specify WITH or WITHOUT ! * OIDS, decide whether to include OIDs based on the ! * "default_use_oids" GUC var ! */ ! | /*EMPTY*/ { $$ = default_use_oids; } ; OnCommitOption: ON COMMIT DROP { $$ = ONCOMMIT_DROP; } Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/misc/guc.c,v retrieving revision 1.163 diff -c -r1.163 guc.c *** src/backend/utils/misc/guc.c 8 Oct 2003 03:49:38 -0000 1.163 --- src/backend/utils/misc/guc.c 17 Oct 2003 19:03:44 -0000 *************** *** 124,129 **** --- 124,131 ---- bool Password_encryption = true; + bool default_use_oids = true; + int log_min_error_statement = PANIC; int log_min_messages = NOTICE; int client_min_messages = NOTICE; *************** *** 261,267 **** /* QUERY_TUNING */ gettext_noop("Query Tuning"), /* QUERY_TUNING_METHOD */ ! gettext_noop("Query Tuning / Planner Method Enabling"), /* QUERY_TUNING_COST */ gettext_noop("Query Tuning / Planner Cost Constants"), /* QUERY_TUNING_GEQO */ --- 263,269 ---- /* QUERY_TUNING */ gettext_noop("Query Tuning"), /* QUERY_TUNING_METHOD */ ! gettext_noop("Query Tuning / Planner Method Configuration"), /* QUERY_TUNING_COST */ gettext_noop("Query Tuning / Planner Cost Constants"), /* QUERY_TUNING_GEQO */ *************** *** 830,835 **** --- 832,845 ---- &check_function_bodies, true, NULL, NULL }, + { + {"default_use_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, + gettext_noop("by default, newly-created tables should have OIDs"), + NULL + }, + &default_use_oids, + true, NULL, NULL + }, /* End-of-list marker */ { Index: src/backend/utils/misc/postgresql.conf.sample =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v retrieving revision 1.92 diff -c -r1.92 postgresql.conf.sample *** src/backend/utils/misc/postgresql.conf.sample 8 Oct 2003 03:49:38 -0000 1.92 --- src/backend/utils/misc/postgresql.conf.sample 17 Oct 2003 19:03:44 -0000 *************** *** 94,100 **** # QUERY TUNING #--------------------------------------------------------------------------- ! # - Planner Method Enabling - #enable_hashagg = true #enable_hashjoin = true --- 94,100 ---- # QUERY TUNING #--------------------------------------------------------------------------- ! # - Planner Method Configuration - #enable_hashagg = true #enable_hashjoin = true *************** *** 249,254 **** --- 249,255 ---- #add_missing_from = true #regex_flavor = advanced # advanced, extended, or basic #sql_inheritance = true + #default_use_oids = true # - Other Platforms & Clients - Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.353 diff -c -r1.353 pg_dump.c *** src/bin/pg_dump/pg_dump.c 8 Oct 2003 03:52:32 -0000 1.353 --- src/bin/pg_dump/pg_dump.c 17 Oct 2003 19:03:44 -0000 *************** *** 5401,5408 **** appendPQExpBuffer(q, ")"); } ! if (!tbinfo->hasoids) ! appendPQExpBuffer(q, " WITHOUT OIDS"); appendPQExpBuffer(q, ";\n"); --- 5401,5407 ---- appendPQExpBuffer(q, ")"); } ! appendPQExpBuffer(q, tbinfo->hasoids ? " WITH OIDS" : " WITHOUT OIDS"); appendPQExpBuffer(q, ";\n"); Index: src/bin/psql/tab-complete.c =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/tab-complete.c,v retrieving revision 1.89 diff -c -r1.89 tab-complete.c *** src/bin/psql/tab-complete.c 17 Oct 2003 11:52:06 -0000 1.89 --- src/bin/psql/tab-complete.c 17 Oct 2003 19:03:44 -0000 *************** *** 535,540 **** --- 535,541 ---- "default_statistics_target", "default_transaction_isolation", "default_transaction_read_only", + "default_use_oids", "dynamic_library_path", "effective_cache_size", "enable_hashagg", Index: src/include/utils/guc.h =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/include/utils/guc.h,v retrieving revision 1.41 diff -c -r1.41 guc.h *** src/include/utils/guc.h 1 Sep 2003 04:15:51 -0000 1.41 --- src/include/utils/guc.h 17 Oct 2003 19:03:44 -0000 *************** *** 109,114 **** --- 109,116 ---- extern bool SQL_inheritance; extern bool Australian_timezones; + extern bool default_use_oids; + extern int log_min_error_statement; extern int log_min_messages; extern int client_min_messages; Index: src/test/regress/expected/without_oid.out =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/test/regress/expected/without_oid.out,v retrieving revision 1.1 diff -c -r1.1 without_oid.out *** src/test/regress/expected/without_oid.out 20 Jul 2002 05:39:46 -0000 1.1 --- src/test/regress/expected/without_oid.out 17 Oct 2003 20:13:49 -0000 *************** *** 1,7 **** -- -- WITHOUT OID -- ! CREATE TABLE wi (i INT); CREATE TABLE wo (i INT) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1 --- 1,7 ---- -- -- WITHOUT OID -- ! CREATE TABLE wi (i INT) WITH OIDS; CREATE TABLE wo (i INT) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1 Index: src/test/regress/sql/without_oid.sql =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/test/regress/sql/without_oid.sql,v retrieving revision 1.1 diff -c -r1.1 without_oid.sql *** src/test/regress/sql/without_oid.sql 20 Jul 2002 05:39:46 -0000 1.1 --- src/test/regress/sql/without_oid.sql 17 Oct 2003 20:03:58 -0000 *************** *** 2,8 **** -- WITHOUT OID -- ! CREATE TABLE wi (i INT); CREATE TABLE wo (i INT) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1 --- 2,8 ---- -- WITHOUT OID -- ! CREATE TABLE wi (i INT) WITH OIDS; CREATE TABLE wo (i INT) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1