Using clang-format to style nazi myself
parent
6a212e9e4c
commit
f9d69b3f1f
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "postgres.h"
|
||||
#include "funcapi.h"
|
||||
|
@ -51,7 +50,7 @@ PG_MODULE_MAGIC;
|
|||
*/
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
#define TIMESTAMPTZ_TO_USEC_SINCE_EPOCH(t) \
|
||||
t + ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY * USECS_PER_SEC);
|
||||
t + ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY *USECS_PER_SEC);
|
||||
#else
|
||||
#define TIMESTAMPTZ_TO_USEC_SINCE_EPOCH(t) \
|
||||
(t + ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY)) * 1000.0;
|
||||
|
@ -135,8 +134,7 @@ static void pg_decode_shutdown(LogicalDecodingContext *ctx) {
|
|||
|
||||
/* BEGIN callback */
|
||||
static void pg_decode_begin_txn(LogicalDecodingContext *ctx,
|
||||
ReorderBufferTXN *txn) {
|
||||
}
|
||||
ReorderBufferTXN *txn) {}
|
||||
|
||||
/* COMMIT callback */
|
||||
static void pg_decode_commit_txn(LogicalDecodingContext *ctx,
|
||||
|
@ -151,7 +149,7 @@ static void free_row_msg_subs(Decoderbufs__RowMessage *msg) {
|
|||
|
||||
pfree(msg->table);
|
||||
if (msg->n_new_tuple > 0) {
|
||||
for (int i=0; i < msg->n_new_tuple; i++) {
|
||||
for (int i = 0; i < msg->n_new_tuple; i++) {
|
||||
if (msg->new_tuple[i]) {
|
||||
if (msg->new_tuple[i]->datum_string) {
|
||||
pfree(msg->new_tuple[i]->datum_string);
|
||||
|
@ -166,7 +164,7 @@ static void free_row_msg_subs(Decoderbufs__RowMessage *msg) {
|
|||
pfree(msg->new_tuple);
|
||||
}
|
||||
if (msg->n_old_tuple > 0) {
|
||||
for (int i=0; i < msg->n_old_tuple; i++) {
|
||||
for (int i = 0; i < msg->n_old_tuple; i++) {
|
||||
if (msg->old_tuple[i]) {
|
||||
if (msg->old_tuple[i]->datum_string) {
|
||||
pfree(msg->old_tuple[i]->datum_string);
|
||||
|
@ -182,9 +180,10 @@ static void free_row_msg_subs(Decoderbufs__RowMessage *msg) {
|
|||
}
|
||||
}
|
||||
|
||||
static void print_tuple_msg(StringInfo out, Decoderbufs__DatumMessage **tup, size_t n) {
|
||||
static void print_tuple_msg(StringInfo out, Decoderbufs__DatumMessage **tup,
|
||||
size_t n) {
|
||||
if (tup) {
|
||||
for (int i=0; i < n; i++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
Decoderbufs__DatumMessage *dmsg = tup[i];
|
||||
if (dmsg->column_name)
|
||||
appendStringInfo(out, "column_name[%s]", dmsg->column_name);
|
||||
|
@ -308,8 +307,9 @@ static void set_datum_value(Decoderbufs__DatumMessage *datum_msg, Oid typid,
|
|||
}
|
||||
}
|
||||
|
||||
static void tuple_to_tuple_msg(Decoderbufs__DatumMessage **tmsg, Relation relation,
|
||||
HeapTuple tuple, TupleDesc tupdesc) {
|
||||
static void tuple_to_tuple_msg(Decoderbufs__DatumMessage **tmsg,
|
||||
Relation relation, HeapTuple tuple,
|
||||
TupleDesc tupdesc) {
|
||||
int natt;
|
||||
|
||||
/* build column names and values */
|
||||
|
@ -357,7 +357,6 @@ static void tuple_to_tuple_msg(Decoderbufs__DatumMessage **tmsg, Relation relati
|
|||
tmsg[natt] = palloc(sizeof(datum_msg));
|
||||
memcpy(tmsg[natt], &datum_msg, sizeof(datum_msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -399,8 +398,10 @@ static void pg_decode_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
|||
if (change->data.tp.newtuple != NULL) {
|
||||
TupleDesc tupdesc = RelationGetDescr(relation);
|
||||
rmsg.n_new_tuple = tupdesc->natts;
|
||||
rmsg.new_tuple = palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.new_tuple, relation, &change->data.tp.newtuple->tuple, tupdesc);
|
||||
rmsg.new_tuple =
|
||||
palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.new_tuple, relation,
|
||||
&change->data.tp.newtuple->tuple, tupdesc);
|
||||
}
|
||||
break;
|
||||
case REORDER_BUFFER_CHANGE_UPDATE:
|
||||
|
@ -410,14 +411,18 @@ static void pg_decode_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
|||
if (change->data.tp.oldtuple != NULL) {
|
||||
TupleDesc tupdesc = RelationGetDescr(relation);
|
||||
rmsg.n_old_tuple = tupdesc->natts;
|
||||
rmsg.old_tuple = palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.old_tuple, relation, &change->data.tp.oldtuple->tuple, tupdesc);
|
||||
rmsg.old_tuple =
|
||||
palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.old_tuple, relation,
|
||||
&change->data.tp.oldtuple->tuple, tupdesc);
|
||||
}
|
||||
if (change->data.tp.newtuple != NULL) {
|
||||
TupleDesc tupdesc = RelationGetDescr(relation);
|
||||
rmsg.n_new_tuple = tupdesc->natts;
|
||||
rmsg.new_tuple = palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.new_tuple, relation, &change->data.tp.newtuple->tuple, tupdesc);
|
||||
rmsg.new_tuple =
|
||||
palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.new_tuple, relation,
|
||||
&change->data.tp.newtuple->tuple, tupdesc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -428,8 +433,10 @@ static void pg_decode_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
|||
if (!is_rel_non_selective && change->data.tp.oldtuple != NULL) {
|
||||
TupleDesc tupdesc = RelationGetDescr(relation);
|
||||
rmsg.n_old_tuple = tupdesc->natts;
|
||||
rmsg.old_tuple = palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.old_tuple, relation, &change->data.tp.oldtuple->tuple, tupdesc);
|
||||
rmsg.old_tuple =
|
||||
palloc(sizeof(Decoderbufs__DatumMessage) * tupdesc->natts);
|
||||
tuple_to_tuple_msg(rmsg.old_tuple, relation,
|
||||
&change->data.tp.oldtuple->tuple, tupdesc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue