From ff02d0a05280e96e0b91b97ec50e98611f9c7598 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Sun, 13 Mar 2005 09:36:31 +0000 Subject: [PATCH] Make default_with_oids default to false -- user-created tables will now no longer include OIDs, unless WITH OIDS is specified or the default_with_oids configuration parameter is enabled. Update the docs accordingly. --- doc/src/sgml/datatype.sgml | 37 +++++-------------- doc/src/sgml/ddl.sgml | 11 +++--- doc/src/sgml/plpgsql.sgml | 5 ++- doc/src/sgml/pltcl.sgml | 7 ++-- doc/src/sgml/ref/select_into.sgml | 17 ++++----- doc/src/sgml/runtime.sgml | 31 +++++++--------- src/backend/utils/misc/guc.c | 8 ++-- src/backend/utils/misc/postgresql.conf.sample | 2 +- 8 files changed, 48 insertions(+), 70 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 3794aa2f78..5ca2ab2f61 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ @@ -2980,12 +2980,12 @@ SELECT * FROM test; 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 - configuration variable is set to false. Type oid - represents an object identifier. There are also several alias - types for oid: regproc, regprocedure, + system tables. OIDs are not added to user-created tables, unless + WITH OIDS is specified when the table is + created, or the + configuration variable is enabled. Type oid represents + an object identifier. There are also several alias types for + oid: regproc, regprocedure, regoper, regoperator, regclass, and regtype. shows an overview. @@ -3000,28 +3000,11 @@ SELECT * FROM test; 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_with_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. - It can be cast to - integer, however, and then manipulated using the standard integer - operators. (Beware of possible signed-versus-unsigned confusion - if you do this.) + It can be cast to integer, however, and then manipulated using the + standard integer operators. (Beware of possible + signed-versus-unsigned confusion if you do this.) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index 2de8888254..b0d413bbea 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -1,4 +1,4 @@ - + Data Definition @@ -868,11 +868,10 @@ CREATE TABLE order_items ( OID column - The object identifier (object ID) of a row. This is a serial - number that is automatically added by - PostgreSQL to all table rows (unless - the table was created using WITHOUT OIDS, in which - case this column is not present). This column is of type + The object identifier (object ID) of a row. This column is only + present if the table was created using WITH + OIDS, or if the + configuration variable was enabled. This column is of type oid (same name as the column); see for more information about the type. diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 6284b793b0..77924fd569 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ @@ -1299,7 +1299,8 @@ GET DIAGNOSTICS variable = itemSQL engine, and RESULT_OID, the OID of the last row inserted by the most recent SQL command. Note that RESULT_OID - is only useful after an INSERT command. + is only useful after an INSERT command into a + table containing OIDs. diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index 1d22035fa9..7cb60a3c58 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -1,5 +1,5 @@ @@ -400,8 +400,9 @@ $$ LANGUAGE pltcl; Returns the OID of the row inserted by the last - spi_exec or spi_execp, - if the command was a single-row INSERT. (If not, you get zero.) + spi_exec or spi_execp, if the + command was a single-row INSERT and the modified + table contained OIDs. (If not, you get zero.) diff --git a/doc/src/sgml/ref/select_into.sgml b/doc/src/sgml/ref/select_into.sgml index 11389d190b..9198a02e4c 100644 --- a/doc/src/sgml/ref/select_into.sgml +++ b/doc/src/sgml/ref/select_into.sgml @@ -1,5 +1,5 @@ @@ -94,14 +94,13 @@ SELECT [ ALL | DISTINCT [ ON ( expression - Prior to PostgreSQL 8.0, the table created by - SELECT INTO always included OIDs. - As of PostgreSQL 8.0, the - inclusion of OIDs in the table created by SELECT - INTO is controlled by the - configuration variable. This - variable currently defaults to true, but will likely default to - false in a future release of PostgreSQL. + Prior to PostgreSQL 8.1, the table created by + SELECT INTO included OIDs by default. In + PostgreSQL 8.1, this is not the case + — to include OIDs in the new table, the configuration variable must be + enabled. Alternatively, CREATE TABLE AS can be + used with the WITH OIDS clause. diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 5ba8b9b2b3..3517dd58d0 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,5 +1,5 @@ @@ -3587,23 +3587,18 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' newly-created tables, if neither WITH OIDS nor WITHOUT OIDS is specified. It also determines whether OIDs will be included in tables created by - SELECT INTO. In - PostgreSQL &version; - default_with_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. This - option will probably 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 explicitly specify WITH - OIDS when those tables are created. + SELECT INTO. In PostgreSQL + 8.1 default_with_oids is disabled by default; in + prior versions of PostgreSQL, it was true by default. + + + + The use of OIDs in user tables is considered deprecated, so + most installations should leave this variable disabled. + Applications that require OIDs for a particular table should + specify WITH OIDS when creating the + table. This variable can be enabled for compatibility with old + applications that do not follow this behavior. diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index b9486e8663..67374a4b61 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.254 2005/03/04 20:21:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.255 2005/03/13 09:36:31 neilc Exp $ * *-------------------------------------------------------------------- */ @@ -139,7 +139,7 @@ bool Australian_timezones = false; bool Password_encryption = true; -bool default_with_oids = true; +bool default_with_oids = false; int log_min_error_statement = PANIC; int log_min_messages = NOTICE; @@ -801,11 +801,11 @@ static struct config_bool ConfigureNamesBool[] = }, { {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, - gettext_noop("By default, newly-created tables should have OIDs."), + gettext_noop("Create new tables with OIDs by default."), NULL }, &default_with_oids, - true, NULL, NULL + false, NULL, NULL }, { {"redirect_stderr", PGC_POSTMASTER, LOGGING_WHERE, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 74a029e657..070d1e7632 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -314,7 +314,7 @@ #add_missing_from = true #regex_flavor = advanced # advanced, extended, or basic #sql_inheritance = true -#default_with_oids = true +#default_with_oids = false # - Other Platforms & Clients - -- 2.40.0