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

Commit6bcda4a

Browse files
committed
Fix incorrect uses of Datum conversion macros
Since these macros just cast whatever you give them to the designatedoutput type, and many normal uses also cast the output type further, anumber of incorrect uses go undiscovered. The fixes in this patchhave been discovered by changing these macros to inline functions,which is the subject of a future patch.Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>Discussion:https://www.postgresql.org/message-id/flat/8528fb7e-0aa2-6b54-85fb-0c0886dbd6ed%40enterprisedb.com
1 parent6dc0738 commit6bcda4a

File tree

22 files changed

+33
-33
lines changed

22 files changed

+33
-33
lines changed

‎contrib/btree_gist/btree_utils_num.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
153153
datum=CashGetDatum(*(Cash*)entry->key);
154154
break;
155155
default:
156-
datum=PointerGetDatum(entry->key);
156+
datum=entry->key;
157157
}
158158

159159
retval=palloc(sizeof(GISTENTRY));

‎contrib/dblink/dblink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ dblink_get_connections(PG_FUNCTION_ARGS)
13361336
}
13371337

13381338
if (astate)
1339-
PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate,
1339+
PG_RETURN_DATUM(makeArrayResult(astate,
13401340
CurrentMemoryContext));
13411341
else
13421342
PG_RETURN_NULL();

‎contrib/hstore/hstore_op.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ hstore_each(PG_FUNCTION_ARGS)
10641064
tuple=heap_form_tuple(funcctx->tuple_desc,dvalues,nulls);
10651065
res=HeapTupleGetDatum(tuple);
10661066

1067-
SRF_RETURN_NEXT(funcctx,PointerGetDatum(res));
1067+
SRF_RETURN_NEXT(funcctx,res);
10681068
}
10691069

10701070
SRF_RETURN_DONE(funcctx);

‎contrib/pageinspect/heapfuncs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ tuple_data_split_internal(Oid relid, char *tupdata,
383383
errmsg("unexpected end of tuple data")));
384384

385385
if (attr->attlen==-1&&do_detoast)
386-
attr_data=DatumGetByteaPCopy(tupdata+off);
386+
attr_data=pg_detoast_datum_copy((structvarlena*) (tupdata+off));
387387
else
388388
{
389389
attr_data= (bytea*)palloc(len+VARHDRSZ);
@@ -492,7 +492,7 @@ tuple_data_split(PG_FUNCTION_ARGS)
492492
if (t_bits)
493493
pfree(t_bits);
494494

495-
PG_RETURN_ARRAYTYPE_P(res);
495+
PG_RETURN_DATUM(res);
496496
}
497497

498498
/*

‎src/backend/access/brin/brin_bloom.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ brin_bloom_summary_out(PG_FUNCTION_ARGS)
767767
StringInfoDatastr;
768768

769769
/* detoast the data to get value with a full 4B header */
770-
filter= (BloomFilter*)PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
770+
filter= (BloomFilter*)PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(0));
771771

772772
initStringInfo(&str);
773773
appendStringInfoChar(&str,'{');

‎src/backend/access/brin/brin_minmax_multi.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,12 @@ brin_range_deserialize(int maxvalues, SerializedRanges *serialized)
774774
datalen+=MAXALIGN(typlen);
775775
elseif (typlen==-1)/* varlena */
776776
{
777-
datalen+=MAXALIGN(VARSIZE_ANY(DatumGetPointer(ptr)));
778-
ptr+=VARSIZE_ANY(DatumGetPointer(ptr));
777+
datalen+=MAXALIGN(VARSIZE_ANY(ptr));
778+
ptr+=VARSIZE_ANY(ptr);
779779
}
780780
elseif (typlen==-2)/* cstring */
781781
{
782-
Sizeslen=strlen(DatumGetCString(ptr))+1;
782+
Sizeslen=strlen(ptr)+1;
783783

784784
datalen+=MAXALIGN(slen);
785785
ptr+=slen;
@@ -3033,7 +3033,7 @@ brin_minmax_multi_summary_out(PG_FUNCTION_ARGS)
30333033
* Detoast to get value with full 4B header (can't be stored in a toast
30343034
* table, but can use 1B header).
30353035
*/
3036-
ranges= (SerializedRanges*)PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
3036+
ranges= (SerializedRanges*)PG_DETOAST_DATUM_PACKED(PG_GETARG_DATUM(0));
30373037

30383038
/* lookup output func for the type */
30393039
getTypeOutputInfo(ranges->typid,&outfunc,&isvarlena);
@@ -3081,7 +3081,7 @@ brin_minmax_multi_summary_out(PG_FUNCTION_ARGS)
30813081

30823082
getTypeOutputInfo(ANYARRAYOID,&typoutput,&typIsVarlena);
30833083

3084-
val=PointerGetDatum(makeArrayResult(astate_values,CurrentMemoryContext));
3084+
val=makeArrayResult(astate_values,CurrentMemoryContext);
30853085

30863086
extval=OidOutputFunctionCall(typoutput,val);
30873087

@@ -3121,7 +3121,7 @@ brin_minmax_multi_summary_out(PG_FUNCTION_ARGS)
31213121

31223122
getTypeOutputInfo(ANYARRAYOID,&typoutput,&typIsVarlena);
31233123

3124-
val=PointerGetDatum(makeArrayResult(astate_values,CurrentMemoryContext));
3124+
val=makeArrayResult(astate_values,CurrentMemoryContext);
31253125

31263126
extval=OidOutputFunctionCall(typoutput,val);
31273127

‎src/backend/access/common/toast_compression.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pglz_compress_datum(const struct varlena *value)
4444
len;
4545
structvarlena*tmp=NULL;
4646

47-
valsize=VARSIZE_ANY_EXHDR(DatumGetPointer(value));
47+
valsize=VARSIZE_ANY_EXHDR(value);
4848

4949
/*
5050
* No point in wasting a palloc cycle if value size is outside the allowed

‎src/backend/access/table/toast_helper.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ toast_delete_external(Relation rel, Datum *values, bool *isnull,
330330

331331
if (isnull[i])
332332
continue;
333-
elseif (VARATT_IS_EXTERNAL_ONDISK(PointerGetDatum(value)))
333+
elseif (VARATT_IS_EXTERNAL_ONDISK(value))
334334
toast_delete_datum(rel,value,is_speculative);
335335
}
336336
}

‎src/backend/access/transam/xlogfuncs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ pg_wal_lsn_diff(PG_FUNCTION_ARGS)
555555
PG_GETARG_DATUM(0),
556556
PG_GETARG_DATUM(1));
557557

558-
PG_RETURN_NUMERIC(result);
558+
PG_RETURN_DATUM(result);
559559
}
560560

561561
/*

‎src/backend/statistics/mcv.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,8 +1444,8 @@ pg_stats_ext_mcvlist_items(PG_FUNCTION_ARGS)
14441444
}
14451445

14461446
values[0]=Int32GetDatum(funcctx->call_cntr);
1447-
values[1]=PointerGetDatum(makeArrayResult(astate_values,CurrentMemoryContext));
1448-
values[2]=PointerGetDatum(makeArrayResult(astate_nulls,CurrentMemoryContext));
1447+
values[1]=makeArrayResult(astate_values,CurrentMemoryContext);
1448+
values[2]=makeArrayResult(astate_nulls,CurrentMemoryContext);
14491449
values[3]=Float8GetDatum(item->frequency);
14501450
values[4]=Float8GetDatum(item->base_frequency);
14511451

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp