mirror of https://github.com/citusdata/citus.git
Copy data from heap tuples instead of using references
The general rule is: If the data is used within the bounds of table_open ... table_close > no need to copy If the data is required for use even after the table is closed > copypull/5967/head
parent
27ddb4fc8e
commit
dc9da7630f
|
@ -2874,7 +2874,7 @@ InstalledExtensionVersionColumnar(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
installedExtensionVersion = text_to_cstring(DatumGetTextPP(installedVersion));
|
installedExtensionVersion = text_to_cstring(DatumGetTextPCopy(installedVersion));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -175,7 +175,7 @@ RecreateDomainStmt(Oid domainOid)
|
||||||
*
|
*
|
||||||
* There is no supported way to go from a cooked expression to a raw expression.
|
* There is no supported way to go from a cooked expression to a raw expression.
|
||||||
*/
|
*/
|
||||||
constraint->cooked_expr = TextDatumGetCString(conbin);
|
constraint->cooked_expr = text_to_cstring(DatumGetTextPCopy(conbin));
|
||||||
|
|
||||||
stmt->constraints = lappend(stmt->constraints, constraint);
|
stmt->constraints = lappend(stmt->constraints, constraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,6 +337,7 @@ ExtractEncryptedPassword(Oid roleOid)
|
||||||
|
|
||||||
Datum passwordDatum = heap_getattr(tuple, Anum_pg_authid_rolpassword,
|
Datum passwordDatum = heap_getattr(tuple, Anum_pg_authid_rolpassword,
|
||||||
pgAuthIdDescription, &isNull);
|
pgAuthIdDescription, &isNull);
|
||||||
|
char *passwordCstring = text_to_cstring(DatumGetTextPCopy(passwordDatum));
|
||||||
|
|
||||||
table_close(pgAuthId, AccessShareLock);
|
table_close(pgAuthId, AccessShareLock);
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
|
@ -346,7 +347,7 @@ ExtractEncryptedPassword(Oid roleOid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pstrdup(TextDatumGetCString(passwordDatum));
|
return pstrdup(passwordCstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,7 +399,7 @@ GenerateAlterRoleSetIfExistsCommandList(HeapTuple tuple,
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nconfigs; i++)
|
for (i = 0; i < nconfigs; i++)
|
||||||
{
|
{
|
||||||
char *config = TextDatumGetCString(configs[i]);
|
char *config = text_to_cstring(DatumGetTextPCopy(configs[i]));
|
||||||
stmt->setstmt = MakeVariableSetStmt(config);
|
stmt->setstmt = MakeVariableSetStmt(config);
|
||||||
commandList = lappend(commandList,
|
commandList = lappend(commandList,
|
||||||
(void *) CreateAlterRoleSetIfExistsCommand(stmt));
|
(void *) CreateAlterRoleSetIfExistsCommand(stmt));
|
||||||
|
|
|
@ -207,6 +207,7 @@ GetTextSearchDictionaryInitOptions(HeapTuple tup, Form_pg_ts_dict dict)
|
||||||
List *initOptionDefElemList = NIL;
|
List *initOptionDefElemList = NIL;
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
{
|
{
|
||||||
|
/* TODO: might need copying */
|
||||||
initOptionDefElemList = deserialize_deflist(dictinitoption);
|
initOptionDefElemList = deserialize_deflist(dictinitoption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ get_extension_version(Oid extensionId)
|
||||||
RelationGetDescr(relation), &isNull);
|
RelationGetDescr(relation), &isNull);
|
||||||
if (!isNull)
|
if (!isNull)
|
||||||
{
|
{
|
||||||
versionName = text_to_cstring(DatumGetTextPP(versionDatum));
|
versionName = text_to_cstring(DatumGetTextPCopy(versionDatum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
#include "utils/datum.h"
|
#include "utils/datum.h"
|
||||||
#include "utils/elog.h"
|
#include "utils/elog.h"
|
||||||
#include "utils/hsearch.h"
|
#include "utils/hsearch.h"
|
||||||
|
#include "utils/jsonb.h"
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||||
#include "common/hashfn.h"
|
#include "common/hashfn.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2276,7 +2277,7 @@ InstalledExtensionVersion(void)
|
||||||
MemoryContext oldMemoryContext = MemoryContextSwitchTo(
|
MemoryContext oldMemoryContext = MemoryContextSwitchTo(
|
||||||
MetadataCacheMemoryContext);
|
MetadataCacheMemoryContext);
|
||||||
|
|
||||||
installedExtensionVersion = text_to_cstring(DatumGetTextPP(installedVersion));
|
installedExtensionVersion = text_to_cstring(DatumGetTextPCopy(installedVersion));
|
||||||
|
|
||||||
MemoryContextSwitchTo(oldMemoryContext);
|
MemoryContextSwitchTo(oldMemoryContext);
|
||||||
}
|
}
|
||||||
|
@ -4910,6 +4911,10 @@ DistNodeMetadata(void)
|
||||||
"could not find any entries in pg_dist_metadata")));
|
"could not find any entries in pg_dist_metadata")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy the jsonb result before closing the table */
|
||||||
|
/* since that memory can be freed */
|
||||||
|
metadata = JsonbPGetDatum(DatumGetJsonbPCopy(metadata));
|
||||||
|
|
||||||
systable_endscan(scanDescriptor);
|
systable_endscan(scanDescriptor);
|
||||||
table_close(pgDistNodeMetadata, AccessShareLock);
|
table_close(pgDistNodeMetadata, AccessShareLock);
|
||||||
|
|
||||||
|
|
|
@ -1286,6 +1286,7 @@ ExplainAnalyzeDestPutTuple(TupleDestination *self, Task *task,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: might need copying */
|
||||||
char *fetchedExplainAnalyzePlan = TextDatumGetCString(explainAnalyze);
|
char *fetchedExplainAnalyzePlan = TextDatumGetCString(explainAnalyze);
|
||||||
double fetchedExplainAnalyzeExecutionDuration = DatumGetFloat8(executionDuration);
|
double fetchedExplainAnalyzeExecutionDuration = DatumGetFloat8(executionDuration);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue