From f2853c779c905cb986b5da0c011f3280236187c7 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Wed, 1 Aug 2007 10:24:46 +0000 Subject: [PATCH] make C modules work on 8.3 --- sql/logtriga/textbuf.c | 10 +++++++--- sql/londiste/structure/tables.sql | 10 ++++++++++ sql/txid/txid.c | 13 +++++++++---- sql/txid/txid.h | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/sql/logtriga/textbuf.c b/sql/logtriga/textbuf.c index 0c9ebf94..bb3e0127 100644 --- a/sql/logtriga/textbuf.c +++ b/sql/logtriga/textbuf.c @@ -16,6 +16,10 @@ #include "textbuf.h" +#ifndef SET_VARSIZE +#define SET_VARSIZE(x, len) VARATT_SIZEP(x) = (len) +#endif + struct TBuf { text *data; int size; @@ -42,7 +46,7 @@ static inline char *get_endp(TBuf *tbuf) static inline void inc_used(TBuf *tbuf, int len) { - VARATT_SIZEP(tbuf->data) += len; + SET_VARSIZE(tbuf->data, VARSIZE(tbuf->data) + len); } static void tbuf_init(TBuf *tbuf, int start_size) @@ -51,7 +55,7 @@ static void tbuf_init(TBuf *tbuf, int start_size) start_size = VARHDRSZ; tbuf->data = talloc(start_size); tbuf->size = start_size; - VARATT_SIZEP(tbuf->data) = VARHDRSZ; + SET_VARSIZE(tbuf->data, VARHDRSZ); } TBuf *tbuf_alloc(int start_size) @@ -76,7 +80,7 @@ int tbuf_get_size(TBuf *tbuf) void tbuf_reset(TBuf *tbuf) { - VARATT_SIZEP(tbuf->data) = VARHDRSZ; + SET_VARSIZE(tbuf->data, VARHDRSZ); } const text *tbuf_look_text(TBuf *tbuf) diff --git a/sql/londiste/structure/tables.sql b/sql/londiste/structure/tables.sql index 5b6b0d88..6e783983 100644 --- a/sql/londiste/structure/tables.sql +++ b/sql/londiste/structure/tables.sql @@ -52,3 +52,13 @@ create table londiste.subscriber_seq ( primary key (queue_name, seq_name) ); +create table londiste.subscriber_pending_fkeys( + from_table text not null, + to_table text not null, + fkey_name text not null, + fkey_def text not null, + + primary key (from_table, to_table, fkey_name), + unique (to_table, from_table, fkey_name) +); + diff --git a/sql/txid/txid.c b/sql/txid/txid.c index 256d3608..eb0e619a 100644 --- a/sql/txid/txid.c +++ b/sql/txid/txid.c @@ -27,6 +27,11 @@ PG_MODULE_MAGIC; #endif +#ifndef SET_VARSIZE +#define SET_VARSIZE(x, len) VARATT_SIZEP(x) = len +#endif + + /* * public functions */ @@ -135,7 +140,7 @@ parse_snapshot(const char *str) size = offsetof(TxidSnapshot, xip) + sizeof(txid) * a_used; snap = (TxidSnapshot *) palloc(size); - snap->varsz = size; + SET_VARSIZE(snap, size); snap->xmin = xmin; snap->xmax = xmax; snap->nxip = a_used; @@ -184,7 +189,7 @@ txid_current_snapshot(PG_FUNCTION_ARGS) num = SerializableSnapshot->xcnt; size = offsetof(TxidSnapshot, xip) + sizeof(txid) * num; snap = palloc(size); - snap->varsz = size; + SET_VARSIZE(snap, size); snap->xmin = txid_convert_xid(SerializableSnapshot->xmin, &state); snap->xmax = txid_convert_xid(SerializableSnapshot->xmax, &state); snap->nxip = num; @@ -342,11 +347,11 @@ txid_snapshot_active(PG_FUNCTION_ARGS) snap = (TxidSnapshot *) PG_GETARG_VARLENA_P(0); fctx = SRF_FIRSTCALL_INIT(); - statelen = sizeof(*state) + snap->varsz; + statelen = sizeof(*state) + VARSIZE(snap); state = MemoryContextAlloc(fctx->multi_call_memory_ctx, statelen); state->pos = 0; state->snap = (TxidSnapshot *)((char *)state + sizeof(*state)); - memcpy(state->snap, snap, snap->varsz); + memcpy(state->snap, snap, VARSIZE(snap)); fctx->user_fctx = state; PG_FREE_IF_COPY(snap, 0); diff --git a/sql/txid/txid.h b/sql/txid/txid.h index 8c648754..b2536a77 100644 --- a/sql/txid/txid.h +++ b/sql/txid/txid.h @@ -8,7 +8,7 @@ typedef uint64 txid; typedef struct { - int32 varsz; + int32 __varsz; /* should not be touched directly */ uint32 nxip; txid xmin; txid xmax; -- 2.39.5