Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit984d56b

Browse files
committed
Fix another longstanding problem in copy_relation_data: it was blithely
assuming that a local char[] array would be aligned on at least a wordboundary. There are architectures on which that is pretty much guaranteed toNOT be the case ... and those arches also don't like non-aligned memoryaccesses, meaning that log_newpage() would crash if it ever got invoked.Even on Intel-ish machines there's a potential for a large performance penaltyfrom doing I/O to an inadequately aligned buffer. So palloc it instead.Backpatch to 8.0 --- 7.4 doesn't have this code.
1 parent5b48e2e commit984d56b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.336 2010/07/2911:06:34 sriggs Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.337 2010/07/2919:23:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -7230,11 +7230,20 @@ static void
72307230
copy_relation_data(SMgrRelationsrc,SMgrRelationdst,
72317231
ForkNumberforkNum,boolistemp)
72327232
{
7233+
char*buf;
7234+
Pagepage;
72337235
booluse_wal;
72347236
BlockNumbernblocks;
72357237
BlockNumberblkno;
7236-
charbuf[BLCKSZ];
7237-
Pagepage= (Page)buf;
7238+
7239+
/*
7240+
* palloc the buffer so that it's MAXALIGN'd. If it were just a local
7241+
* char[] array, the compiler might align it on any byte boundary, which
7242+
* can seriously hurt transfer speed to and from the kernel; not to
7243+
* mention possibly making log_newpage's accesses to the page header fail.
7244+
*/
7245+
buf= (char*)palloc(BLCKSZ);
7246+
page= (Page)buf;
72387247

72397248
/*
72407249
* We need to log the copied data in WAL iff WAL archiving/streaming is
@@ -7263,6 +7272,8 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst,
72637272
smgrextend(dst,forkNum,blkno,buf, true);
72647273
}
72657274

7275+
pfree(buf);
7276+
72667277
/*
72677278
* If the rel isn't temp, we must fsync it down to disk before it's safe
72687279
* to commit the transaction. (For a temp rel we don't care since the rel

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp