Skip to content

Commit

Permalink
Rebase with master upto commit 1c781b7
Browse files Browse the repository at this point in the history
  • Loading branch information
nocaway committed Jul 20, 2023
1 parent 59f8df7 commit 50a962e
Show file tree
Hide file tree
Showing 136 changed files with 7,647 additions and 1,264 deletions.
4 changes: 3 additions & 1 deletion src/postgres/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: true
# Leave AlignConsecutiveDeclarations to default as YB team can use either of the
# styles. Not aligned is preferred in most cases but this is not enforced.
# AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: true
Expand Down
3 changes: 2 additions & 1 deletion src/postgres/contrib/file_fdw/file_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ fileGetForeignPlan(PlannerInfo *root,
best_path->fdw_private,
NIL, /* no custom tlist */
NIL, /* no remote quals */
outer_plan);
outer_plan,
best_path->path.yb_path_info);
}

/*
Expand Down
1 change: 1 addition & 0 deletions src/postgres/contrib/oid2name/oid2name.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "postgres_fe.h"

#include "catalog/pg_class_d.h"

#include "common/connect.h"
#include "common/logging.h"
#include "common/string.h"
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/contrib/pg_stat_monitor/pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
MemoryContext oldcxt;

oldcxt = MemoryContextSwitchTo(queryDesc->estate->es_query_cxt);
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_ALL);
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_ALL, false);
MemoryContextSwitchTo(oldcxt);
}
pgss_store(queryId, /* query id */
Expand Down Expand Up @@ -3076,4 +3076,4 @@ get_histogram_timings(PG_FUNCTION_ARGS)
}
pfree(tmp_str);
return CStringGetTextDatum(text_str);
}
}
3 changes: 2 additions & 1 deletion src/postgres/contrib/postgres_fdw/postgres_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,8 @@ postgresGetForeignPlan(PlannerInfo *root,
fdw_private,
fdw_scan_tlist,
fdw_recheck_quals,
outer_plan);
outer_plan,
best_path->path.yb_path_info);
}

/*
Expand Down
1 change: 1 addition & 0 deletions src/postgres/contrib/vacuumlo/vacuumlo.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#endif

#include "catalog/pg_class_d.h"

#include "common/connect.h"
#include "common/logging.h"
#include "common/string.h"
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/contrib/yb_pg_metrics/yb_pg_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ ybpgm_ExecutorStart(QueryDesc *queryDesc, int eflags)
{
MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(queryDesc->estate->es_query_cxt);
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_TIMER);
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_TIMER, false);
MemoryContextSwitchTo(oldcxt);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/backend/access/brin/brin.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
tmp = index_getprocinfo(idxRel, keyattno,
BRIN_PROCNUM_CONSISTENT);
fmgr_info_copy(&consistentFn[keyattno - 1], tmp,
CurrentMemoryContext);
GetCurrentMemoryContext());
}

/* Add key to the proper per-attribute array. */
Expand Down
11 changes: 8 additions & 3 deletions src/postgres/src/backend/access/common/attmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "access/htup_details.h"
#include "utils/builtins.h"

/* Yugabyte includes */
#include "pg_yb_utils.h"

static bool check_attrmap_match(TupleDesc indesc,
TupleDesc outdesc,
Expand Down Expand Up @@ -172,7 +174,8 @@ build_attrmap_by_position(TupleDesc indesc,
*/
AttrMap *
build_attrmap_by_name(TupleDesc indesc,
TupleDesc outdesc)
TupleDesc outdesc,
bool yb_ignore_type_mismatch)
{
AttrMap *attrMap;
int outnatts;
Expand Down Expand Up @@ -223,7 +226,8 @@ build_attrmap_by_name(TupleDesc indesc,
if (strcmp(attname, NameStr(inatt->attname)) == 0)
{
/* Found it, check type */
if (atttypid != inatt->atttypid || atttypmod != inatt->atttypmod)
if ((atttypid != inatt->atttypid || atttypmod != inatt->atttypmod) &&
!(IsYugaByteEnabled() && yb_ignore_type_mismatch))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("could not convert row type"),
Expand Down Expand Up @@ -262,7 +266,8 @@ build_attrmap_by_name_if_req(TupleDesc indesc,
AttrMap *attrMap;

/* Verify compatibility and prepare attribute-number map */
attrMap = build_attrmap_by_name(indesc, outdesc);
attrMap = build_attrmap_by_name(indesc, outdesc,
false /* yb_ignore_type_mismatch */);

/* Check if the map has a one-to-one match */
if (check_attrmap_match(indesc, outdesc, attrMap))
Expand Down
7 changes: 1 addition & 6 deletions src/postgres/src/backend/access/common/printtup.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
else
{
/* Binary output */
bytea *outputbytes;

outputbytes = SendFunctionCall(&thisState->finfo, attr);
pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ);
pq_sendbytes(buf, VARDATA(outputbytes),
VARSIZE(outputbytes) - VARHDRSZ);
StringInfoSendFunctionCall(buf, &thisState->finfo, attr);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/backend/access/index/genam.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
scan->yb_scan_plan = NULL;
scan->yb_rel_pushdown = NULL;
scan->yb_idx_pushdown = NULL;
scan->yb_aggrefs = NIL;
scan->yb_agg_slot = NULL;
return scan;
}

Expand Down
6 changes: 1 addition & 5 deletions src/postgres/src/backend/access/index/indexam.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,7 @@ index_fetch_heap(IndexScanDesc scan, TupleTableSlot *slot)
* - If YugaByte returns a heap_tuple, all requested data was already selected in the tuple.
*/
if (IsYBRelation(scan->heapRelation))
{
if (scan->xs_hitup != 0)
return scan->xs_hitup;
return YbFetchTableSlot(scan->heapRelation, &scan->xs_heaptid, slot);
}
return scan->xs_hitup;

found = table_index_fetch_tuple(scan->xs_heapfetch, &scan->xs_heaptid,
scan->xs_snapshot, slot,
Expand Down
52 changes: 48 additions & 4 deletions src/postgres/src/backend/access/yb_access/yb_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ ybcinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys
YbScanDesc ybScan = ybcBeginScan(scan->heapRelation, scan->indexRelation,
scan->xs_want_itup, nscankeys, scankey,
scan->yb_scan_plan, scan->yb_rel_pushdown,
scan->yb_idx_pushdown);
scan->yb_idx_pushdown, scan->yb_aggrefs,
scan->yb_exec_params);
scan->opaque = ybScan;
}

Expand All @@ -447,13 +448,56 @@ ybcingettuple(IndexScanDesc scan, ScanDirection dir)

YbScanDesc ybscan = (YbScanDesc) scan->opaque;
ybscan->exec_params = scan->yb_exec_params;
/* exec_params can be NULL in case of systable_getnext, for example. */
if (ybscan->exec_params)
ybscan->exec_params->work_mem = work_mem;

if (!ybscan->exec_params) {
ereport(DEBUG1, (errmsg("null exec_params")));
/* Special case: aggregate pushdown. */
if (scan->yb_aggrefs)
{
/*
* TODO(#18018): deduplicate with ybc_getnext_heaptuple,
* ybc_getnext_indextuple.
*/
if (ybscan->quit_scan)
return NULL;

/*
* As of 2023-06-28, aggregate pushdown is only implemented for
* IndexOnlyScan, not IndexScan.
*/
Assert(ybscan->prepare_params.index_only_scan);

/*
* TODO(#18018): deduplicate with ybc_getnext_heaptuple,
* ybc_getnext_indextuple.
*/
scan->xs_recheck = (ybscan->nhash_keys > 0 ||
!ybscan->is_full_cond_bound);
if (!ybscan->is_exec_done)
{
HandleYBStatus(YBCPgSetForwardScan(ybscan->handle,
is_forward_scan));
HandleYBStatus(YBCPgExecSelect(ybscan->handle,
ybscan->exec_params));
ybscan->is_exec_done = true;
}

/*
* Aggregate pushdown directly modifies the scan slot rather than
* passing it through xs_hitup or xs_itup.
*
* The index id passed into ybFetchNext is likely not going to be used
* as it is only used for system table scans, which have oid, and there
* shouldn't exist any system table secondary indexes that index the
* oid column.
* TODO(jason): deduplicate with ybcingettuple.
*/
scan->yb_agg_slot =
ybFetchNext(ybscan->handle, scan->yb_agg_slot,
RelationGetRelid(scan->indexRelation));
return !TTS_EMPTY(scan->yb_agg_slot);
}
Assert(PointerIsValid(ybscan));

/*
* IndexScan(SysTable, Index) --> HeapTuple.
Expand Down
Loading

0 comments on commit 50a962e

Please sign in to comment.