@@ -405,6 +405,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
405
405
transform_element_list transform_type_list
406
406
TriggerTransitions TriggerReferencing
407
407
publication_name_list
408
+ optCompressionParameters
408
409
vacuum_relation_list opt_vacuum_relation_list
409
410
410
411
%type <list> group_by_list
@@ -590,6 +591,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
590
591
%type <list> hash_partbound
591
592
%type <defelt> hash_partbound_elem
592
593
594
+ %type <node> optColumnCompression alterColumnCompression
595
+ %type <str> compressionClause
596
+ %type <list> optCompressionPreserve
597
+
593
598
/*
594
599
* Non-keyword token types. These are hard-wired into the "flex" lexer.
595
600
* They must be listed first so that their numeric codes do not depend on
@@ -622,9 +627,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
622
627
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
623
628
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
624
629
CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
625
- COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
626
- CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
627
- CROSS CSV CUBE CURRENT_P
630
+ COMMITTED COMPRESSION CONCURRENTLY CONFIGURATION CONFLICT
631
+ CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
632
+ COST CREATE CROSS CSV CUBE CURRENT_P
628
633
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
629
634
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
630
635
@@ -2219,6 +2224,15 @@ alter_table_cmd:
2219
2224
n->missing_ok = true ;
2220
2225
$$ = (Node *)n;
2221
2226
}
2227
+ /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET (COMPRESSION <cm> [WITH (<options>)]) */
2228
+ | ALTER opt_column ColId SET alterColumnCompression
2229
+ {
2230
+ AlterTableCmd *n = makeNode(AlterTableCmd);
2231
+ n->subtype = AT_SetCompression;
2232
+ n->name = $3 ;
2233
+ n->def = $5 ;
2234
+ $$ = (Node *)n;
2235
+ }
2222
2236
/* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
2223
2237
| DROP opt_column IF_P EXISTS ColId opt_drop_behavior
2224
2238
{
@@ -3326,11 +3340,12 @@ TypedTableElement:
3326
3340
| TableConstraint { $$ = $1 ; }
3327
3341
;
3328
3342
3329
- columnDef : ColId Typename create_generic_options ColQualList
3343
+ columnDef : ColId Typename optColumnCompression create_generic_options ColQualList
3330
3344
{
3331
3345
ColumnDef *n = makeNode(ColumnDef);
3332
3346
n->colname = $1 ;
3333
3347
n->typeName = $2 ;
3348
+ n->compression = (ColumnCompression *) $3 ;
3334
3349
n->inhcount = 0 ;
3335
3350
n->is_local = true ;
3336
3351
n->is_not_null = false ;
@@ -3339,8 +3354,8 @@ columnDef: ColId Typename create_generic_options ColQualList
3339
3354
n->raw_default = NULL ;
3340
3355
n->cooked_default = NULL ;
3341
3356
n->collOid = InvalidOid;
3342
- n->fdwoptions = $3 ;
3343
- SplitColQualList ($4 , &n->constraints, &n->collClause,
3357
+ n->fdwoptions = $4 ;
3358
+ SplitColQualList ($5 , &n->constraints, &n->collClause,
3344
3359
yyscanner);
3345
3360
n->location = @1 ;
3346
3361
$$ = (Node *)n;
@@ -3385,6 +3400,43 @@ columnOptions: ColId ColQualList
3385
3400
}
3386
3401
;
3387
3402
3403
+ optCompressionPreserve :
3404
+ PRESERVE ' (' name_list ' )' { $$ = $3 ; }
3405
+ | /* EMPTY*/ { $$ = NULL ; }
3406
+ ;
3407
+
3408
+ optCompressionParameters :
3409
+ WITH ' (' generic_option_list ' )' { $$ = $3 ; }
3410
+ | /* EMPTY*/ { $$ = NULL ; }
3411
+ ;
3412
+
3413
+ compressionClause :
3414
+ COMPRESSION name { $$ = pstrdup($2 ); }
3415
+ ;
3416
+
3417
+ optColumnCompression :
3418
+ compressionClause optCompressionParameters
3419
+ {
3420
+ ColumnCompression *n = makeNode(ColumnCompression);
3421
+ n->amname = $1 ;
3422
+ n->options = (List *) $2 ;
3423
+ n->preserve = NIL;
3424
+ $$ = (Node *) n;
3425
+ }
3426
+ | /* EMPTY*/ { $$ = NULL ; }
3427
+ ;
3428
+
3429
+ alterColumnCompression :
3430
+ compressionClause optCompressionParameters optCompressionPreserve
3431
+ {
3432
+ ColumnCompression *n = makeNode(ColumnCompression);
3433
+ n->amname = $1 ;
3434
+ n->options = (List *) $2 ;
3435
+ n->preserve = (List *) $3 ;
3436
+ $$ = (Node *) n;
3437
+ }
3438
+ ;
3439
+
3388
3440
ColQualList :
3389
3441
ColQualList ColConstraint { $$ = lappend($1 , $2 ); }
3390
3442
| /* EMPTY*/ { $$ = NIL; }
@@ -3614,6 +3666,7 @@ TableLikeOption:
3614
3666
| INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; }
3615
3667
| STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; }
3616
3668
| STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; }
3669
+ | COMPRESSION { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
3617
3670
| ALL { $$ = CREATE_TABLE_LIKE_ALL; }
3618
3671
;
3619
3672
@@ -5312,6 +5365,7 @@ CreateAmStmt: CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
5312
5365
am_type :
5313
5366
INDEX { $$ = AMTYPE_INDEX; }
5314
5367
| TABLE { $$ = AMTYPE_TABLE; }
5368
+ | COMPRESSION { $$ = AMTYPE_COMPRESSION; }
5315
5369
;
5316
5370
5317
5371
/* ****************************************************************************
@@ -15055,6 +15109,7 @@ unreserved_keyword:
15055
15109
| COMMENTS
15056
15110
| COMMIT
15057
15111
| COMMITTED
15112
+ | COMPRESSION
15058
15113
| CONFIGURATION
15059
15114
| CONFLICT
15060
15115
| CONNECTION
0 commit comments