forked from openGauss-Ecosystem/openGauss-server
printtup优化
This commit is contained in:
parent
91594ce000
commit
69348ac2c2
|
@ -4582,7 +4582,7 @@ static char* get_str_from_var(NumericVar* var)
|
|||
* CAUTION: var's contents may be modified by rounding!
|
||||
* Returns a palloc'd string.
|
||||
*/
|
||||
static char output_buffer_str_from_var[64] = {0};
|
||||
char output_buffer_str_from_var[64] = {0};
|
||||
static char* output_get_str_from_var(NumericVar* var)
|
||||
{
|
||||
int dscale;
|
||||
|
@ -4613,7 +4613,11 @@ static char* output_get_str_from_var(NumericVar* var)
|
|||
i = 1;
|
||||
|
||||
len = i + dscale + DEC_DIGITS + 2;
|
||||
str = (char*)palloc(len);
|
||||
if (len > 64) {
|
||||
str = (char*)palloc(len);
|
||||
} else {
|
||||
str = (char*)output_buffer_str_from_var;
|
||||
}
|
||||
cp = str;
|
||||
|
||||
/*
|
||||
|
|
|
@ -230,7 +230,7 @@ char* text_to_cstring(const text* t)
|
|||
return result;
|
||||
}
|
||||
|
||||
static char output_buffer[256] {0};
|
||||
char output_buffer[256] {0};
|
||||
char* output_text_to_cstring(const text* t)
|
||||
{
|
||||
if (unlikely(t == NULL)) {
|
||||
|
@ -244,7 +244,11 @@ char* output_text_to_cstring(const text* t)
|
|||
int len = VARSIZE_ANY_EXHDR(tunpacked);
|
||||
char* result = NULL;
|
||||
|
||||
result = (char*)palloc(len + 1);
|
||||
if (len + 1 > 256) {
|
||||
result = (char*)palloc(len + 1);
|
||||
} else {
|
||||
result = output_buffer;
|
||||
}
|
||||
memcpy(result, VARDATA_ANY(tunpacked), len);
|
||||
result[len] = '\0';
|
||||
|
||||
|
@ -254,12 +258,11 @@ char* output_text_to_cstring(const text* t)
|
|||
return result;
|
||||
}
|
||||
|
||||
static char output_int32_buffer[32] = {0};
|
||||
char output_int32_buffer[32] = {0};
|
||||
char* output_int32_to_cstring(int32 value)
|
||||
{
|
||||
char* result = (char*)palloc(12); /*sign, 10 digits, '\0' */
|
||||
pg_ltoa(value, result);
|
||||
return result;
|
||||
pg_ltoa(value, output_int32_buffer);
|
||||
return output_int32_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1022,7 +1022,6 @@ void printtup(TupleTableSlot *slot, DestReceiver *self)
|
|||
/* just as we define in backend/commands/analyze.cpp */
|
||||
#define WIDTH_THRESHOLD 1024
|
||||
|
||||
StreamTimeSerilizeStart(t_thrd.pgxc_cxt.GlobalNetInstr);
|
||||
/* Set or update my derived attribute info, if needed */
|
||||
if (myState->attrinfo != typeinfo || myState->nattrs != natts)
|
||||
printtup_prepare_info(myState, typeinfo, natts);
|
||||
|
@ -1052,7 +1051,6 @@ void printtup(TupleTableSlot *slot, DestReceiver *self)
|
|||
appendBinaryStringInfo(buf, slot->tts_dataRow, slot->tts_dataLen);
|
||||
AddCheckInfo(buf);
|
||||
pq_endmessage_reuse(buf);
|
||||
StreamTimeSerilizeEnd(t_thrd.pgxc_cxt.GlobalNetInstr);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1164,7 +1162,6 @@ void printtup(TupleTableSlot *slot, DestReceiver *self)
|
|||
}
|
||||
|
||||
(void)MemoryContextSwitchTo(old_context);
|
||||
StreamTimeSerilizeEnd(t_thrd.pgxc_cxt.GlobalNetInstr);
|
||||
|
||||
AddCheckInfo(buf);
|
||||
pq_endmessage_reuse(buf);
|
||||
|
|
Loading…
Reference in New Issue