aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-01-13 18:14:53 +0100
committerPeter Eisentraut <peter@eisentraut.org>2024-01-13 18:14:53 +0100
commit4f622503d6de975ac87448aea5cea7de4bc140d5 (patch)
treec09756e667e5150678e8ebf9aee6c1cd5e376a96 /src/backend/parser
parent45da69371ebfc4d6982695e58791989660c1cc33 (diff)
downloadpostgresql-4f622503d6de975ac87448aea5cea7de4bc140d5.tar.gz
postgresql-4f622503d6de975ac87448aea5cea7de4bc140d5.zip
Make attstattarget nullable
This changes the pg_attribute field attstattarget into a nullable field in the variable-length part of the row. If no value is set by the user for attstattarget, it is now null instead of previously -1. This saves space in pg_attribute and tuple descriptors for most practical scenarios. (ATTRIBUTE_FIXED_PART_SIZE is reduced from 108 to 104.) Also, null is the semantically more correct value. The ANALYZE code internally continues to represent the default statistics target by -1, so that that code can avoid having to deal with null values. But that is now contained to the ANALYZE code. Only the DDL code deals with attstattarget possibly null. For system columns, the field is now always null. The ANALYZE code skips system columns anyway. To set a column's statistics target to the default value, the new command form ALTER TABLE ... SET STATISTICS DEFAULT can be used. (SET STATISTICS -1 still works.) Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://www.postgresql.org/message-id/flat/4da8d211-d54d-44b9-9847-f2a9f1184c76@eisentraut.org
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 6b88096e8e1..3460fea56ba 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -337,6 +337,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> alter_table_cmds alter_type_cmds
%type <list> alter_identity_column_option_list
%type <defelt> alter_identity_column_option
+%type <node> set_statistics_value
%type <list> createdb_opt_list createdb_opt_items copy_opt_list
transaction_mode_list
@@ -2446,18 +2447,18 @@ alter_table_cmd:
n->missing_ok = true;
$$ = (Node *) n;
}
- /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STATISTICS <SignedIconst> */
- | ALTER opt_column ColId SET STATISTICS SignedIconst
+ /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STATISTICS */
+ | ALTER opt_column ColId SET STATISTICS set_statistics_value
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetStatistics;
n->name = $3;
- n->def = (Node *) makeInteger($6);
+ n->def = $6;
$$ = (Node *) n;
}
- /* ALTER TABLE <name> ALTER [COLUMN] <colnum> SET STATISTICS <SignedIconst> */
- | ALTER opt_column Iconst SET STATISTICS SignedIconst
+ /* ALTER TABLE <name> ALTER [COLUMN] <colnum> SET STATISTICS */
+ | ALTER opt_column Iconst SET STATISTICS set_statistics_value
{
AlterTableCmd *n = makeNode(AlterTableCmd);
@@ -2469,7 +2470,7 @@ alter_table_cmd:
n->subtype = AT_SetStatistics;
n->num = (int16) $3;
- n->def = (Node *) makeInteger($6);
+ n->def = $6;
$$ = (Node *) n;
}
/* ALTER TABLE <name> ALTER [COLUMN] <colname> SET ( column_parameter = value [, ... ] ) */
@@ -3070,6 +3071,11 @@ alter_identity_column_option:
}
;
+set_statistics_value:
+ SignedIconst { $$ = (Node *) makeInteger($1); }
+ | DEFAULT { $$ = NULL; }
+ ;
+
PartitionBoundSpec:
/* a HASH partition */
FOR VALUES WITH '(' hash_partbound ')'