agora inbox for [email protected]
help / color / mirror / Atom feed[PATCH 1/8] Make syntax changes for custom compression methods
11+ messages / 7 participants
[nested] [flat]
* [PATCH 1/8] Make syntax changes for custom compression methods
@ 2018-06-18 09:25 Ildus Kurbangaliev <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Ildus Kurbangaliev @ 2018-06-18 09:25 UTC (permalink / raw)
Signed-off-by: Ildus Kurbangaliev <[email protected]>
---
src/backend/parser/gram.y | 76 ++++++++++++++++++++++++++++++----
src/include/catalog/pg_am.h | 1 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 19 ++++++++-
src/include/parser/kwlist.h | 1 +
5 files changed, 89 insertions(+), 9 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 2c2208ffb7..2087eeb08d 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -311,6 +311,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
opt_grant_grant_option opt_grant_admin_option
opt_nowait opt_if_exists opt_with_data
%type <ival> opt_nowait_or_skip
+%type <ival> AccessMethodType
%type <list> OptRoleList AlterOptRoleList
%type <defelt> CreateOptRoleElem AlterOptRoleElem
@@ -399,6 +400,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
transform_element_list transform_type_list
TriggerTransitions TriggerReferencing
publication_name_list
+ optCompressionParameters
vacuum_relation_list opt_vacuum_relation_list
%type <list> group_by_list
@@ -585,6 +587,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound partbound_datum_list range_datum_list
%type <defelt> hash_partbound_elem
+%type <node> optColumnCompression alterColumnCompression
+%type <str> compressionClause
+%type <list> optCompressionPreserve
+
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
* They must be listed first so that their numeric codes do not depend on
@@ -617,9 +623,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
- COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
- CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
- CROSS CSV CUBE CURRENT_P
+ COMMITTED COMPRESSION CONCURRENTLY CONFIGURATION CONFLICT
+ CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
+ COST CREATE CROSS CSV CUBE CURRENT_P
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
@@ -2213,6 +2219,15 @@ alter_table_cmd:
n->missing_ok = true;
$$ = (Node *)n;
}
+ /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET (COMPRESSION <cm> [WITH (<options>)]) */
+ | ALTER opt_column ColId SET alterColumnCompression
+ {
+ AlterTableCmd *n = makeNode(AlterTableCmd);
+ n->subtype = AT_SetCompression;
+ n->name = $3;
+ n->def = $5;
+ $$ = (Node *)n;
+ }
/* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
| DROP opt_column IF_P EXISTS ColId opt_drop_behavior
{
@@ -3358,11 +3373,12 @@ TypedTableElement:
| TableConstraint { $$ = $1; }
;
-columnDef: ColId Typename create_generic_options ColQualList
+columnDef: ColId Typename optColumnCompression create_generic_options ColQualList
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->typeName = $2;
+ n->compression = (ColumnCompression *) $3;
n->inhcount = 0;
n->is_local = true;
n->is_not_null = false;
@@ -3371,8 +3387,8 @@ columnDef: ColId Typename create_generic_options ColQualList
n->raw_default = NULL;
n->cooked_default = NULL;
n->collOid = InvalidOid;
- n->fdwoptions = $3;
- SplitColQualList($4, &n->constraints, &n->collClause,
+ n->fdwoptions = $4;
+ SplitColQualList($5, &n->constraints, &n->collClause,
yyscanner);
n->location = @1;
$$ = (Node *)n;
@@ -3417,6 +3433,43 @@ columnOptions: ColId ColQualList
}
;
+optCompressionPreserve:
+ PRESERVE '(' name_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+optCompressionParameters:
+ WITH '(' generic_option_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+compressionClause:
+ COMPRESSION name { $$ = pstrdup($2); }
+ ;
+
+optColumnCompression:
+ compressionClause optCompressionParameters
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = NIL;
+ $$ = (Node *) n;
+ }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+alterColumnCompression:
+ compressionClause optCompressionParameters optCompressionPreserve
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = (List *) $3;
+ $$ = (Node *) n;
+ }
+ ;
+
ColQualList:
ColQualList ColConstraint { $$ = lappend($1, $2); }
| /*EMPTY*/ { $$ = NIL; }
@@ -3622,6 +3675,7 @@ TableLikeOption:
| INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; }
| STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; }
| STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; }
+ | COMPRESSION { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
| ALL { $$ = CREATE_TABLE_LIKE_ALL; }
;
@@ -5298,12 +5352,17 @@ row_security_cmd:
*
*****************************************************************************/
-CreateAmStmt: CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
+AccessMethodType:
+ INDEX { $$ = AMTYPE_INDEX; }
+ | COMPRESSION { $$ = AMTYPE_COMPRESSION; }
+ ;
+
+CreateAmStmt: CREATE ACCESS METHOD name TYPE_P AccessMethodType HANDLER handler_name
{
CreateAmStmt *n = makeNode(CreateAmStmt);
n->amname = $4;
n->handler_name = $8;
- n->amtype = AMTYPE_INDEX;
+ n->amtype = $6;
$$ = (Node *) n;
}
;
@@ -15003,6 +15062,7 @@ unreserved_keyword:
| COMMENTS
| COMMIT
| COMMITTED
+ | COMPRESSION
| CONFIGURATION
| CONFLICT
| CONNECTION
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 57d65f830f..f990e52025 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -53,6 +53,7 @@ typedef FormData_pg_am *Form_pg_am;
* Allowed values for amtype
*/
#define AMTYPE_INDEX 'i' /* index access method */
+#define AMTYPE_COMPRESSION 'c' /* compression access method */
#endif /* EXPOSE_TO_CLIENT_CODE */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index cac6ff0eda..a392fcdd2c 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -474,6 +474,7 @@ typedef enum NodeTag
T_PartitionBoundSpec,
T_PartitionRangeDatum,
T_PartitionCmd,
+ T_ColumnCompression,
T_VacuumRelation,
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index e5bdc1cec5..d7be502409 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -622,6 +622,20 @@ typedef struct RangeTableSample
int location; /* method name location, or -1 if unknown */
} RangeTableSample;
+/*
+ * ColumnCompression - compression parameters for some attribute
+ *
+ * This represents compression information defined using clause:
+ * .. COMPRESSION <compression method> WITH (<params>) PRESERVE <compression AMs>
+ */
+typedef struct ColumnCompression
+{
+ NodeTag type;
+ char *amname;
+ List *options;
+ List *preserve;
+} ColumnCompression;
+
/*
* ColumnDef - column definition (used in various creates)
*
@@ -645,6 +659,7 @@ typedef struct ColumnDef
NodeTag type;
char *colname; /* name of column */
TypeName *typeName; /* type of column */
+ ColumnCompression *compression;
int inhcount; /* number of times column is inherited */
bool is_local; /* column has local (non-inherited) def'n */
bool is_not_null; /* NOT NULL constraint specified? */
@@ -681,6 +696,7 @@ typedef enum TableLikeOption
CREATE_TABLE_LIKE_INDEXES = 1 << 4,
CREATE_TABLE_LIKE_STATISTICS = 1 << 5,
CREATE_TABLE_LIKE_STORAGE = 1 << 6,
+ CREATE_TABLE_LIKE_COMPRESSION = 1 << 7,
CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
} TableLikeOption;
@@ -1800,7 +1816,8 @@ typedef enum AlterTableType
AT_DetachPartition, /* DETACH PARTITION */
AT_AddIdentity, /* ADD IDENTITY */
AT_SetIdentity, /* SET identity column options */
- AT_DropIdentity /* DROP IDENTITY */
+ AT_DropIdentity, /* DROP IDENTITY */
+ AT_SetCompression /* SET COMPRESSION */
} AlterTableType;
typedef struct ReplicaIdentityStmt
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 23db40147b..76c33cbc5f 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -88,6 +88,7 @@ PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD)
PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD)
PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD)
PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD)
+PG_KEYWORD("compression", COMPRESSION, UNRESERVED_KEYWORD)
PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD)
PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD)
PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD)
--
2.19.2
--MP_/P_fMam4EyVB+zJLBGfX5oUD
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0002-Add-compression-catalog-tables-and-the-basic-inf-v20.patch
^ permalink raw reply [nested|flat] 11+ messages in thread
* [PATCH 1/8] Make syntax changes for custom compression methods
@ 2018-06-18 09:25 Ildus Kurbangaliev <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Ildus Kurbangaliev @ 2018-06-18 09:25 UTC (permalink / raw)
Signed-off-by: Ildus Kurbangaliev <[email protected]>
---
src/backend/parser/gram.y | 76 ++++++++++++++++++++++++++++++----
src/include/catalog/pg_am.h | 1 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 19 ++++++++-
src/include/parser/kwlist.h | 1 +
5 files changed, 89 insertions(+), 9 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 4bd2223f26..12ad9e5210 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -311,6 +311,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
opt_grant_grant_option opt_grant_admin_option
opt_nowait opt_if_exists opt_with_data
%type <ival> opt_nowait_or_skip
+%type <ival> AccessMethodType
%type <list> OptRoleList AlterOptRoleList
%type <defelt> CreateOptRoleElem AlterOptRoleElem
@@ -399,6 +400,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
transform_element_list transform_type_list
TriggerTransitions TriggerReferencing
publication_name_list
+ optCompressionParameters
vacuum_relation_list opt_vacuum_relation_list
%type <list> group_by_list
@@ -585,6 +587,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound partbound_datum_list range_datum_list
%type <defelt> hash_partbound_elem
+%type <node> optColumnCompression alterColumnCompression
+%type <str> compressionClause
+%type <list> optCompressionPreserve
+
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
* They must be listed first so that their numeric codes do not depend on
@@ -617,9 +623,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
- COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
- CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
- CROSS CSV CUBE CURRENT_P
+ COMMITTED COMPRESSION CONCURRENTLY CONFIGURATION CONFLICT
+ CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
+ COST CREATE CROSS CSV CUBE CURRENT_P
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
@@ -2214,6 +2220,15 @@ alter_table_cmd:
n->missing_ok = true;
$$ = (Node *)n;
}
+ /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET (COMPRESSION <cm> [WITH (<options>)]) */
+ | ALTER opt_column ColId SET alterColumnCompression
+ {
+ AlterTableCmd *n = makeNode(AlterTableCmd);
+ n->subtype = AT_SetCompression;
+ n->name = $3;
+ n->def = $5;
+ $$ = (Node *)n;
+ }
/* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
| DROP opt_column IF_P EXISTS ColId opt_drop_behavior
{
@@ -3380,11 +3395,12 @@ TypedTableElement:
| TableConstraint { $$ = $1; }
;
-columnDef: ColId Typename create_generic_options ColQualList
+columnDef: ColId Typename optColumnCompression create_generic_options ColQualList
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->typeName = $2;
+ n->compression = (ColumnCompression *) $3;
n->inhcount = 0;
n->is_local = true;
n->is_not_null = false;
@@ -3394,8 +3410,8 @@ columnDef: ColId Typename create_generic_options ColQualList
n->raw_default = NULL;
n->cooked_default = NULL;
n->collOid = InvalidOid;
- n->fdwoptions = $3;
- SplitColQualList($4, &n->constraints, &n->collClause,
+ n->fdwoptions = $4;
+ SplitColQualList($5, &n->constraints, &n->collClause,
yyscanner);
n->location = @1;
$$ = (Node *)n;
@@ -3442,6 +3458,43 @@ columnOptions: ColId ColQualList
}
;
+optCompressionPreserve:
+ PRESERVE '(' name_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+optCompressionParameters:
+ WITH '(' generic_option_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+compressionClause:
+ COMPRESSION name { $$ = pstrdup($2); }
+ ;
+
+optColumnCompression:
+ compressionClause optCompressionParameters
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = NIL;
+ $$ = (Node *) n;
+ }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+alterColumnCompression:
+ compressionClause optCompressionParameters optCompressionPreserve
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = (List *) $3;
+ $$ = (Node *) n;
+ }
+ ;
+
ColQualList:
ColQualList ColConstraint { $$ = lappend($1, $2); }
| /*EMPTY*/ { $$ = NIL; }
@@ -3647,6 +3700,7 @@ TableLikeOption:
| INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; }
| STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; }
| STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; }
+ | COMPRESSION { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
| ALL { $$ = CREATE_TABLE_LIKE_ALL; }
;
@@ -5324,12 +5378,17 @@ row_security_cmd:
*
*****************************************************************************/
-CreateAmStmt: CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
+AccessMethodType:
+ INDEX { $$ = AMTYPE_INDEX; }
+ | COMPRESSION { $$ = AMTYPE_COMPRESSION; }
+ ;
+
+CreateAmStmt: CREATE ACCESS METHOD name TYPE_P AccessMethodType HANDLER handler_name
{
CreateAmStmt *n = makeNode(CreateAmStmt);
n->amname = $4;
n->handler_name = $8;
- n->amtype = AMTYPE_INDEX;
+ n->amtype = $6;
$$ = (Node *) n;
}
;
@@ -15042,6 +15101,7 @@ unreserved_keyword:
| COMMENTS
| COMMIT
| COMMITTED
+ | COMPRESSION
| CONFIGURATION
| CONFLICT
| CONNECTION
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 26cb234987..a3b75c5256 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -51,6 +51,7 @@ typedef FormData_pg_am *Form_pg_am;
* Allowed values for amtype
*/
#define AMTYPE_INDEX 'i' /* index access method */
+#define AMTYPE_COMPRESSION 'c' /* compression access method */
#endif /* EXPOSE_TO_CLIENT_CODE */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 697d3d7a5f..c84c67a1f2 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -474,6 +474,7 @@ typedef enum NodeTag
T_PartitionBoundSpec,
T_PartitionRangeDatum,
T_PartitionCmd,
+ T_ColumnCompression,
T_VacuumRelation,
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 07ab1a3dde..c32a4546e7 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -623,6 +623,20 @@ typedef struct RangeTableSample
int location; /* method name location, or -1 if unknown */
} RangeTableSample;
+/*
+ * ColumnCompression - compression parameters for some attribute
+ *
+ * This represents compression information defined using clause:
+ * .. COMPRESSION <compression method> WITH (<params>) PRESERVE <compression AMs>
+ */
+typedef struct ColumnCompression
+{
+ NodeTag type;
+ char *amname;
+ List *options;
+ List *preserve;
+} ColumnCompression;
+
/*
* ColumnDef - column definition (used in various creates)
*
@@ -646,6 +660,7 @@ typedef struct ColumnDef
NodeTag type;
char *colname; /* name of column */
TypeName *typeName; /* type of column */
+ ColumnCompression *compression;
int inhcount; /* number of times column is inherited */
bool is_local; /* column has local (non-inherited) def'n */
bool is_not_null; /* NOT NULL constraint specified? */
@@ -683,6 +698,7 @@ typedef enum TableLikeOption
CREATE_TABLE_LIKE_INDEXES = 1 << 4,
CREATE_TABLE_LIKE_STATISTICS = 1 << 5,
CREATE_TABLE_LIKE_STORAGE = 1 << 6,
+ CREATE_TABLE_LIKE_COMPRESSION = 1 << 7,
CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
} TableLikeOption;
@@ -1790,7 +1806,8 @@ typedef enum AlterTableType
AT_DetachPartition, /* DETACH PARTITION */
AT_AddIdentity, /* ADD IDENTITY */
AT_SetIdentity, /* SET identity column options */
- AT_DropIdentity /* DROP IDENTITY */
+ AT_DropIdentity, /* DROP IDENTITY */
+ AT_SetCompression /* SET COMPRESSION */
} AlterTableType;
typedef struct ReplicaIdentityStmt
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 23db40147b..76c33cbc5f 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -88,6 +88,7 @@ PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD)
PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD)
PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD)
PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD)
+PG_KEYWORD("compression", COMPRESSION, UNRESERVED_KEYWORD)
PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD)
PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD)
PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD)
--
2.18.0
--MP_/tqROVSJLfUtKS/DWevR5Hf=
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0002-Add-compression-catalog-tables-and-the-basic-inf-v19.patch
^ permalink raw reply [nested|flat] 11+ messages in thread
* [PATCH 1/8] Make syntax changes for custom compression methods
@ 2018-06-18 09:25 Ildus Kurbangaliev <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Ildus Kurbangaliev @ 2018-06-18 09:25 UTC (permalink / raw)
Signed-off-by: Ildus Kurbangaliev <[email protected]>
---
src/backend/parser/gram.y | 76 ++++++++++++++++++++++++++++++----
src/include/catalog/pg_am.h | 1 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 19 ++++++++-
src/include/parser/kwlist.h | 1 +
5 files changed, 89 insertions(+), 9 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 6d23bfb0b3..ffcfb3c05b 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -311,6 +311,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
opt_grant_grant_option opt_grant_admin_option
opt_nowait opt_if_exists opt_with_data
%type <ival> opt_nowait_or_skip
+%type <ival> AccessMethodType
%type <list> OptRoleList AlterOptRoleList
%type <defelt> CreateOptRoleElem AlterOptRoleElem
@@ -399,6 +400,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
transform_element_list transform_type_list
TriggerTransitions TriggerReferencing
publication_name_list
+ optCompressionParameters
vacuum_relation_list opt_vacuum_relation_list
%type <list> group_by_list
@@ -585,6 +587,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound partbound_datum_list range_datum_list
%type <defelt> hash_partbound_elem
+%type <node> optColumnCompression alterColumnCompression
+%type <str> compressionClause
+%type <list> optCompressionPreserve
+
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
* They must be listed first so that their numeric codes do not depend on
@@ -617,9 +623,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
CACHE CALL CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMENTS COMMIT
- COMMITTED CONCURRENTLY CONFIGURATION CONFLICT CONNECTION CONSTRAINT
- CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE
- CROSS CSV CUBE CURRENT_P
+ COMMITTED COMPRESSION CONCURRENTLY CONFIGURATION CONFLICT
+ CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONTINUE_P CONVERSION_P COPY
+ COST CREATE CROSS CSV CUBE CURRENT_P
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
@@ -2213,6 +2219,15 @@ alter_table_cmd:
n->missing_ok = true;
$$ = (Node *)n;
}
+ /* ALTER TABLE <name> ALTER [COLUMN] <colname> SET (COMPRESSION <cm> [WITH (<options>)]) */
+ | ALTER opt_column ColId SET alterColumnCompression
+ {
+ AlterTableCmd *n = makeNode(AlterTableCmd);
+ n->subtype = AT_SetCompression;
+ n->name = $3;
+ n->def = $5;
+ $$ = (Node *)n;
+ }
/* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
| DROP opt_column IF_P EXISTS ColId opt_drop_behavior
{
@@ -3379,11 +3394,12 @@ TypedTableElement:
| TableConstraint { $$ = $1; }
;
-columnDef: ColId Typename create_generic_options ColQualList
+columnDef: ColId Typename optColumnCompression create_generic_options ColQualList
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->typeName = $2;
+ n->compression = (ColumnCompression *) $3;
n->inhcount = 0;
n->is_local = true;
n->is_not_null = false;
@@ -3393,8 +3409,8 @@ columnDef: ColId Typename create_generic_options ColQualList
n->raw_default = NULL;
n->cooked_default = NULL;
n->collOid = InvalidOid;
- n->fdwoptions = $3;
- SplitColQualList($4, &n->constraints, &n->collClause,
+ n->fdwoptions = $4;
+ SplitColQualList($5, &n->constraints, &n->collClause,
yyscanner);
n->location = @1;
$$ = (Node *)n;
@@ -3441,6 +3457,43 @@ columnOptions: ColId ColQualList
}
;
+optCompressionPreserve:
+ PRESERVE '(' name_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+optCompressionParameters:
+ WITH '(' generic_option_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+compressionClause:
+ COMPRESSION name { $$ = pstrdup($2); }
+ ;
+
+optColumnCompression:
+ compressionClause optCompressionParameters
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = NIL;
+ $$ = (Node *) n;
+ }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+alterColumnCompression:
+ compressionClause optCompressionParameters optCompressionPreserve
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->amname = $1;
+ n->options = (List *) $2;
+ n->preserve = (List *) $3;
+ $$ = (Node *) n;
+ }
+ ;
+
ColQualList:
ColQualList ColConstraint { $$ = lappend($1, $2); }
| /*EMPTY*/ { $$ = NIL; }
@@ -3646,6 +3699,7 @@ TableLikeOption:
| INDEXES { $$ = CREATE_TABLE_LIKE_INDEXES; }
| STATISTICS { $$ = CREATE_TABLE_LIKE_STATISTICS; }
| STORAGE { $$ = CREATE_TABLE_LIKE_STORAGE; }
+ | COMPRESSION { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
| ALL { $$ = CREATE_TABLE_LIKE_ALL; }
;
@@ -5323,12 +5377,17 @@ row_security_cmd:
*
*****************************************************************************/
-CreateAmStmt: CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
+AccessMethodType:
+ INDEX { $$ = AMTYPE_INDEX; }
+ | COMPRESSION { $$ = AMTYPE_COMPRESSION; }
+ ;
+
+CreateAmStmt: CREATE ACCESS METHOD name TYPE_P AccessMethodType HANDLER handler_name
{
CreateAmStmt *n = makeNode(CreateAmStmt);
n->amname = $4;
n->handler_name = $8;
- n->amtype = AMTYPE_INDEX;
+ n->amtype = $6;
$$ = (Node *) n;
}
;
@@ -15029,6 +15088,7 @@ unreserved_keyword:
| COMMENTS
| COMMIT
| COMMITTED
+ | COMPRESSION
| CONFIGURATION
| CONFLICT
| CONNECTION
diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h
index 26cb234987..a3b75c5256 100644
--- a/src/include/catalog/pg_am.h
+++ b/src/include/catalog/pg_am.h
@@ -51,6 +51,7 @@ typedef FormData_pg_am *Form_pg_am;
* Allowed values for amtype
*/
#define AMTYPE_INDEX 'i' /* index access method */
+#define AMTYPE_COMPRESSION 'c' /* compression access method */
#endif /* EXPOSE_TO_CLIENT_CODE */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index cac6ff0eda..a392fcdd2c 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -474,6 +474,7 @@ typedef enum NodeTag
T_PartitionBoundSpec,
T_PartitionRangeDatum,
T_PartitionCmd,
+ T_ColumnCompression,
T_VacuumRelation,
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index aa4a0dba2a..dde4697425 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -622,6 +622,20 @@ typedef struct RangeTableSample
int location; /* method name location, or -1 if unknown */
} RangeTableSample;
+/*
+ * ColumnCompression - compression parameters for some attribute
+ *
+ * This represents compression information defined using clause:
+ * .. COMPRESSION <compression method> WITH (<params>) PRESERVE <compression AMs>
+ */
+typedef struct ColumnCompression
+{
+ NodeTag type;
+ char *amname;
+ List *options;
+ List *preserve;
+} ColumnCompression;
+
/*
* ColumnDef - column definition (used in various creates)
*
@@ -645,6 +659,7 @@ typedef struct ColumnDef
NodeTag type;
char *colname; /* name of column */
TypeName *typeName; /* type of column */
+ ColumnCompression *compression;
int inhcount; /* number of times column is inherited */
bool is_local; /* column has local (non-inherited) def'n */
bool is_not_null; /* NOT NULL constraint specified? */
@@ -682,6 +697,7 @@ typedef enum TableLikeOption
CREATE_TABLE_LIKE_INDEXES = 1 << 4,
CREATE_TABLE_LIKE_STATISTICS = 1 << 5,
CREATE_TABLE_LIKE_STORAGE = 1 << 6,
+ CREATE_TABLE_LIKE_COMPRESSION = 1 << 7,
CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
} TableLikeOption;
@@ -1803,7 +1819,8 @@ typedef enum AlterTableType
AT_DetachPartition, /* DETACH PARTITION */
AT_AddIdentity, /* ADD IDENTITY */
AT_SetIdentity, /* SET identity column options */
- AT_DropIdentity /* DROP IDENTITY */
+ AT_DropIdentity, /* DROP IDENTITY */
+ AT_SetCompression /* SET COMPRESSION */
} AlterTableType;
typedef struct ReplicaIdentityStmt
diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h
index 23db40147b..76c33cbc5f 100644
--- a/src/include/parser/kwlist.h
+++ b/src/include/parser/kwlist.h
@@ -88,6 +88,7 @@ PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD)
PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD)
PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD)
PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD)
+PG_KEYWORD("compression", COMPRESSION, UNRESERVED_KEYWORD)
PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD)
PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD)
PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD)
--
2.19.1
--MP_/7ZVSJ3tZdZjf_J65xpltpI_
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0002-Add-compression-catalog-tables-and-the-basic-inf-v20.patch
^ permalink raw reply [nested|flat] 11+ messages in thread
* [PATCH v3] print table associated with given TOAST table
@ 2019-05-01 00:05 Justin Pryzby <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Justin Pryzby @ 2019-05-01 00:05 UTC (permalink / raw)
---
src/bin/psql/describe.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index c65bc82..ff98c4f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2153,6 +2153,28 @@ describeOneTableDetails(const char *schemaname,
}
}
+ /* print table associated with given TOAST table */
+ if (tableinfo.relkind == RELKIND_TOASTVALUE)
+ {
+ PGresult *result = NULL;
+ printfPQExpBuffer(&buf,
+ "SELECT relnamespace::pg_catalog.regnamespace, relname FROM pg_class WHERE reltoastrelid = '%s'",
+ oid);
+ result = PSQLexec(buf.data);
+ if (!result) {
+ goto error_return;
+ } else if (1 != PQntuples(result)) {
+ PQclear(result);
+ goto error_return;
+ } else {
+ char *schemaname = PQgetvalue(result, 0, 0);
+ char *relname = PQgetvalue(result, 0, 1);
+ appendPQExpBuffer(&tmpbuf, _("For table: \"%s.%s\""),
+ schemaname, relname);
+ printTableAddFooter(&cont, tmpbuf.data);
+ }
+ }
+
if (tableinfo.relkind == RELKIND_PARTITIONED_TABLE)
{
/* Get the partition key information */
--
2.7.4
--AqsLC8rIMeq19msA
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v3-0001-make-d-pg_toast.foo-show-its-indices.patch"
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Eliminating SPI from RI triggers - take 2
@ 2023-03-20 18:53 Gregory Stark (as CFM) <[email protected]>
2023-03-21 05:03 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Gregory Stark (as CFM) @ 2023-03-20 18:53 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: Amit Langote <[email protected]>; pgsql-hackers; Tom Lane <[email protected]>
On Mon, 17 Oct 2022 at 14:59, Robert Haas <[email protected]> wrote:
>
> On Sat, Oct 15, 2022 at 1:47 AM Amit Langote <[email protected]> wrote:
>
> But I think the bigger problem for this patch set is that the
> design-level feedback from
> https://www.postgresql.org/message-id/CA%2BTgmoaiTNj4DgQy42OT9JmTTP1NWcMV%2Bke0i%3D%2Ba7%3DVgnzqGXw%...
> hasn't really been addressed, AFAICS. ri_LookupKeyInPkRelPlanIsValid
> is still trivial in v7, and that still seems wrong to me. And I still
> don't know how we're going to avoid changing the semantics in ways
> that are undesirable, or even knowing precisely what we did change. If
> we don't have answers to those questions, then I suspect that this
> patch set isn't going anywhere.
Amit, do you plan to work on this patch for this commitfest (and
therefore this release?). And do you think it has a realistic chance
of being ready for commit this month?
It looks to me like you have some good feedback and can progress and
are unlikely to finish this patch for this release. In which case
maybe we can move it forward to the next release?
--
Gregory Stark
As Commitfest Manager
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Eliminating SPI from RI triggers - take 2
2023-03-20 18:53 Re: Eliminating SPI from RI triggers - take 2 Gregory Stark (as CFM) <[email protected]>
@ 2023-03-21 05:03 ` Amit Langote <[email protected]>
2023-07-10 08:27 ` Re: Eliminating SPI from RI triggers - take 2 Daniel Gustafsson <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Amit Langote @ 2023-03-21 05:03 UTC (permalink / raw)
To: Gregory Stark (as CFM) <[email protected]>; +Cc: Robert Haas <[email protected]>; pgsql-hackers; Tom Lane <[email protected]>
Hi Greg,
On Tue, Mar 21, 2023 at 3:54 AM Gregory Stark (as CFM)
<[email protected]> wrote:
> On Mon, 17 Oct 2022 at 14:59, Robert Haas <[email protected]> wrote:
> > But I think the bigger problem for this patch set is that the
> > design-level feedback from
> > https://www.postgresql.org/message-id/CA%2BTgmoaiTNj4DgQy42OT9JmTTP1NWcMV%2Bke0i%3D%2Ba7%3DVgnzqGXw%...
> > hasn't really been addressed, AFAICS. ri_LookupKeyInPkRelPlanIsValid
> > is still trivial in v7, and that still seems wrong to me. And I still
> > don't know how we're going to avoid changing the semantics in ways
> > that are undesirable, or even knowing precisely what we did change. If
> > we don't have answers to those questions, then I suspect that this
> > patch set isn't going anywhere.
>
> Amit, do you plan to work on this patch for this commitfest (and
> therefore this release?). And do you think it has a realistic chance
> of being ready for commit this month?
Unfortunately, I don't think so.
> It looks to me like you have some good feedback and can progress and
> are unlikely to finish this patch for this release. In which case
> maybe we can move it forward to the next release?
Yes, that's what I am thinking too at this point.
I agree with Robert's point that changing the implementation from an
SQL query plan to a hand-rolled C function is going to change the
semantics in some known and perhaps many unknown ways. Until I have
enumerated all those semantic changes, it's hard to judge whether the
hand-rolled implementation is correct to begin with. I had started
doing that a few months back but couldn't keep up due to some other
work.
An example I had found of a thing that would be broken by taking out
the executor out of the equation, as the patch does, is the behavior
of an update under READ COMMITTED isolation, whereby a PK tuple being
checked for existence is concurrently updated and thus needs to
rechecked whether it still satisfies the RI query's conditions. The
executor has the EvalPlanQual() mechanism to do that, but while the
hand-rolled implementation did refactor ExecLockRows() to allow doing
the tuple-locking without a PlanState, it gave no consideration to
handling rechecking under READ COMMITTED isolation.
There may be other such things and I think I'd better look for them
carefully in the next cycle than in the next couple of weeks for this
release. My apologies that I didn't withdraw the patch sooner.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Eliminating SPI from RI triggers - take 2
2023-03-20 18:53 Re: Eliminating SPI from RI triggers - take 2 Gregory Stark (as CFM) <[email protected]>
2023-03-21 05:03 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
@ 2023-07-10 08:27 ` Daniel Gustafsson <[email protected]>
2023-07-10 08:30 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Gustafsson @ 2023-07-10 08:27 UTC (permalink / raw)
To: Amit Langote <[email protected]>; +Cc: Gregory Stark (as CFM) <[email protected]>; Robert Haas <[email protected]>; pgsql-hackers; Tom Lane <[email protected]>
> On 21 Mar 2023, at 06:03, Amit Langote <[email protected]> wrote:
> On Tue, Mar 21, 2023 at 3:54 AM Gregory Stark (as CFM) <[email protected]> wrote:
>> On Mon, 17 Oct 2022 at 14:59, Robert Haas <[email protected]> wrote:
>>> But I think the bigger problem for this patch set is that the
>>> design-level feedback from
>>> https://www.postgresql.org/message-id/CA%2BTgmoaiTNj4DgQy42OT9JmTTP1NWcMV%2Bke0i%3D%2Ba7%3DVgnzqGXw%...
>>> hasn't really been addressed, AFAICS. ri_LookupKeyInPkRelPlanIsValid
>>> is still trivial in v7, and that still seems wrong to me. And I still
>>> don't know how we're going to avoid changing the semantics in ways
>>> that are undesirable, or even knowing precisely what we did change. If
>>> we don't have answers to those questions, then I suspect that this
>>> patch set isn't going anywhere.
>>
>> Amit, do you plan to work on this patch for this commitfest (and
>> therefore this release?). And do you think it has a realistic chance
>> of being ready for commit this month?
>
> Unfortunately, I don't think so.
This thread has stalled with the patch not building and/or applying for a
while, so I am going to mark this Returned with Feebdback. Please feel free to
resubmit to a future CF when there is renewed interest/time to work on this.
--
Daniel Gustafsson
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Eliminating SPI from RI triggers - take 2
2023-03-20 18:53 Re: Eliminating SPI from RI triggers - take 2 Gregory Stark (as CFM) <[email protected]>
2023-03-21 05:03 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
2023-07-10 08:27 ` Re: Eliminating SPI from RI triggers - take 2 Daniel Gustafsson <[email protected]>
@ 2023-07-10 08:30 ` Amit Langote <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Amit Langote @ 2023-07-10 08:30 UTC (permalink / raw)
To: Daniel Gustafsson <[email protected]>; +Cc: Gregory Stark (as CFM) <[email protected]>; Robert Haas <[email protected]>; pgsql-hackers; Tom Lane <[email protected]>
On Mon, Jul 10, 2023 at 5:27 PM Daniel Gustafsson <[email protected]> wrote:
> > On 21 Mar 2023, at 06:03, Amit Langote <[email protected]> wrote:
> > On Tue, Mar 21, 2023 at 3:54 AM Gregory Stark (as CFM) <[email protected]> wrote:
> >> On Mon, 17 Oct 2022 at 14:59, Robert Haas <[email protected]> wrote:
>
> >>> But I think the bigger problem for this patch set is that the
> >>> design-level feedback from
> >>> https://www.postgresql.org/message-id/CA%2BTgmoaiTNj4DgQy42OT9JmTTP1NWcMV%2Bke0i%3D%2Ba7%3DVgnzqGXw%...
> >>> hasn't really been addressed, AFAICS. ri_LookupKeyInPkRelPlanIsValid
> >>> is still trivial in v7, and that still seems wrong to me. And I still
> >>> don't know how we're going to avoid changing the semantics in ways
> >>> that are undesirable, or even knowing precisely what we did change. If
> >>> we don't have answers to those questions, then I suspect that this
> >>> patch set isn't going anywhere.
> >>
> >> Amit, do you plan to work on this patch for this commitfest (and
> >> therefore this release?). And do you think it has a realistic chance
> >> of being ready for commit this month?
> >
> > Unfortunately, I don't think so.
>
> This thread has stalled with the patch not building and/or applying for a
> while, so I am going to mark this Returned with Feebdback.
Agreed, I was about to do so myself.
I'll give this another try later in the cycle.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgbnech: allow to cancel queries during benchmark
@ 2024-01-19 07:51 Yugo NAGATA <[email protected]>
2024-01-19 08:46 ` Re: pgbnech: allow to cancel queries during benchmark Tatsuo Ishii <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Yugo NAGATA @ 2024-01-19 07:51 UTC (permalink / raw)
To: Tatsuo Ishii <[email protected]>; +Cc: [email protected]; [email protected]
On Mon, 15 Jan 2024 16:49:44 +0900 (JST)
Tatsuo Ishii <[email protected]> wrote:
> > On Wed, 6 Sep 2023 20:13:34 +0900
> > Yugo NAGATA <[email protected]> wrote:
> >
> >> I attached the updated patch v3. The changes since the previous
> >> patch includes the following;
> >>
> >> I removed the unnecessary condition (&& false) that you
> >> pointed out in [1].
> >>
> >> The test was rewritten by using IPC::Run signal() and integrated
> >> to "001_pgbench_with_server.pl". This test is skipped on Windows
> >> because SIGINT causes to terminate the test itself as discussed
> >> in [2] about query cancellation test in psql.
> >>
> >> I added some comments to describe how query cancellation is
> >> handled as I explained in [1].
> >>
> >> Also, I found the previous patch didn't work on Windows so fixed it.
> >> On non-Windows system, a thread waiting a response of long query can
> >> be interrupted by SIGINT, but on Windows, threads do not return from
> >> waiting until queries they are running are cancelled. This is because,
> >> when the signal is received, the system just creates a new thread to
> >> execute the callback function specified by setup_cancel_handler, and
> >> other thread continue to run[3]. Therefore, the queries have to be
> >> cancelled in the callback function.
> >>
> >> [1] https://www.postgresql.org/message-id/a58388ac-5411-4760-ea46-71324d8324cb%40mines-paristech.fr
> >> [2] https://www.postgresql.org/message-id/20230906004524.2fd6ee049f8a6c6f2690b99c%40sraoss.co.jp
> >> [3] https://learn.microsoft.com/en-us/windows/console/handlerroutine
> >
> > I found that --disable-thread-safety option was removed in 68a4b58eca0329.
> > So, I removed codes involving ENABLE_THREAD_SAFETY from the patch.
> >
> > Also, I wrote a commit log draft.
>
> > Previously, Ctrl+C during benchmark killed pgbench immediately,
> > but queries running at that time were not cancelled.
>
> Better to mention explicitely that queries keep on running on the
> backend. What about this?
>
> Previously, Ctrl+C during benchmark killed pgbench immediately, but
> queries were not canceled and they keep on running on the backend
> until they tried to send the result to pgbench.
Thank you for your comments. I agree with you, so I fixed the message
as your suggestion.
> > The commit
> > fixes this so that cancel requests are sent for all connections
> > before pgbench exits.
>
> "sent for" -> "sent to"
Fixed.
> > Attached is the updated version, v4.
>
> +/* send cancel requests to all connections */
> +static void
> +cancel_all()
> +{
> + for (int i = 0; i < nclients; i++)
> + {
> + char errbuf[1];
> + if (client_states[i].cancel != NULL)
> + (void) PQcancel(client_states[i].cancel, errbuf, sizeof(errbuf));
> + }
> +}
> +
>
> Why in case of errors from PQCancel the error message is neglected? I
> think it's better to print out the error message in case of error.
Is the message useful for pgbench users? I saw the error is ignored
in pg_dump, for example in bin/pg_dump/parallel.c
/*
* Send QueryCancel to leader connection, if enabled. Ignore errors,
* there's not much we can do about them anyway.
*/
if (signal_info.myAH != NULL && signal_info.myAH->connCancel != NULL)
(void) PQcancel(signal_info.myAH->connCancel,
errbuf, sizeof(errbuf));
> + * On non-Windows, any callback function is not set. When SIGINT is
> + * received, CancelRequested is just set, and only thread #0 is interrupted
> + * and returns from waiting input from the backend. After that, the thread
> + * sends cancel requests to all benchmark queries.
>
> The second line is a little bit long according to the coding
> standard. Fix like this?
>
> * On non-Windows, any callback function is not set. When SIGINT is
> * received, CancelRequested is just set, and only thread #0 is
> * interrupted and returns from waiting input from the backend. After
> * that, the thread sends cancel requests to all benchmark queries.
Fixed.
The attached is the updated patch, v5.
Regards,
Yugo Nagata
> Best reagards,
> --
> Tatsuo Ishii
> SRA OSS LLC
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
--
Yugo NAGATA <[email protected]>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgbnech: allow to cancel queries during benchmark
2024-01-19 07:51 Re: pgbnech: allow to cancel queries during benchmark Yugo NAGATA <[email protected]>
@ 2024-01-19 08:46 ` Tatsuo Ishii <[email protected]>
2024-01-24 13:17 ` Re: pgbnech: allow to cancel queries during benchmark Yugo NAGATA <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Tatsuo Ishii @ 2024-01-19 08:46 UTC (permalink / raw)
To: [email protected]; +Cc: [email protected]; [email protected]
>> +/* send cancel requests to all connections */
>> +static void
>> +cancel_all()
>> +{
>> + for (int i = 0; i < nclients; i++)
>> + {
>> + char errbuf[1];
>> + if (client_states[i].cancel != NULL)
>> + (void) PQcancel(client_states[i].cancel, errbuf, sizeof(errbuf));
>> + }
>> +}
>> +
>>
>> Why in case of errors from PQCancel the error message is neglected? I
>> think it's better to print out the error message in case of error.
>
> Is the message useful for pgbench users? I saw the error is ignored
> in pg_dump, for example in bin/pg_dump/parallel.c
I think the situation is different from pg_dump. Unlike pg_dump, if
PQcancel does not work, users can fix the problem by using
pg_terminate_backend or kill command. In order to make this work, an
appropriate error message is essential.
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: pgbnech: allow to cancel queries during benchmark
2024-01-19 07:51 Re: pgbnech: allow to cancel queries during benchmark Yugo NAGATA <[email protected]>
2024-01-19 08:46 ` Re: pgbnech: allow to cancel queries during benchmark Tatsuo Ishii <[email protected]>
@ 2024-01-24 13:17 ` Yugo NAGATA <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Yugo NAGATA @ 2024-01-24 13:17 UTC (permalink / raw)
To: Tatsuo Ishii <[email protected]>; +Cc: [email protected]; [email protected]
On Fri, 19 Jan 2024 17:46:03 +0900 (JST)
Tatsuo Ishii <[email protected]> wrote:
> >> +/* send cancel requests to all connections */
> >> +static void
> >> +cancel_all()
> >> +{
> >> + for (int i = 0; i < nclients; i++)
> >> + {
> >> + char errbuf[1];
> >> + if (client_states[i].cancel != NULL)
> >> + (void) PQcancel(client_states[i].cancel, errbuf, sizeof(errbuf));
> >> + }
> >> +}
> >> +
> >>
> >> Why in case of errors from PQCancel the error message is neglected? I
> >> think it's better to print out the error message in case of error.
> >
> > Is the message useful for pgbench users? I saw the error is ignored
> > in pg_dump, for example in bin/pg_dump/parallel.c
>
> I think the situation is different from pg_dump. Unlike pg_dump, if
> PQcancel does not work, users can fix the problem by using
> pg_terminate_backend or kill command. In order to make this work, an
> appropriate error message is essential.
Makes sense. I fixed to emit an error message when PQcancel fails.
Also, I added some comments about the signal handling on Windows
to explain why the different way than non-Windows is required;
+ * On Windows, a callback function is set in which query cancel requests
+ * are sent to all benchmark queries running in the backend. This is
+ * required because all threads running queries continue to run without
+ * interrupted even when the signal is received.
+ *
Attached is the updated patch, v6.
> Best reagards,
> --
> Tatsuo Ishii
> SRA OSS LLC
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
>
>
--
Yugo NAGATA <[email protected]>
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2024-01-24 13:17 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 09:25 [PATCH 1/8] Make syntax changes for custom compression methods Ildus Kurbangaliev <[email protected]>
2018-06-18 09:25 [PATCH 1/8] Make syntax changes for custom compression methods Ildus Kurbangaliev <[email protected]>
2018-06-18 09:25 [PATCH 1/8] Make syntax changes for custom compression methods Ildus Kurbangaliev <[email protected]>
2019-05-01 00:05 [PATCH v3] print table associated with given TOAST table Justin Pryzby <[email protected]>
2023-03-20 18:53 Re: Eliminating SPI from RI triggers - take 2 Gregory Stark (as CFM) <[email protected]>
2023-03-21 05:03 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
2023-07-10 08:27 ` Re: Eliminating SPI from RI triggers - take 2 Daniel Gustafsson <[email protected]>
2023-07-10 08:30 ` Re: Eliminating SPI from RI triggers - take 2 Amit Langote <[email protected]>
2024-01-19 07:51 Re: pgbnech: allow to cancel queries during benchmark Yugo NAGATA <[email protected]>
2024-01-19 08:46 ` Re: pgbnech: allow to cancel queries during benchmark Tatsuo Ishii <[email protected]>
2024-01-24 13:17 ` Re: pgbnech: allow to cancel queries during benchmark Yugo NAGATA <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox