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