public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v24 7/7] Add support for PRESERVE
3+ messages / 3 participants
[nested] [flat]
* [PATCH v24 7/7] Add support for PRESERVE
@ 2021-02-10 06:19 Dilip Kumar <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Dilip Kumar @ 2021-02-10 06:19 UTC (permalink / raw)
Now the compression method can be changed without forcing a table
rewrite, by including the old method in the PRESERVE list. �For
supporting this the column will maintain the dependency with all
the supported compression methods. �So whenever the compression
method is altered the dependency is added with the new compression
method and the dependency is removed for all the old compression
methods which are not given in the preserve list. �If PRESERVE ALL
is given then all the dependency is maintained.
Dilip Kumar based on the patches from Ildus Kurbangaliev.
Design input from Tomas Vondra and Robert Haas
Reviewed by Robert Haas, Tomas Vondra, Alexander Korotkov and Justin Pryzby
---
doc/src/sgml/ref/alter_table.sgml | 10 +-
src/backend/catalog/pg_depend.c | 7 +
src/backend/commands/Makefile | 1 +
src/backend/commands/compressioncmds.c | 300 ++++++++++++++++++++
src/backend/commands/tablecmds.c | 126 ++++----
src/backend/executor/nodeModifyTable.c | 12 +-
src/backend/nodes/copyfuncs.c | 17 +-
src/backend/nodes/equalfuncs.c | 15 +-
src/backend/nodes/outfuncs.c | 15 +-
src/backend/parser/gram.y | 52 +++-
src/backend/parser/parse_utilcmd.c | 2 +-
src/bin/pg_dump/pg_dump.c | 101 +++++++
src/bin/pg_dump/pg_dump.h | 15 +-
src/bin/psql/tab-complete.c | 7 +
src/include/commands/defrem.h | 7 +
src/include/commands/tablecmds.h | 2 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 16 +-
src/test/regress/expected/compression.out | 37 ++-
src/test/regress/expected/compression_1.out | 39 ++-
src/test/regress/expected/create_index.out | 56 ++--
src/test/regress/sql/compression.sql | 9 +
22 files changed, 739 insertions(+), 108 deletions(-)
create mode 100644 src/backend/commands/compressioncmds.c
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 0bd0c1a503..c9f443a59c 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -54,7 +54,7 @@ ALTER TABLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable>
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] )
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] )
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
- ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable>
+ ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable> [ PRESERVE (<replaceable class="parameter">compression_preserve_list</replaceable>) | PRESERVE ALL ]
ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
ADD <replaceable class="parameter">table_constraint_using_index</replaceable>
ALTER CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
@@ -387,7 +387,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
<varlistentry>
<term>
- <literal>SET COMPRESSION <replaceable class="parameter">compression_method</replaceable></literal>
+ <literal>SET COMPRESSION <replaceable class="parameter">compression_method</replaceable> [ PRESERVE (<replaceable class="parameter">compression_preserve_list</replaceable>) | PRESERVE ALL ]</literal>
</term>
<listitem>
<para>
@@ -395,6 +395,12 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
methods are <literal>pglz</literal> and <literal>lz4</literal>.
<literal>lz4</literal> is available only if <literal>--with-lz4</literal>
was used when building <productname>PostgreSQL</productname>.
+ The <literal>PRESERVE</literal> list contains a list of compression
+ methods used in the column and determines which of them may be kept.
+ Without <literal>PRESERVE</literal> or if any of the pre-existing
+ compression methods are not preserved, the table will be rewritten. If
+ <literal>PRESERVE ALL</literal> is specified, then all of the existing
+ methods will be preserved and the table will not be rewritten.
</para>
</listitem>
</varlistentry>
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index 63da24322d..dd376484b7 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -17,6 +17,7 @@
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
+#include "catalog/pg_am.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_collation.h"
@@ -125,6 +126,12 @@ recordMultipleDependencies(const ObjectAddress *depender,
if (referenced->objectId == DEFAULT_COLLATION_OID)
ignore_systempin = true;
}
+ /*
+ * Record the dependency on compression access method for handling
+ * preserve.
+ */
+ if (referenced->classId == AccessMethodRelationId)
+ ignore_systempin = true;
}
else
Assert(!version);
diff --git a/src/backend/commands/Makefile b/src/backend/commands/Makefile
index e8504f0ae4..a7395ad77d 100644
--- a/src/backend/commands/Makefile
+++ b/src/backend/commands/Makefile
@@ -21,6 +21,7 @@ OBJS = \
cluster.o \
collationcmds.o \
comment.o \
+ compressioncmds.o \
constraint.o \
conversioncmds.o \
copy.o \
diff --git a/src/backend/commands/compressioncmds.c b/src/backend/commands/compressioncmds.c
new file mode 100644
index 0000000000..fd6db24e7f
--- /dev/null
+++ b/src/backend/commands/compressioncmds.c
@@ -0,0 +1,300 @@
+/*-------------------------------------------------------------------------
+ *
+ * compressioncmds.c
+ * Routines for SQL commands for attribute compression methods
+ *
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * src/backend/commands/compressioncmds.c
+ *-------------------------------------------------------------------------
+ */
+#include "postgres.h"
+
+#include "access/compressamapi.h"
+#include "access/heapam.h"
+#include "access/htup_details.h"
+#include "access/reloptions.h"
+#include "catalog/catalog.h"
+#include "catalog/dependency.h"
+#include "catalog/indexing.h"
+#include "catalog/pg_attribute.h"
+#include "catalog/pg_depend.h"
+#include "commands/defrem.h"
+#include "commands/tablecmds.h"
+#include "miscadmin.h"
+#include "nodes/parsenodes.h"
+#include "utils/builtins.h"
+#include "utils/fmgroids.h"
+#include "utils/lsyscache.h"
+
+/*
+ * Get list of all supported compression methods for the given attribute.
+ *
+ * We maintain dependency of the attribute on the pg_am row for the current
+ * compression AM and all the preserved compression AM. So scan pg_depend and
+ * find the column dependency on the pg_am. Collect the list of access method
+ * oids on which this attribute has a dependency.
+ */
+static List *
+lookup_attribute_compression(Oid attrelid, AttrNumber attnum, List *oldcmoids)
+{
+ LOCKMODE lock = AccessShareLock;
+ HeapTuple tup;
+ Relation rel;
+ SysScanDesc scan;
+ ScanKeyData key[3];
+ List *cmoids = NIL;
+
+ rel = table_open(DependRelationId, lock);
+
+ ScanKeyInit(&key[0],
+ Anum_pg_depend_classid,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(RelationRelationId));
+ ScanKeyInit(&key[1],
+ Anum_pg_depend_objid,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(attrelid));
+ ScanKeyInit(&key[2],
+ Anum_pg_depend_objsubid,
+ BTEqualStrategyNumber, F_INT4EQ,
+ Int32GetDatum((int32) attnum));
+
+ scan = systable_beginscan(rel, DependDependerIndexId, true,
+ NULL, 3, key);
+
+ while (HeapTupleIsValid(tup = systable_getnext(scan)))
+ {
+ Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+
+ if (depform->refclassid == AccessMethodRelationId)
+ cmoids = list_append_unique_oid(cmoids, depform->refobjid);
+ }
+
+ systable_endscan(scan);
+ table_close(rel, lock);
+
+ return cmoids;
+}
+
+/*
+ * Remove the attribute dependency on the old compression methods
+ *
+ * Scan the pg_depend and search the attribute dependency on the pg_am. Remove
+ * dependency on previous am which is not preserved. The list of non-preserved
+ * AMs is given in cmoids.
+ */
+static void
+remove_old_dependencies(Oid attrelid, AttrNumber attnum, List *cmoids)
+{
+ LOCKMODE lock = AccessShareLock;
+ HeapTuple tup;
+ Relation rel;
+ SysScanDesc scan;
+ ScanKeyData key[3];
+
+ rel = table_open(DependRelationId, lock);
+
+ ScanKeyInit(&key[0],
+ Anum_pg_depend_classid,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(RelationRelationId));
+ ScanKeyInit(&key[1],
+ Anum_pg_depend_objid,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(attrelid));
+ ScanKeyInit(&key[2],
+ Anum_pg_depend_objsubid,
+ BTEqualStrategyNumber, F_INT4EQ,
+ Int32GetDatum((int32) attnum));
+
+ scan = systable_beginscan(rel, DependDependerIndexId, true,
+ NULL, 3, key);
+
+ while (HeapTupleIsValid(tup = systable_getnext(scan)))
+ {
+ Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
+
+ if (list_member_oid(cmoids, depform->refobjid))
+ {
+ Assert(depform->refclassid == AccessMethodRelationId);
+ CatalogTupleDelete(rel, &tup->t_self);
+ }
+ }
+
+ systable_endscan(scan);
+ table_close(rel, lock);
+}
+
+/*
+ * Check whether the given compression method oid is supported by
+ * the target attribute.
+ */
+bool
+IsCompressionSupported(Form_pg_attribute att, Oid cmoid)
+{
+ List *cmoids = NIL;
+
+ /* Check whether it is same as the current compression oid */
+ if (cmoid == att->attcompression)
+ return true;
+
+ /* Check the oid in all preserved compresion methods */
+ cmoids = lookup_attribute_compression(att->attrelid, att->attnum, NULL);
+ if (list_member_oid(cmoids, cmoid))
+ return true;
+ else
+ return false;
+}
+
+/*
+ * In binary upgrade mode add the dependencies for all the preserved compression
+ * method.
+ */
+static void
+BinaryUpgradeAddPreserve(Form_pg_attribute att, List *preserve)
+{
+ ListCell *cell;
+
+ foreach(cell, preserve)
+ {
+ char *cmname_p = strVal(lfirst(cell));
+ Oid cmoid_p = get_compression_am_oid(cmname_p, false);
+
+ add_column_compression_dependency(att->attrelid, att->attnum, cmoid_p);
+ }
+}
+
+/*
+ * Get the compression method oid based on the compression method name. When
+ * compression is not specified returns default attribute compression. It is
+ * possible case for CREATE TABLE and ADD COLUMN commands where COMPRESSION
+ * syntax is optional.
+ *
+ * For ALTER command, check all the supported compression methods for the
+ * attribute and if the preserve list is not passed or some of the old
+ * compression methods are not given in the preserved list then delete
+ * dependency from the old compression methods and force the table rewrite.
+ */
+Oid
+GetAttributeCompression(Form_pg_attribute att, ColumnCompression *compression,
+ bool *need_rewrite)
+{
+ Oid cmoid;
+ char typstorage = get_typstorage(att->atttypid);
+ ListCell *cell;
+
+ /*
+ * No compression for the plain/external storage, refer comments atop
+ * attcompression parameter in pg_attribute.h
+ */
+ if (!IsStorageCompressible(typstorage))
+ {
+ if (compression == NULL)
+ return InvalidOid;
+
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("column data type %s does not support compression",
+ format_type_be(att->atttypid))));
+ }
+
+ /* fallback to default compression if it's not specified */
+ if (compression == NULL)
+ return GetDefaultToastCompression();
+
+ cmoid = get_compression_am_oid(compression->cmname, false);
+
+#ifndef HAVE_LIBLZ4
+ if (cmoid == LZ4_COMPRESSION_AM_OID)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("not built with lz4 support")));
+#endif
+
+ /*
+ * Determine if the column needs rewrite or not. Rewrite conditions: SET
+ * COMPRESSION without PRESERVE - SET COMPRESSION with PRESERVE but not
+ * with full list of previous access methods.
+ */
+ if (need_rewrite != NULL)
+ {
+ List *previous_cmoids = NIL;
+
+ *need_rewrite = false;
+
+ /*
+ * In binary upgrade mode, just create a dependency on all preserved
+ * methods.
+ */
+ if (IsBinaryUpgrade)
+ {
+ BinaryUpgradeAddPreserve(att, compression->preserve);
+ return cmoid;
+ }
+
+ /* If we have preserved all then rewrite is not required */
+ if (compression->preserve_all)
+ return cmoid;
+
+ previous_cmoids =
+ lookup_attribute_compression(att->attrelid, att->attnum, NULL);
+
+ foreach(cell, compression->preserve)
+ {
+ char *cmname_p = strVal(lfirst(cell));
+ Oid cmoid_p = get_compression_am_oid(cmname_p, false);
+
+ if (!list_member_oid(previous_cmoids, cmoid_p))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("\"%s\" compression access method cannot be preserved", cmname_p)));
+
+ /*
+ * Remove from previous list, also protect from duplicate
+ * entries in the PRESERVE list
+ */
+ previous_cmoids = list_delete_oid(previous_cmoids, cmoid_p);
+ }
+
+ /* delete the current cmoid from the list */
+ previous_cmoids = list_delete_oid(previous_cmoids, cmoid);
+
+ /*
+ * If the list of previous Oids is not empty after deletions then
+ * we need to rewrite tuples in the table. Also remove the dependency
+ * on the old compression methods which are no longer preserved.
+ */
+ if (list_length(previous_cmoids) != 0)
+ {
+ remove_old_dependencies(att->attrelid, att->attnum,
+ previous_cmoids);
+ *need_rewrite = true;
+ }
+
+ /* Cleanup */
+ list_free(previous_cmoids);
+ }
+
+ return cmoid;
+}
+
+/*
+ * Construct ColumnCompression node from the compression method oid.
+ */
+ColumnCompression *
+MakeColumnCompression(Oid attcompression)
+{
+ ColumnCompression *node;
+
+ if (!OidIsValid(attcompression))
+ return NULL;
+
+ node = makeNode(ColumnCompression);
+ node->cmname = get_am_name(attcompression);
+
+ return node;
+}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 586a92f0c1..2a1841c353 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -530,7 +530,9 @@ static void ATExecEnableRowSecurity(Relation rel);
static void ATExecDisableRowSecurity(Relation rel);
static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
static ObjectAddress ATExecSetCompression(AlteredTableInfo *tab, Relation rel,
- const char *column, Node *newValue, LOCKMODE lockmode);
+ const char *column,
+ ColumnCompression *compression,
+ LOCKMODE lockmode);
static void index_copy_data(Relation rel, RelFileNode newrnode);
static const char *storage_name(char c);
@@ -562,7 +564,6 @@ static void refuseDupeIndexAttach(Relation parentIdx, Relation partIdx,
static List *GetParentedForeignKeyRefs(Relation partition);
static void ATDetachCheckNoForeignKeyRefs(Relation partition);
static void ATExecAlterCollationRefreshVersion(Relation rel, List *coll);
-static Oid GetAttributeCompression(Form_pg_attribute att, char *compression);
/* ----------------------------------------------------------------
* DefineRelation
@@ -587,6 +588,7 @@ ObjectAddress
DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
ObjectAddress *typaddress, const char *queryString)
{
+ int i;
char relname[NAMEDATALEN];
Oid namespaceId;
Oid relationId;
@@ -865,7 +867,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
relkind == RELKIND_PARTITIONED_TABLE ||
relkind == RELKIND_MATVIEW)
attr->attcompression =
- GetAttributeCompression(attr, colDef->compression);
+ GetAttributeCompression(attr, colDef->compression, NULL);
else
attr->attcompression = InvalidOid;
}
@@ -935,6 +937,20 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
*/
rel = relation_open(relationId, AccessExclusiveLock);
+ /*
+ * Add the dependency on the respective compression AM for the relation
+ * attributes.
+ */
+ for (i = 0; i < (RelationGetDescr(rel))->natts; i++)
+ {
+ Form_pg_attribute attr;
+
+ attr = TupleDescAttr(RelationGetDescr(rel), i);
+ if (OidIsValid(attr->attcompression))
+ add_column_compression_dependency(attr->attrelid, attr->attnum,
+ attr->attcompression);
+ }
+
/*
* Now add any newly specified column default and generation expressions
* to the new relation. These are passed to us in the form of raw
@@ -2415,16 +2431,17 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
/* Copy/check compression parameter */
if (OidIsValid(attribute->attcompression))
{
- char *compression = get_am_name(attribute->attcompression);
+ ColumnCompression *compression =
+ MakeColumnCompression(attribute->attcompression);
if (!def->compression)
def->compression = compression;
- else if (strcmp(def->compression, compression) != 0)
+ else if (strcmp(def->compression->cmname, compression->cmname))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("column \"%s\" has a compression method conflict",
attributeName),
- errdetail("%s versus %s", def->compression, compression)));
+ errdetail("%s versus %s", def->compression->cmname, compression->cmname)));
}
def->inhcount++;
@@ -2461,7 +2478,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
def->collOid = attribute->attcollation;
def->constraints = NIL;
def->location = -1;
- def->compression = get_am_name(attribute->attcompression);
+ def->compression = MakeColumnCompression(
+ attribute->attcompression);
inhSchema = lappend(inhSchema, def);
newattmap->attnums[parent_attno - 1] = ++child_attno;
}
@@ -2712,12 +2730,12 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
def->compression = newdef->compression;
else if (newdef->compression)
{
- if (strcmp(def->compression, newdef->compression))
+ if (strcmp(def->compression->cmname, newdef->compression->cmname))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("column \"%s\" has a compression method conflict",
attributeName),
- errdetail("%s versus %s", def->compression, newdef->compression)));
+ errdetail("%s versus %s", def->compression->cmname, newdef->compression->cmname)));
}
/* Mark the column as locally defined */
@@ -4908,7 +4926,8 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
ATExecAlterCollationRefreshVersion(rel, cmd->object);
break;
case AT_SetCompression:
- address = ATExecSetCompression(tab, rel, cmd->name, cmd->def,
+ address = ATExecSetCompression(tab, rel, cmd->name,
+ (ColumnCompression *) cmd->def,
lockmode);
break;
default: /* oops */
@@ -6414,7 +6433,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
if (rel->rd_rel->relkind == RELKIND_RELATION ||
rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
attribute.attcompression = GetAttributeCompression(&attribute,
- colDef->compression);
+ colDef->compression,
+ NULL);
else
attribute.attcompression = InvalidOid;
@@ -6589,6 +6609,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
*/
add_column_datatype_dependency(myrelid, newattnum, attribute.atttypid);
add_column_collation_dependency(myrelid, newattnum, attribute.attcollation);
+ add_column_compression_dependency(myrelid, newattnum, attribute.attcompression);
/*
* Propagate to children as appropriate. Unlike most other ALTER
@@ -6736,6 +6757,28 @@ add_column_collation_dependency(Oid relid, int32 attnum, Oid collid)
}
}
+/*
+ * Install a dependency for compression on its column.
+ *
+ * This is used for identifying all the supported compression methods
+ * (current and preserved) for a attribute.
+ *
+ * If dependency is already there the whole thing is skipped.
+ */
+void
+add_column_compression_dependency(Oid relid, int32 attnum, Oid cmoid)
+{
+ ObjectAddress acref,
+ attref;
+
+ Assert(relid > 0 && attnum > 0);
+
+ ObjectAddressSet(acref, AccessMethodRelationId, cmoid);
+ ObjectAddressSubSet(attref, RelationRelationId, relid, attnum);
+
+ recordMultipleDependencies(&attref, &acref, 1, DEPENDENCY_NORMAL, true);
+}
+
/*
* ALTER TABLE ALTER COLUMN DROP NOT NULL
*/
@@ -11867,7 +11910,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
foundDep->refobjid == attTup->attcollation) &&
!(foundDep->refclassid == RelationRelationId &&
foundDep->refobjid == RelationGetRelid(rel) &&
- foundDep->refobjsubid != 0)
+ foundDep->refobjsubid != 0) &&
+ foundDep->refclassid != AccessMethodRelationId
)
elog(ERROR, "found unexpected dependency for column: %s",
getObjectDescription(&foundObject, false));
@@ -11982,6 +12026,11 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype);
add_column_collation_dependency(RelationGetRelid(rel), attnum, targetcollid);
+ /* Create dependency for new attribute compression */
+ if (OidIsValid(attTup->attcompression))
+ add_column_compression_dependency(RelationGetRelid(rel), attnum,
+ attTup->attcompression);
+
/*
* Drop any pg_statistic entry for the column, since it's now wrong type
*/
@@ -15086,24 +15135,21 @@ static ObjectAddress
ATExecSetCompression(AlteredTableInfo *tab,
Relation rel,
const char *column,
- Node *newValue,
+ ColumnCompression *compression,
LOCKMODE lockmode)
{
Relation attrel;
HeapTuple tuple;
Form_pg_attribute atttableform;
AttrNumber attnum;
- char *compression;
char typstorage;
Oid cmoid;
+ bool need_rewrite;
Datum values[Natts_pg_attribute];
bool nulls[Natts_pg_attribute];
bool replace[Natts_pg_attribute];
ObjectAddress address;
- Assert(IsA(newValue, String));
- compression = strVal(newValue);
-
attrel = table_open(AttributeRelationId, RowExclusiveLock);
tuple = SearchSysCacheAttName(RelationGetRelid(rel), column);
@@ -15136,11 +15182,16 @@ ATExecSetCompression(AlteredTableInfo *tab,
memset(replace, false, sizeof(replace));
/* Get the attribute compression method. */
- cmoid = GetAttributeCompression(atttableform, compression);
+ cmoid = GetAttributeCompression(atttableform, compression, &need_rewrite);
if (atttableform->attcompression != cmoid)
+ add_column_compression_dependency(atttableform->attrelid,
+ atttableform->attnum, cmoid);
+ if (need_rewrite)
tab->rewrite |= AT_REWRITE_ALTER_COMPRESSION;
+ atttableform->attcompression = cmoid;
+
atttableform->attcompression = cmoid;
CatalogTupleUpdate(attrel, &tuple->t_self, tuple);
@@ -17865,42 +17916,3 @@ ATExecAlterCollationRefreshVersion(Relation rel, List *coll)
index_update_collation_versions(rel->rd_id, get_collation_oid(coll, false));
CacheInvalidateRelcache(rel);
}
-
-/*
- * resolve column compression specification to an OID.
- */
-static Oid
-GetAttributeCompression(Form_pg_attribute att, char *compression)
-{
- char typstorage = get_typstorage(att->atttypid);
- Oid amoid;
-
- /*
- * No compression for the plain/external storage, refer comments atop
- * attcompression parameter in pg_attribute.h
- */
- if (!IsStorageCompressible(typstorage))
- {
- if (compression == NULL)
- return InvalidOid;
-
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("column data type %s does not support compression",
- format_type_be(att->atttypid))));
- }
-
- /* fallback to default compression if it's not specified */
- if (compression == NULL)
- return GetDefaultToastCompression();
-
- amoid = get_compression_am_oid(compression, false);
-
-#ifndef HAVE_LIBLZ4
- if (amoid == LZ4_COMPRESSION_AM_OID)
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("not built with lz4 support")));
-#endif
- return amoid;
-}
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index ea82a05591..90d092671e 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -44,6 +44,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/catalog.h"
+#include "commands/defrem.h"
#include "commands/trigger.h"
#include "executor/execPartition.h"
#include "executor/executor.h"
@@ -2068,8 +2069,8 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
/*
* Loop over all the attributes in the tuple and check if any attribute is
- * compressed and its compression method is not same as the target
- * atrribute's compression method then decompress it.
+ * compressed and its compression method is not is not supported by the
+ * target attribute then we need to decompress
*/
for (i = 0; i < natts; i++)
{
@@ -2094,12 +2095,13 @@ CompareCompressionMethodAndDecompress(TupleTableSlot *slot,
DatumGetPointer(slot->tts_values[attnum - 1]);
/*
- * Get the compression method Oid stored in the toast header and
- * compare it with the compression method of the target.
+ * Get the compression method stored in the toast header and if the
+ * compression method is not supported by the target attribute then
+ * we need to decompress it.
*/
cmoid = toast_get_compression_oid(new_value);
if (OidIsValid(cmoid) &&
- targetTupDesc->attrs[i].attcompression != cmoid)
+ !IsCompressionSupported(&targetTupDesc->attrs[i], cmoid))
{
new_value = detoast_attr(new_value);
slot->tts_values[attnum - 1] = PointerGetDatum(new_value);
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 1338e04409..6a11f8eb60 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2966,7 +2966,7 @@ _copyColumnDef(const ColumnDef *from)
COPY_STRING_FIELD(colname);
COPY_NODE_FIELD(typeName);
- COPY_STRING_FIELD(compression);
+ COPY_NODE_FIELD(compression);
COPY_SCALAR_FIELD(inhcount);
COPY_SCALAR_FIELD(is_local);
COPY_SCALAR_FIELD(is_not_null);
@@ -2986,6 +2986,18 @@ _copyColumnDef(const ColumnDef *from)
return newnode;
}
+static ColumnCompression *
+_copyColumnCompression(const ColumnCompression *from)
+{
+ ColumnCompression *newnode = makeNode(ColumnCompression);
+
+ COPY_STRING_FIELD(cmname);
+ COPY_SCALAR_FIELD(preserve_all);
+ COPY_NODE_FIELD(preserve);
+
+ return newnode;
+}
+
static Constraint *
_copyConstraint(const Constraint *from)
{
@@ -5675,6 +5687,9 @@ copyObjectImpl(const void *from)
case T_ColumnDef:
retval = _copyColumnDef(from);
break;
+ case T_ColumnCompression:
+ retval = _copyColumnCompression(from);
+ break;
case T_Constraint:
retval = _copyConstraint(from);
break;
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index f3592003da..26a9b85974 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -2599,7 +2599,7 @@ _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
{
COMPARE_STRING_FIELD(colname);
COMPARE_NODE_FIELD(typeName);
- COMPARE_STRING_FIELD(compression);
+ COMPARE_NODE_FIELD(compression);
COMPARE_SCALAR_FIELD(inhcount);
COMPARE_SCALAR_FIELD(is_local);
COMPARE_SCALAR_FIELD(is_not_null);
@@ -2619,6 +2619,16 @@ _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
return true;
}
+static bool
+_equalColumnCompression(const ColumnCompression *a, const ColumnCompression *b)
+{
+ COMPARE_STRING_FIELD(cmname);
+ COMPARE_SCALAR_FIELD(preserve_all);
+ COMPARE_NODE_FIELD(preserve);
+
+ return true;
+}
+
static bool
_equalConstraint(const Constraint *a, const Constraint *b)
{
@@ -3724,6 +3734,9 @@ equal(const void *a, const void *b)
case T_ColumnDef:
retval = _equalColumnDef(a, b);
break;
+ case T_ColumnCompression:
+ retval = _equalColumnCompression(a, b);
+ break;
case T_Constraint:
retval = _equalConstraint(a, b);
break;
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 0605ef3f84..b584a58ba3 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -2863,7 +2863,7 @@ _outColumnDef(StringInfo str, const ColumnDef *node)
WRITE_STRING_FIELD(colname);
WRITE_NODE_FIELD(typeName);
- WRITE_STRING_FIELD(compression);
+ WRITE_NODE_FIELD(compression);
WRITE_INT_FIELD(inhcount);
WRITE_BOOL_FIELD(is_local);
WRITE_BOOL_FIELD(is_not_null);
@@ -2881,6 +2881,16 @@ _outColumnDef(StringInfo str, const ColumnDef *node)
WRITE_LOCATION_FIELD(location);
}
+static void
+_outColumnCompression(StringInfo str, const ColumnCompression *node)
+{
+ WRITE_NODE_TYPE("COLUMNCOMPRESSION");
+
+ WRITE_STRING_FIELD(cmname);
+ WRITE_BOOL_FIELD(preserve_all);
+ WRITE_NODE_FIELD(preserve);
+}
+
static void
_outTypeName(StringInfo str, const TypeName *node)
{
@@ -4258,6 +4268,9 @@ outNode(StringInfo str, const void *obj)
case T_ColumnDef:
_outColumnDef(str, obj);
break;
+ case T_ColumnCompression:
+ _outColumnCompression(str, obj);
+ break;
case T_TypeName:
_outTypeName(str, obj);
break;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 30acfe615d..9eb2b04d58 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -596,7 +596,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound
%type <defelt> hash_partbound_elem
-%type <str> optColumnCompression
+%type <node> optColumnCompression alterColumnCompression
+%type <str> compressionClause
+%type <list> optCompressionPreserve
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
@@ -2309,12 +2311,12 @@ alter_table_cmd:
$$ = (Node *)n;
}
/* ALTER TABLE <name> ALTER [COLUMN] <colname> SET (COMPRESSION <cm>) */
- | ALTER opt_column ColId SET optColumnCompression
+ | ALTER opt_column ColId SET alterColumnCompression
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetCompression;
n->name = $3;
- n->def = (Node *) makeString($5);
+ n->def = $5;
$$ = (Node *)n;
}
/* ALTER TABLE <name> DROP [COLUMN] IF EXISTS <colname> [RESTRICT|CASCADE] */
@@ -3437,7 +3439,7 @@ columnDef: ColId Typename optColumnCompression create_generic_options ColQualLis
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
n->typeName = $2;
- n->compression = $3;
+ n->compression = (ColumnCompression *) $3;
n->inhcount = 0;
n->is_local = true;
n->is_not_null = false;
@@ -3492,13 +3494,43 @@ columnOptions: ColId ColQualList
}
;
+optCompressionPreserve:
+ PRESERVE '(' name_list ')' { $$ = $3; }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+compressionClause:
+ COMPRESSION name { $$ = pstrdup($2); }
+ ;
+
optColumnCompression:
- COMPRESSION name
- {
- $$ = $2;
- }
- | /*EMPTY*/ { $$ = NULL; }
- ;
+ compressionClause
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->cmname = $1;
+ n->preserve = NIL;
+ $$ = (Node *) n;
+ }
+ | /*EMPTY*/ { $$ = NULL; }
+ ;
+
+alterColumnCompression:
+ compressionClause optCompressionPreserve
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->cmname = $1;
+ n->preserve = (List *) $2;
+ $$ = (Node *) n;
+ }
+ | compressionClause PRESERVE ALL
+ {
+ ColumnCompression *n = makeNode(ColumnCompression);
+ n->cmname = $1;
+ n->preserve_all = true;
+ n->preserve = NIL;
+ $$ = (Node *) n;
+ }
+ ;
ColQualList:
ColQualList ColConstraint { $$ = lappend($1, $2); }
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index cf4413da64..45f4724a13 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1086,7 +1086,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
/* Likewise, copy compression if requested */
if ((table_like_clause->options & CREATE_TABLE_LIKE_COMPRESSION) != 0
&& OidIsValid(attribute->attcompression))
- def->compression = get_am_name(attribute->attcompression);
+ def->compression = MakeColumnCompression(attribute->attcompression);
else
def->compression = NULL;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 46044cb92a..7bf345a4ac 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -9037,6 +9037,80 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
}
PQclear(res);
}
+
+ /*
+ * Get compression info
+ */
+ if (fout->remoteVersion >= 140000 && dopt->binary_upgrade)
+ {
+ int i_amname;
+ int i_amoid;
+ int i_curattnum;
+ int start;
+
+ pg_log_info("finding compression info for table \"%s.%s\"",
+ tbinfo->dobj.namespace->dobj.name,
+ tbinfo->dobj.name);
+
+ tbinfo->attcompression = pg_malloc0(tbinfo->numatts * sizeof(AttrCompressionInfo *));
+
+ resetPQExpBuffer(q);
+ appendPQExpBuffer(q,
+ " SELECT attrelid::pg_catalog.regclass AS relname, attname,"
+ " amname, am.oid as amoid, d.objsubid AS curattnum"
+ " FROM pg_depend d"
+ " JOIN pg_attribute a ON"
+ " (classid = 'pg_class'::pg_catalog.regclass::pg_catalog.oid AND a.attrelid = d.objid"
+ " AND a.attnum = d.objsubid AND d.deptype = 'n'"
+ " AND d.refclassid = 'pg_am'::pg_catalog.regclass::pg_catalog.oid)"
+ " JOIN pg_am am ON"
+ " (d.deptype = 'n' AND d.refobjid = am.oid)"
+ " WHERE (deptype = 'n' AND d.objid = %d AND a.attcompression != am.oid);",
+ tbinfo->dobj.catId.oid);
+
+ res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
+ ntups = PQntuples(res);
+
+ if (ntups > 0)
+ {
+ int j;
+ int k;
+
+ i_amname = PQfnumber(res, "amname");
+ i_amoid = PQfnumber(res, "amoid");
+ i_curattnum = PQfnumber(res, "curattnum");
+
+ start = 0;
+
+ for (j = 0; j < ntups; j++)
+ {
+ int attnum = atoi(PQgetvalue(res, j, i_curattnum));
+
+ if ((j == ntups - 1) || atoi(PQgetvalue(res, j + 1, i_curattnum)) != attnum)
+ {
+ AttrCompressionInfo *cminfo = pg_malloc(sizeof(AttrCompressionInfo));
+
+ cminfo->nitems = j - start + 1;
+ cminfo->items = pg_malloc(sizeof(AttrCompressionItem *) * cminfo->nitems);
+
+ for (k = start; k < start + cminfo->nitems; k++)
+ {
+ AttrCompressionItem *cmitem = pg_malloc0(sizeof(AttrCompressionItem));
+
+ cmitem->amname = pg_strdup(PQgetvalue(res, k, i_amname));
+ cmitem->amoid = atooid(PQgetvalue(res, k, i_amoid));
+
+ cminfo->items[k - start] = cmitem;
+ }
+
+ tbinfo->attcompression[attnum - 1] = cminfo;
+ start = j + 1; /* start from next */
+ }
+ }
+ }
+
+ PQclear(res);
+ }
}
destroyPQExpBuffer(q);
@@ -16343,6 +16417,33 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
qualrelname,
fmtId(tbinfo->attnames[j]),
tbinfo->attfdwoptions[j]);
+
+ /*
+ * Dump per-column compression options
+ */
+ if (tbinfo->attcompression && tbinfo->attcompression[j])
+ {
+ AttrCompressionInfo *cminfo = tbinfo->attcompression[j];
+
+ appendPQExpBuffer(q, "ALTER TABLE %s ALTER COLUMN %s\nSET COMPRESSION %s",
+ qualrelname, fmtId(tbinfo->attnames[j]), tbinfo->attcmnames[j]);
+
+ if (cminfo->nitems > 0)
+ {
+ appendPQExpBuffer(q, "\nPRESERVE (");
+ for (int i = 0; i < cminfo->nitems; i++)
+ {
+ AttrCompressionItem *item = cminfo->items[i];
+
+ if (i == 0)
+ appendPQExpBuffer(q, "%s", item->amname);
+ else
+ appendPQExpBuffer(q, ", %s", item->amname);
+ }
+ appendPQExpBuffer(q, ")");
+ }
+ appendPQExpBuffer(q, ";\n");
+ }
}
if (ftoptions)
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 1789e18f46..a829528cd0 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -327,7 +327,8 @@ typedef struct _tableInfo
bool needs_override; /* has GENERATED ALWAYS AS IDENTITY */
char *amname; /* relation access method */
char **attcmnames; /* per-attribute current compression method */
-
+ struct _attrCompressionInfo **attcompression; /* per-attribute all
+ compression data */
/*
* Stuff computed only for dumpable tables.
*/
@@ -356,6 +357,18 @@ typedef struct _attrDefInfo
bool separate; /* true if must dump as separate item */
} AttrDefInfo;
+typedef struct _attrCompressionItem
+{
+ Oid amoid; /* attribute compression oid */
+ char *amname; /* compression access method name */
+} AttrCompressionItem;
+
+typedef struct _attrCompressionInfo
+{
+ int nitems;
+ AttrCompressionItem **items;
+} AttrCompressionInfo;
+
typedef struct _tableDataInfo
{
DumpableObject dobj;
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ffa8d05edf..869fd3676d 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2103,6 +2103,13 @@ psql_completion(const char *text, int start, int end)
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "(") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "("))
COMPLETE_WITH("n_distinct", "n_distinct_inherited");
+ /* ALTER TABLE ALTER [COLUMN] <foo> SET COMPRESSION */
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "COMPRESSION", MatchAny) ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "COMPRESSION", MatchAny))
+ COMPLETE_WITH("PRESERVE");
+ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "COMPRESSION", MatchAny, "PRESERVE") ||
+ Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "COMPRESSION", MatchAny, "PRESERVE"))
+ COMPLETE_WITH("( ", "ALL");
/* ALTER TABLE ALTER [COLUMN] <foo> SET STORAGE */
else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET", "STORAGE") ||
Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET", "STORAGE"))
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index e5aea8a240..bd53f9bb0f 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -143,6 +143,13 @@ extern Oid get_compression_am_oid(const char *amname, bool missing_ok);
extern Oid get_am_oid(const char *amname, bool missing_ok);
extern char *get_am_name(Oid amOid);
+/* commands/compressioncmds.c */
+extern Oid GetAttributeCompression(Form_pg_attribute att,
+ ColumnCompression *compression,
+ bool *need_rewrite);
+extern ColumnCompression *MakeColumnCompression(Oid atttcompression);
+extern bool IsCompressionSupported(Form_pg_attribute att, Oid cmoid);
+
/* support routines in commands/define.c */
extern char *defGetString(DefElem *def);
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index b3d30acc35..e6c98e65d4 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -97,5 +97,7 @@ extern void RangeVarCallbackOwnsRelation(const RangeVar *relation,
Oid relId, Oid oldRelId, void *arg);
extern bool PartConstraintImpliedByRelConstraint(Relation scanrel,
List *partConstraint);
+extern void add_column_compression_dependency(Oid relid, int32 attnum,
+ Oid cmoid);
#endif /* TABLECMDS_H */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 20d6f96f62..24deaad253 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -481,6 +481,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 f9a87dee02..ce0913e18a 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> PRESERVE <compression methods>
+ */
+typedef struct ColumnCompression
+{
+ NodeTag type;
+ char *cmname;
+ bool preserve_all;
+ List *preserve;
+} ColumnCompression;
+
/*
* ColumnDef - column definition (used in various creates)
*
@@ -646,7 +660,7 @@ typedef struct ColumnDef
NodeTag type;
char *colname; /* name of column */
TypeName *typeName; /* type of column */
- char *compression; /* compression method for column */
+ ColumnCompression *compression; /* column 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? */
diff --git a/src/test/regress/expected/compression.out b/src/test/regress/expected/compression.out
index 21c1b451d2..3ed33b6534 100644
--- a/src/test/regress/expected/compression.out
+++ b/src/test/regress/expected/compression.out
@@ -226,12 +226,47 @@ SELECT pg_column_compression(f1) FROM cmpart;
lz4
(2 rows)
+-- preserve old compression method
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION pglz PRESERVE (lz4);
+INSERT INTO cmdata VALUES (repeat('1234567890',1004));
+\d+ cmdata
+ Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
+--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
+ f1 | text | | | | extended | pglz | |
+Indexes:
+ "idx" btree (f1)
+
+SELECT pg_column_compression(f1) FROM cmdata;
+ pg_column_compression
+-----------------------
+ lz4
+ pglz
+(2 rows)
+
+\d+ cmdata
+ Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
+--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
+ f1 | text | | | | extended | pglz | |
+Indexes:
+ "idx" btree (f1)
+
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4 PRESERVE ALL;
+SELECT pg_column_compression(f1) FROM cmdata;
+ pg_column_compression
+-----------------------
+ lz4
+ pglz
+(2 rows)
+
-- check data is ok
SELECT length(f1) FROM cmdata;
length
--------
10000
-(1 row)
+ 10040
+(2 rows)
SELECT length(f1) FROM cmdata1;
length
diff --git a/src/test/regress/expected/compression_1.out b/src/test/regress/expected/compression_1.out
index 64c5855bf7..36a5f8ba5e 100644
--- a/src/test/regress/expected/compression_1.out
+++ b/src/test/regress/expected/compression_1.out
@@ -205,12 +205,49 @@ SELECT pg_column_compression(f1) FROM cmpart;
ERROR: relation "cmpart" does not exist
LINE 1: SELECT pg_column_compression(f1) FROM cmpart;
^
+-- preserve old compression method
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION pglz PRESERVE (lz4);
+ERROR: "lz4" compression access method cannot be preserved
+INSERT INTO cmdata VALUES (repeat('1234567890',1004));
+\d+ cmdata
+ Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
+--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
+ f1 | text | | | | extended | pglz | |
+Indexes:
+ "idx" btree (f1)
+
+SELECT pg_column_compression(f1) FROM cmdata;
+ pg_column_compression
+-----------------------
+ pglz
+ pglz
+(2 rows)
+
+\d+ cmdata
+ Table "public.cmdata"
+ Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
+--------+------+-----------+----------+---------+----------+-------------+--------------+-------------
+ f1 | text | | | | extended | pglz | |
+Indexes:
+ "idx" btree (f1)
+
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4 PRESERVE ALL;
+ERROR: not built with lz4 support
+SELECT pg_column_compression(f1) FROM cmdata;
+ pg_column_compression
+-----------------------
+ pglz
+ pglz
+(2 rows)
+
-- check data is ok
SELECT length(f1) FROM cmdata;
length
--------
10000
-(1 row)
+ 10040
+(2 rows)
SELECT length(f1) FROM cmdata1;
ERROR: relation "cmdata1" does not exist
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index 830fdddf24..8f984510ac 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -2066,19 +2066,21 @@ WHERE classid = 'pg_class'::regclass AND
'concur_reindex_ind4'::regclass,
'concur_reindex_matview'::regclass)
ORDER BY 1, 2;
- obj | objref | deptype
-------------------------------------------+------------------------------------------------------------+---------
- index concur_reindex_ind1 | constraint concur_reindex_ind1 on table concur_reindex_tab | i
- index concur_reindex_ind2 | collation "default" | n
- index concur_reindex_ind2 | column c2 of table concur_reindex_tab | a
- index concur_reindex_ind3 | column c1 of table concur_reindex_tab | a
- index concur_reindex_ind3 | table concur_reindex_tab | a
- index concur_reindex_ind4 | collation "default" | n
- index concur_reindex_ind4 | column c1 of table concur_reindex_tab | a
- index concur_reindex_ind4 | column c2 of table concur_reindex_tab | a
- materialized view concur_reindex_matview | schema public | n
- table concur_reindex_tab | schema public | n
-(10 rows)
+ obj | objref | deptype
+-------------------------------------------------------+------------------------------------------------------------+---------
+ column c2 of materialized view concur_reindex_matview | access method pglz | n
+ column c2 of table concur_reindex_tab | access method pglz | n
+ index concur_reindex_ind1 | constraint concur_reindex_ind1 on table concur_reindex_tab | i
+ index concur_reindex_ind2 | collation "default" | n
+ index concur_reindex_ind2 | column c2 of table concur_reindex_tab | a
+ index concur_reindex_ind3 | column c1 of table concur_reindex_tab | a
+ index concur_reindex_ind3 | table concur_reindex_tab | a
+ index concur_reindex_ind4 | collation "default" | n
+ index concur_reindex_ind4 | column c1 of table concur_reindex_tab | a
+ index concur_reindex_ind4 | column c2 of table concur_reindex_tab | a
+ materialized view concur_reindex_matview | schema public | n
+ table concur_reindex_tab | schema public | n
+(12 rows)
REINDEX INDEX CONCURRENTLY concur_reindex_ind1;
REINDEX TABLE CONCURRENTLY concur_reindex_tab;
@@ -2095,19 +2097,21 @@ WHERE classid = 'pg_class'::regclass AND
'concur_reindex_ind4'::regclass,
'concur_reindex_matview'::regclass)
ORDER BY 1, 2;
- obj | objref | deptype
-------------------------------------------+------------------------------------------------------------+---------
- index concur_reindex_ind1 | constraint concur_reindex_ind1 on table concur_reindex_tab | i
- index concur_reindex_ind2 | collation "default" | n
- index concur_reindex_ind2 | column c2 of table concur_reindex_tab | a
- index concur_reindex_ind3 | column c1 of table concur_reindex_tab | a
- index concur_reindex_ind3 | table concur_reindex_tab | a
- index concur_reindex_ind4 | collation "default" | n
- index concur_reindex_ind4 | column c1 of table concur_reindex_tab | a
- index concur_reindex_ind4 | column c2 of table concur_reindex_tab | a
- materialized view concur_reindex_matview | schema public | n
- table concur_reindex_tab | schema public | n
-(10 rows)
+ obj | objref | deptype
+-------------------------------------------------------+------------------------------------------------------------+---------
+ column c2 of materialized view concur_reindex_matview | access method pglz | n
+ column c2 of table concur_reindex_tab | access method pglz | n
+ index concur_reindex_ind1 | constraint concur_reindex_ind1 on table concur_reindex_tab | i
+ index concur_reindex_ind2 | collation "default" | n
+ index concur_reindex_ind2 | column c2 of table concur_reindex_tab | a
+ index concur_reindex_ind3 | column c1 of table concur_reindex_tab | a
+ index concur_reindex_ind3 | table concur_reindex_tab | a
+ index concur_reindex_ind4 | collation "default" | n
+ index concur_reindex_ind4 | column c1 of table concur_reindex_tab | a
+ index concur_reindex_ind4 | column c2 of table concur_reindex_tab | a
+ materialized view concur_reindex_matview | schema public | n
+ table concur_reindex_tab | schema public | n
+(12 rows)
-- Check that comments are preserved
CREATE TABLE testcomment (i int);
diff --git a/src/test/regress/sql/compression.sql b/src/test/regress/sql/compression.sql
index b9daa33b74..5774b55d82 100644
--- a/src/test/regress/sql/compression.sql
+++ b/src/test/regress/sql/compression.sql
@@ -96,6 +96,15 @@ ALTER TABLE cmpart1 ALTER COLUMN f1 SET COMPRESSION pglz;
ALTER TABLE cmpart2 ALTER COLUMN f1 SET COMPRESSION lz4;
SELECT pg_column_compression(f1) FROM cmpart;
+-- preserve old compression method
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION pglz PRESERVE (lz4);
+INSERT INTO cmdata VALUES (repeat('1234567890',1004));
+\d+ cmdata
+SELECT pg_column_compression(f1) FROM cmdata;
+\d+ cmdata
+ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4 PRESERVE ALL;
+SELECT pg_column_compression(f1) FROM cmdata;
+
-- check data is ok
SELECT length(f1) FROM cmdata;
SELECT length(f1) FROM cmdata1;
--
2.17.0
--YZ5djTAD1cGYuMQK--
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: support for MERGE
@ 2022-01-12 06:12 Jaime Casanova <[email protected]>
2022-01-20 21:02 ` Re: support for MERGE Alvaro Herrera <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Jaime Casanova @ 2022-01-12 06:12 UTC (permalink / raw)
To: Simon Riggs <[email protected]>; +Cc: Alvaro Herrera <[email protected]>; Tomas Vondra <[email protected]>; Zhihong Yu <[email protected]>; Daniel Westermann <[email protected]>; Amit Langote <[email protected]>; Justin Pryzby <[email protected]>; Pg Hackers <[email protected]>; Pavan Deolasee <[email protected]>
On Wed, Dec 22, 2021 at 11:35:56AM +0000, Simon Riggs wrote:
> On Mon, 15 Nov 2021 at 22:45, Alvaro Herrera <[email protected]> wrote:
> >
> > On 2021-Nov-15, Alvaro Herrera wrote:
> >
> > > Thanks everyone for the feedback. I attach a version with the fixes
> > > that were submitted, as well as some additional changes:
> >
> > Attachment failure.
>
> I rebased this, please check.
>
Hi,
I found two crashes, actually I found them on the original patch Álvaro
sent on november but just checked that those already exists.
I configured with:
CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" ./configure --prefix=/opt/var/pgdg/15/merge --enable-debug --enable-depend --enable-cassert --with-llvm --enable-tap-tests --with-pgport=54315
And tested on the regression database.
Attached the SQL files for the crashes and its respective stacktraces.
FWIW, the second crash doesn't appear to be caused by the MERGE patch
but I cannot trigger it other way.
--
Jaime Casanova
Director de Servicios Profesionales
SystemGuards - Consultores de PostgreSQL
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
set = {__val = {4194304, 140726414547632, 2, 6, 5309120, 94249822928768, 4611686018427388799, 140446649031334, 0, 281470681751456, 0, 0, 0, 0, 0, 0}}
pid = <optimized out>
tid = <optimized out>
ret = <optimized out>
#1 0x00007fbc4867c535 in __GI_abort () at abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 0, 0, 0, 0, 140446646788085, 2, 4062868317402242624, 7017002064575424051, 94249829619760,
7003715557358071819, 674, 12862997737215894016, 140726414547872, 140726414547888, 140726414548720}}, sa_flags = 22, sa_restorer = 0x7ffd6bf31bb0}
sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x000055b83f88c8b5 in ExceptionalCondition (conditionName=conditionName@entry=0x55b83f9d61c8 "resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts",
errorType=errorType@entry=0x55b83f8e700b "FailedAssertion", fileName=fileName@entry=0x55b83f9d5830 "execExprInterp.c", lineNumber=lineNumber@entry=674) at assert.c:69
No locals.
#3 0x000055b83f58ea5f in ExecInterpExpr (state=0x55b840b0ac18, econtext=0x55b840b0aa10, isnull=0x7ffd6bf31fff) at execExprInterp.c:674
resultnum = <optimized out>
op = 0x55b840b0adb0
resultslot = 0x55b840b0ab40
innerslot = 0x55b840b08660
outerslot = 0x0
scanslot = 0x0
dispatch_table = {0x55b83f58e5c4 <ExecInterpExpr+88>, 0x55b83f58e5e4 <ExecInterpExpr+120>, 0x55b83f58e616 <ExecInterpExpr+170>, 0x55b83f58e648 <ExecInterpExpr+220>, 0x55b83f58e67a <ExecInterpExpr+270>,
0x55b83f58e6db <ExecInterpExpr+367>, 0x55b83f58e73c <ExecInterpExpr+464>, 0x55b83f58e79d <ExecInterpExpr+561>, 0x55b83f58e7bc <ExecInterpExpr+592>, 0x55b83f58e7db <ExecInterpExpr+623>,
0x55b83f58e7fa <ExecInterpExpr+654>, 0x55b83f58e815 <ExecInterpExpr+681>, 0x55b83f58e8b7 <ExecInterpExpr+843>, 0x55b83f58e959 <ExecInterpExpr+1005>, 0x55b83f58e9fb <ExecInterpExpr+1167>,
0x55b83f58ea5f <ExecInterpExpr+1267>, 0x55b83f58eaeb <ExecInterpExpr+1407>, 0x55b83f58eb0c <ExecInterpExpr+1440>, 0x55b83f58eb39 <ExecInterpExpr+1485>, 0x55b83f58eb92 <ExecInterpExpr+1574>,
0x55b83f58ebad <ExecInterpExpr+1601>, 0x55b83f58ebc8 <ExecInterpExpr+1628>, 0x55b83f58ebcf <ExecInterpExpr+1635>, 0x55b83f58ec16 <ExecInterpExpr+1706>, 0x55b83f58ec4c <ExecInterpExpr+1760>,
0x55b83f58ec53 <ExecInterpExpr+1767>, 0x55b83f58ec9a <ExecInterpExpr+1838>, 0x55b83f58ecd0 <ExecInterpExpr+1892>, 0x55b83f58ecf5 <ExecInterpExpr+1929>, 0x55b83f58ed43 <ExecInterpExpr+2007>,
0x55b83f58ed64 <ExecInterpExpr+2040>, 0x55b83f58ed9a <ExecInterpExpr+2094>, 0x55b83f58edd0 <ExecInterpExpr+2148>, 0x55b83f58ee10 <ExecInterpExpr+2212>, 0x55b83f58ee3f <ExecInterpExpr+2259>,
0x55b83f58ee6e <ExecInterpExpr+2306>, 0x55b83f58ee89 <ExecInterpExpr+2333>, 0x55b83f58eea4 <ExecInterpExpr+2360>, 0x55b83f58eecb <ExecInterpExpr+2399>, 0x55b83f58ef0d <ExecInterpExpr+2465>,
0x55b83f58ef4f <ExecInterpExpr+2531>, 0x55b83f58ef76 <ExecInterpExpr+2570>, 0x55b83f58ef91 <ExecInterpExpr+2597>, 0x55b83f58efac <ExecInterpExpr+2624>, 0x55b83f58efc5 <ExecInterpExpr+2649>,
0x55b83f58f053 <ExecInterpExpr+2791>, 0x55b83f58f08b <ExecInterpExpr+2847>, 0x55b83f58f1c9 <ExecInterpExpr+3165>, 0x55b83f58f24a <ExecInterpExpr+3294>, 0x55b83f58f2ba <ExecInterpExpr+3406>,
0x55b83f58f323 <ExecInterpExpr+3511>, 0x55b83f58f33a <ExecInterpExpr+3534>, 0x55b83f58f345 <ExecInterpExpr+3545>, 0x55b83f58f35c <ExecInterpExpr+3568>, 0x55b83f58f373 <ExecInterpExpr+3591>,
0x55b83f58f38e <ExecInterpExpr+3618>, 0x55b83f58f3a5 <ExecInterpExpr+3641>, 0x55b83f58f467 <ExecInterpExpr+3835>, 0x55b83f58f511 <ExecInterpExpr+4005>, 0x55b83f58f528 <ExecInterpExpr+4028>,
0x55b83f58f540 <ExecInterpExpr+4052>, 0x55b83f58f558 <ExecInterpExpr+4076>, 0x55b83f58f570 <ExecInterpExpr+4100>, 0x55b83f58f5a8 <ExecInterpExpr+4156>, 0x55b83f58f5aa <ExecInterpExpr+4158>,
0x55b83f58f5aa <ExecInterpExpr+4158>, 0x55b83f58f00c <ExecInterpExpr+2720>, 0x55b83f58f604 <ExecInterpExpr+4248>, 0x55b83f58f618 <ExecInterpExpr+4268>, 0x55b83f58f5c0 <ExecInterpExpr+4180>,
0x55b83f58f5d8 <ExecInterpExpr+4204>, 0x55b83f58f5ec <ExecInterpExpr+4224>, 0x55b83f58f62c <ExecInterpExpr+4288>, 0x55b83f58f643 <ExecInterpExpr+4311>, 0x55b83f58f69d <ExecInterpExpr+4401>,
0x55b83f58f6b4 <ExecInterpExpr+4424>, 0x55b83f58f715 <ExecInterpExpr+4521>, 0x55b83f58f730 <ExecInterpExpr+4548>, 0x55b83f58f75b <ExecInterpExpr+4591>, 0x55b83f58f7d9 <ExecInterpExpr+4717>,
0x55b83f58f829 <ExecInterpExpr+4797>, 0x55b83f58f874 <ExecInterpExpr+4872>, 0x55b83f58f8e4 <ExecInterpExpr+4984>, 0x55b83f58f9f6 <ExecInterpExpr+5258>, 0x55b83f58faef <ExecInterpExpr+5507>,
0x55b83f58fbe1 <ExecInterpExpr+5749>, 0x55b83f58fd30 <ExecInterpExpr+6084>, 0x55b83f58fe61 <ExecInterpExpr+6389>, 0x55b83f58ff85 <ExecInterpExpr+6681>, 0x55b83f58ffa0 <ExecInterpExpr+6708>,
0x55b83f58ffbb <ExecInterpExpr+6735>}
#4 0x000055b83f58ae18 in ExecInterpExprStillValid (state=0x55b840b0ac18, econtext=0x55b840b0aa10, isNull=0x7ffd6bf31fff) at execExprInterp.c:1824
No locals.
#5 0x000055b83f597f7b in ExecEvalExprSwitchContext (isNull=0x7ffd6bf31fff, econtext=0x55b840b0aa10, state=0x55b840b0ac18) at ../../../src/include/executor/executor.h:339
retDatum = <optimized out>
oldContext = 0x55b840ad7b40
retDatum = <optimized out>
oldContext = <optimized out>
#6 ExecProject (projInfo=0x55b840b0ac10) at ../../../src/include/executor/executor.h:373
econtext = 0x55b840b0aa10
state = 0x55b840b0ac18
slot = 0x55b840b0ab40
isnull = false
econtext = <optimized out>
state = <optimized out>
slot = <optimized out>
isnull = <optimized out>
#7 ExecMergeNotMatched (mtstate=mtstate@entry=0x55b840ad7f08, resultRelInfo=resultRelInfo@entry=0x55b840ad8120, estate=estate@entry=0x55b840ad7c60, slot=slot@entry=0x55b840b08660) at execMerge.c:543
action = 0x55b840b0abd8
commandType = <optimized out>
l__state = <optimized out>
econtext = <optimized out>
rootRelInfo = 0x55b840ad8538
insert_slot = <optimized out>
actionStates = <optimized out>
l = <optimized out>
__func__ = "ExecMergeNotMatched"
#8 0x000055b83f5981d1 in ExecMerge (mtstate=mtstate@entry=0x55b840ad7f08, resultRelInfo=0x55b840ad8120, estate=estate@entry=0x55b840ad7c60, slot=slot@entry=0x55b840b08660) at execMerge.c:143
econtext = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}
matched = <optimized out>
datum = <optimized out>
isNull = <optimized out>
#9 0x000055b83f5c9c03 in ExecModifyTable (pstate=0x55b840ad7f08) at nodeModifyTable.c:2579
datum = <optimized out>
isNull = <optimized out>
resultoid = <optimized out>
node = 0x55b840ad7f08
estate = 0x55b840ad7c60
operation = CMD_MERGE
resultRelInfo = 0x55b840ad8120
subplanstate = 0x55b840ad8858
slot = 0x55b840b08660
planSlot = 0x55b840b08660
oldSlot = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 16558, bi_lo = 21944}, ip_posid = 0}
oldtupdata = {t_len = 1811095808, t_self = {ip_blkid = {bi_hi = 32765, bi_lo = 0}, ip_posid = 15546}, t_tableOid = 21944, t_data = 0x2}
oldtuple = <optimized out>
proute = 0x55b840b0b558
relinfos = 0x0
lc = <optimized out>
__func__ = "ExecModifyTable"
#10 0x000055b83f59cbf7 in ExecProcNodeFirst (node=0x55b840ad7f08) at execProcnode.c:463
No locals.
#11 0x000055b83f593a74 in ExecProcNode (node=0x55b840ad7f08) at ../../../src/include/executor/executor.h:257
No locals.
#12 ExecutePlan (estate=estate@entry=0x55b840ad7c60, planstate=0x55b840ad7f08, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_MERGE, sendTuples=sendTuples@entry=false,
numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x55b840aed730, execute_once=true) at execMain.c:1555
slot = <optimized out>
current_tuple_count = 0
#13 0x000055b83f594715 in standard_ExecutorRun (queryDesc=0x55b840ac84c0, direction=ForwardScanDirection, count=0, execute_once=execute_once@entry=true) at execMain.c:362
estate = 0x55b840ad7c60
operation = CMD_MERGE
dest = 0x55b840aed730
sendTuples = false
oldcontext = 0x55b840ac83a0
__func__ = "standard_ExecutorRun"
#14 0x000055b83f5947de in ExecutorRun (queryDesc=queryDesc@entry=0x55b840ac84c0, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:306
No locals.
#15 0x000055b83f756768 in ProcessQuery (plan=plan@entry=0x55b840aed640, sourceText=<optimized out>, params=0x0, queryEnv=0x0, dest=dest@entry=0x55b840aed730, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:160
queryDesc = 0x55b840ac84c0
#16 0x000055b83f757382 in PortalRunMulti (portal=portal@entry=0x55b840a66520, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x55b840aed730,
altdest=altdest@entry=0x55b840aed730, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:1277
pstmt = 0x55b840aed640
stmtlist_item__state = <optimized out>
active_snapshot_set = true
stmtlist_item = 0x55b840aed6f0
#17 0x000055b83f757914 in PortalRun (portal=portal@entry=0x55b840a66520, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x55b840aed730,
altdest=altdest@entry=0x55b840aed730, qc=0x7ffd6bf324a0) at pquery.c:791
_save_exception_stack = 0x7ffd6bf32540
_save_context_stack = 0x0
_local_sigjmp_buf = {{__jmpbuf = {0, 6828001597788628319, 94249846583488, 94249846990112, 94249846990112, 94249847543600, 6828001597962691935, 741763848760436063}, __mask_was_saved = 0, __saved_mask = {
__val = {94249847001696, 140726414549968, 94249846998320, 94249830163381, 112, 94249846583488, 94249846577040, 0, 162, 140726414550032, 94249828466653, 1, 2, 94249846583488, 94249846990112,
140726414550064}}}}
_do_rethrow = <optimized out>
result = <optimized out>
nprocessed = <optimized out>
saveTopTransactionResourceOwner = 0x55b840a7cdf0
saveTopTransactionContext = 0x55b840a889b0
saveActivePortal = 0x0
saveResourceOwner = 0x55b840a7cdf0
savePortalContext = 0x0
saveMemoryContext = 0x55b840a889b0
__func__ = "PortalRun"
#18 0x000055b83f7539ef in exec_simple_query (
query_string=query_string@entry=0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"...) at postgres.c:1215
snapshot_set = <optimized out>
per_parsetree_context = 0x0
plantree_list = 0x55b840aed6d8
parsetree = 0x55b840a030c0
commandTag = <optimized out>
qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
querytree_list = <optimized out>
portal = 0x55b840a66520
receiver = 0x55b840aed730
format = 0
parsetree_item__state = <optimized out>
dest = DestRemote
oldcontext = 0x55b840a889b0
parsetree_list = 0x55b840a030f8
parsetree_item = 0x55b840a03110
save_log_statement_stats = false
was_logged = false
use_implicit_block = false
msec_str = "\200\177\242@\270U\000\000\b\000\000\000\000\000\000\000\340$\363k\375\177\000\000?\"\212?\270U\000"
__func__ = "exec_simple_query"
#19 0x000055b83f75594c in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4498
query_string = 0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"...
firstchar = <optimized out>
input_message = {
data = 0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"..., len = 203, maxlen = 1024, cursor = 203}
local_sigjmp_buf = {{__jmpbuf = {140726414550304, 6828001597845251423, 1121585057, 94249846734720, 8, 94249846734720, 6828001597817988447, 741763847300162911}, __mask_was_saved = 1, __saved_mask = {
__val = {4194304, 18446744073709551536, 15616, 94249846734720, 140446645740515, 0, 94249846550368, 140726414550544, 15616, 15680, 94249828434542, 0, 94249846550368, 15616, 94249846734720, 8}}}}
send_ready_for_query = false
idle_in_transaction_timeout_enabled = false
idle_session_timeout_enabled = false
__func__ = "PostgresMain"
#20 0x000055b83f6b1014 in BackendRun (port=port@entry=0x55b840a27f80) at postmaster.c:4594
No locals.
#21 0x000055b83f6b41b6 in BackendStartup (port=port@entry=0x55b840a27f80) at postmaster.c:4322
bn = 0x55b840a25cf0
pid = 0
__func__ = "BackendStartup"
#22 0x000055b83f6b43d1 in ServerLoop () at postmaster.c:1802
port = 0x55b840a27f80
i = 2
rmask = {fds_bits = {128, 0 <repeats 15 times>}}
selres = <optimized out>
now = <optimized out>
readmask = {fds_bits = {224, 0 <repeats 15 times>}}
nSockets = 8
last_lockfile_recheck_time = 1641966476
last_touch_time = 1641966295
__func__ = "ServerLoop"
#23 0x000055b83f6b5971 in PostmasterMain (argc=3, argv=<optimized out>) at postmaster.c:1474
opt = <optimized out>
status = <optimized out>
userDoption = <optimized out>
listen_addr_saved = true
i = <optimized out>
output_config_variable = <optimized out>
__func__ = "PostmasterMain"
#24 0x000055b83f5f429b in main (argc=3, argv=0x55b8409faec0) at main.c:198
No locals.
#0 pg_detoast_datum_packed (datum=0x0) at fmgr.c:1756
No locals.
#1 0x000055b83f8609e3 in bpcharcmp (fcinfo=0x7ffd6bf31c40) at varchar.c:905
arg1 = 0x55b840a95130
arg2 = <optimized out>
len1 = <optimized out>
len2 = <optimized out>
cmp = <optimized out>
#2 0x000055b83f895893 in FunctionCall2Coll (flinfo=flinfo@entry=0x55b840ad2338, collation=<optimized out>, arg1=<optimized out>, arg2=arg2@entry=0) at fmgr.c:1160
fcinfodata = {fcinfo = {flinfo = 0x55b840ad2338, context = 0x0, resultinfo = 0x0, fncollation = 100, isnull = false, nargs = 2, args = 0x7ffd6bf31c60},
fcinfo_data = "8#\255@\270U", '\000' <repeats 18 times>, "d\000\000\000\000U\002\000\060Q\251@\270U\000\000\000u`?\270U", '\000' <repeats 11 times>, "\004\260@\270U\000"}
fcinfo = 0x7ffd6bf31c40
result = <optimized out>
__func__ = "FunctionCall2Coll"
#3 0x000055b83f698fca in partition_list_bsearch (partsupfunc=0x55b840ad2338, partcollation=0x55b840ad2390, boundinfo=boundinfo@entry=0x55b840a95098, value=0, is_equal=is_equal@entry=0x7ffd6bf31d0f)
at partbounds.c:3638
cmpval = <optimized out>
lo = -1
hi = 0
mid = 0
#4 0x000055b83f59a6f6 in get_partition_for_tuple (pd=pd@entry=0x55b840b1a4d8, values=values@entry=0x7ffd6bf31db0, isnull=isnull@entry=0x7ffd6bf31d90) at execPartition.c:1372
equal = false
bound_offset = <optimized out>
part_index = -1
key = 0x55b840ad2240
partdesc = <optimized out>
boundinfo = 0x55b840a95098
__func__ = "get_partition_for_tuple"
#5 0x000055b83f59bef5 in ExecFindPartition (mtstate=mtstate@entry=0x55b840affaa8, rootResultRelInfo=rootResultRelInfo@entry=0x55b840affed8, proute=0x55b840b1a448, slot=slot@entry=0x55b840b1a3b0,
estate=estate@entry=0x55b840aff800) at execPartition.c:314
partidx = -1
is_leaf = <optimized out>
pd = 0x55b840b1a530
values = {0, 94249823350511, 94249847625024, 94249847666560, 140726414548480, 15, 94249847729120, 94249847729116, 94249847692344, 94249847692304, 94249847691184, 21474836511, 16, 94249847729119,
94249847692344, 4, 94249847624984, 94249847617248, 140446491906016, 94249847618216, 140726414548608, 94249828466970, 94249847729119, 2, 94249847624984, 5, 140726414548640, 94249822988364,
94249847618752, 140446491906016, 140726414548752, 94249822989220}
isnull = {false, 29, 243, 107, 253, 127, false, false, 67, 32, 90, 63, 184, 85, false, false, 88, 22, 176, 64, 184, 85, false, false, 8, 172, 177, 64, 184, 85, false, false}
rel = 0x7fbc3f419f78
dispatch = 0x55b840b1a4d8
partdesc = 0x55b840a95060
ecxt = 0x55b840b1b158
ecxt_scantuple_saved = 0x0
rootslot = 0x55b840b1a3b0
myslot = 0x0
oldcxt = 0x55b840aff6e0
rri = 0x0
__func__ = "ExecFindPartition"
#6 0x000055b83f5c7f2d in ExecPrepareTupleRouting (mtstate=mtstate@entry=0x55b840affaa8, estate=estate@entry=0x55b840aff800, proute=<optimized out>, targetRelInfo=targetRelInfo@entry=0x55b840affed8,
slot=slot@entry=0x55b840b1a3b0, partRelInfo=partRelInfo@entry=0x7ffd6bf31f58) at nodeModifyTable.c:2426
partrel = <optimized out>
map = <optimized out>
#7 0x000055b83f5c7ffc in ExecInsert (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=resultRelInfo@entry=0x55b840affed8, slot=slot@entry=0x55b840b1a3b0, planSlot=planSlot@entry=0x55b840b15400,
estate=estate@entry=0x55b840aff800, actionState=actionState@entry=0x55b840b19a70, canSetTag=true) at nodeModifyTable.c:614
partRelInfo = 0x55b840affcc0
resultRelationDesc = <optimized out>
recheckIndexes = 0x0
result = 0x0
ar_insert_trig_tcs = <optimized out>
node = <optimized out>
onconflict = ONCONFLICT_NONE
proute = <optimized out>
oldContext = <optimized out>
#8 0x000055b83f597fdc in ExecMergeNotMatched (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=0x55b840affed8, resultRelInfo@entry=0x55b840affcc0, estate=estate@entry=0x55b840aff800,
slot=slot@entry=0x55b840b15400) at execMerge.c:571
action = 0x55b840b19a70
commandType = <optimized out>
l__state = <optimized out>
econtext = <optimized out>
rootRelInfo = 0x55b840affed8
insert_slot = 0x55b840b1a3b0
actionStates = <optimized out>
l = <optimized out>
__func__ = "ExecMergeNotMatched"
#9 0x000055b83f5981d1 in ExecMerge (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=0x55b840affcc0, estate=estate@entry=0x55b840aff800, slot=slot@entry=0x55b840b15400) at execMerge.c:143
econtext = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}
matched = <optimized out>
datum = <optimized out>
isNull = <optimized out>
#10 0x000055b83f5c9c03 in ExecModifyTable (pstate=0x55b840affaa8) at nodeModifyTable.c:2579
datum = <optimized out>
isNull = <optimized out>
resultoid = <optimized out>
node = 0x55b840affaa8
estate = 0x55b840aff800
operation = CMD_MERGE
resultRelInfo = 0x55b840affcc0
subplanstate = 0x55b840b001f8
slot = 0x55b840b15400
planSlot = 0x55b840b15400
oldSlot = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 16559, bi_lo = 21944}, ip_posid = 0}
oldtupdata = {t_len = 1811095808, t_self = {ip_blkid = {bi_hi = 32765, bi_lo = 0}, ip_posid = 15546}, t_tableOid = 21944, t_data = 0x7ffd6bf32100}
oldtuple = <optimized out>
proute = 0x55b840b1a448
relinfos = 0x0
lc = <optimized out>
__func__ = "ExecModifyTable"
#11 0x000055b83f59cbf7 in ExecProcNodeFirst (node=0x55b840affaa8) at execProcnode.c:463
No locals.
#12 0x000055b83f593a74 in ExecProcNode (node=0x55b840affaa8) at ../../../src/include/executor/executor.h:257
No locals.
#13 ExecutePlan (estate=estate@entry=0x55b840aff800, planstate=0x55b840affaa8, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_MERGE, sendTuples=sendTuples@entry=false,
numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x7fbc3f3e8348, execute_once=true) at execMain.c:1555
slot = <optimized out>
current_tuple_count = 0
#14 0x000055b83f594715 in standard_ExecutorRun (queryDesc=0x55b840aeb840, direction=ForwardScanDirection, count=0, execute_once=execute_once@entry=true) at execMain.c:362
estate = 0x55b840aff800
operation = CMD_MERGE
dest = 0x7fbc3f3e8348
sendTuples = false
oldcontext = 0x55b840aeb720
__func__ = "standard_ExecutorRun"
#15 0x000055b83f5947de in ExecutorRun (queryDesc=queryDesc@entry=0x55b840aeb840, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:306
No locals.
#16 0x000055b83f756768 in ProcessQuery (plan=plan@entry=0x7fbc3f3e69a8, sourceText=<optimized out>, params=0x0, queryEnv=0x0, dest=dest@entry=0x7fbc3f3e8348, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:160
queryDesc = 0x55b840aeb840
#17 0x000055b83f757382 in PortalRunMulti (portal=portal@entry=0x55b840a6c8a0, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x7fbc3f3e8348,
altdest=altdest@entry=0x7fbc3f3e8348, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:1277
pstmt = 0x7fbc3f3e69a8
stmtlist_item__state = <optimized out>
active_snapshot_set = true
stmtlist_item = 0x7fbc3f3e8308
#18 0x000055b83f757914 in PortalRun (portal=portal@entry=0x55b840a6c8a0, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x7fbc3f3e8348,
altdest=altdest@entry=0x7fbc3f3e8348, qc=0x7ffd6bf324a0) at pquery.c:791
_save_exception_stack = 0x7ffd6bf32540
_save_context_stack = 0x0
_local_sigjmp_buf = {{__jmpbuf = {0, 6828001597788628319, 94249846584752, 94249847015584, 94249847015584, 140446491640648, 6828001597962691935, 741763848760436063}, __mask_was_saved = 0,
__saved_mask = {__val = {94249847027168, 140726414549968, 94249847023792, 94249830163381, 112, 94249846584752, 94249846577040, 0, 162, 140726414550032, 94249828466653, 1, 2, 94249846584752,
94249847015584, 140726414550064}}}}
_do_rethrow = <optimized out>
result = <optimized out>
nprocessed = <optimized out>
saveTopTransactionResourceOwner = 0x55b840a32110
saveTopTransactionContext = 0x55b840a843c0
saveActivePortal = 0x0
saveResourceOwner = 0x55b840a32110
savePortalContext = 0x0
saveMemoryContext = 0x55b840a843c0
__func__ = "PortalRun"
#19 0x000055b83f7539ef in exec_simple_query (
query_string=query_string@entry=0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"...) at postgres.c:1215
snapshot_set = <optimized out>
per_parsetree_context = 0x0
plantree_list = 0x7fbc3f3e82f0
parsetree = 0x55b840a035b0
commandTag = <optimized out>
qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
querytree_list = <optimized out>
portal = 0x55b840a6c8a0
receiver = 0x7fbc3f3e8348
format = 0
parsetree_item__state = <optimized out>
dest = DestRemote
oldcontext = 0x55b840a843c0
parsetree_list = 0x55b840a035e8
parsetree_item = 0x55b840a03600
save_log_statement_stats = false
was_logged = false
use_implicit_block = false
msec_str = "\220\203\242@\270U\000\000\b\000\000\000\000\000\000\000\340$\363k\375\177\000\000?\"\212?\270U\000"
__func__ = "exec_simple_query"
#20 0x000055b83f75594c in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4498
query_string = 0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"...
firstchar = <optimized out>
input_message = {
data = 0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"..., len = 309, maxlen = 1024, cursor = 309}
local_sigjmp_buf = {{__jmpbuf = {140726414550304, 6828001597845251423, 2478168661, 94249846735760, 8, 94249846735760, 6828001597817988447, 741763847300162911}, __mask_was_saved = 1, __saved_mask = {
__val = {4194304, 18446744073709551536, 15616, 94249846735760, 140446645740515, 0, 94249846550368, 140726414550544, 15616, 15680, 94249828434542, 0, 94249846550368, 15616, 94249846735760, 8}}}}
send_ready_for_query = false
idle_in_transaction_timeout_enabled = false
idle_session_timeout_enabled = false
__func__ = "PostgresMain"
#21 0x000055b83f6b1014 in BackendRun (port=port@entry=0x55b840a28390) at postmaster.c:4594
No locals.
#22 0x000055b83f6b41b6 in BackendStartup (port=port@entry=0x55b840a28390) at postmaster.c:4322
bn = 0x55b840a25cf0
pid = 0
__func__ = "BackendStartup"
#23 0x000055b83f6b43d1 in ServerLoop () at postmaster.c:1802
port = 0x55b840a28390
i = 2
rmask = {fds_bits = {128, 0 <repeats 15 times>}}
selres = <optimized out>
now = <optimized out>
readmask = {fds_bits = {224, 0 <repeats 15 times>}}
nSockets = 8
last_lockfile_recheck_time = 1641966712
last_touch_time = 1641966295
__func__ = "ServerLoop"
#24 0x000055b83f6b5971 in PostmasterMain (argc=3, argv=<optimized out>) at postmaster.c:1474
opt = <optimized out>
status = <optimized out>
userDoption = <optimized out>
listen_addr_saved = true
i = <optimized out>
output_config_variable = <optimized out>
__func__ = "PostmasterMain"
#25 0x000055b83f5f429b in main (argc=3, argv=0x55b8409faec0) at main.c:198
No locals.
Attachments:
[application/sql] merge1.sql (203B, ../../Yd5xaqRWPB4JW90z@ahch-to/2-merge1.sql)
download
[text/plain] merge1.stacktrace.txt (14.1K, ../../Yd5xaqRWPB4JW90z@ahch-to/3-merge1.stacktrace.txt)
download | inline:
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
set = {__val = {4194304, 140726414547632, 2, 6, 5309120, 94249822928768, 4611686018427388799, 140446649031334, 0, 281470681751456, 0, 0, 0, 0, 0, 0}}
pid = <optimized out>
tid = <optimized out>
ret = <optimized out>
#1 0x00007fbc4867c535 in __GI_abort () at abort.c:79
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0, 0, 0, 0, 0, 140446646788085, 2, 4062868317402242624, 7017002064575424051, 94249829619760,
7003715557358071819, 674, 12862997737215894016, 140726414547872, 140726414547888, 140726414548720}}, sa_flags = 22, sa_restorer = 0x7ffd6bf31bb0}
sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x000055b83f88c8b5 in ExceptionalCondition (conditionName=conditionName@entry=0x55b83f9d61c8 "resultnum >= 0 && resultnum < resultslot->tts_tupleDescriptor->natts",
errorType=errorType@entry=0x55b83f8e700b "FailedAssertion", fileName=fileName@entry=0x55b83f9d5830 "execExprInterp.c", lineNumber=lineNumber@entry=674) at assert.c:69
No locals.
#3 0x000055b83f58ea5f in ExecInterpExpr (state=0x55b840b0ac18, econtext=0x55b840b0aa10, isnull=0x7ffd6bf31fff) at execExprInterp.c:674
resultnum = <optimized out>
op = 0x55b840b0adb0
resultslot = 0x55b840b0ab40
innerslot = 0x55b840b08660
outerslot = 0x0
scanslot = 0x0
dispatch_table = {0x55b83f58e5c4 <ExecInterpExpr+88>, 0x55b83f58e5e4 <ExecInterpExpr+120>, 0x55b83f58e616 <ExecInterpExpr+170>, 0x55b83f58e648 <ExecInterpExpr+220>, 0x55b83f58e67a <ExecInterpExpr+270>,
0x55b83f58e6db <ExecInterpExpr+367>, 0x55b83f58e73c <ExecInterpExpr+464>, 0x55b83f58e79d <ExecInterpExpr+561>, 0x55b83f58e7bc <ExecInterpExpr+592>, 0x55b83f58e7db <ExecInterpExpr+623>,
0x55b83f58e7fa <ExecInterpExpr+654>, 0x55b83f58e815 <ExecInterpExpr+681>, 0x55b83f58e8b7 <ExecInterpExpr+843>, 0x55b83f58e959 <ExecInterpExpr+1005>, 0x55b83f58e9fb <ExecInterpExpr+1167>,
0x55b83f58ea5f <ExecInterpExpr+1267>, 0x55b83f58eaeb <ExecInterpExpr+1407>, 0x55b83f58eb0c <ExecInterpExpr+1440>, 0x55b83f58eb39 <ExecInterpExpr+1485>, 0x55b83f58eb92 <ExecInterpExpr+1574>,
0x55b83f58ebad <ExecInterpExpr+1601>, 0x55b83f58ebc8 <ExecInterpExpr+1628>, 0x55b83f58ebcf <ExecInterpExpr+1635>, 0x55b83f58ec16 <ExecInterpExpr+1706>, 0x55b83f58ec4c <ExecInterpExpr+1760>,
0x55b83f58ec53 <ExecInterpExpr+1767>, 0x55b83f58ec9a <ExecInterpExpr+1838>, 0x55b83f58ecd0 <ExecInterpExpr+1892>, 0x55b83f58ecf5 <ExecInterpExpr+1929>, 0x55b83f58ed43 <ExecInterpExpr+2007>,
0x55b83f58ed64 <ExecInterpExpr+2040>, 0x55b83f58ed9a <ExecInterpExpr+2094>, 0x55b83f58edd0 <ExecInterpExpr+2148>, 0x55b83f58ee10 <ExecInterpExpr+2212>, 0x55b83f58ee3f <ExecInterpExpr+2259>,
0x55b83f58ee6e <ExecInterpExpr+2306>, 0x55b83f58ee89 <ExecInterpExpr+2333>, 0x55b83f58eea4 <ExecInterpExpr+2360>, 0x55b83f58eecb <ExecInterpExpr+2399>, 0x55b83f58ef0d <ExecInterpExpr+2465>,
0x55b83f58ef4f <ExecInterpExpr+2531>, 0x55b83f58ef76 <ExecInterpExpr+2570>, 0x55b83f58ef91 <ExecInterpExpr+2597>, 0x55b83f58efac <ExecInterpExpr+2624>, 0x55b83f58efc5 <ExecInterpExpr+2649>,
0x55b83f58f053 <ExecInterpExpr+2791>, 0x55b83f58f08b <ExecInterpExpr+2847>, 0x55b83f58f1c9 <ExecInterpExpr+3165>, 0x55b83f58f24a <ExecInterpExpr+3294>, 0x55b83f58f2ba <ExecInterpExpr+3406>,
0x55b83f58f323 <ExecInterpExpr+3511>, 0x55b83f58f33a <ExecInterpExpr+3534>, 0x55b83f58f345 <ExecInterpExpr+3545>, 0x55b83f58f35c <ExecInterpExpr+3568>, 0x55b83f58f373 <ExecInterpExpr+3591>,
0x55b83f58f38e <ExecInterpExpr+3618>, 0x55b83f58f3a5 <ExecInterpExpr+3641>, 0x55b83f58f467 <ExecInterpExpr+3835>, 0x55b83f58f511 <ExecInterpExpr+4005>, 0x55b83f58f528 <ExecInterpExpr+4028>,
0x55b83f58f540 <ExecInterpExpr+4052>, 0x55b83f58f558 <ExecInterpExpr+4076>, 0x55b83f58f570 <ExecInterpExpr+4100>, 0x55b83f58f5a8 <ExecInterpExpr+4156>, 0x55b83f58f5aa <ExecInterpExpr+4158>,
0x55b83f58f5aa <ExecInterpExpr+4158>, 0x55b83f58f00c <ExecInterpExpr+2720>, 0x55b83f58f604 <ExecInterpExpr+4248>, 0x55b83f58f618 <ExecInterpExpr+4268>, 0x55b83f58f5c0 <ExecInterpExpr+4180>,
0x55b83f58f5d8 <ExecInterpExpr+4204>, 0x55b83f58f5ec <ExecInterpExpr+4224>, 0x55b83f58f62c <ExecInterpExpr+4288>, 0x55b83f58f643 <ExecInterpExpr+4311>, 0x55b83f58f69d <ExecInterpExpr+4401>,
0x55b83f58f6b4 <ExecInterpExpr+4424>, 0x55b83f58f715 <ExecInterpExpr+4521>, 0x55b83f58f730 <ExecInterpExpr+4548>, 0x55b83f58f75b <ExecInterpExpr+4591>, 0x55b83f58f7d9 <ExecInterpExpr+4717>,
0x55b83f58f829 <ExecInterpExpr+4797>, 0x55b83f58f874 <ExecInterpExpr+4872>, 0x55b83f58f8e4 <ExecInterpExpr+4984>, 0x55b83f58f9f6 <ExecInterpExpr+5258>, 0x55b83f58faef <ExecInterpExpr+5507>,
0x55b83f58fbe1 <ExecInterpExpr+5749>, 0x55b83f58fd30 <ExecInterpExpr+6084>, 0x55b83f58fe61 <ExecInterpExpr+6389>, 0x55b83f58ff85 <ExecInterpExpr+6681>, 0x55b83f58ffa0 <ExecInterpExpr+6708>,
0x55b83f58ffbb <ExecInterpExpr+6735>}
#4 0x000055b83f58ae18 in ExecInterpExprStillValid (state=0x55b840b0ac18, econtext=0x55b840b0aa10, isNull=0x7ffd6bf31fff) at execExprInterp.c:1824
No locals.
#5 0x000055b83f597f7b in ExecEvalExprSwitchContext (isNull=0x7ffd6bf31fff, econtext=0x55b840b0aa10, state=0x55b840b0ac18) at ../../../src/include/executor/executor.h:339
retDatum = <optimized out>
oldContext = 0x55b840ad7b40
retDatum = <optimized out>
oldContext = <optimized out>
#6 ExecProject (projInfo=0x55b840b0ac10) at ../../../src/include/executor/executor.h:373
econtext = 0x55b840b0aa10
state = 0x55b840b0ac18
slot = 0x55b840b0ab40
isnull = false
econtext = <optimized out>
state = <optimized out>
slot = <optimized out>
isnull = <optimized out>
#7 ExecMergeNotMatched (mtstate=mtstate@entry=0x55b840ad7f08, resultRelInfo=resultRelInfo@entry=0x55b840ad8120, estate=estate@entry=0x55b840ad7c60, slot=slot@entry=0x55b840b08660) at execMerge.c:543
action = 0x55b840b0abd8
commandType = <optimized out>
l__state = <optimized out>
econtext = <optimized out>
rootRelInfo = 0x55b840ad8538
insert_slot = <optimized out>
actionStates = <optimized out>
l = <optimized out>
__func__ = "ExecMergeNotMatched"
#8 0x000055b83f5981d1 in ExecMerge (mtstate=mtstate@entry=0x55b840ad7f08, resultRelInfo=0x55b840ad8120, estate=estate@entry=0x55b840ad7c60, slot=slot@entry=0x55b840b08660) at execMerge.c:143
econtext = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}
matched = <optimized out>
datum = <optimized out>
isNull = <optimized out>
#9 0x000055b83f5c9c03 in ExecModifyTable (pstate=0x55b840ad7f08) at nodeModifyTable.c:2579
datum = <optimized out>
isNull = <optimized out>
resultoid = <optimized out>
node = 0x55b840ad7f08
estate = 0x55b840ad7c60
operation = CMD_MERGE
resultRelInfo = 0x55b840ad8120
subplanstate = 0x55b840ad8858
slot = 0x55b840b08660
planSlot = 0x55b840b08660
oldSlot = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 16558, bi_lo = 21944}, ip_posid = 0}
oldtupdata = {t_len = 1811095808, t_self = {ip_blkid = {bi_hi = 32765, bi_lo = 0}, ip_posid = 15546}, t_tableOid = 21944, t_data = 0x2}
oldtuple = <optimized out>
proute = 0x55b840b0b558
relinfos = 0x0
lc = <optimized out>
__func__ = "ExecModifyTable"
#10 0x000055b83f59cbf7 in ExecProcNodeFirst (node=0x55b840ad7f08) at execProcnode.c:463
No locals.
#11 0x000055b83f593a74 in ExecProcNode (node=0x55b840ad7f08) at ../../../src/include/executor/executor.h:257
No locals.
#12 ExecutePlan (estate=estate@entry=0x55b840ad7c60, planstate=0x55b840ad7f08, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_MERGE, sendTuples=sendTuples@entry=false,
numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x55b840aed730, execute_once=true) at execMain.c:1555
slot = <optimized out>
current_tuple_count = 0
#13 0x000055b83f594715 in standard_ExecutorRun (queryDesc=0x55b840ac84c0, direction=ForwardScanDirection, count=0, execute_once=execute_once@entry=true) at execMain.c:362
estate = 0x55b840ad7c60
operation = CMD_MERGE
dest = 0x55b840aed730
sendTuples = false
oldcontext = 0x55b840ac83a0
__func__ = "standard_ExecutorRun"
#14 0x000055b83f5947de in ExecutorRun (queryDesc=queryDesc@entry=0x55b840ac84c0, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:306
No locals.
#15 0x000055b83f756768 in ProcessQuery (plan=plan@entry=0x55b840aed640, sourceText=<optimized out>, params=0x0, queryEnv=0x0, dest=dest@entry=0x55b840aed730, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:160
queryDesc = 0x55b840ac84c0
#16 0x000055b83f757382 in PortalRunMulti (portal=portal@entry=0x55b840a66520, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x55b840aed730,
altdest=altdest@entry=0x55b840aed730, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:1277
pstmt = 0x55b840aed640
stmtlist_item__state = <optimized out>
active_snapshot_set = true
stmtlist_item = 0x55b840aed6f0
#17 0x000055b83f757914 in PortalRun (portal=portal@entry=0x55b840a66520, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x55b840aed730,
altdest=altdest@entry=0x55b840aed730, qc=0x7ffd6bf324a0) at pquery.c:791
_save_exception_stack = 0x7ffd6bf32540
_save_context_stack = 0x0
_local_sigjmp_buf = {{__jmpbuf = {0, 6828001597788628319, 94249846583488, 94249846990112, 94249846990112, 94249847543600, 6828001597962691935, 741763848760436063}, __mask_was_saved = 0, __saved_mask = {
__val = {94249847001696, 140726414549968, 94249846998320, 94249830163381, 112, 94249846583488, 94249846577040, 0, 162, 140726414550032, 94249828466653, 1, 2, 94249846583488, 94249846990112,
140726414550064}}}}
_do_rethrow = <optimized out>
result = <optimized out>
nprocessed = <optimized out>
saveTopTransactionResourceOwner = 0x55b840a7cdf0
saveTopTransactionContext = 0x55b840a889b0
saveActivePortal = 0x0
saveResourceOwner = 0x55b840a7cdf0
savePortalContext = 0x0
saveMemoryContext = 0x55b840a889b0
__func__ = "PortalRun"
#18 0x000055b83f7539ef in exec_simple_query (
query_string=query_string@entry=0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"...) at postgres.c:1215
snapshot_set = <optimized out>
per_parsetree_context = 0x0
plantree_list = 0x55b840aed6d8
parsetree = 0x55b840a030c0
commandTag = <optimized out>
qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
querytree_list = <optimized out>
portal = 0x55b840a66520
receiver = 0x55b840aed730
format = 0
parsetree_item__state = <optimized out>
dest = DestRemote
oldcontext = 0x55b840a889b0
parsetree_list = 0x55b840a030f8
parsetree_item = 0x55b840a03110
save_log_statement_stats = false
was_logged = false
use_implicit_block = false
msec_str = "\200\177\242@\270U\000\000\b\000\000\000\000\000\000\000\340$\363k\375\177\000\000?\"\212?\270U\000"
__func__ = "exec_simple_query"
#19 0x000055b83f75594c in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4498
query_string = 0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"...
firstchar = <optimized out>
input_message = {
data = 0x55b840a018b0 "MERGE INTO public.idxpart3 as target_0\nUSING public.rtest_view2 as ref_0\nON target_0.a = ref_0.a \nWHEN NOT MATCHED AND (pg_catalog.lastval() = cast(null as int2)) or (true) \n THEN INSERT VALUES ( 20"..., len = 203, maxlen = 1024, cursor = 203}
local_sigjmp_buf = {{__jmpbuf = {140726414550304, 6828001597845251423, 1121585057, 94249846734720, 8, 94249846734720, 6828001597817988447, 741763847300162911}, __mask_was_saved = 1, __saved_mask = {
__val = {4194304, 18446744073709551536, 15616, 94249846734720, 140446645740515, 0, 94249846550368, 140726414550544, 15616, 15680, 94249828434542, 0, 94249846550368, 15616, 94249846734720, 8}}}}
send_ready_for_query = false
idle_in_transaction_timeout_enabled = false
idle_session_timeout_enabled = false
__func__ = "PostgresMain"
#20 0x000055b83f6b1014 in BackendRun (port=port@entry=0x55b840a27f80) at postmaster.c:4594
No locals.
#21 0x000055b83f6b41b6 in BackendStartup (port=port@entry=0x55b840a27f80) at postmaster.c:4322
bn = 0x55b840a25cf0
pid = 0
__func__ = "BackendStartup"
#22 0x000055b83f6b43d1 in ServerLoop () at postmaster.c:1802
port = 0x55b840a27f80
i = 2
rmask = {fds_bits = {128, 0 <repeats 15 times>}}
selres = <optimized out>
now = <optimized out>
readmask = {fds_bits = {224, 0 <repeats 15 times>}}
nSockets = 8
last_lockfile_recheck_time = 1641966476
last_touch_time = 1641966295
__func__ = "ServerLoop"
#23 0x000055b83f6b5971 in PostmasterMain (argc=3, argv=<optimized out>) at postmaster.c:1474
opt = <optimized out>
status = <optimized out>
userDoption = <optimized out>
listen_addr_saved = true
i = <optimized out>
output_config_variable = <optimized out>
__func__ = "PostmasterMain"
#24 0x000055b83f5f429b in main (argc=3, argv=0x55b8409faec0) at main.c:198
No locals.
[application/sql] merge2.sql (308B, ../../Yd5xaqRWPB4JW90z@ahch-to/4-merge2.sql)
download
[text/plain] merge2.stacktrace.txt (12.2K, ../../Yd5xaqRWPB4JW90z@ahch-to/5-merge2.stacktrace.txt)
download | inline:
#0 pg_detoast_datum_packed (datum=0x0) at fmgr.c:1756
No locals.
#1 0x000055b83f8609e3 in bpcharcmp (fcinfo=0x7ffd6bf31c40) at varchar.c:905
arg1 = 0x55b840a95130
arg2 = <optimized out>
len1 = <optimized out>
len2 = <optimized out>
cmp = <optimized out>
#2 0x000055b83f895893 in FunctionCall2Coll (flinfo=flinfo@entry=0x55b840ad2338, collation=<optimized out>, arg1=<optimized out>, arg2=arg2@entry=0) at fmgr.c:1160
fcinfodata = {fcinfo = {flinfo = 0x55b840ad2338, context = 0x0, resultinfo = 0x0, fncollation = 100, isnull = false, nargs = 2, args = 0x7ffd6bf31c60},
fcinfo_data = "8#\255@\270U", '\000' <repeats 18 times>, "d\000\000\000\000U\002\000\060Q\251@\270U\000\000\000u`?\270U", '\000' <repeats 11 times>, "\004\260@\270U\000"}
fcinfo = 0x7ffd6bf31c40
result = <optimized out>
__func__ = "FunctionCall2Coll"
#3 0x000055b83f698fca in partition_list_bsearch (partsupfunc=0x55b840ad2338, partcollation=0x55b840ad2390, boundinfo=boundinfo@entry=0x55b840a95098, value=0, is_equal=is_equal@entry=0x7ffd6bf31d0f)
at partbounds.c:3638
cmpval = <optimized out>
lo = -1
hi = 0
mid = 0
#4 0x000055b83f59a6f6 in get_partition_for_tuple (pd=pd@entry=0x55b840b1a4d8, values=values@entry=0x7ffd6bf31db0, isnull=isnull@entry=0x7ffd6bf31d90) at execPartition.c:1372
equal = false
bound_offset = <optimized out>
part_index = -1
key = 0x55b840ad2240
partdesc = <optimized out>
boundinfo = 0x55b840a95098
__func__ = "get_partition_for_tuple"
#5 0x000055b83f59bef5 in ExecFindPartition (mtstate=mtstate@entry=0x55b840affaa8, rootResultRelInfo=rootResultRelInfo@entry=0x55b840affed8, proute=0x55b840b1a448, slot=slot@entry=0x55b840b1a3b0,
estate=estate@entry=0x55b840aff800) at execPartition.c:314
partidx = -1
is_leaf = <optimized out>
pd = 0x55b840b1a530
values = {0, 94249823350511, 94249847625024, 94249847666560, 140726414548480, 15, 94249847729120, 94249847729116, 94249847692344, 94249847692304, 94249847691184, 21474836511, 16, 94249847729119,
94249847692344, 4, 94249847624984, 94249847617248, 140446491906016, 94249847618216, 140726414548608, 94249828466970, 94249847729119, 2, 94249847624984, 5, 140726414548640, 94249822988364,
94249847618752, 140446491906016, 140726414548752, 94249822989220}
isnull = {false, 29, 243, 107, 253, 127, false, false, 67, 32, 90, 63, 184, 85, false, false, 88, 22, 176, 64, 184, 85, false, false, 8, 172, 177, 64, 184, 85, false, false}
rel = 0x7fbc3f419f78
dispatch = 0x55b840b1a4d8
partdesc = 0x55b840a95060
ecxt = 0x55b840b1b158
ecxt_scantuple_saved = 0x0
rootslot = 0x55b840b1a3b0
myslot = 0x0
oldcxt = 0x55b840aff6e0
rri = 0x0
__func__ = "ExecFindPartition"
#6 0x000055b83f5c7f2d in ExecPrepareTupleRouting (mtstate=mtstate@entry=0x55b840affaa8, estate=estate@entry=0x55b840aff800, proute=<optimized out>, targetRelInfo=targetRelInfo@entry=0x55b840affed8,
slot=slot@entry=0x55b840b1a3b0, partRelInfo=partRelInfo@entry=0x7ffd6bf31f58) at nodeModifyTable.c:2426
partrel = <optimized out>
map = <optimized out>
#7 0x000055b83f5c7ffc in ExecInsert (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=resultRelInfo@entry=0x55b840affed8, slot=slot@entry=0x55b840b1a3b0, planSlot=planSlot@entry=0x55b840b15400,
estate=estate@entry=0x55b840aff800, actionState=actionState@entry=0x55b840b19a70, canSetTag=true) at nodeModifyTable.c:614
partRelInfo = 0x55b840affcc0
resultRelationDesc = <optimized out>
recheckIndexes = 0x0
result = 0x0
ar_insert_trig_tcs = <optimized out>
node = <optimized out>
onconflict = ONCONFLICT_NONE
proute = <optimized out>
oldContext = <optimized out>
#8 0x000055b83f597fdc in ExecMergeNotMatched (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=0x55b840affed8, resultRelInfo@entry=0x55b840affcc0, estate=estate@entry=0x55b840aff800,
slot=slot@entry=0x55b840b15400) at execMerge.c:571
action = 0x55b840b19a70
commandType = <optimized out>
l__state = <optimized out>
econtext = <optimized out>
rootRelInfo = 0x55b840affed8
insert_slot = 0x55b840b1a3b0
actionStates = <optimized out>
l = <optimized out>
__func__ = "ExecMergeNotMatched"
#9 0x000055b83f5981d1 in ExecMerge (mtstate=mtstate@entry=0x55b840affaa8, resultRelInfo=0x55b840affcc0, estate=estate@entry=0x55b840aff800, slot=slot@entry=0x55b840b15400) at execMerge.c:143
econtext = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 0, bi_lo = 0}, ip_posid = 0}
matched = <optimized out>
datum = <optimized out>
isNull = <optimized out>
#10 0x000055b83f5c9c03 in ExecModifyTable (pstate=0x55b840affaa8) at nodeModifyTable.c:2579
datum = <optimized out>
isNull = <optimized out>
resultoid = <optimized out>
node = 0x55b840affaa8
estate = 0x55b840aff800
operation = CMD_MERGE
resultRelInfo = 0x55b840affcc0
subplanstate = 0x55b840b001f8
slot = 0x55b840b15400
planSlot = 0x55b840b15400
oldSlot = <optimized out>
tupleid = <optimized out>
tuple_ctid = {ip_blkid = {bi_hi = 16559, bi_lo = 21944}, ip_posid = 0}
oldtupdata = {t_len = 1811095808, t_self = {ip_blkid = {bi_hi = 32765, bi_lo = 0}, ip_posid = 15546}, t_tableOid = 21944, t_data = 0x7ffd6bf32100}
oldtuple = <optimized out>
proute = 0x55b840b1a448
relinfos = 0x0
lc = <optimized out>
__func__ = "ExecModifyTable"
#11 0x000055b83f59cbf7 in ExecProcNodeFirst (node=0x55b840affaa8) at execProcnode.c:463
No locals.
#12 0x000055b83f593a74 in ExecProcNode (node=0x55b840affaa8) at ../../../src/include/executor/executor.h:257
No locals.
#13 ExecutePlan (estate=estate@entry=0x55b840aff800, planstate=0x55b840affaa8, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_MERGE, sendTuples=sendTuples@entry=false,
numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x7fbc3f3e8348, execute_once=true) at execMain.c:1555
slot = <optimized out>
current_tuple_count = 0
#14 0x000055b83f594715 in standard_ExecutorRun (queryDesc=0x55b840aeb840, direction=ForwardScanDirection, count=0, execute_once=execute_once@entry=true) at execMain.c:362
estate = 0x55b840aff800
operation = CMD_MERGE
dest = 0x7fbc3f3e8348
sendTuples = false
oldcontext = 0x55b840aeb720
__func__ = "standard_ExecutorRun"
#15 0x000055b83f5947de in ExecutorRun (queryDesc=queryDesc@entry=0x55b840aeb840, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:306
No locals.
#16 0x000055b83f756768 in ProcessQuery (plan=plan@entry=0x7fbc3f3e69a8, sourceText=<optimized out>, params=0x0, queryEnv=0x0, dest=dest@entry=0x7fbc3f3e8348, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:160
queryDesc = 0x55b840aeb840
#17 0x000055b83f757382 in PortalRunMulti (portal=portal@entry=0x55b840a6c8a0, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x7fbc3f3e8348,
altdest=altdest@entry=0x7fbc3f3e8348, qc=qc@entry=0x7ffd6bf324a0) at pquery.c:1277
pstmt = 0x7fbc3f3e69a8
stmtlist_item__state = <optimized out>
active_snapshot_set = true
stmtlist_item = 0x7fbc3f3e8308
#18 0x000055b83f757914 in PortalRun (portal=portal@entry=0x55b840a6c8a0, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x7fbc3f3e8348,
altdest=altdest@entry=0x7fbc3f3e8348, qc=0x7ffd6bf324a0) at pquery.c:791
_save_exception_stack = 0x7ffd6bf32540
_save_context_stack = 0x0
_local_sigjmp_buf = {{__jmpbuf = {0, 6828001597788628319, 94249846584752, 94249847015584, 94249847015584, 140446491640648, 6828001597962691935, 741763848760436063}, __mask_was_saved = 0,
__saved_mask = {__val = {94249847027168, 140726414549968, 94249847023792, 94249830163381, 112, 94249846584752, 94249846577040, 0, 162, 140726414550032, 94249828466653, 1, 2, 94249846584752,
94249847015584, 140726414550064}}}}
_do_rethrow = <optimized out>
result = <optimized out>
nprocessed = <optimized out>
saveTopTransactionResourceOwner = 0x55b840a32110
saveTopTransactionContext = 0x55b840a843c0
saveActivePortal = 0x0
saveResourceOwner = 0x55b840a32110
savePortalContext = 0x0
saveMemoryContext = 0x55b840a843c0
__func__ = "PortalRun"
#19 0x000055b83f7539ef in exec_simple_query (
query_string=query_string@entry=0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"...) at postgres.c:1215
snapshot_set = <optimized out>
per_parsetree_context = 0x0
plantree_list = 0x7fbc3f3e82f0
parsetree = 0x55b840a035b0
commandTag = <optimized out>
qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
querytree_list = <optimized out>
portal = 0x55b840a6c8a0
receiver = 0x7fbc3f3e8348
format = 0
parsetree_item__state = <optimized out>
dest = DestRemote
oldcontext = 0x55b840a843c0
parsetree_list = 0x55b840a035e8
parsetree_item = 0x55b840a03600
save_log_statement_stats = false
was_logged = false
use_implicit_block = false
msec_str = "\220\203\242@\270U\000\000\b\000\000\000\000\000\000\000\340$\363k\375\177\000\000?\"\212?\270U\000"
__func__ = "exec_simple_query"
#20 0x000055b83f75594c in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4498
query_string = 0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"...
firstchar = <optimized out>
input_message = {
data = 0x55b840a018b0 "MERGE INTO public.part_7 as target_0\nUSING public.tenk1 as ref_0\n left join public.num_exp_ln as sample_0 \n on (ref_0.twenty = sample_0.id )\nON target_0.a = sample_0.id \nWHEN MATCHED AND 41 is NULL\n"..., len = 309, maxlen = 1024, cursor = 309}
local_sigjmp_buf = {{__jmpbuf = {140726414550304, 6828001597845251423, 2478168661, 94249846735760, 8, 94249846735760, 6828001597817988447, 741763847300162911}, __mask_was_saved = 1, __saved_mask = {
__val = {4194304, 18446744073709551536, 15616, 94249846735760, 140446645740515, 0, 94249846550368, 140726414550544, 15616, 15680, 94249828434542, 0, 94249846550368, 15616, 94249846735760, 8}}}}
send_ready_for_query = false
idle_in_transaction_timeout_enabled = false
idle_session_timeout_enabled = false
__func__ = "PostgresMain"
#21 0x000055b83f6b1014 in BackendRun (port=port@entry=0x55b840a28390) at postmaster.c:4594
No locals.
#22 0x000055b83f6b41b6 in BackendStartup (port=port@entry=0x55b840a28390) at postmaster.c:4322
bn = 0x55b840a25cf0
pid = 0
__func__ = "BackendStartup"
#23 0x000055b83f6b43d1 in ServerLoop () at postmaster.c:1802
port = 0x55b840a28390
i = 2
rmask = {fds_bits = {128, 0 <repeats 15 times>}}
selres = <optimized out>
now = <optimized out>
readmask = {fds_bits = {224, 0 <repeats 15 times>}}
nSockets = 8
last_lockfile_recheck_time = 1641966712
last_touch_time = 1641966295
__func__ = "ServerLoop"
#24 0x000055b83f6b5971 in PostmasterMain (argc=3, argv=<optimized out>) at postmaster.c:1474
opt = <optimized out>
status = <optimized out>
userDoption = <optimized out>
listen_addr_saved = true
i = <optimized out>
output_config_variable = <optimized out>
__func__ = "PostmasterMain"
#25 0x000055b83f5f429b in main (argc=3, argv=0x55b8409faec0) at main.c:198
No locals.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: support for MERGE
2022-01-12 06:12 Re: support for MERGE Jaime Casanova <[email protected]>
@ 2022-01-20 21:02 ` Alvaro Herrera <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2022-01-20 21:02 UTC (permalink / raw)
To: Jaime Casanova <[email protected]>; +Cc: Simon Riggs <[email protected]>; Tomas Vondra <[email protected]>; Zhihong Yu <[email protected]>; Daniel Westermann <[email protected]>; Amit Langote <[email protected]>; Justin Pryzby <[email protected]>; Pg Hackers <[email protected]>; Pavan Deolasee <[email protected]>
On 2022-Jan-12, Jaime Casanova wrote:
> I found two crashes, actually I found them on the original patch Álvaro
> sent on november but just checked that those already exists.
>
> I configured with:
>
> CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" ./configure --prefix=/opt/var/pgdg/15/merge --enable-debug --enable-depend --enable-cassert --with-llvm --enable-tap-tests --with-pgport=54315
>
> And tested on the regression database.
>
> Attached the SQL files for the crashes and its respective stacktraces.
> FWIW, the second crash doesn't appear to be caused by the MERGE patch
> but I cannot trigger it other way.
Thanks for this! The problem in the first crash was that when
partitioned tables are being used and the topmost one has a tuple
descriptor different from the partitions, we were doing the projection
to the partition's slot using the root's tupledesc and a targetlist
written for the root. The reason this crashed in such ugly way is that
in this case the parent has 3 columns (2 dropped) while the partitions
only have one, so the projection was trying to write to an attribute
that didn't exist.
I fixed it by making all NOT MATCHED actions use the root table's
descriptor and slot.
This change fixes both your reported crashes. I didn't look closely to
see if the second one is caused by exactly the same issue.
--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
Tom: There seems to be something broken here.
Teodor: I'm in sackcloth and ashes... Fixed.
http://archives.postgresql.org/message-id/[email protected]
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2022-01-20 21:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 06:19 [PATCH v24 7/7] Add support for PRESERVE Dilip Kumar <[email protected]>
2022-01-12 06:12 Re: support for MERGE Jaime Casanova <[email protected]>
2022-01-20 21:02 ` Re: support for MERGE Alvaro Herrera <[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