Skip to content

Commit

Permalink
follow coding conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayato Kuroda committed Nov 16, 2024
1 parent 21da8ac commit c533664
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions pg_follower_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* pg_follower_output.c
* logical decoding output plugin
*
*
* IDENTIFICATION
* pg_follower/pg_follower_output.c
*
Expand Down Expand Up @@ -53,7 +53,7 @@ static void follower_truncate(struct LogicalDecodingContext *ctx,
typedef struct
{
MemoryContext context;
} PgFollowerData;
} PgFollowerData;

/*
* Print literal `outputstr' already represented as string of type `typid'
Expand Down Expand Up @@ -119,10 +119,10 @@ static void
output_insert(StringInfo out, Relation relation, char *schema_name,
ReorderBufferChange *change)
{
HeapTuple new_tuple;
TupleDesc descriptor;
bool first_try = true;
StringInfoData values;
HeapTuple new_tuple;
TupleDesc descriptor;
bool first_try = true;
StringInfoData values;

Assert(change->action == REORDER_BUFFER_CHANGE_INSERT);

Expand All @@ -142,11 +142,11 @@ output_insert(StringInfo out, Relation relation, char *schema_name,
*/
for (int atts = 0; atts < descriptor->natts; atts++)
{
Form_pg_attribute att = TupleDescAttr(descriptor, atts);
bool isnull;
Datum datum;
Oid typoutput;
bool typisvarlena;
Form_pg_attribute att = TupleDescAttr(descriptor, atts);
bool isnull;
Datum datum;
Oid typoutput;
bool typisvarlena;

/* Skip if the attribute is invalid */
if (att->attisdropped || att->attgenerated)
Expand All @@ -167,8 +167,9 @@ output_insert(StringInfo out, Relation relation, char *schema_name,
}

/*
* OK, let's start to write the each attributes. Since someone might be
* skipped, all to-be-written attributes must be explicitly described.
* OK, let's start to write the each attributes. Since someone might
* be skipped, all to-be-written attributes must be explicitly
* described.
*/
appendStringInfo(out, "%s", quote_identifier(NameStr(att->attname)));

Expand Down Expand Up @@ -204,18 +205,18 @@ static void
output_update(StringInfo out, Relation relation, char *schema_name,
ReorderBufferChange *change)
{
// HeapTuple old_tuple;
// HeapTuple new_tuple;
/* HeapTuple old_tuple; */
/* HeapTuple new_tuple; */

Assert(change->action == REORDER_BUFFER_CHANGE_UPDATE);

// /* Extract information from arguments */
// old_tuple = change->data.tp.oldtuple;
// new_tuple = change->data.tp.newtuple;
/* Extract information from arguments */
/* old_tuple = change->data.tp.oldtuple; */
/* new_tuple = change->data.tp.newtuple; */

/* Construction the query */
appendStringInfo(out, "UPDATE %s.%s SET ", schema_name,
RelationGetRelationName(relation));
appendStringInfo(out, "UPDATE %s.%s SET ", schema_name,
RelationGetRelationName(relation));
}

/*
Expand All @@ -225,16 +226,16 @@ static void
output_delete(StringInfo out, Relation relation, char *schema_name,
ReorderBufferChange *change)
{
// HeapTuple old_tuple;
/* HeapTuple old_tuple; */

Assert(change->action == REORDER_BUFFER_CHANGE_DELETE);

// /* Extract information from arguments */
// old_tuple = change->data.tp.oldtuple;
/* Extract information from arguments */
/* old_tuple = change->data.tp.oldtuple; */

/* Construction the query */
appendStringInfo(out, "DELETE FROM %s.%s ", schema_name,
RelationGetRelationName(relation));
appendStringInfo(out, "DELETE FROM %s.%s ", schema_name,
RelationGetRelationName(relation));
}

/* Callback routines */
Expand Down Expand Up @@ -282,9 +283,9 @@ static void
follower_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
Relation relation, ReorderBufferChange *change)
{
char *schema_name;
char *schema_name;
PgFollowerData *data = (PgFollowerData *) ctx->output_plugin_private;
MemoryContext old;
MemoryContext old;

/* Avoid leaking memory by using and resetting our own context */
old = MemoryContextSwitchTo(data->context);
Expand Down

0 comments on commit c533664

Please sign in to comment.