mirror of https://github.com/citusdata/citus.git
Support GENERATE ALWAYS AS STORED
parent
936d546a3c
commit
41dca121e2
|
@ -1368,7 +1368,11 @@ TupleDescColumnNameList(TupleDesc tupleDescriptor)
|
|||
Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex);
|
||||
char *columnName = NameStr(currentColumn->attname);
|
||||
|
||||
if (currentColumn->attisdropped)
|
||||
if (currentColumn->attisdropped
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|| currentColumn->attgenerated == ATTRIBUTE_GENERATED_STORED
|
||||
#endif
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "access/sysattr.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/pg_attribute.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/copy.h"
|
||||
#include "commands/defrem.h"
|
||||
|
@ -481,7 +482,11 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag)
|
|||
Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex);
|
||||
char *columnName = NameStr(currentColumn->attname);
|
||||
|
||||
if (currentColumn->attisdropped)
|
||||
if (currentColumn->attisdropped
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|| currentColumn->attgenerated == ATTRIBUTE_GENERATED_STORED
|
||||
#endif
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -510,7 +515,7 @@ CopyToExistingShards(CopyStmt *copyStatement, char *completionTag)
|
|||
* of BeginCopyFrom. However, we obviously should not do this in relcache
|
||||
* and therefore make a copy of the Relation.
|
||||
*/
|
||||
copiedDistributedRelation = (Relation) palloc0(sizeof(RelationData));
|
||||
copiedDistributedRelation = (Relation) palloc(sizeof(RelationData));
|
||||
copiedDistributedRelationTuple = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
|
||||
|
||||
/*
|
||||
|
@ -1028,7 +1033,11 @@ CanUseBinaryCopyFormat(TupleDesc tupleDescription)
|
|||
Form_pg_attribute currentColumn = TupleDescAttr(tupleDescription, columnIndex);
|
||||
Oid typeId = InvalidOid;
|
||||
|
||||
if (currentColumn->attisdropped)
|
||||
if (currentColumn->attisdropped
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|| currentColumn->attgenerated == ATTRIBUTE_GENERATED_STORED
|
||||
#endif
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1667,7 +1676,11 @@ AppendCopyRowData(Datum *valueArray, bool *isNullArray, TupleDesc rowDescriptor,
|
|||
value = CoerceColumnValue(value, &columnCoercionPaths[columnIndex]);
|
||||
}
|
||||
|
||||
if (currentColumn->attisdropped)
|
||||
if (currentColumn->attisdropped
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
|| currentColumn->attgenerated == ATTRIBUTE_GENERATED_STORED
|
||||
#endif
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1787,7 +1800,11 @@ AvailableColumnCount(TupleDesc tupleDescriptor)
|
|||
{
|
||||
Form_pg_attribute currentColumn = TupleDescAttr(tupleDescriptor, columnIndex);
|
||||
|
||||
if (!currentColumn->attisdropped)
|
||||
if (!currentColumn->attisdropped
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
&& currentColumn->attgenerated != ATTRIBUTE_GENERATED_STORED
|
||||
#endif
|
||||
)
|
||||
{
|
||||
columnCount++;
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ pg_get_tableschemadef_string(Oid tableRelationId, bool includeSequenceDefaults)
|
|||
* reasoning behind this is that Citus implements declarative partitioning
|
||||
* by creating the partitions first and then sending
|
||||
* "ALTER TABLE parent_table ATTACH PARTITION .." command. This may not play
|
||||
* well with regular inhereted tables, which isn't a big concern from Citus'
|
||||
* well with regular inherited tables, which isn't a big concern from Citus'
|
||||
* perspective.
|
||||
*/
|
||||
if (!attributeForm->attisdropped)
|
||||
|
@ -371,7 +371,19 @@ pg_get_tableschemadef_string(Oid tableRelationId, bool includeSequenceDefaults)
|
|||
defaultString = deparse_expression(defaultNode, defaultContext,
|
||||
false, false);
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
if (attributeForm->attgenerated == ATTRIBUTE_GENERATED_STORED)
|
||||
{
|
||||
appendStringInfo(&buffer, " GENERATED ALWAYS AS (%s) STORED",
|
||||
defaultString);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendStringInfo(&buffer, " DEFAULT %s", defaultString);
|
||||
}
|
||||
#else
|
||||
appendStringInfo(&buffer, " DEFAULT %s", defaultString);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue