Beispiel #1
0
/*
 * Error callback to give more context info about type conversion failure.
 */
static void
slot_store_error_callback(void *arg)
{
	SlotErrCallbackArg *errarg = (SlotErrCallbackArg *) arg;
	LogicalRepRelMapEntry *rel;
	char	   *remotetypname;
	Oid			remotetypoid,
				localtypoid;

	/* Nothing to do if remote attribute number is not set */
	if (errarg->remote_attnum < 0)
		return;

	rel = errarg->rel;
	remotetypoid = rel->remoterel.atttyps[errarg->remote_attnum];

	/* Fetch remote type name from the LogicalRepTypMap cache */
	remotetypname = logicalrep_typmap_gettypname(remotetypoid);

	/* Fetch local type OID from the local sys cache */
	localtypoid = get_atttype(rel->localreloid, errarg->local_attnum + 1);

	errcontext("processing remote data for replication target relation \"%s.%s\" column \"%s\", "
			   "remote type %s, local type %s",
			   rel->remoterel.nspname, rel->remoterel.relname,
			   rel->remoterel.attnames[errarg->remote_attnum],
			   remotetypname,
			   format_type_be(localtypoid));
}
Beispiel #2
0
/*
 * Main function for aggregating leaf partition MCV/Freq to compute
 * root or interior partition MCV/Freq
 * Input:
 * 	- relationOid: Oid of root or interior partition
 * 	- attnum: column number
 * 	- nEntries: target number of MCVs/Freqs to be collected, the real number of
 * 	MCVs/Freqs returned may be less
 * Output:
 * 	- result: two dimensional arrays of MCVs and Freqs
 */
void
aggregate_leaf_partition_MCVs
(
    Oid relationOid,
    AttrNumber attnum,
    unsigned int nEntries,
    ArrayType **result
)
{
    List *lRelOids = rel_get_leaf_children_relids(relationOid); /* list of OIDs of leaf partitions */
    Oid typoid = get_atttype(relationOid, attnum);
    TypInfo *typInfo = (TypInfo*) palloc(sizeof(TypInfo));
    initTypInfo(typInfo, typoid);

    HTAB* datumHash = createDatumHashTable(nEntries);
    float4 sumReltuples = 0;

    ListCell *le = NULL;
    foreach (le, lRelOids)
    {
        Oid partOid = lfirst_oid(le);
        HeapTuple heaptupleStats = get_att_stats(partOid, attnum);
        if (!HeapTupleIsValid(heaptupleStats))
        {
            continue;
        }

        float4 partReltuples = 0;
        addAllMCVsToHashTable(datumHash, partOid, heaptupleStats, typInfo, &partReltuples);
        heap_freetuple(heaptupleStats);
        sumReltuples += partReltuples;
    }