mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Change argument of appendBinaryStringInfo from char * to void *
There is some code that uses this function to assemble some kind of packed binary layout, which requires a bunch of casts because of this. Functions taking binary data plus length should take void * instead, like memcpy() for example. Discussion: https://www.postgresql.org/message-id/flat/a0086cfc-ff0f-2827-20fe-52b591d2666c%40enterprisedb.com
This commit is contained in:
parent
33a33f0ba4
commit
1f605b82ba
@ -267,18 +267,18 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
|
|||||||
case jpiString:
|
case jpiString:
|
||||||
case jpiVariable:
|
case jpiVariable:
|
||||||
case jpiKey:
|
case jpiKey:
|
||||||
appendBinaryStringInfo(buf, (char *) &item->value.string.len,
|
appendBinaryStringInfo(buf, &item->value.string.len,
|
||||||
sizeof(item->value.string.len));
|
sizeof(item->value.string.len));
|
||||||
appendBinaryStringInfo(buf, item->value.string.val,
|
appendBinaryStringInfo(buf, item->value.string.val,
|
||||||
item->value.string.len);
|
item->value.string.len);
|
||||||
appendStringInfoChar(buf, '\0');
|
appendStringInfoChar(buf, '\0');
|
||||||
break;
|
break;
|
||||||
case jpiNumeric:
|
case jpiNumeric:
|
||||||
appendBinaryStringInfo(buf, (char *) item->value.numeric,
|
appendBinaryStringInfo(buf, item->value.numeric,
|
||||||
VARSIZE(item->value.numeric));
|
VARSIZE(item->value.numeric));
|
||||||
break;
|
break;
|
||||||
case jpiBool:
|
case jpiBool:
|
||||||
appendBinaryStringInfo(buf, (char *) &item->value.boolean,
|
appendBinaryStringInfo(buf, &item->value.boolean,
|
||||||
sizeof(item->value.boolean));
|
sizeof(item->value.boolean));
|
||||||
break;
|
break;
|
||||||
case jpiAnd:
|
case jpiAnd:
|
||||||
@ -328,11 +328,11 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
|
|||||||
int32 offs;
|
int32 offs;
|
||||||
|
|
||||||
appendBinaryStringInfo(buf,
|
appendBinaryStringInfo(buf,
|
||||||
(char *) &item->value.like_regex.flags,
|
&item->value.like_regex.flags,
|
||||||
sizeof(item->value.like_regex.flags));
|
sizeof(item->value.like_regex.flags));
|
||||||
offs = reserveSpaceForItemPointer(buf);
|
offs = reserveSpaceForItemPointer(buf);
|
||||||
appendBinaryStringInfo(buf,
|
appendBinaryStringInfo(buf,
|
||||||
(char *) &item->value.like_regex.patternlen,
|
&item->value.like_regex.patternlen,
|
||||||
sizeof(item->value.like_regex.patternlen));
|
sizeof(item->value.like_regex.patternlen));
|
||||||
appendBinaryStringInfo(buf, item->value.like_regex.pattern,
|
appendBinaryStringInfo(buf, item->value.like_regex.pattern,
|
||||||
item->value.like_regex.patternlen);
|
item->value.like_regex.patternlen);
|
||||||
@ -393,7 +393,7 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
|
|||||||
int offset;
|
int offset;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
appendBinaryStringInfo(buf, (char *) &nelems, sizeof(nelems));
|
appendBinaryStringInfo(buf, &nelems, sizeof(nelems));
|
||||||
|
|
||||||
offset = buf->len;
|
offset = buf->len;
|
||||||
|
|
||||||
@ -431,10 +431,10 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
|
|||||||
break;
|
break;
|
||||||
case jpiAny:
|
case jpiAny:
|
||||||
appendBinaryStringInfo(buf,
|
appendBinaryStringInfo(buf,
|
||||||
(char *) &item->value.anybounds.first,
|
&item->value.anybounds.first,
|
||||||
sizeof(item->value.anybounds.first));
|
sizeof(item->value.anybounds.first));
|
||||||
appendBinaryStringInfo(buf,
|
appendBinaryStringInfo(buf,
|
||||||
(char *) &item->value.anybounds.last,
|
&item->value.anybounds.last,
|
||||||
sizeof(item->value.anybounds.last));
|
sizeof(item->value.anybounds.last));
|
||||||
break;
|
break;
|
||||||
case jpiType:
|
case jpiType:
|
||||||
@ -496,7 +496,7 @@ reserveSpaceForItemPointer(StringInfo buf)
|
|||||||
int32 pos = buf->len;
|
int32 pos = buf->len;
|
||||||
int32 ptr = 0;
|
int32 ptr = 0;
|
||||||
|
|
||||||
appendBinaryStringInfo(buf, (char *) &ptr, sizeof(ptr));
|
appendBinaryStringInfo(buf, &ptr, sizeof(ptr));
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ buf_init(FullTransactionId xmin, FullTransactionId xmax)
|
|||||||
snap.nxip = 0;
|
snap.nxip = 0;
|
||||||
|
|
||||||
buf = makeStringInfo();
|
buf = makeStringInfo();
|
||||||
appendBinaryStringInfo(buf, (char *) &snap, PG_SNAPSHOT_SIZE(0));
|
appendBinaryStringInfo(buf, &snap, PG_SNAPSHOT_SIZE(0));
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ buf_add_txid(StringInfo buf, FullTransactionId fxid)
|
|||||||
/* do this before possible realloc */
|
/* do this before possible realloc */
|
||||||
snap->nxip++;
|
snap->nxip++;
|
||||||
|
|
||||||
appendBinaryStringInfo(buf, (char *) &fxid, sizeof(fxid));
|
appendBinaryStringInfo(buf, &fxid, sizeof(fxid));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pg_snapshot *
|
static pg_snapshot *
|
||||||
|
@ -224,7 +224,7 @@ appendStringInfoSpaces(StringInfo str, int count)
|
|||||||
* if necessary. Ensures that a trailing null byte is present.
|
* if necessary. Ensures that a trailing null byte is present.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
|
appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
|
||||||
{
|
{
|
||||||
Assert(str != NULL);
|
Assert(str != NULL);
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
|
|||||||
* if necessary. Does not ensure a trailing null-byte exists.
|
* if necessary. Does not ensure a trailing null-byte exists.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
appendBinaryStringInfoNT(StringInfo str, const char *data, int datalen)
|
appendBinaryStringInfoNT(StringInfo str, const void *data, int datalen)
|
||||||
{
|
{
|
||||||
Assert(str != NULL);
|
Assert(str != NULL);
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ extern void appendStringInfoSpaces(StringInfo str, int count);
|
|||||||
* if necessary.
|
* if necessary.
|
||||||
*/
|
*/
|
||||||
extern void appendBinaryStringInfo(StringInfo str,
|
extern void appendBinaryStringInfo(StringInfo str,
|
||||||
const char *data, int datalen);
|
const void *data, int datalen);
|
||||||
|
|
||||||
/*------------------------
|
/*------------------------
|
||||||
* appendBinaryStringInfoNT
|
* appendBinaryStringInfoNT
|
||||||
@ -150,7 +150,7 @@ extern void appendBinaryStringInfo(StringInfo str,
|
|||||||
* if necessary. Does not ensure a trailing null-byte exists.
|
* if necessary. Does not ensure a trailing null-byte exists.
|
||||||
*/
|
*/
|
||||||
extern void appendBinaryStringInfoNT(StringInfo str,
|
extern void appendBinaryStringInfoNT(StringInfo str,
|
||||||
const char *data, int datalen);
|
const void *data, int datalen);
|
||||||
|
|
||||||
/*------------------------
|
/*------------------------
|
||||||
* enlargeStringInfo
|
* enlargeStringInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user