diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index a52bfad2f3d..d329388bb9a 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -163,7 +163,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
Optionally, GLOBAL or LOCAL
can be written before TEMPORARY> or TEMP>.
- This makes no difference in PostgreSQL>, but see
+ This presently makes no difference in PostgreSQL>
+ and is deprecated; see
.
@@ -1304,13 +1305,20 @@ CREATE TABLE employees OF employee_type (
- The standard's distinction between global and local temporary tables
- is not in PostgreSQL, since that distinction
- depends on the concept of modules, which
- PostgreSQL does not have.
+ The SQL standard also distinguishes between global and local temporary
+ tables, where a local temporary table is only visible within a specific
+ SQL module, though its definition is still shared across sessions. Since
+ PostgreSQL does not support SQL modules, this
+ distinction is not relevant in PostgreSQL.
+
+
+
For compatibility's sake, PostgreSQL will
accept the GLOBAL and LOCAL keywords
- in a temporary table declaration, but they have no effect.
+ in a temporary table declaration, but they currently have no effect.
+ Use of these keywords is discouraged, since future versions of
+ PostgreSQL might adopt a more
+ standard-compliant interpretation of their meaning.
diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml
index 1be9f4d1f6a..29d161940c7 100644
--- a/doc/src/sgml/ref/create_table_as.sgml
+++ b/doc/src/sgml/ref/create_table_as.sgml
@@ -62,9 +62,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE GLOBAL or LOCAL
- Ignored for compatibility. Refer to for
- details.
+ Ignored for compatibility. Use of these keywords is deprecated;
+ refer to for details.
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 9eb1bed58e6..8389337ecc2 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -2507,15 +2507,31 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
* Redundancy here is needed to avoid shift/reduce conflicts,
* since TEMP is not a reserved word. See also OptTempTableName.
*
- * NOTE: we accept both GLOBAL and LOCAL options; since we have no modules
- * the LOCAL keyword is really meaningless.
+ * NOTE: we accept both GLOBAL and LOCAL options. They currently do nothing,
+ * but future versions might consider GLOBAL to request SQL-spec-compliant
+ * temp table behavior, so warn about that. Since we have no modules the
+ * LOCAL keyword is really meaningless; furthermore, some other products
+ * implement LOCAL as meaning the same as our default temp table behavior,
+ * so we'll probably continue to treat LOCAL as a noise word.
*/
OptTemp: TEMPORARY { $$ = RELPERSISTENCE_TEMP; }
| TEMP { $$ = RELPERSISTENCE_TEMP; }
| LOCAL TEMPORARY { $$ = RELPERSISTENCE_TEMP; }
| LOCAL TEMP { $$ = RELPERSISTENCE_TEMP; }
- | GLOBAL TEMPORARY { $$ = RELPERSISTENCE_TEMP; }
- | GLOBAL TEMP { $$ = RELPERSISTENCE_TEMP; }
+ | GLOBAL TEMPORARY
+ {
+ ereport(WARNING,
+ (errmsg("GLOBAL is deprecated in temporary table creation"),
+ parser_errposition(@1)));
+ $$ = RELPERSISTENCE_TEMP;
+ }
+ | GLOBAL TEMP
+ {
+ ereport(WARNING,
+ (errmsg("GLOBAL is deprecated in temporary table creation"),
+ parser_errposition(@1)));
+ $$ = RELPERSISTENCE_TEMP;
+ }
| UNLOGGED { $$ = RELPERSISTENCE_UNLOGGED; }
| /*EMPTY*/ { $$ = RELPERSISTENCE_PERMANENT; }
;
@@ -8930,11 +8946,17 @@ OptTempTableName:
}
| GLOBAL TEMPORARY opt_table qualified_name
{
+ ereport(WARNING,
+ (errmsg("GLOBAL is deprecated in temporary table creation"),
+ parser_errposition(@1)));
$$ = $4;
$$->relpersistence = RELPERSISTENCE_TEMP;
}
| GLOBAL TEMP opt_table qualified_name
{
+ ereport(WARNING,
+ (errmsg("GLOBAL is deprecated in temporary table creation"),
+ parser_errposition(@1)));
$$ = $4;
$$->relpersistence = RELPERSISTENCE_TEMP;
}