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

Commit8c95168

Browse files
Teach datum_image_eq() about cstring datums.
Bring datum_image_eq() in line with datumIsEqual() by adding support forcomparing cstring datums.An upcoming patch that adds deduplication to the nbtree AM will usedatum_image_eq(). datum_image_eq() will need to work with all datatypesthat can be used as the storage type of a B-Tree index column, includingcstring. (cstring is used as the storage type for columns of type"name" as a space-saving optimization.)Discussion:https://postgr.es/m/CAH2-Wzn3Ee49Gmxb7V1VJ3-AC8fWn-Fr8pfWQebHe8rYRxt5OQ@mail.gmail.com
1 parent7a0574b commit8c95168

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

‎src/backend/utils/adt/datum.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen)
263263
bool
264264
datum_image_eq(Datumvalue1,Datumvalue2,booltypByVal,inttypLen)
265265
{
266+
Sizelen1,
267+
len2;
266268
boolresult= true;
267269

268270
if (typByVal)
@@ -277,9 +279,6 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
277279
}
278280
elseif (typLen==-1)
279281
{
280-
Sizelen1,
281-
len2;
282-
283282
len1=toast_raw_datum_size(value1);
284283
len2=toast_raw_datum_size(value2);
285284
/* No need to de-toast if lengths don't match. */
@@ -304,6 +303,20 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
304303
pfree(arg2val);
305304
}
306305
}
306+
elseif (typLen==-2)
307+
{
308+
char*s1,
309+
*s2;
310+
311+
/* Compare cstring datums */
312+
s1=DatumGetCString(value1);
313+
s2=DatumGetCString(value2);
314+
len1=strlen(s1)+1;
315+
len2=strlen(s2)+1;
316+
if (len1!=len2)
317+
return false;
318+
result= (memcmp(s1,s2,len1)==0);
319+
}
307320
else
308321
elog(ERROR,"unexpected typLen: %d",typLen);
309322

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp