summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/bloom/blinsert.c12
-rw-r--r--contrib/pg_prewarm/pg_prewarm.c4
-rw-r--r--contrib/pg_standby/pg_standby.c10
3 files changed, 11 insertions, 15 deletions
diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c
index 4afdea7c9a3..9f223d3b2a7 100644
--- a/contrib/bloom/blinsert.c
+++ b/contrib/bloom/blinsert.c
@@ -36,7 +36,7 @@ typedef struct
int64 indtuples; /* total number of tuples indexed */
MemoryContext tmpCtx; /* temporary memory context reset after each
* tuple */
- char data[BLCKSZ]; /* cached page */
+ PGAlignedBlock data; /* cached page */
int count; /* number of tuples in cached page */
} BloomBuildState;
@@ -52,7 +52,7 @@ flushCachedPage(Relation index, BloomBuildState *buildstate)
state = GenericXLogStart(index);
page = GenericXLogRegisterBuffer(state, buffer, GENERIC_XLOG_FULL_IMAGE);
- memcpy(page, buildstate->data, BLCKSZ);
+ memcpy(page, buildstate->data.data, BLCKSZ);
GenericXLogFinish(state);
UnlockReleaseBuffer(buffer);
}
@@ -63,8 +63,8 @@ flushCachedPage(Relation index, BloomBuildState *buildstate)
static void
initCachedPage(BloomBuildState *buildstate)
{
- memset(buildstate->data, 0, BLCKSZ);
- BloomInitPage(buildstate->data, 0);
+ memset(buildstate->data.data, 0, BLCKSZ);
+ BloomInitPage(buildstate->data.data, 0);
buildstate->count = 0;
}
@@ -84,7 +84,7 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
itup = BloomFormTuple(&buildstate->blstate, &htup->t_self, values, isnull);
/* Try to add next item to cached page */
- if (BloomPageAddItem(&buildstate->blstate, buildstate->data, itup))
+ if (BloomPageAddItem(&buildstate->blstate, buildstate->data.data, itup))
{
/* Next item was added successfully */
buildstate->count++;
@@ -98,7 +98,7 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
initCachedPage(buildstate);
- if (!BloomPageAddItem(&buildstate->blstate, buildstate->data, itup))
+ if (!BloomPageAddItem(&buildstate->blstate, buildstate->data.data, itup))
{
/* We shouldn't be here since we're inserting to the empty page */
elog(ERROR, "could not add new bloom tuple to empty page");
diff --git a/contrib/pg_prewarm/pg_prewarm.c b/contrib/pg_prewarm/pg_prewarm.c
index 3cbb7c2b889..1f4bfb8c0d4 100644
--- a/contrib/pg_prewarm/pg_prewarm.c
+++ b/contrib/pg_prewarm/pg_prewarm.c
@@ -36,7 +36,7 @@ typedef enum
PREWARM_BUFFER
} PrewarmType;
-static char blockbuffer[BLCKSZ];
+static PGAlignedBlock blockbuffer;
/*
* pg_prewarm(regclass, mode text, fork text,
@@ -178,7 +178,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
for (block = first_block; block <= last_block; ++block)
{
CHECK_FOR_INTERRUPTS();
- smgrread(rel->rd_smgr, forkNumber, block, blockbuffer);
+ smgrread(rel->rd_smgr, forkNumber, block, blockbuffer.data);
++blocks_done;
}
}
diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c
index d840940e410..ee1fbd7b332 100644
--- a/contrib/pg_standby/pg_standby.c
+++ b/contrib/pg_standby/pg_standby.c
@@ -401,9 +401,7 @@ SetWALSegSize(void)
{
bool ret_val = false;
int fd;
-
- /* malloc this buffer to ensure sufficient alignment: */
- char *buf = (char *) pg_malloc(XLOG_BLCKSZ);
+ PGAlignedXLogBlock buf;
Assert(WalSegSz == -1);
@@ -411,14 +409,13 @@ SetWALSegSize(void)
{
fprintf(stderr, "%s: could not open WAL file \"%s\": %s\n",
progname, WALFilePath, strerror(errno));
- pg_free(buf);
return false;
}
errno = 0;
- if (read(fd, buf, XLOG_BLCKSZ) == XLOG_BLCKSZ)
+ if (read(fd, buf.data, XLOG_BLCKSZ) == XLOG_BLCKSZ)
{
- XLogLongPageHeader longhdr = (XLogLongPageHeader) buf;
+ XLogLongPageHeader longhdr = (XLogLongPageHeader) buf.data;
WalSegSz = longhdr->xlp_seg_size;
@@ -455,7 +452,6 @@ SetWALSegSize(void)
fflush(stderr);
close(fd);
- pg_free(buf);
return ret_val;
}