Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9424d0

Browse files
committed
Support writing "CREATE/ALTER TABLE ... SET STORAGE DEFAULT".
We already allow explicitly writing DEFAULT for SET COMPRESSION,so it seems a bit inflexible and non-orthogonal to not have itfor STORAGE.Aleksander AlekseevDiscussion:https://postgr.es/m/CAJ7c6TMX9ui+6y3TQFaXJYVpZyBukvqhQbVDJ8OUokeLRhtnpA@mail.gmail.com
1 parentb158e0b commitb9424d0

File tree

9 files changed

+31
-22
lines changed

9 files changed

+31
-22
lines changed

‎doc/src/sgml/ref/alter_foreign_table.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ALTER FOREIGN TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceab
4141
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable>
4242
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
4343
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
44-
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
44+
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT}
4545
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> OPTIONS ( [ ADD | SET | DROP ] <replaceable class="parameter">option</replaceable> ['<replaceable class="parameter">value</replaceable>'] [, ... ])
4646
ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
4747
VALIDATE CONSTRAINT <replaceable class="parameter">constraint_name</replaceable>

‎doc/src/sgml/ref/alter_materialized_view.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</r
3939
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable>
4040
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
4141
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
42-
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
42+
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT}
4343
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable>
4444
CLUSTER ON <replaceable class="parameter">index_name</replaceable>
4545
SET WITHOUT CLUSTER

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
5353
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable>
5454
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
5555
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
56-
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
56+
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT}
5757
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable>
5858
ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
5959
ADD <replaceable class="parameter">table_constraint_using_index</replaceable>
@@ -367,7 +367,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
367367

368368
<varlistentry>
369369
<term>
370-
<literal>SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }</literal>
370+
<literal>SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT}</literal>
371371
<indexterm>
372372
<primary>TOAST</primary>
373373
<secondary>per-column storage settings</secondary>
@@ -376,20 +376,24 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
376376
<listitem>
377377
<para>
378378
This form sets the storage mode for a column. This controls whether this
379-
column is held inline or in a secondary <acronym>TOAST</acronym> table, and
380-
whether the data
379+
column is held inline or in a secondary <acronym>TOAST</acronym> table,
380+
andwhether the data
381381
should be compressed or not. <literal>PLAIN</literal> must be used
382382
for fixed-length values such as <type>integer</type> and is
383383
inline, uncompressed. <literal>MAIN</literal> is for inline,
384384
compressible data. <literal>EXTERNAL</literal> is for external,
385385
uncompressed data, and <literal>EXTENDED</literal> is for external,
386-
compressed data. <literal>EXTENDED</literal> is the default for most
387-
data types that support non-<literal>PLAIN</literal> storage.
386+
compressed data.
387+
Writing <literal>DEFAULT</literal> sets the storage mode to the default
388+
mode for the column's data type. <literal>EXTENDED</literal> is the
389+
default for most data types that support non-<literal>PLAIN</literal>
390+
storage.
388391
Use of <literal>EXTERNAL</literal> will make substring operations on
389392
very large <type>text</type> and <type>bytea</type> values run faster,
390-
at the penalty of increased storage space. Note that
391-
<literal>SET STORAGE</literal> doesn't itself change anything in the table,
392-
it just sets the strategy to be pursued during future table updates.
393+
at the penalty of increased storage space.
394+
Note that <literal>ALTER TABLE ... SET STORAGE</literal> doesn't itself
395+
change anything in the table; it just sets the strategy to be pursued
396+
during future table updates.
393397
See <xref linkend="storage-toast"/> for more information.
394398
</para>
395399
</listitem>

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PostgreSQL documentation
2222
<refsynopsisdiv>
2323
<synopsis>
2424
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name</replaceable> ( [
25-
{ <replaceable class="parameter">column_name</replaceable> <replaceable class="parameter">data_type</replaceable> [ STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN } ] [ COMPRESSION <replaceable>compression_method</replaceable> ] [ COLLATE <replaceable>collation</replaceable> ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
25+
{ <replaceable class="parameter">column_name</replaceable> <replaceable class="parameter">data_type</replaceable> [ STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT} ] [ COMPRESSION <replaceable>compression_method</replaceable> ] [ COLLATE <replaceable>collation</replaceable> ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
2626
| <replaceable>table_constraint</replaceable>
2727
| LIKE <replaceable>source_table</replaceable> [ <replaceable>like_option</replaceable> ... ] }
2828
[, ... ]
@@ -299,7 +299,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
299299

300300
<varlistentry>
301301
<term>
302-
<literal>STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }</literal>
302+
<literal>STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN| DEFAULT}</literal>
303303
<indexterm>
304304
<primary>TOAST</primary>
305305
<secondary>per-column storage settings</secondary>
@@ -314,12 +314,14 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
314314
inline, uncompressed. <literal>MAIN</literal> is for inline, compressible
315315
data. <literal>EXTERNAL</literal> is for external, uncompressed data, and
316316
<literal>EXTENDED</literal> is for external, compressed data.
317-
<literal>EXTENDED</literal> is the default for most data types that
318-
support non-<literal>PLAIN</literal> storage. Use of
319-
<literal>EXTERNAL</literal> will make substring operations on very large
320-
<type>text</type> and <type>bytea</type> values run faster, at the penalty
321-
of increased storage space. See <xref linkend="storage-toast"/> for more
322-
information.
317+
Writing <literal>DEFAULT</literal> sets the storage mode to the default
318+
mode for the column's data type. <literal>EXTENDED</literal> is the
319+
default for most data types that support non-<literal>PLAIN</literal>
320+
storage.
321+
Use of <literal>EXTERNAL</literal> will make substring operations on
322+
very large <type>text</type> and <type>bytea</type> values run faster,
323+
at the penalty of increased storage space.
324+
See <xref linkend="storage-toast"/> for more information.
323325
</para>
324326
</listitem>
325327
</varlistentry>

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19311,6 +19311,8 @@ GetAttributeStorage(Oid atttypid, const char *storagemode)
1931119311
cstorage = TYPSTORAGE_EXTENDED;
1931219312
else if (pg_strcasecmp(storagemode, "main") == 0)
1931319313
cstorage = TYPSTORAGE_MAIN;
19314+
else if (pg_strcasecmp(storagemode, "default") == 0)
19315+
cstorage = get_typstorage(atttypid);
1931419316
else
1931519317
ereport(ERROR,
1931619318
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),

‎src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,7 @@ opt_column_compression:
37583758

37593759
column_storage:
37603760
STORAGEColId{$$ =$2; }
3761+
|STORAGEDEFAULT{$$ = pstrdup("default"); }
37613762
;
37623763

37633764
opt_column_storage:

‎src/bin/psql/tab-complete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ psql_completion(const char *text, int start, int end)
24202420
/* ALTER TABLE ALTER [COLUMN] <foo> SET STORAGE */
24212421
elseif (Matches("ALTER","TABLE",MatchAny,"ALTER","COLUMN",MatchAny,"SET","STORAGE")||
24222422
Matches("ALTER","TABLE",MatchAny,"ALTER",MatchAny,"SET","STORAGE"))
2423-
COMPLETE_WITH("PLAIN","EXTERNAL","EXTENDED","MAIN");
2423+
COMPLETE_WITH("DEFAULT","PLAIN","EXTERNAL","EXTENDED","MAIN");
24242424
/* ALTER TABLE ALTER [COLUMN] <foo> SET STATISTICS */
24252425
elseif (Matches("ALTER","TABLE",MatchAny,"ALTER","COLUMN",MatchAny,"SET","STATISTICS")||
24262426
Matches("ALTER","TABLE",MatchAny,"ALTER",MatchAny,"SET","STATISTICS"))

‎src/test/regress/expected/alter_table.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,7 +2262,7 @@ select reltoastrelid <> 0 as has_toast_table
22622262
f
22632263
(1 row)
22642264

2265-
alter table test_storage alter a set storageextended; -- re-add TOAST table
2265+
alter table test_storage alter a set storagedefault; -- re-add TOAST table
22662266
select reltoastrelid <> 0 as has_toast_table
22672267
from pg_class where oid = 'test_storage'::regclass;
22682268
has_toast_table

‎src/test/regress/sql/alter_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ alter table test_storage alter a set storage plain;
15351535
altertable test_storage add bint default random()::int;
15361536
select reltoastrelid<>0as has_toast_table
15371537
from pg_classwhereoid='test_storage'::regclass;
1538-
altertable test_storage alter aset storageextended;-- re-add TOAST table
1538+
altertable test_storage alter aset storagedefault;-- re-add TOAST table
15391539
select reltoastrelid<>0as has_toast_table
15401540
from pg_classwhereoid='test_storage'::regclass;
15411541

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp