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

Commitc36418b

Browse files
committed
Fix getDatumCopy(): don't use store_att_byval to copy into a Datum
variable (this accounts for regression failures on PPC64, and in factwon't work on any big-endian machine). Get rid of hardwired knowledgeabout datum size rules; make it look just like datumCopy().
1 parente040ab4 commitc36418b

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

‎src/backend/access/gin/ginbulk.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.3 2006/07/14 14:52:16 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.4 2006/07/16 00:54:22 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include"postgres.h"
16+
1617
#include"access/gin.h"
18+
#include"utils/datum.h"
19+
1720

1821
#defineDEF_NENTRY2048
1922
#defineDEF_NPTR4
@@ -66,37 +69,31 @@ ginInsertData(BuildAccumulator *accum, EntryAccumulator *entry, ItemPointer heap
6669
entry->number++;
6770
}
6871

72+
/*
73+
* This is basically the same as datumCopy(), but we duplicate some code
74+
* to avoid computing the datum size twice.
75+
*/
6976
staticDatum
7077
getDatumCopy(BuildAccumulator*accum,Datumvalue) {
7178
Form_pg_attribute*att=accum->ginstate->tupdesc->attrs;
72-
Datumnewvalue;
73-
intdata_length=0;
74-
void*ptr;
79+
Datumres;
7580

76-
if (att[0]->attbyval ) {
77-
store_att_byval(&newvalue,value,att[0]->attlen);
78-
}else {
79-
/* pass-by-reference */
80-
if (att[0]->attlen==-1) {
81-
/* varlena */
82-
data_length=VARATT_SIZE(DatumGetPointer(value));
83-
}elseif (att[0]->attlen==-2) {
84-
/* c-string */
85-
data_length=strlen(DatumGetCString(value))+1;
86-
}else {
87-
/* fixed-length pass-by-reference */
88-
Assert(att[0]->attlen>0);
89-
data_length=att[0]->attlen;
90-
}
81+
if (att[0]->attbyval)
82+
res=value;
83+
else
84+
{
85+
SizerealSize;
86+
char*s;
9187

92-
ptr=palloc(data_length );
93-
memcpy(ptr,DatumGetPointer(value),data_length);
94-
newvalue=PointerGetDatum(ptr);
95-
}
88+
realSize=datumGetSize(value, false,att[0]->attlen);
9689

97-
accum->allocatedMemory+=data_length;
90+
s= (char*)palloc(realSize);
91+
memcpy(s,DatumGetPointer(value),realSize);
92+
res=PointerGetDatum(s);
9893

99-
returnnewvalue;
94+
accum->allocatedMemory+=realSize;
95+
}
96+
returnres;
10097
}
10198

10299
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp