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

Commit68c1d7d

Browse files
committed
Dodge a macro-name conflict with Perl.
Some versions of Perl export a macro named HS_KEY. This creates aconflict in contrib/hstore_plperl against hstore's macro of the samename. The most future-proof solution seems to be to rename our macro;I chose HSTORE_KEY. For consistency, rename HS_VAL and related macrossimilarly.Back-patch to 9.5. contrib/hstore_plperl doesn't exist before thatso there is no need to worry about the conflict in older releases.Per reports from Marco Atzeri and Mike Blackwell.
1 parentdb135e8 commit68c1d7d

File tree

8 files changed

+153
-129
lines changed

8 files changed

+153
-129
lines changed

‎contrib/hstore/hstore.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ typedef struct
7676
#defineSTRPTR(x)( (char*)(ARRPTR(x) + HS_COUNT((HStore*)(x)) * 2) )
7777

7878
/* note multiple/non evaluations */
79-
#defineHS_KEY(arr_,str_,i_)((str_) + HSE_OFF((arr_)[2*(i_)]))
80-
#defineHS_VAL(arr_,str_,i_)((str_) + HSE_OFF((arr_)[2*(i_)+1]))
81-
#defineHS_KEYLEN(arr_,i_)(HSE_LEN((arr_)[2*(i_)]))
82-
#defineHS_VALLEN(arr_,i_)(HSE_LEN((arr_)[2*(i_)+1]))
83-
#defineHS_VALISNULL(arr_,i_)(HSE_ISNULL((arr_)[2*(i_)+1]))
79+
#defineHSTORE_KEY(arr_,str_,i_)((str_) + HSE_OFF((arr_)[2*(i_)]))
80+
#defineHSTORE_VAL(arr_,str_,i_)((str_) + HSE_OFF((arr_)[2*(i_)+1]))
81+
#defineHSTORE_KEYLEN(arr_,i_)(HSE_LEN((arr_)[2*(i_)]))
82+
#defineHSTORE_VALLEN(arr_,i_)(HSE_LEN((arr_)[2*(i_)+1]))
83+
#defineHSTORE_VALISNULL(arr_,i_)(HSE_ISNULL((arr_)[2*(i_)+1]))
8484

8585
/*
8686
* currently, these following macros are the _only_ places that rely

‎contrib/hstore/hstore_compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ hstoreValidNewFormat(HStore *hs)
149149

150150
for (i=1;i<count;++i)
151151
{
152-
if (HS_KEYLEN(entries,i)<HS_KEYLEN(entries,i-1))
152+
if (HSTORE_KEYLEN(entries,i)<HSTORE_KEYLEN(entries,i-1))
153153
return0;
154154
if (HSE_ISNULL(entries[2*i]))
155155
return0;

‎contrib/hstore/hstore_gin.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ gin_extract_hstore(PG_FUNCTION_ARGS)
5959
{
6060
text*item;
6161

62-
item=makeitem(HS_KEY(hsent,ptr,i),HS_KEYLEN(hsent,i),
62+
item=makeitem(HSTORE_KEY(hsent,ptr,i),
63+
HSTORE_KEYLEN(hsent,i),
6364
KEYFLAG);
6465
entries[2*i]=PointerGetDatum(item);
6566

66-
if (HS_VALISNULL(hsent,i))
67+
if (HSTORE_VALISNULL(hsent,i))
6768
item=makeitem(NULL,0,NULLFLAG);
6869
else
69-
item=makeitem(HS_VAL(hsent,ptr,i),HS_VALLEN(hsent,i),
70+
item=makeitem(HSTORE_VAL(hsent,ptr,i),
71+
HSTORE_VALLEN(hsent,i),
7072
VALFLAG);
7173
entries[2*i+1]=PointerGetDatum(item);
7274
}

‎contrib/hstore/hstore_gist.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ ghstore_compress(PG_FUNCTION_ARGS)
129129
{
130130
inth;
131131

132-
h=crc32_sz((char*)HS_KEY(hsent,ptr,i),HS_KEYLEN(hsent,i));
132+
h=crc32_sz((char*)HSTORE_KEY(hsent,ptr,i),
133+
HSTORE_KEYLEN(hsent,i));
133134
HASH(GETSIGN(res),h);
134-
if (!HS_VALISNULL(hsent,i))
135+
if (!HSTORE_VALISNULL(hsent,i))
135136
{
136-
h=crc32_sz((char*)HS_VAL(hsent,ptr,i),HS_VALLEN(hsent,i));
137+
h=crc32_sz((char*)HSTORE_VAL(hsent,ptr,i),
138+
HSTORE_VALLEN(hsent,i));
137139
HASH(GETSIGN(res),h);
138140
}
139141
}
@@ -524,13 +526,15 @@ ghstore_consistent(PG_FUNCTION_ARGS)
524526

525527
for (i=0;res&&i<count;++i)
526528
{
527-
intcrc=crc32_sz((char*)HS_KEY(qe,qv,i),HS_KEYLEN(qe,i));
529+
intcrc=crc32_sz((char*)HSTORE_KEY(qe,qv,i),
530+
HSTORE_KEYLEN(qe,i));
528531

529532
if (GETBIT(sign,HASHVAL(crc)))
530533
{
531-
if (!HS_VALISNULL(qe,i))
534+
if (!HSTORE_VALISNULL(qe,i))
532535
{
533-
crc=crc32_sz((char*)HS_VAL(qe,qv,i),HS_VALLEN(qe,i));
536+
crc=crc32_sz((char*)HSTORE_VAL(qe,qv,i),
537+
HSTORE_VALLEN(qe,i));
534538
if (!GETBIT(sign,HASHVAL(crc)))
535539
res= false;
536540
}

‎contrib/hstore/hstore_io.c

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ hstore_populate_record(PG_FUNCTION_ARGS)
10681068
column_info->column_type=column_type;
10691069
}
10701070

1071-
if (idx<0||HS_VALISNULL(entries,idx))
1071+
if (idx<0||HSTORE_VALISNULL(entries,idx))
10721072
{
10731073
/*
10741074
* need InputFunctionCall to happen even for nulls, so that domain
@@ -1081,9 +1081,9 @@ hstore_populate_record(PG_FUNCTION_ARGS)
10811081
}
10821082
else
10831083
{
1084-
vallen=HS_VALLEN(entries,idx);
1084+
vallen=HSTORE_VALLEN(entries,idx);
10851085
value=palloc(1+vallen);
1086-
memcpy(value,HS_VAL(entries,ptr,idx),vallen);
1086+
memcpy(value,HSTORE_VAL(entries,ptr,idx),vallen);
10871087
value[vallen]=0;
10881088

10891089
values[i]=InputFunctionCall(&column_info->proc,value,
@@ -1144,23 +1144,23 @@ hstore_out(PG_FUNCTION_ARGS)
11441144
for (i=0;i<count;i++)
11451145
{
11461146
/* include "" and => and comma-space */
1147-
buflen+=6+2*HS_KEYLEN(entries,i);
1147+
buflen+=6+2*HSTORE_KEYLEN(entries,i);
11481148
/* include "" only if nonnull */
1149-
buflen+=2+ (HS_VALISNULL(entries,i)
1149+
buflen+=2+ (HSTORE_VALISNULL(entries,i)
11501150
?2
1151-
:2*HS_VALLEN(entries,i));
1151+
:2*HSTORE_VALLEN(entries,i));
11521152
}
11531153

11541154
out=ptr=palloc(buflen);
11551155

11561156
for (i=0;i<count;i++)
11571157
{
11581158
*ptr++='"';
1159-
ptr=cpw(ptr,HS_KEY(entries,base,i),HS_KEYLEN(entries,i));
1159+
ptr=cpw(ptr,HSTORE_KEY(entries,base,i),HSTORE_KEYLEN(entries,i));
11601160
*ptr++='"';
11611161
*ptr++='=';
11621162
*ptr++='>';
1163-
if (HS_VALISNULL(entries,i))
1163+
if (HSTORE_VALISNULL(entries,i))
11641164
{
11651165
*ptr++='N';
11661166
*ptr++='U';
@@ -1170,7 +1170,7 @@ hstore_out(PG_FUNCTION_ARGS)
11701170
else
11711171
{
11721172
*ptr++='"';
1173-
ptr=cpw(ptr,HS_VAL(entries,base,i),HS_VALLEN(entries,i));
1173+
ptr=cpw(ptr,HSTORE_VAL(entries,base,i),HSTORE_VALLEN(entries,i));
11741174
*ptr++='"';
11751175
}
11761176

@@ -1203,20 +1203,20 @@ hstore_send(PG_FUNCTION_ARGS)
12031203

12041204
for (i=0;i<count;i++)
12051205
{
1206-
int32keylen=HS_KEYLEN(entries,i);
1206+
int32keylen=HSTORE_KEYLEN(entries,i);
12071207

12081208
pq_sendint(&buf,keylen,4);
1209-
pq_sendtext(&buf,HS_KEY(entries,base,i),keylen);
1210-
if (HS_VALISNULL(entries,i))
1209+
pq_sendtext(&buf,HSTORE_KEY(entries,base,i),keylen);
1210+
if (HSTORE_VALISNULL(entries,i))
12111211
{
12121212
pq_sendint(&buf,-1,4);
12131213
}
12141214
else
12151215
{
1216-
int32vallen=HS_VALLEN(entries,i);
1216+
int32vallen=HSTORE_VALLEN(entries,i);
12171217

12181218
pq_sendint(&buf,vallen,4);
1219-
pq_sendtext(&buf,HS_VAL(entries,base,i),vallen);
1219+
pq_sendtext(&buf,HSTORE_VAL(entries,base,i),vallen);
12201220
}
12211221
}
12221222

@@ -1255,20 +1255,24 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
12551255
for (i=0;i<count;i++)
12561256
{
12571257
resetStringInfo(&tmp);
1258-
appendBinaryStringInfo(&tmp,HS_KEY(entries,base,i),HS_KEYLEN(entries,i));
1258+
appendBinaryStringInfo(&tmp,HSTORE_KEY(entries,base,i),
1259+
HSTORE_KEYLEN(entries,i));
12591260
escape_json(&dst,tmp.data);
12601261
appendStringInfoString(&dst,": ");
1261-
if (HS_VALISNULL(entries,i))
1262+
if (HSTORE_VALISNULL(entries,i))
12621263
appendStringInfoString(&dst,"null");
12631264
/* guess that values of 't' or 'f' are booleans */
1264-
elseif (HS_VALLEN(entries,i)==1&&*(HS_VAL(entries,base,i))=='t')
1265+
elseif (HSTORE_VALLEN(entries,i)==1&&
1266+
*(HSTORE_VAL(entries,base,i))=='t')
12651267
appendStringInfoString(&dst,"true");
1266-
elseif (HS_VALLEN(entries,i)==1&&*(HS_VAL(entries,base,i))=='f')
1268+
elseif (HSTORE_VALLEN(entries,i)==1&&
1269+
*(HSTORE_VAL(entries,base,i))=='f')
12671270
appendStringInfoString(&dst,"false");
12681271
else
12691272
{
12701273
resetStringInfo(&tmp);
1271-
appendBinaryStringInfo(&tmp,HS_VAL(entries,base,i),HS_VALLEN(entries,i));
1274+
appendBinaryStringInfo(&tmp,HSTORE_VAL(entries,base,i),
1275+
HSTORE_VALLEN(entries,i));
12721276
if (IsValidJsonNumber(tmp.data,tmp.len))
12731277
appendBinaryStringInfo(&dst,tmp.data,tmp.len);
12741278
else
@@ -1306,15 +1310,17 @@ hstore_to_json(PG_FUNCTION_ARGS)
13061310
for (i=0;i<count;i++)
13071311
{
13081312
resetStringInfo(&tmp);
1309-
appendBinaryStringInfo(&tmp,HS_KEY(entries,base,i),HS_KEYLEN(entries,i));
1313+
appendBinaryStringInfo(&tmp,HSTORE_KEY(entries,base,i),
1314+
HSTORE_KEYLEN(entries,i));
13101315
escape_json(&dst,tmp.data);
13111316
appendStringInfoString(&dst,": ");
1312-
if (HS_VALISNULL(entries,i))
1317+
if (HSTORE_VALISNULL(entries,i))
13131318
appendStringInfoString(&dst,"null");
13141319
else
13151320
{
13161321
resetStringInfo(&tmp);
1317-
appendBinaryStringInfo(&tmp,HS_VAL(entries,base,i),HS_VALLEN(entries,i));
1322+
appendBinaryStringInfo(&tmp,HSTORE_VAL(entries,base,i),
1323+
HSTORE_VALLEN(entries,i));
13181324
escape_json(&dst,tmp.data);
13191325
}
13201326

@@ -1346,20 +1352,20 @@ hstore_to_jsonb(PG_FUNCTION_ARGS)
13461352
val;
13471353

13481354
key.type=jbvString;
1349-
key.val.string.len=HS_KEYLEN(entries,i);
1350-
key.val.string.val=HS_KEY(entries,base,i);
1355+
key.val.string.len=HSTORE_KEYLEN(entries,i);
1356+
key.val.string.val=HSTORE_KEY(entries,base,i);
13511357

13521358
(void)pushJsonbValue(&state,WJB_KEY,&key);
13531359

1354-
if (HS_VALISNULL(entries,i))
1360+
if (HSTORE_VALISNULL(entries,i))
13551361
{
13561362
val.type=jbvNull;
13571363
}
13581364
else
13591365
{
13601366
val.type=jbvString;
1361-
val.val.string.len=HS_VALLEN(entries,i);
1362-
val.val.string.val=HS_VAL(entries,base,i);
1367+
val.val.string.len=HSTORE_VALLEN(entries,i);
1368+
val.val.string.val=HSTORE_VAL(entries,base,i);
13631369
}
13641370
(void)pushJsonbValue(&state,WJB_VALUE,&val);
13651371
}
@@ -1393,22 +1399,24 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
13931399
val;
13941400

13951401
key.type=jbvString;
1396-
key.val.string.len=HS_KEYLEN(entries,i);
1397-
key.val.string.val=HS_KEY(entries,base,i);
1402+
key.val.string.len=HSTORE_KEYLEN(entries,i);
1403+
key.val.string.val=HSTORE_KEY(entries,base,i);
13981404

13991405
(void)pushJsonbValue(&state,WJB_KEY,&key);
14001406

1401-
if (HS_VALISNULL(entries,i))
1407+
if (HSTORE_VALISNULL(entries,i))
14021408
{
14031409
val.type=jbvNull;
14041410
}
14051411
/* guess that values of 't' or 'f' are booleans */
1406-
elseif (HS_VALLEN(entries,i)==1&&*(HS_VAL(entries,base,i))=='t')
1412+
elseif (HSTORE_VALLEN(entries,i)==1&&
1413+
*(HSTORE_VAL(entries,base,i))=='t')
14071414
{
14081415
val.type=jbvBool;
14091416
val.val.boolean= true;
14101417
}
1411-
elseif (HS_VALLEN(entries,i)==1&&*(HS_VAL(entries,base,i))=='f')
1418+
elseif (HSTORE_VALLEN(entries,i)==1&&
1419+
*(HSTORE_VAL(entries,base,i))=='f')
14121420
{
14131421
val.type=jbvBool;
14141422
val.val.boolean= false;
@@ -1418,7 +1426,8 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
14181426
is_number= false;
14191427
resetStringInfo(&tmp);
14201428

1421-
appendBinaryStringInfo(&tmp,HS_VAL(entries,base,i),HS_VALLEN(entries,i));
1429+
appendBinaryStringInfo(&tmp,HSTORE_VAL(entries,base,i),
1430+
HSTORE_VALLEN(entries,i));
14221431

14231432
/*
14241433
* don't treat something with a leading zero followed by another
@@ -1461,14 +1470,14 @@ hstore_to_jsonb_loose(PG_FUNCTION_ARGS)
14611470
{
14621471
val.type=jbvNumeric;
14631472
val.val.numeric=DatumGetNumeric(
1464-
DirectFunctionCall3(numeric_in,CStringGetDatum(tmp.data),0,-1));
1465-
1473+
DirectFunctionCall3(numeric_in,
1474+
CStringGetDatum(tmp.data),0,-1));
14661475
}
14671476
else
14681477
{
14691478
val.type=jbvString;
1470-
val.val.string.len=HS_VALLEN(entries,i);
1471-
val.val.string.val=HS_VAL(entries,base,i);
1479+
val.val.string.len=HSTORE_VALLEN(entries,i);
1480+
val.val.string.val=HSTORE_VAL(entries,base,i);
14721481
}
14731482
}
14741483
(void)pushJsonbValue(&state,WJB_VALUE,&val);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp