mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Mark function arguments of type "Datum *" as "const Datum *" where possible
Several functions in the codebase accept "Datum *" parameters but do not modify the pointed-to data. These have been updated to take "const Datum *" instead, improving type safety and making the interfaces clearer about their intent. This change helps the compiler catch accidental modifications and better documents immutability of arguments. Most of "Datum *" parameters have a pairing "bool *isnull" parameter, they are constified as well. No functional behavior is changed by this patch. Author: Chao Li <lic@highgo.com> Discussion: https://www.postgresql.org/message-id/flat/CAEoWx2msfT0knvzUa72ZBwu9LR_RLY4on85w2a9YpE-o2By5HQ@mail.gmail.com
This commit is contained in:
		@@ -846,7 +846,7 @@ int SPI_execute_extended(const char *<parameter>command</parameter>,
 | 
				
			|||||||
<synopsis>
 | 
					<synopsis>
 | 
				
			||||||
int SPI_execute_with_args(const char *<parameter>command</parameter>,
 | 
					int SPI_execute_with_args(const char *<parameter>command</parameter>,
 | 
				
			||||||
                          int <parameter>nargs</parameter>, Oid *<parameter>argtypes</parameter>,
 | 
					                          int <parameter>nargs</parameter>, Oid *<parameter>argtypes</parameter>,
 | 
				
			||||||
                          Datum *<parameter>values</parameter>, const char *<parameter>nulls</parameter>,
 | 
					                          const Datum *<parameter>values</parameter>, const char *<parameter>nulls</parameter>,
 | 
				
			||||||
                          bool <parameter>read_only</parameter>, long <parameter>count</parameter>)
 | 
					                          bool <parameter>read_only</parameter>, long <parameter>count</parameter>)
 | 
				
			||||||
</synopsis>
 | 
					</synopsis>
 | 
				
			||||||
 </refsynopsisdiv>
 | 
					 </refsynopsisdiv>
 | 
				
			||||||
@@ -1671,7 +1671,7 @@ bool SPI_is_cursor_plan(SPIPlanPtr <parameter>plan</parameter>)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 <refsynopsisdiv>
 | 
					 <refsynopsisdiv>
 | 
				
			||||||
<synopsis>
 | 
					<synopsis>
 | 
				
			||||||
int SPI_execute_plan(SPIPlanPtr <parameter>plan</parameter>, Datum * <parameter>values</parameter>, const char * <parameter>nulls</parameter>,
 | 
					int SPI_execute_plan(SPIPlanPtr <parameter>plan</parameter>, const Datum * <parameter>values</parameter>, const char * <parameter>nulls</parameter>,
 | 
				
			||||||
                     bool <parameter>read_only</parameter>, long <parameter>count</parameter>)
 | 
					                     bool <parameter>read_only</parameter>, long <parameter>count</parameter>)
 | 
				
			||||||
</synopsis>
 | 
					</synopsis>
 | 
				
			||||||
 </refsynopsisdiv>
 | 
					 </refsynopsisdiv>
 | 
				
			||||||
@@ -2317,7 +2317,7 @@ Portal SPI_cursor_open(const char * <parameter>name</parameter>, SPIPlanPtr <par
 | 
				
			|||||||
Portal SPI_cursor_open_with_args(const char *<parameter>name</parameter>,
 | 
					Portal SPI_cursor_open_with_args(const char *<parameter>name</parameter>,
 | 
				
			||||||
                                 const char *<parameter>command</parameter>,
 | 
					                                 const char *<parameter>command</parameter>,
 | 
				
			||||||
                                 int <parameter>nargs</parameter>, Oid *<parameter>argtypes</parameter>,
 | 
					                                 int <parameter>nargs</parameter>, Oid *<parameter>argtypes</parameter>,
 | 
				
			||||||
                                 Datum *<parameter>values</parameter>, const char *<parameter>nulls</parameter>,
 | 
					                                 const Datum *<parameter>values</parameter>, const char *<parameter>nulls</parameter>,
 | 
				
			||||||
                                 bool <parameter>read_only</parameter>, int <parameter>cursorOptions</parameter>)
 | 
					                                 bool <parameter>read_only</parameter>, int <parameter>cursorOptions</parameter>)
 | 
				
			||||||
</synopsis>
 | 
					</synopsis>
 | 
				
			||||||
 </refsynopsisdiv>
 | 
					 </refsynopsisdiv>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -276,7 +276,7 @@ static int	compare_values(const void *a, const void *b, void *arg);
 | 
				
			|||||||
 * function (which should be BTLessStrategyNumber).
 | 
					 * function (which should be BTLessStrategyNumber).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
AssertArrayOrder(FmgrInfo *cmp, Oid colloid, Datum *values, int nvalues)
 | 
					AssertArrayOrder(FmgrInfo *cmp, Oid colloid, const Datum *values, int nvalues)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i;
 | 
						int			i;
 | 
				
			||||||
	Datum		lt;
 | 
						Datum		lt;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -316,7 +316,7 @@ _hash_get_indextuple_hashkey(IndexTuple itup)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
_hash_convert_tuple(Relation index,
 | 
					_hash_convert_tuple(Relation index,
 | 
				
			||||||
					Datum *user_values, bool *user_isnull,
 | 
										const Datum *user_values, const bool *user_isnull,
 | 
				
			||||||
					Datum *index_values, bool *index_isnull)
 | 
										Datum *index_values, bool *index_isnull)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint32		hashkey;
 | 
						uint32		hashkey;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -561,8 +561,8 @@ toast_flatten_tuple_to_datum(HeapTupleHeader tup,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
HeapTuple
 | 
					HeapTuple
 | 
				
			||||||
toast_build_flattened_tuple(TupleDesc tupleDesc,
 | 
					toast_build_flattened_tuple(TupleDesc tupleDesc,
 | 
				
			||||||
							Datum *values,
 | 
												const Datum *values,
 | 
				
			||||||
							bool *isnull)
 | 
												const bool *isnull)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	HeapTuple	new_tuple;
 | 
						HeapTuple	new_tuple;
 | 
				
			||||||
	int			numAttrs = tupleDesc->natts;
 | 
						int			numAttrs = tupleDesc->natts;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,7 @@ static int	_bt_num_array_keys(IndexScanDesc scan, Oid *skip_eq_ops_out,
 | 
				
			|||||||
							   int *numSkipArrayKeys_out);
 | 
												   int *numSkipArrayKeys_out);
 | 
				
			||||||
static Datum _bt_find_extreme_element(IndexScanDesc scan, ScanKey skey,
 | 
					static Datum _bt_find_extreme_element(IndexScanDesc scan, ScanKey skey,
 | 
				
			||||||
									  Oid elemtype, StrategyNumber strat,
 | 
														  Oid elemtype, StrategyNumber strat,
 | 
				
			||||||
									  Datum *elems, int nelems);
 | 
														  const Datum *elems, int nelems);
 | 
				
			||||||
static void _bt_setup_array_cmp(IndexScanDesc scan, ScanKey skey, Oid elemtype,
 | 
					static void _bt_setup_array_cmp(IndexScanDesc scan, ScanKey skey, Oid elemtype,
 | 
				
			||||||
								FmgrInfo *orderproc, FmgrInfo **sortprocp);
 | 
													FmgrInfo *orderproc, FmgrInfo **sortprocp);
 | 
				
			||||||
static int	_bt_sort_array_elements(ScanKey skey, FmgrInfo *sortproc,
 | 
					static int	_bt_sort_array_elements(ScanKey skey, FmgrInfo *sortproc,
 | 
				
			||||||
@@ -2569,7 +2569,7 @@ _bt_num_array_keys(IndexScanDesc scan, Oid *skip_eq_ops_out,
 | 
				
			|||||||
static Datum
 | 
					static Datum
 | 
				
			||||||
_bt_find_extreme_element(IndexScanDesc scan, ScanKey skey, Oid elemtype,
 | 
					_bt_find_extreme_element(IndexScanDesc scan, ScanKey skey, Oid elemtype,
 | 
				
			||||||
						 StrategyNumber strat,
 | 
											 StrategyNumber strat,
 | 
				
			||||||
						 Datum *elems, int nelems)
 | 
											 const Datum *elems, int nelems)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Relation	rel = scan->indexRelation;
 | 
						Relation	rel = scan->indexRelation;
 | 
				
			||||||
	Oid			cmp_op;
 | 
						Oid			cmp_op;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -258,7 +258,7 @@ static double _bt_spools_heapscan(Relation heap, Relation index,
 | 
				
			|||||||
								  BTBuildState *buildstate, IndexInfo *indexInfo);
 | 
													  BTBuildState *buildstate, IndexInfo *indexInfo);
 | 
				
			||||||
static void _bt_spooldestroy(BTSpool *btspool);
 | 
					static void _bt_spooldestroy(BTSpool *btspool);
 | 
				
			||||||
static void _bt_spool(BTSpool *btspool, const ItemPointerData *self,
 | 
					static void _bt_spool(BTSpool *btspool, const ItemPointerData *self,
 | 
				
			||||||
					  Datum *values, bool *isnull);
 | 
										  const Datum *values, const bool *isnull);
 | 
				
			||||||
static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
 | 
					static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
 | 
				
			||||||
static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
 | 
					static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
 | 
				
			||||||
							   bool *isnull, bool tupleIsAlive, void *state);
 | 
												   bool *isnull, bool tupleIsAlive, void *state);
 | 
				
			||||||
@@ -525,7 +525,7 @@ _bt_spooldestroy(BTSpool *btspool)
 | 
				
			|||||||
 * spool an index entry into the sort file.
 | 
					 * spool an index entry into the sort file.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
_bt_spool(BTSpool *btspool, const ItemPointerData *self, Datum *values, bool *isnull)
 | 
					_bt_spool(BTSpool *btspool, const ItemPointerData *self, const Datum *values, const bool *isnull)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
 | 
						tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
 | 
				
			||||||
								  self, values, isnull);
 | 
													  self, values, isnull);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1908,7 +1908,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
spgdoinsert(Relation index, SpGistState *state,
 | 
					spgdoinsert(Relation index, SpGistState *state,
 | 
				
			||||||
			const ItemPointerData *heapPtr, Datum *datums, bool *isnulls)
 | 
								const ItemPointerData *heapPtr, const Datum *datums, const bool *isnulls)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	bool		result = true;
 | 
						bool		result = true;
 | 
				
			||||||
	TupleDesc	leafDescriptor = state->leafTupDesc;
 | 
						TupleDesc	leafDescriptor = state->leafTupDesc;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -155,7 +155,7 @@ commonPrefix(const char *a, const char *b, int lena, int lenb)
 | 
				
			|||||||
 * On success, *i gets the match location; on failure, it gets where to insert
 | 
					 * On success, *i gets the match location; on failure, it gets where to insert
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
searchChar(Datum *nodeLabels, int nNodes, int16 c, int *i)
 | 
					searchChar(const Datum *nodeLabels, int nNodes, int16 c, int *i)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			StopLow = 0,
 | 
						int			StopLow = 0,
 | 
				
			||||||
				StopHigh = nNodes;
 | 
									StopHigh = nNodes;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -173,11 +173,11 @@ static void FormPartitionKeyDatum(PartitionDispatch pd,
 | 
				
			|||||||
								  EState *estate,
 | 
													  EState *estate,
 | 
				
			||||||
								  Datum *values,
 | 
													  Datum *values,
 | 
				
			||||||
								  bool *isnull);
 | 
													  bool *isnull);
 | 
				
			||||||
static int	get_partition_for_tuple(PartitionDispatch pd, Datum *values,
 | 
					static int	get_partition_for_tuple(PartitionDispatch pd, const Datum *values,
 | 
				
			||||||
									bool *isnull);
 | 
														const bool *isnull);
 | 
				
			||||||
static char *ExecBuildSlotPartitionKeyDescription(Relation rel,
 | 
					static char *ExecBuildSlotPartitionKeyDescription(Relation rel,
 | 
				
			||||||
												  Datum *values,
 | 
																	  const Datum *values,
 | 
				
			||||||
												  bool *isnull,
 | 
																	  const bool *isnull,
 | 
				
			||||||
												  int maxfieldlen);
 | 
																	  int maxfieldlen);
 | 
				
			||||||
static List *adjust_partition_colnos(List *colnos, ResultRelInfo *leaf_part_rri);
 | 
					static List *adjust_partition_colnos(List *colnos, ResultRelInfo *leaf_part_rri);
 | 
				
			||||||
static List *adjust_partition_colnos_using_map(List *colnos, AttrMap *attrMap);
 | 
					static List *adjust_partition_colnos_using_map(List *colnos, AttrMap *attrMap);
 | 
				
			||||||
@@ -1396,7 +1396,7 @@ FormPartitionKeyDatum(PartitionDispatch pd,
 | 
				
			|||||||
 * found or -1 if none found.
 | 
					 * found or -1 if none found.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull)
 | 
					get_partition_for_tuple(PartitionDispatch pd, const Datum *values, const bool *isnull)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			bound_offset = -1;
 | 
						int			bound_offset = -1;
 | 
				
			||||||
	int			part_index = -1;
 | 
						int			part_index = -1;
 | 
				
			||||||
@@ -1617,8 +1617,8 @@ get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static char *
 | 
					static char *
 | 
				
			||||||
ExecBuildSlotPartitionKeyDescription(Relation rel,
 | 
					ExecBuildSlotPartitionKeyDescription(Relation rel,
 | 
				
			||||||
									 Datum *values,
 | 
														 const Datum *values,
 | 
				
			||||||
									 bool *isnull,
 | 
														 const bool *isnull,
 | 
				
			||||||
									 int maxfieldlen)
 | 
														 int maxfieldlen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	StringInfoData buf;
 | 
						StringInfoData buf;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ static int	cmp_orderbyvals(const Datum *adist, const bool *anulls,
 | 
				
			|||||||
static int	reorderqueue_cmp(const pairingheap_node *a,
 | 
					static int	reorderqueue_cmp(const pairingheap_node *a,
 | 
				
			||||||
							 const pairingheap_node *b, void *arg);
 | 
												 const pairingheap_node *b, void *arg);
 | 
				
			||||||
static void reorderqueue_push(IndexScanState *node, TupleTableSlot *slot,
 | 
					static void reorderqueue_push(IndexScanState *node, TupleTableSlot *slot,
 | 
				
			||||||
							  Datum *orderbyvals, bool *orderbynulls);
 | 
												  const Datum *orderbyvals, const bool *orderbynulls);
 | 
				
			||||||
static HeapTuple reorderqueue_pop(IndexScanState *node);
 | 
					static HeapTuple reorderqueue_pop(IndexScanState *node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -458,7 +458,7 @@ reorderqueue_cmp(const pairingheap_node *a, const pairingheap_node *b,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
reorderqueue_push(IndexScanState *node, TupleTableSlot *slot,
 | 
					reorderqueue_push(IndexScanState *node, TupleTableSlot *slot,
 | 
				
			||||||
				  Datum *orderbyvals, bool *orderbynulls)
 | 
									  const Datum *orderbyvals, const bool *orderbynulls)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	IndexScanDesc scandesc = node->iss_ScanDesc;
 | 
						IndexScanDesc scandesc = node->iss_ScanDesc;
 | 
				
			||||||
	EState	   *estate = node->ss.ps.state;
 | 
						EState	   *estate = node->ss.ps.state;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,7 @@ static int	_SPI_execute_plan(SPIPlanPtr plan, const SPIExecuteOptions *options,
 | 
				
			|||||||
							  bool fire_triggers);
 | 
												  bool fire_triggers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static ParamListInfo _SPI_convert_params(int nargs, Oid *argtypes,
 | 
					static ParamListInfo _SPI_convert_params(int nargs, Oid *argtypes,
 | 
				
			||||||
										 Datum *Values, const char *Nulls);
 | 
															 const Datum *Values, const char *Nulls);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int	_SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount);
 | 
					static int	_SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -669,7 +669,7 @@ SPI_execute_extended(const char *src,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Execute a previously prepared plan */
 | 
					/* Execute a previously prepared plan */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
 | 
					SPI_execute_plan(SPIPlanPtr plan, const Datum *Values, const char *Nulls,
 | 
				
			||||||
				 bool read_only, long tcount)
 | 
									 bool read_only, long tcount)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	SPIExecuteOptions options;
 | 
						SPIExecuteOptions options;
 | 
				
			||||||
@@ -771,7 +771,7 @@ SPI_execute_plan_with_paramlist(SPIPlanPtr plan, ParamListInfo params,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
SPI_execute_snapshot(SPIPlanPtr plan,
 | 
					SPI_execute_snapshot(SPIPlanPtr plan,
 | 
				
			||||||
					 Datum *Values, const char *Nulls,
 | 
										 const Datum *Values, const char *Nulls,
 | 
				
			||||||
					 Snapshot snapshot, Snapshot crosscheck_snapshot,
 | 
										 Snapshot snapshot, Snapshot crosscheck_snapshot,
 | 
				
			||||||
					 bool read_only, bool fire_triggers, long tcount)
 | 
										 bool read_only, bool fire_triggers, long tcount)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -811,7 +811,7 @@ SPI_execute_snapshot(SPIPlanPtr plan,
 | 
				
			|||||||
int
 | 
					int
 | 
				
			||||||
SPI_execute_with_args(const char *src,
 | 
					SPI_execute_with_args(const char *src,
 | 
				
			||||||
					  int nargs, Oid *argtypes,
 | 
										  int nargs, Oid *argtypes,
 | 
				
			||||||
					  Datum *Values, const char *Nulls,
 | 
										  const Datum *Values, const char *Nulls,
 | 
				
			||||||
					  bool read_only, long tcount)
 | 
										  bool read_only, long tcount)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			res;
 | 
						int			res;
 | 
				
			||||||
@@ -1443,7 +1443,7 @@ SPI_freetuptable(SPITupleTable *tuptable)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
Portal
 | 
					Portal
 | 
				
			||||||
SPI_cursor_open(const char *name, SPIPlanPtr plan,
 | 
					SPI_cursor_open(const char *name, SPIPlanPtr plan,
 | 
				
			||||||
				Datum *Values, const char *Nulls,
 | 
									const Datum *Values, const char *Nulls,
 | 
				
			||||||
				bool read_only)
 | 
									bool read_only)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Portal		portal;
 | 
						Portal		portal;
 | 
				
			||||||
@@ -2847,7 +2847,7 @@ fail:
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static ParamListInfo
 | 
					static ParamListInfo
 | 
				
			||||||
_SPI_convert_params(int nargs, Oid *argtypes,
 | 
					_SPI_convert_params(int nargs, Oid *argtypes,
 | 
				
			||||||
					Datum *Values, const char *Nulls)
 | 
										const Datum *Values, const char *Nulls)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ParamListInfo paramLI;
 | 
						ParamListInfo paramLI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3555,8 +3555,8 @@ partition_rbound_cmp(int partnatts, FmgrInfo *partsupfunc,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
int32
 | 
					int32
 | 
				
			||||||
partition_rbound_datum_cmp(FmgrInfo *partsupfunc, Oid *partcollation,
 | 
					partition_rbound_datum_cmp(FmgrInfo *partsupfunc, Oid *partcollation,
 | 
				
			||||||
						   Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
 | 
											   const Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
 | 
				
			||||||
						   Datum *tuple_datums, int n_tuple_datums)
 | 
											   const Datum *tuple_datums, int n_tuple_datums)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i;
 | 
						int			i;
 | 
				
			||||||
	int32		cmpval = -1;
 | 
						int32		cmpval = -1;
 | 
				
			||||||
@@ -3695,7 +3695,7 @@ partition_range_bsearch(int partnatts, FmgrInfo *partsupfunc,
 | 
				
			|||||||
int
 | 
					int
 | 
				
			||||||
partition_range_datum_bsearch(FmgrInfo *partsupfunc, Oid *partcollation,
 | 
					partition_range_datum_bsearch(FmgrInfo *partsupfunc, Oid *partcollation,
 | 
				
			||||||
							  PartitionBoundInfo boundinfo,
 | 
												  PartitionBoundInfo boundinfo,
 | 
				
			||||||
							  int nvalues, Datum *values, bool *is_equal)
 | 
												  int nvalues, const Datum *values, bool *is_equal)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			lo,
 | 
						int			lo,
 | 
				
			||||||
				hi,
 | 
									hi,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -179,13 +179,13 @@ static List *get_steps_using_prefix_recurse(GeneratePruningStepsContext *context
 | 
				
			|||||||
											List *step_exprs,
 | 
																List *step_exprs,
 | 
				
			||||||
											List *step_cmpfns);
 | 
																List *step_cmpfns);
 | 
				
			||||||
static PruneStepResult *get_matching_hash_bounds(PartitionPruneContext *context,
 | 
					static PruneStepResult *get_matching_hash_bounds(PartitionPruneContext *context,
 | 
				
			||||||
												 StrategyNumber opstrategy, Datum *values, int nvalues,
 | 
																	 StrategyNumber opstrategy, const Datum *values, int nvalues,
 | 
				
			||||||
												 FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
																	 FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
				
			||||||
static PruneStepResult *get_matching_list_bounds(PartitionPruneContext *context,
 | 
					static PruneStepResult *get_matching_list_bounds(PartitionPruneContext *context,
 | 
				
			||||||
												 StrategyNumber opstrategy, Datum value, int nvalues,
 | 
																	 StrategyNumber opstrategy, Datum value, int nvalues,
 | 
				
			||||||
												 FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
																	 FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
				
			||||||
static PruneStepResult *get_matching_range_bounds(PartitionPruneContext *context,
 | 
					static PruneStepResult *get_matching_range_bounds(PartitionPruneContext *context,
 | 
				
			||||||
												  StrategyNumber opstrategy, Datum *values, int nvalues,
 | 
																	  StrategyNumber opstrategy, const Datum *values, int nvalues,
 | 
				
			||||||
												  FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
																	  FmgrInfo *partsupfunc, Bitmapset *nullkeys);
 | 
				
			||||||
static Bitmapset *pull_exec_paramids(Expr *expr);
 | 
					static Bitmapset *pull_exec_paramids(Expr *expr);
 | 
				
			||||||
static bool pull_exec_paramids_walker(Node *node, Bitmapset **context);
 | 
					static bool pull_exec_paramids_walker(Node *node, Bitmapset **context);
 | 
				
			||||||
@@ -2690,7 +2690,7 @@ get_steps_using_prefix_recurse(GeneratePruningStepsContext *context,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static PruneStepResult *
 | 
					static PruneStepResult *
 | 
				
			||||||
get_matching_hash_bounds(PartitionPruneContext *context,
 | 
					get_matching_hash_bounds(PartitionPruneContext *context,
 | 
				
			||||||
						 StrategyNumber opstrategy, Datum *values, int nvalues,
 | 
											 StrategyNumber opstrategy, const Datum *values, int nvalues,
 | 
				
			||||||
						 FmgrInfo *partsupfunc, Bitmapset *nullkeys)
 | 
											 FmgrInfo *partsupfunc, Bitmapset *nullkeys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	PruneStepResult *result = (PruneStepResult *) palloc0(sizeof(PruneStepResult));
 | 
						PruneStepResult *result = (PruneStepResult *) palloc0(sizeof(PruneStepResult));
 | 
				
			||||||
@@ -2978,7 +2978,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static PruneStepResult *
 | 
					static PruneStepResult *
 | 
				
			||||||
get_matching_range_bounds(PartitionPruneContext *context,
 | 
					get_matching_range_bounds(PartitionPruneContext *context,
 | 
				
			||||||
						  StrategyNumber opstrategy, Datum *values, int nvalues,
 | 
											  StrategyNumber opstrategy, const Datum *values, int nvalues,
 | 
				
			||||||
						  FmgrInfo *partsupfunc, Bitmapset *nullkeys)
 | 
											  FmgrInfo *partsupfunc, Bitmapset *nullkeys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	PruneStepResult *result = (PruneStepResult *) palloc0(sizeof(PruneStepResult));
 | 
						PruneStepResult *result = (PruneStepResult *) palloc0(sizeof(PruneStepResult));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,7 @@ static void set_stats_slot(Datum *values, bool *nulls, bool *replaces,
 | 
				
			|||||||
						   Datum stanumbers, bool stanumbers_isnull,
 | 
											   Datum stanumbers, bool stanumbers_isnull,
 | 
				
			||||||
						   Datum stavalues, bool stavalues_isnull);
 | 
											   Datum stavalues, bool stavalues_isnull);
 | 
				
			||||||
static void upsert_pg_statistic(Relation starel, HeapTuple oldtup,
 | 
					static void upsert_pg_statistic(Relation starel, HeapTuple oldtup,
 | 
				
			||||||
								Datum *values, bool *nulls, bool *replaces);
 | 
													const Datum *values, const bool *nulls, const bool *replaces);
 | 
				
			||||||
static bool delete_pg_statistic(Oid reloid, AttrNumber attnum, bool stainherit);
 | 
					static bool delete_pg_statistic(Oid reloid, AttrNumber attnum, bool stainherit);
 | 
				
			||||||
static void init_empty_stats_tuple(Oid reloid, int16 attnum, bool inherited,
 | 
					static void init_empty_stats_tuple(Oid reloid, int16 attnum, bool inherited,
 | 
				
			||||||
								   Datum *values, bool *nulls, bool *replaces);
 | 
													   Datum *values, bool *nulls, bool *replaces);
 | 
				
			||||||
@@ -819,7 +819,7 @@ set_stats_slot(Datum *values, bool *nulls, bool *replaces,
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
upsert_pg_statistic(Relation starel, HeapTuple oldtup,
 | 
					upsert_pg_statistic(Relation starel, HeapTuple oldtup,
 | 
				
			||||||
					Datum *values, bool *nulls, bool *replaces)
 | 
										const Datum *values, const bool *nulls, const bool *replaces)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	HeapTuple	newtup;
 | 
						HeapTuple	newtup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,8 +47,8 @@ typedef struct
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static Selectivity tsquerysel(VariableStatData *vardata, Datum constval);
 | 
					static Selectivity tsquerysel(VariableStatData *vardata, Datum constval);
 | 
				
			||||||
static Selectivity mcelem_tsquery_selec(TSQuery query,
 | 
					static Selectivity mcelem_tsquery_selec(TSQuery query,
 | 
				
			||||||
										Datum *mcelem, int nmcelem,
 | 
															const Datum *mcelem, int nmcelem,
 | 
				
			||||||
										float4 *numbers, int nnumbers);
 | 
															const float4 *numbers, int nnumbers);
 | 
				
			||||||
static Selectivity tsquery_opr_selec(QueryItem *item, char *operand,
 | 
					static Selectivity tsquery_opr_selec(QueryItem *item, char *operand,
 | 
				
			||||||
									 TextFreq *lookup, int length, float4 minfreq);
 | 
														 TextFreq *lookup, int length, float4 minfreq);
 | 
				
			||||||
static int	compare_lexeme_textfreq(const void *e1, const void *e2);
 | 
					static int	compare_lexeme_textfreq(const void *e1, const void *e2);
 | 
				
			||||||
@@ -204,8 +204,8 @@ tsquerysel(VariableStatData *vardata, Datum constval)
 | 
				
			|||||||
 * Extract data from the pg_statistic arrays into useful format.
 | 
					 * Extract data from the pg_statistic arrays into useful format.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
mcelem_tsquery_selec(TSQuery query, Datum *mcelem, int nmcelem,
 | 
					mcelem_tsquery_selec(TSQuery query, const Datum *mcelem, int nmcelem,
 | 
				
			||||||
					 float4 *numbers, int nnumbers)
 | 
										 const float4 *numbers, int nnumbers)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	float4		minfreq;
 | 
						float4		minfreq;
 | 
				
			||||||
	TextFreq   *lookup;
 | 
						TextFreq   *lookup;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,25 +39,25 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static Selectivity calc_arraycontsel(VariableStatData *vardata, Datum constval,
 | 
					static Selectivity calc_arraycontsel(VariableStatData *vardata, Datum constval,
 | 
				
			||||||
									 Oid elemtype, Oid operator);
 | 
														 Oid elemtype, Oid operator);
 | 
				
			||||||
static Selectivity mcelem_array_selec(ArrayType *array,
 | 
					static Selectivity mcelem_array_selec(const ArrayType *array,
 | 
				
			||||||
									  TypeCacheEntry *typentry,
 | 
														  TypeCacheEntry *typentry,
 | 
				
			||||||
									  Datum *mcelem, int nmcelem,
 | 
														  const Datum *mcelem, int nmcelem,
 | 
				
			||||||
									  float4 *numbers, int nnumbers,
 | 
														  const float4 *numbers, int nnumbers,
 | 
				
			||||||
									  float4 *hist, int nhist,
 | 
														  const float4 *hist, int nhist,
 | 
				
			||||||
									  Oid operator);
 | 
														  Oid operator);
 | 
				
			||||||
static Selectivity mcelem_array_contain_overlap_selec(Datum *mcelem, int nmcelem,
 | 
					static Selectivity mcelem_array_contain_overlap_selec(const Datum *mcelem, int nmcelem,
 | 
				
			||||||
													  float4 *numbers, int nnumbers,
 | 
																		  const float4 *numbers, int nnumbers,
 | 
				
			||||||
													  Datum *array_data, int nitems,
 | 
																		  const Datum *array_data, int nitems,
 | 
				
			||||||
													  Oid operator, TypeCacheEntry *typentry);
 | 
																		  Oid operator, TypeCacheEntry *typentry);
 | 
				
			||||||
static Selectivity mcelem_array_contained_selec(Datum *mcelem, int nmcelem,
 | 
					static Selectivity mcelem_array_contained_selec(const Datum *mcelem, int nmcelem,
 | 
				
			||||||
												float4 *numbers, int nnumbers,
 | 
																	const float4 *numbers, int nnumbers,
 | 
				
			||||||
												Datum *array_data, int nitems,
 | 
																	const Datum *array_data, int nitems,
 | 
				
			||||||
												float4 *hist, int nhist,
 | 
																	const float4 *hist, int nhist,
 | 
				
			||||||
												Oid operator, TypeCacheEntry *typentry);
 | 
																	Oid operator, TypeCacheEntry *typentry);
 | 
				
			||||||
static float *calc_hist(const float4 *hist, int nhist, int n);
 | 
					static float *calc_hist(const float4 *hist, int nhist, int n);
 | 
				
			||||||
static float *calc_distr(const float *p, int n, int m, float rest);
 | 
					static float *calc_distr(const float *p, int n, int m, float rest);
 | 
				
			||||||
static int	floor_log2(uint32 n);
 | 
					static int	floor_log2(uint32 n);
 | 
				
			||||||
static bool find_next_mcelem(Datum *mcelem, int nmcelem, Datum value,
 | 
					static bool find_next_mcelem(const Datum *mcelem, int nmcelem, Datum value,
 | 
				
			||||||
							 int *index, TypeCacheEntry *typentry);
 | 
												 int *index, TypeCacheEntry *typentry);
 | 
				
			||||||
static int	element_compare(const void *key1, const void *key2, void *arg);
 | 
					static int	element_compare(const void *key1, const void *key2, void *arg);
 | 
				
			||||||
static int	float_compare_desc(const void *key1, const void *key2);
 | 
					static int	float_compare_desc(const void *key1, const void *key2);
 | 
				
			||||||
@@ -425,10 +425,10 @@ calc_arraycontsel(VariableStatData *vardata, Datum constval,
 | 
				
			|||||||
 * mcelem_array_contained_selec depending on the operator.
 | 
					 * mcelem_array_contained_selec depending on the operator.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
mcelem_array_selec(ArrayType *array, TypeCacheEntry *typentry,
 | 
					mcelem_array_selec(const ArrayType *array, TypeCacheEntry *typentry,
 | 
				
			||||||
				   Datum *mcelem, int nmcelem,
 | 
									   const Datum *mcelem, int nmcelem,
 | 
				
			||||||
				   float4 *numbers, int nnumbers,
 | 
									   const float4 *numbers, int nnumbers,
 | 
				
			||||||
				   float4 *hist, int nhist,
 | 
									   const float4 *hist, int nhist,
 | 
				
			||||||
				   Oid operator)
 | 
									   Oid operator)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Selectivity selec;
 | 
						Selectivity selec;
 | 
				
			||||||
@@ -518,9 +518,9 @@ mcelem_array_selec(ArrayType *array, TypeCacheEntry *typentry,
 | 
				
			|||||||
 * fraction of nonempty arrays in the column.
 | 
					 * fraction of nonempty arrays in the column.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
mcelem_array_contain_overlap_selec(Datum *mcelem, int nmcelem,
 | 
					mcelem_array_contain_overlap_selec(const Datum *mcelem, int nmcelem,
 | 
				
			||||||
								   float4 *numbers, int nnumbers,
 | 
													   const float4 *numbers, int nnumbers,
 | 
				
			||||||
								   Datum *array_data, int nitems,
 | 
													   const Datum *array_data, int nitems,
 | 
				
			||||||
								   Oid operator, TypeCacheEntry *typentry)
 | 
													   Oid operator, TypeCacheEntry *typentry)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Selectivity selec,
 | 
						Selectivity selec,
 | 
				
			||||||
@@ -699,10 +699,10 @@ mcelem_array_contain_overlap_selec(Datum *mcelem, int nmcelem,
 | 
				
			|||||||
 * ... * fn^on * (1 - fn)^(1 - on), o1, o2, ..., on) | o1 + o2 + .. on = m
 | 
					 * ... * fn^on * (1 - fn)^(1 - on), o1, o2, ..., on) | o1 + o2 + .. on = m
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
mcelem_array_contained_selec(Datum *mcelem, int nmcelem,
 | 
					mcelem_array_contained_selec(const Datum *mcelem, int nmcelem,
 | 
				
			||||||
							 float4 *numbers, int nnumbers,
 | 
												 const float4 *numbers, int nnumbers,
 | 
				
			||||||
							 Datum *array_data, int nitems,
 | 
												 const Datum *array_data, int nitems,
 | 
				
			||||||
							 float4 *hist, int nhist,
 | 
												 const float4 *hist, int nhist,
 | 
				
			||||||
							 Oid operator, TypeCacheEntry *typentry)
 | 
												 Oid operator, TypeCacheEntry *typentry)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			mcelem_index,
 | 
						int			mcelem_index,
 | 
				
			||||||
@@ -1136,7 +1136,7 @@ floor_log2(uint32 n)
 | 
				
			|||||||
 * exact match.)
 | 
					 * exact match.)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
find_next_mcelem(Datum *mcelem, int nmcelem, Datum value, int *index,
 | 
					find_next_mcelem(const Datum *mcelem, int nmcelem, Datum value, int *index,
 | 
				
			||||||
				 TypeCacheEntry *typentry)
 | 
									 TypeCacheEntry *typentry)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			l = *index,
 | 
						int			l = *index,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -960,8 +960,8 @@ ending_error:
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
CopyArrayEls(ArrayType *array,
 | 
					CopyArrayEls(ArrayType *array,
 | 
				
			||||||
			 Datum *values,
 | 
								 const Datum *values,
 | 
				
			||||||
			 bool *nulls,
 | 
								 const bool *nulls,
 | 
				
			||||||
			 int nitems,
 | 
								 int nitems,
 | 
				
			||||||
			 int typlen,
 | 
								 int typlen,
 | 
				
			||||||
			 bool typbyval,
 | 
								 bool typbyval,
 | 
				
			||||||
@@ -3629,7 +3629,7 @@ construct_empty_expanded_array(Oid element_type,
 | 
				
			|||||||
 * to hard-wire values if the element type is hard-wired.
 | 
					 * to hard-wire values if the element type is hard-wired.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
deconstruct_array(ArrayType *array,
 | 
					deconstruct_array(const ArrayType *array,
 | 
				
			||||||
				  Oid elmtype,
 | 
									  Oid elmtype,
 | 
				
			||||||
				  int elmlen, bool elmbyval, char elmalign,
 | 
									  int elmlen, bool elmbyval, char elmalign,
 | 
				
			||||||
				  Datum **elemsp, bool **nullsp, int *nelemsp)
 | 
									  Datum **elemsp, bool **nullsp, int *nelemsp)
 | 
				
			||||||
@@ -3695,7 +3695,7 @@ deconstruct_array(ArrayType *array,
 | 
				
			|||||||
 * useful when manipulating arrays from/for system catalogs.
 | 
					 * useful when manipulating arrays from/for system catalogs.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
deconstruct_array_builtin(ArrayType *array,
 | 
					deconstruct_array_builtin(const ArrayType *array,
 | 
				
			||||||
						  Oid elmtype,
 | 
											  Oid elmtype,
 | 
				
			||||||
						  Datum **elemsp, bool **nullsp, int *nelemsp)
 | 
											  Datum **elemsp, bool **nullsp, int *nelemsp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -3765,7 +3765,7 @@ deconstruct_array_builtin(ArrayType *array,
 | 
				
			|||||||
 * if the array *might* contain a null.
 | 
					 * if the array *might* contain a null.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
array_contains_nulls(ArrayType *array)
 | 
					array_contains_nulls(const ArrayType *array)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			nelems;
 | 
						int			nelems;
 | 
				
			||||||
	bits8	   *bitmap;
 | 
						bits8	   *bitmap;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,7 +89,7 @@ typedef struct JsonAggState
 | 
				
			|||||||
static void composite_to_json(Datum composite, StringInfo result,
 | 
					static void composite_to_json(Datum composite, StringInfo result,
 | 
				
			||||||
							  bool use_line_feeds);
 | 
												  bool use_line_feeds);
 | 
				
			||||||
static void array_dim_to_json(StringInfo result, int dim, int ndims, int *dims,
 | 
					static void array_dim_to_json(StringInfo result, int dim, int ndims, int *dims,
 | 
				
			||||||
							  Datum *vals, bool *nulls, int *valcount,
 | 
												  const Datum *vals, const bool *nulls, int *valcount,
 | 
				
			||||||
							  JsonTypeCategory tcategory, Oid outfuncoid,
 | 
												  JsonTypeCategory tcategory, Oid outfuncoid,
 | 
				
			||||||
							  bool use_line_feeds);
 | 
												  bool use_line_feeds);
 | 
				
			||||||
static void array_to_json_internal(Datum array, StringInfo result,
 | 
					static void array_to_json_internal(Datum array, StringInfo result,
 | 
				
			||||||
@@ -429,8 +429,8 @@ JsonEncodeDateTime(char *buf, Datum value, Oid typid, const int *tzp)
 | 
				
			|||||||
 * ourselves recursively to process the next dimension.
 | 
					 * ourselves recursively to process the next dimension.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
array_dim_to_json(StringInfo result, int dim, int ndims, int *dims, Datum *vals,
 | 
					array_dim_to_json(StringInfo result, int dim, int ndims, int *dims, const Datum *vals,
 | 
				
			||||||
				  bool *nulls, int *valcount, JsonTypeCategory tcategory,
 | 
									  const bool *nulls, int *valcount, JsonTypeCategory tcategory,
 | 
				
			||||||
				  Oid outfuncoid, bool use_line_feeds)
 | 
									  Oid outfuncoid, bool use_line_feeds)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i;
 | 
						int			i;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -477,16 +477,16 @@ static Datum populate_domain(DomainIOData *io, Oid typid, const char *colname,
 | 
				
			|||||||
/* functions supporting jsonb_delete, jsonb_set and jsonb_concat */
 | 
					/* functions supporting jsonb_delete, jsonb_set and jsonb_concat */
 | 
				
			||||||
static JsonbValue *IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
 | 
					static JsonbValue *IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
 | 
				
			||||||
								  JsonbParseState **state);
 | 
													  JsonbParseState **state);
 | 
				
			||||||
static JsonbValue *setPath(JsonbIterator **it, Datum *path_elems,
 | 
					static JsonbValue *setPath(JsonbIterator **it, const Datum *path_elems,
 | 
				
			||||||
						   bool *path_nulls, int path_len,
 | 
											   const bool *path_nulls, int path_len,
 | 
				
			||||||
						   JsonbParseState **st, int level, JsonbValue *newval,
 | 
											   JsonbParseState **st, int level, JsonbValue *newval,
 | 
				
			||||||
						   int op_type);
 | 
											   int op_type);
 | 
				
			||||||
static void setPathObject(JsonbIterator **it, Datum *path_elems,
 | 
					static void setPathObject(JsonbIterator **it, const Datum *path_elems,
 | 
				
			||||||
						  bool *path_nulls, int path_len, JsonbParseState **st,
 | 
											  const bool *path_nulls, int path_len, JsonbParseState **st,
 | 
				
			||||||
						  int level,
 | 
											  int level,
 | 
				
			||||||
						  JsonbValue *newval, uint32 npairs, int op_type);
 | 
											  JsonbValue *newval, uint32 npairs, int op_type);
 | 
				
			||||||
static void setPathArray(JsonbIterator **it, Datum *path_elems,
 | 
					static void setPathArray(JsonbIterator **it, const Datum *path_elems,
 | 
				
			||||||
						 bool *path_nulls, int path_len, JsonbParseState **st,
 | 
											 const bool *path_nulls, int path_len, JsonbParseState **st,
 | 
				
			||||||
						 int level,
 | 
											 int level,
 | 
				
			||||||
						 JsonbValue *newval, uint32 nelems, int op_type);
 | 
											 JsonbValue *newval, uint32 nelems, int op_type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1528,7 +1528,7 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Datum
 | 
					Datum
 | 
				
			||||||
jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text)
 | 
					jsonb_get_element(Jsonb *jb, const Datum *path, int npath, bool *isnull, bool as_text)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	JsonbContainer *container = &jb->root;
 | 
						JsonbContainer *container = &jb->root;
 | 
				
			||||||
	JsonbValue *jbvp = NULL;
 | 
						JsonbValue *jbvp = NULL;
 | 
				
			||||||
@@ -1676,7 +1676,7 @@ jsonb_get_element(Jsonb *jb, Datum *path, int npath, bool *isnull, bool as_text)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Datum
 | 
					Datum
 | 
				
			||||||
jsonb_set_element(Jsonb *jb, Datum *path, int path_len,
 | 
					jsonb_set_element(Jsonb *jb, const Datum *path, int path_len,
 | 
				
			||||||
				  JsonbValue *newval)
 | 
									  JsonbValue *newval)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	JsonbValue *res;
 | 
						JsonbValue *res;
 | 
				
			||||||
@@ -1718,8 +1718,8 @@ push_null_elements(JsonbParseState **ps, int num)
 | 
				
			|||||||
 * Caller is responsible to make sure such path does not exist yet.
 | 
					 * Caller is responsible to make sure such path does not exist yet.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
push_path(JsonbParseState **st, int level, Datum *path_elems,
 | 
					push_path(JsonbParseState **st, int level, const Datum *path_elems,
 | 
				
			||||||
		  bool *path_nulls, int path_len, JsonbValue *newval)
 | 
							  const bool *path_nulls, int path_len, JsonbValue *newval)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * tpath contains expected type of an empty jsonb created at each level
 | 
						 * tpath contains expected type of an empty jsonb created at each level
 | 
				
			||||||
@@ -5201,8 +5201,8 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
 | 
				
			|||||||
 * whatever bits in op_type are set, or nothing is done.
 | 
					 * whatever bits in op_type are set, or nothing is done.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static JsonbValue *
 | 
					static JsonbValue *
 | 
				
			||||||
setPath(JsonbIterator **it, Datum *path_elems,
 | 
					setPath(JsonbIterator **it, const Datum *path_elems,
 | 
				
			||||||
		bool *path_nulls, int path_len,
 | 
							const bool *path_nulls, int path_len,
 | 
				
			||||||
		JsonbParseState **st, int level, JsonbValue *newval, int op_type)
 | 
							JsonbParseState **st, int level, JsonbValue *newval, int op_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	JsonbValue	v;
 | 
						JsonbValue	v;
 | 
				
			||||||
@@ -5283,7 +5283,7 @@ setPath(JsonbIterator **it, Datum *path_elems,
 | 
				
			|||||||
 * Object walker for setPath
 | 
					 * Object walker for setPath
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
 | 
					setPathObject(JsonbIterator **it, const Datum *path_elems, const bool *path_nulls,
 | 
				
			||||||
			  int path_len, JsonbParseState **st, int level,
 | 
								  int path_len, JsonbParseState **st, int level,
 | 
				
			||||||
			  JsonbValue *newval, uint32 npairs, int op_type)
 | 
								  JsonbValue *newval, uint32 npairs, int op_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -5422,7 +5422,7 @@ setPathObject(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
 | 
				
			|||||||
 * Array walker for setPath
 | 
					 * Array walker for setPath
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
setPathArray(JsonbIterator **it, Datum *path_elems, bool *path_nulls,
 | 
					setPathArray(JsonbIterator **it, const Datum *path_elems, const bool *path_nulls,
 | 
				
			||||||
			 int path_len, JsonbParseState **st, int level,
 | 
								 int path_len, JsonbParseState **st, int level,
 | 
				
			||||||
			 JsonbValue *newval, uint32 nelems, int op_type)
 | 
								 JsonbValue *newval, uint32 nelems, int op_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,10 +49,10 @@ static float8 get_position(TypeCacheEntry *typcache, const RangeBound *value,
 | 
				
			|||||||
static float8 get_len_position(double value, double hist1, double hist2);
 | 
					static float8 get_len_position(double value, double hist1, double hist2);
 | 
				
			||||||
static float8 get_distance(TypeCacheEntry *typcache, const RangeBound *bound1,
 | 
					static float8 get_distance(TypeCacheEntry *typcache, const RangeBound *bound1,
 | 
				
			||||||
						   const RangeBound *bound2);
 | 
											   const RangeBound *bound2);
 | 
				
			||||||
static int	length_hist_bsearch(Datum *length_hist_values,
 | 
					static int	length_hist_bsearch(const Datum *length_hist_values,
 | 
				
			||||||
								int length_hist_nvalues, double value,
 | 
													int length_hist_nvalues, double value,
 | 
				
			||||||
								bool equal);
 | 
													bool equal);
 | 
				
			||||||
static double calc_length_hist_frac(Datum *length_hist_values,
 | 
					static double calc_length_hist_frac(const Datum *length_hist_values,
 | 
				
			||||||
									int length_hist_nvalues, double length1,
 | 
														int length_hist_nvalues, double length1,
 | 
				
			||||||
									double length2, bool equal);
 | 
														double length2, bool equal);
 | 
				
			||||||
static double calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
					static double calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
				
			||||||
@@ -60,14 +60,14 @@ static double calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
				
			|||||||
											  RangeBound *upper,
 | 
																  RangeBound *upper,
 | 
				
			||||||
											  const RangeBound *hist_lower,
 | 
																  const RangeBound *hist_lower,
 | 
				
			||||||
											  int hist_nvalues,
 | 
																  int hist_nvalues,
 | 
				
			||||||
											  Datum *length_hist_values,
 | 
																  const Datum *length_hist_values,
 | 
				
			||||||
											  int length_hist_nvalues);
 | 
																  int length_hist_nvalues);
 | 
				
			||||||
static double calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
					static double calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
				
			||||||
											 const RangeBound *lower,
 | 
																 const RangeBound *lower,
 | 
				
			||||||
											 const RangeBound *upper,
 | 
																 const RangeBound *upper,
 | 
				
			||||||
											 const RangeBound *hist_lower,
 | 
																 const RangeBound *hist_lower,
 | 
				
			||||||
											 int hist_nvalues,
 | 
																 int hist_nvalues,
 | 
				
			||||||
											 Datum *length_hist_values,
 | 
																 const Datum *length_hist_values,
 | 
				
			||||||
											 int length_hist_nvalues);
 | 
																 int length_hist_nvalues);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -765,7 +765,7 @@ rbound_bsearch(TypeCacheEntry *typcache, const RangeBound *value, const RangeBou
 | 
				
			|||||||
 * given length, returns -1.
 | 
					 * given length, returns -1.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
length_hist_bsearch(Datum *length_hist_values, int length_hist_nvalues,
 | 
					length_hist_bsearch(const Datum *length_hist_values, int length_hist_nvalues,
 | 
				
			||||||
					double value, bool equal)
 | 
										double value, bool equal)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			lower = -1,
 | 
						int			lower = -1,
 | 
				
			||||||
@@ -963,7 +963,7 @@ get_distance(TypeCacheEntry *typcache, const RangeBound *bound1, const RangeBoun
 | 
				
			|||||||
 * 'equal' is true).
 | 
					 * 'equal' is true).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static double
 | 
					static double
 | 
				
			||||||
calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
 | 
					calc_length_hist_frac(const Datum *length_hist_values, int length_hist_nvalues,
 | 
				
			||||||
					  double length1, double length2, bool equal)
 | 
										  double length1, double length2, bool equal)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	double		frac;
 | 
						double		frac;
 | 
				
			||||||
@@ -1131,7 +1131,7 @@ static double
 | 
				
			|||||||
calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
					calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
				
			||||||
								const RangeBound *lower, RangeBound *upper,
 | 
													const RangeBound *lower, RangeBound *upper,
 | 
				
			||||||
								const RangeBound *hist_lower, int hist_nvalues,
 | 
													const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
								Datum *length_hist_values, int length_hist_nvalues)
 | 
													const Datum *length_hist_values, int length_hist_nvalues)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i,
 | 
						int			i,
 | 
				
			||||||
				upper_index;
 | 
									upper_index;
 | 
				
			||||||
@@ -1252,7 +1252,7 @@ static double
 | 
				
			|||||||
calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
					calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
				
			||||||
							   const RangeBound *lower, const RangeBound *upper,
 | 
												   const RangeBound *lower, const RangeBound *upper,
 | 
				
			||||||
							   const RangeBound *hist_lower, int hist_nvalues,
 | 
												   const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
							   Datum *length_hist_values, int length_hist_nvalues)
 | 
												   const Datum *length_hist_values, int length_hist_nvalues)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i,
 | 
						int			i,
 | 
				
			||||||
				lower_index;
 | 
									lower_index;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,17 +48,17 @@ static Selectivity networkjoinsel_inner(Oid operator,
 | 
				
			|||||||
static Selectivity networkjoinsel_semi(Oid operator,
 | 
					static Selectivity networkjoinsel_semi(Oid operator,
 | 
				
			||||||
									   VariableStatData *vardata1, VariableStatData *vardata2);
 | 
														   VariableStatData *vardata1, VariableStatData *vardata2);
 | 
				
			||||||
static Selectivity mcv_population(float4 *mcv_numbers, int mcv_nvalues);
 | 
					static Selectivity mcv_population(float4 *mcv_numbers, int mcv_nvalues);
 | 
				
			||||||
static Selectivity inet_hist_value_sel(Datum *values, int nvalues,
 | 
					static Selectivity inet_hist_value_sel(const Datum *values, int nvalues,
 | 
				
			||||||
									   Datum constvalue, int opr_codenum);
 | 
														   Datum constvalue, int opr_codenum);
 | 
				
			||||||
static Selectivity inet_mcv_join_sel(Datum *mcv1_values,
 | 
					static Selectivity inet_mcv_join_sel(Datum *mcv1_values,
 | 
				
			||||||
									 float4 *mcv1_numbers, int mcv1_nvalues, Datum *mcv2_values,
 | 
														 float4 *mcv1_numbers, int mcv1_nvalues, Datum *mcv2_values,
 | 
				
			||||||
									 float4 *mcv2_numbers, int mcv2_nvalues, Oid operator);
 | 
														 float4 *mcv2_numbers, int mcv2_nvalues, Oid operator);
 | 
				
			||||||
static Selectivity inet_mcv_hist_sel(Datum *mcv_values, float4 *mcv_numbers,
 | 
					static Selectivity inet_mcv_hist_sel(const Datum *mcv_values, float4 *mcv_numbers,
 | 
				
			||||||
									 int mcv_nvalues, Datum *hist_values, int hist_nvalues,
 | 
														 int mcv_nvalues, const Datum *hist_values, int hist_nvalues,
 | 
				
			||||||
									 int opr_codenum);
 | 
														 int opr_codenum);
 | 
				
			||||||
static Selectivity inet_hist_inclusion_join_sel(Datum *hist1_values,
 | 
					static Selectivity inet_hist_inclusion_join_sel(const Datum *hist1_values,
 | 
				
			||||||
												int hist1_nvalues,
 | 
																	int hist1_nvalues,
 | 
				
			||||||
												Datum *hist2_values, int hist2_nvalues,
 | 
																	const Datum *hist2_values, int hist2_nvalues,
 | 
				
			||||||
												int opr_codenum);
 | 
																	int opr_codenum);
 | 
				
			||||||
static Selectivity inet_semi_join_sel(Datum lhs_value,
 | 
					static Selectivity inet_semi_join_sel(Datum lhs_value,
 | 
				
			||||||
									  bool mcv_exists, Datum *mcv_values, int mcv_nvalues,
 | 
														  bool mcv_exists, Datum *mcv_values, int mcv_nvalues,
 | 
				
			||||||
@@ -601,7 +601,7 @@ mcv_population(float4 *mcv_numbers, int mcv_nvalues)
 | 
				
			|||||||
 * better option than not considering these buckets at all.
 | 
					 * better option than not considering these buckets at all.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
inet_hist_value_sel(Datum *values, int nvalues, Datum constvalue,
 | 
					inet_hist_value_sel(const Datum *values, int nvalues, Datum constvalue,
 | 
				
			||||||
					int opr_codenum)
 | 
										int opr_codenum)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Selectivity match = 0.0;
 | 
						Selectivity match = 0.0;
 | 
				
			||||||
@@ -702,8 +702,8 @@ inet_mcv_join_sel(Datum *mcv1_values, float4 *mcv1_numbers, int mcv1_nvalues,
 | 
				
			|||||||
 * the histogram.
 | 
					 * the histogram.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
inet_mcv_hist_sel(Datum *mcv_values, float4 *mcv_numbers, int mcv_nvalues,
 | 
					inet_mcv_hist_sel(const Datum *mcv_values, float4 *mcv_numbers, int mcv_nvalues,
 | 
				
			||||||
				  Datum *hist_values, int hist_nvalues,
 | 
									  const Datum *hist_values, int hist_nvalues,
 | 
				
			||||||
				  int opr_codenum)
 | 
									  int opr_codenum)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Selectivity selec = 0.0;
 | 
						Selectivity selec = 0.0;
 | 
				
			||||||
@@ -739,8 +739,8 @@ inet_mcv_hist_sel(Datum *mcv_values, float4 *mcv_numbers, int mcv_nvalues,
 | 
				
			|||||||
 * average?  That would at least avoid non-commutative estimation results.
 | 
					 * average?  That would at least avoid non-commutative estimation results.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static Selectivity
 | 
					static Selectivity
 | 
				
			||||||
inet_hist_inclusion_join_sel(Datum *hist1_values, int hist1_nvalues,
 | 
					inet_hist_inclusion_join_sel(const Datum *hist1_values, int hist1_nvalues,
 | 
				
			||||||
							 Datum *hist2_values, int hist2_nvalues,
 | 
												 const Datum *hist2_values, int hist2_nvalues,
 | 
				
			||||||
							 int opr_codenum)
 | 
												 int opr_codenum)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	double		match = 0.0;
 | 
						double		match = 0.0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -660,8 +660,8 @@ pct_info_cmp(const void *pa, const void *pb)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static struct pct_info *
 | 
					static struct pct_info *
 | 
				
			||||||
setup_pct_info(int num_percentiles,
 | 
					setup_pct_info(int num_percentiles,
 | 
				
			||||||
			   Datum *percentiles_datum,
 | 
								   const Datum *percentiles_datum,
 | 
				
			||||||
			   bool *percentiles_null,
 | 
								   const bool *percentiles_null,
 | 
				
			||||||
			   int64 rowcount,
 | 
								   int64 rowcount,
 | 
				
			||||||
			   bool continuous)
 | 
								   bool continuous)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,18 +46,18 @@ static float8 get_position(TypeCacheEntry *typcache, const RangeBound *value,
 | 
				
			|||||||
static float8 get_len_position(double value, double hist1, double hist2);
 | 
					static float8 get_len_position(double value, double hist1, double hist2);
 | 
				
			||||||
static float8 get_distance(TypeCacheEntry *typcache, const RangeBound *bound1,
 | 
					static float8 get_distance(TypeCacheEntry *typcache, const RangeBound *bound1,
 | 
				
			||||||
						   const RangeBound *bound2);
 | 
											   const RangeBound *bound2);
 | 
				
			||||||
static int	length_hist_bsearch(Datum *length_hist_values,
 | 
					static int	length_hist_bsearch(const Datum *length_hist_values,
 | 
				
			||||||
								int length_hist_nvalues, double value, bool equal);
 | 
													int length_hist_nvalues, double value, bool equal);
 | 
				
			||||||
static double calc_length_hist_frac(Datum *length_hist_values,
 | 
					static double calc_length_hist_frac(const Datum *length_hist_values,
 | 
				
			||||||
									int length_hist_nvalues, double length1, double length2, bool equal);
 | 
														int length_hist_nvalues, double length1, double length2, bool equal);
 | 
				
			||||||
static double calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
					static double calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
				
			||||||
											  const RangeBound *lower, RangeBound *upper,
 | 
																  const RangeBound *lower, RangeBound *upper,
 | 
				
			||||||
											  const RangeBound *hist_lower, int hist_nvalues,
 | 
																  const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
											  Datum *length_hist_values, int length_hist_nvalues);
 | 
																  const Datum *length_hist_values, int length_hist_nvalues);
 | 
				
			||||||
static double calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
					static double calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
				
			||||||
											 const RangeBound *lower, const RangeBound *upper,
 | 
																 const RangeBound *lower, const RangeBound *upper,
 | 
				
			||||||
											 const RangeBound *hist_lower, int hist_nvalues,
 | 
																 const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
											 Datum *length_hist_values, int length_hist_nvalues);
 | 
																 const Datum *length_hist_values, int length_hist_nvalues);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Returns a default selectivity estimate for given operator, when we don't
 | 
					 * Returns a default selectivity estimate for given operator, when we don't
 | 
				
			||||||
@@ -654,7 +654,7 @@ rbound_bsearch(TypeCacheEntry *typcache, const RangeBound *value, const RangeBou
 | 
				
			|||||||
 * given length, returns -1.
 | 
					 * given length, returns -1.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
length_hist_bsearch(Datum *length_hist_values, int length_hist_nvalues,
 | 
					length_hist_bsearch(const Datum *length_hist_values, int length_hist_nvalues,
 | 
				
			||||||
					double value, bool equal)
 | 
										double value, bool equal)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			lower = -1,
 | 
						int			lower = -1,
 | 
				
			||||||
@@ -852,7 +852,7 @@ get_distance(TypeCacheEntry *typcache, const RangeBound *bound1, const RangeBoun
 | 
				
			|||||||
 * 'equal' is true).
 | 
					 * 'equal' is true).
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static double
 | 
					static double
 | 
				
			||||||
calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
 | 
					calc_length_hist_frac(const Datum *length_hist_values, int length_hist_nvalues,
 | 
				
			||||||
					  double length1, double length2, bool equal)
 | 
										  double length1, double length2, bool equal)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	double		frac;
 | 
						double		frac;
 | 
				
			||||||
@@ -1018,7 +1018,7 @@ static double
 | 
				
			|||||||
calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
					calc_hist_selectivity_contained(TypeCacheEntry *typcache,
 | 
				
			||||||
								const RangeBound *lower, RangeBound *upper,
 | 
													const RangeBound *lower, RangeBound *upper,
 | 
				
			||||||
								const RangeBound *hist_lower, int hist_nvalues,
 | 
													const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
								Datum *length_hist_values, int length_hist_nvalues)
 | 
													const Datum *length_hist_values, int length_hist_nvalues)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i,
 | 
						int			i,
 | 
				
			||||||
				upper_index;
 | 
									upper_index;
 | 
				
			||||||
@@ -1139,7 +1139,7 @@ static double
 | 
				
			|||||||
calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
					calc_hist_selectivity_contains(TypeCacheEntry *typcache,
 | 
				
			||||||
							   const RangeBound *lower, const RangeBound *upper,
 | 
												   const RangeBound *lower, const RangeBound *upper,
 | 
				
			||||||
							   const RangeBound *hist_lower, int hist_nvalues,
 | 
												   const RangeBound *hist_lower, int hist_nvalues,
 | 
				
			||||||
							   Datum *length_hist_values, int length_hist_nvalues)
 | 
												   const Datum *length_hist_values, int length_hist_nvalues)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i,
 | 
						int			i,
 | 
				
			||||||
				lower_index;
 | 
									lower_index;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -891,8 +891,8 @@ xmltotext_with_options(xmltype *data, XmlOptionType xmloption_arg, bool indent)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
xmltype *
 | 
					xmltype *
 | 
				
			||||||
xmlelement(XmlExpr *xexpr,
 | 
					xmlelement(XmlExpr *xexpr,
 | 
				
			||||||
		   Datum *named_argvalue, bool *named_argnull,
 | 
							   const Datum *named_argvalue, const bool *named_argnull,
 | 
				
			||||||
		   Datum *argvalue, bool *argnull)
 | 
							   const Datum *argvalue, const bool *argnull)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
#ifdef USE_LIBXML
 | 
					#ifdef USE_LIBXML
 | 
				
			||||||
	xmltype    *result;
 | 
						xmltype    *result;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								src/backend/utils/cache/catcache.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								src/backend/utils/cache/catcache.c
									
									
									
									
										vendored
									
									
								
							@@ -117,10 +117,10 @@ static CatCTup *CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void ReleaseCatCacheWithOwner(HeapTuple tuple, ResourceOwner resowner);
 | 
					static void ReleaseCatCacheWithOwner(HeapTuple tuple, ResourceOwner resowner);
 | 
				
			||||||
static void ReleaseCatCacheListWithOwner(CatCList *list, ResourceOwner resowner);
 | 
					static void ReleaseCatCacheListWithOwner(CatCList *list, ResourceOwner resowner);
 | 
				
			||||||
static void CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos,
 | 
					static void CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, const int *attnos,
 | 
				
			||||||
							 Datum *keys);
 | 
												 const Datum *keys);
 | 
				
			||||||
static void CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, int *attnos,
 | 
					static void CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, const int *attnos,
 | 
				
			||||||
							 Datum *srckeys, Datum *dstkeys);
 | 
												 const Datum *srckeys, Datum *dstkeys);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -2279,7 +2279,7 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, Datum *arguments,
 | 
				
			|||||||
 * Helper routine that frees keys stored in the keys array.
 | 
					 * Helper routine that frees keys stored in the keys array.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos, Datum *keys)
 | 
					CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, const int *attnos, const Datum *keys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i;
 | 
						int			i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2301,8 +2301,8 @@ CatCacheFreeKeys(TupleDesc tupdesc, int nkeys, int *attnos, Datum *keys)
 | 
				
			|||||||
 * context.
 | 
					 * context.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, int *attnos,
 | 
					CatCacheCopyKeys(TupleDesc tupdesc, int nkeys, const int *attnos,
 | 
				
			||||||
				 Datum *srckeys, Datum *dstkeys)
 | 
									 const Datum *srckeys, Datum *dstkeys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			i;
 | 
						int			i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -468,7 +468,7 @@ extern uint32 _hash_get_totalbuckets(uint32 splitpoint_phase);
 | 
				
			|||||||
extern void _hash_checkpage(Relation rel, Buffer buf, int flags);
 | 
					extern void _hash_checkpage(Relation rel, Buffer buf, int flags);
 | 
				
			||||||
extern uint32 _hash_get_indextuple_hashkey(IndexTuple itup);
 | 
					extern uint32 _hash_get_indextuple_hashkey(IndexTuple itup);
 | 
				
			||||||
extern bool _hash_convert_tuple(Relation index,
 | 
					extern bool _hash_convert_tuple(Relation index,
 | 
				
			||||||
								Datum *user_values, bool *user_isnull,
 | 
													const Datum *user_values, const bool *user_isnull,
 | 
				
			||||||
								Datum *index_values, bool *index_isnull);
 | 
													Datum *index_values, bool *index_isnull);
 | 
				
			||||||
extern OffsetNumber _hash_binsearch(Page page, uint32 hash_value);
 | 
					extern OffsetNumber _hash_binsearch(Page page, uint32 hash_value);
 | 
				
			||||||
extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
 | 
					extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,8 +133,8 @@ extern Datum toast_flatten_tuple_to_datum(HeapTupleHeader tup,
 | 
				
			|||||||
 * ----------
 | 
					 * ----------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
extern HeapTuple toast_build_flattened_tuple(TupleDesc tupleDesc,
 | 
					extern HeapTuple toast_build_flattened_tuple(TupleDesc tupleDesc,
 | 
				
			||||||
											 Datum *values,
 | 
																 const Datum *values,
 | 
				
			||||||
											 bool *isnull);
 | 
																 const bool *isnull);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ----------
 | 
					/* ----------
 | 
				
			||||||
 * heap_fetch_toast_slice
 | 
					 * heap_fetch_toast_slice
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -541,7 +541,7 @@ extern void spgPageIndexMultiDelete(SpGistState *state, Page page,
 | 
				
			|||||||
									int firststate, int reststate,
 | 
														int firststate, int reststate,
 | 
				
			||||||
									BlockNumber blkno, OffsetNumber offnum);
 | 
														BlockNumber blkno, OffsetNumber offnum);
 | 
				
			||||||
extern bool spgdoinsert(Relation index, SpGistState *state,
 | 
					extern bool spgdoinsert(Relation index, SpGistState *state,
 | 
				
			||||||
						const ItemPointerData *heapPtr, Datum *datums, bool *isnulls);
 | 
											const ItemPointerData *heapPtr, const Datum *datums, const bool *isnulls);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* spgproc.c */
 | 
					/* spgproc.c */
 | 
				
			||||||
extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
 | 
					extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -111,7 +111,7 @@ extern int	SPI_finish(void);
 | 
				
			|||||||
extern int	SPI_execute(const char *src, bool read_only, long tcount);
 | 
					extern int	SPI_execute(const char *src, bool read_only, long tcount);
 | 
				
			||||||
extern int	SPI_execute_extended(const char *src,
 | 
					extern int	SPI_execute_extended(const char *src,
 | 
				
			||||||
								 const SPIExecuteOptions *options);
 | 
													 const SPIExecuteOptions *options);
 | 
				
			||||||
extern int	SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls,
 | 
					extern int	SPI_execute_plan(SPIPlanPtr plan, const Datum *Values, const char *Nulls,
 | 
				
			||||||
							 bool read_only, long tcount);
 | 
												 bool read_only, long tcount);
 | 
				
			||||||
extern int	SPI_execute_plan_extended(SPIPlanPtr plan,
 | 
					extern int	SPI_execute_plan_extended(SPIPlanPtr plan,
 | 
				
			||||||
									  const SPIExecuteOptions *options);
 | 
														  const SPIExecuteOptions *options);
 | 
				
			||||||
@@ -122,13 +122,13 @@ extern int	SPI_exec(const char *src, long tcount);
 | 
				
			|||||||
extern int	SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls,
 | 
					extern int	SPI_execp(SPIPlanPtr plan, Datum *Values, const char *Nulls,
 | 
				
			||||||
					  long tcount);
 | 
										  long tcount);
 | 
				
			||||||
extern int	SPI_execute_snapshot(SPIPlanPtr plan,
 | 
					extern int	SPI_execute_snapshot(SPIPlanPtr plan,
 | 
				
			||||||
								 Datum *Values, const char *Nulls,
 | 
													 const Datum *Values, const char *Nulls,
 | 
				
			||||||
								 Snapshot snapshot,
 | 
													 Snapshot snapshot,
 | 
				
			||||||
								 Snapshot crosscheck_snapshot,
 | 
													 Snapshot crosscheck_snapshot,
 | 
				
			||||||
								 bool read_only, bool fire_triggers, long tcount);
 | 
													 bool read_only, bool fire_triggers, long tcount);
 | 
				
			||||||
extern int	SPI_execute_with_args(const char *src,
 | 
					extern int	SPI_execute_with_args(const char *src,
 | 
				
			||||||
								  int nargs, Oid *argtypes,
 | 
													  int nargs, Oid *argtypes,
 | 
				
			||||||
								  Datum *Values, const char *Nulls,
 | 
													  const Datum *Values, const char *Nulls,
 | 
				
			||||||
								  bool read_only, long tcount);
 | 
													  bool read_only, long tcount);
 | 
				
			||||||
extern SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes);
 | 
					extern SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes);
 | 
				
			||||||
extern SPIPlanPtr SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes,
 | 
					extern SPIPlanPtr SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes,
 | 
				
			||||||
@@ -172,7 +172,7 @@ extern void SPI_freetuple(HeapTuple tuple);
 | 
				
			|||||||
extern void SPI_freetuptable(SPITupleTable *tuptable);
 | 
					extern void SPI_freetuptable(SPITupleTable *tuptable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern Portal SPI_cursor_open(const char *name, SPIPlanPtr plan,
 | 
					extern Portal SPI_cursor_open(const char *name, SPIPlanPtr plan,
 | 
				
			||||||
							  Datum *Values, const char *Nulls, bool read_only);
 | 
												  const Datum *Values, const char *Nulls, bool read_only);
 | 
				
			||||||
extern Portal SPI_cursor_open_with_args(const char *name,
 | 
					extern Portal SPI_cursor_open_with_args(const char *name,
 | 
				
			||||||
										const char *src,
 | 
															const char *src,
 | 
				
			||||||
										int nargs, Oid *argtypes,
 | 
															int nargs, Oid *argtypes,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,8 +130,8 @@ extern void check_default_partition_contents(Relation parent,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
 | 
					extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
 | 
				
			||||||
										Oid *partcollation,
 | 
															Oid *partcollation,
 | 
				
			||||||
										Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
 | 
															const Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
 | 
				
			||||||
										Datum *tuple_datums, int n_tuple_datums);
 | 
															const Datum *tuple_datums, int n_tuple_datums);
 | 
				
			||||||
extern int	partition_list_bsearch(FmgrInfo *partsupfunc,
 | 
					extern int	partition_list_bsearch(FmgrInfo *partsupfunc,
 | 
				
			||||||
								   Oid *partcollation,
 | 
													   Oid *partcollation,
 | 
				
			||||||
								   PartitionBoundInfo boundinfo,
 | 
													   PartitionBoundInfo boundinfo,
 | 
				
			||||||
@@ -139,7 +139,7 @@ extern int	partition_list_bsearch(FmgrInfo *partsupfunc,
 | 
				
			|||||||
extern int	partition_range_datum_bsearch(FmgrInfo *partsupfunc,
 | 
					extern int	partition_range_datum_bsearch(FmgrInfo *partsupfunc,
 | 
				
			||||||
										  Oid *partcollation,
 | 
															  Oid *partcollation,
 | 
				
			||||||
										  PartitionBoundInfo boundinfo,
 | 
															  PartitionBoundInfo boundinfo,
 | 
				
			||||||
										  int nvalues, Datum *values, bool *is_equal);
 | 
															  int nvalues, const Datum *values, bool *is_equal);
 | 
				
			||||||
extern int	partition_hash_bsearch(PartitionBoundInfo boundinfo,
 | 
					extern int	partition_hash_bsearch(PartitionBoundInfo boundinfo,
 | 
				
			||||||
								   int modulus, int remainder);
 | 
													   int modulus, int remainder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -352,8 +352,8 @@ extern PGDLLIMPORT bool Array_nulls;
 | 
				
			|||||||
 * prototypes for functions defined in arrayfuncs.c
 | 
					 * prototypes for functions defined in arrayfuncs.c
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
extern void CopyArrayEls(ArrayType *array,
 | 
					extern void CopyArrayEls(ArrayType *array,
 | 
				
			||||||
						 Datum *values,
 | 
											 const Datum *values,
 | 
				
			||||||
						 bool *nulls,
 | 
											 const bool *nulls,
 | 
				
			||||||
						 int nitems,
 | 
											 int nitems,
 | 
				
			||||||
						 int typlen,
 | 
											 int typlen,
 | 
				
			||||||
						 bool typbyval,
 | 
											 bool typbyval,
 | 
				
			||||||
@@ -405,14 +405,14 @@ extern ArrayType *construct_empty_array(Oid elmtype);
 | 
				
			|||||||
extern ExpandedArrayHeader *construct_empty_expanded_array(Oid element_type,
 | 
					extern ExpandedArrayHeader *construct_empty_expanded_array(Oid element_type,
 | 
				
			||||||
														   MemoryContext parentcontext,
 | 
																			   MemoryContext parentcontext,
 | 
				
			||||||
														   ArrayMetaState *metacache);
 | 
																			   ArrayMetaState *metacache);
 | 
				
			||||||
extern void deconstruct_array(ArrayType *array,
 | 
					extern void deconstruct_array(const ArrayType *array,
 | 
				
			||||||
							  Oid elmtype,
 | 
												  Oid elmtype,
 | 
				
			||||||
							  int elmlen, bool elmbyval, char elmalign,
 | 
												  int elmlen, bool elmbyval, char elmalign,
 | 
				
			||||||
							  Datum **elemsp, bool **nullsp, int *nelemsp);
 | 
												  Datum **elemsp, bool **nullsp, int *nelemsp);
 | 
				
			||||||
extern void deconstruct_array_builtin(ArrayType *array,
 | 
					extern void deconstruct_array_builtin(const ArrayType *array,
 | 
				
			||||||
									  Oid elmtype,
 | 
														  Oid elmtype,
 | 
				
			||||||
									  Datum **elemsp, bool **nullsp, int *nelemsp);
 | 
														  Datum **elemsp, bool **nullsp, int *nelemsp);
 | 
				
			||||||
extern bool array_contains_nulls(ArrayType *array);
 | 
					extern bool array_contains_nulls(const ArrayType *array);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern ArrayBuildState *initArrayResult(Oid element_type,
 | 
					extern ArrayBuildState *initArrayResult(Oid element_type,
 | 
				
			||||||
										MemoryContext rcontext, bool subcontext);
 | 
															MemoryContext rcontext, bool subcontext);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -426,9 +426,9 @@ extern char *JsonbUnquote(Jsonb *jb);
 | 
				
			|||||||
extern bool JsonbExtractScalar(JsonbContainer *jbc, JsonbValue *res);
 | 
					extern bool JsonbExtractScalar(JsonbContainer *jbc, JsonbValue *res);
 | 
				
			||||||
extern const char *JsonbTypeName(JsonbValue *val);
 | 
					extern const char *JsonbTypeName(JsonbValue *val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern Datum jsonb_set_element(Jsonb *jb, Datum *path, int path_len,
 | 
					extern Datum jsonb_set_element(Jsonb *jb, const Datum *path, int path_len,
 | 
				
			||||||
							   JsonbValue *newval);
 | 
												   JsonbValue *newval);
 | 
				
			||||||
extern Datum jsonb_get_element(Jsonb *jb, Datum *path, int npath,
 | 
					extern Datum jsonb_get_element(Jsonb *jb, const Datum *path, int npath,
 | 
				
			||||||
							   bool *isnull, bool as_text);
 | 
												   bool *isnull, bool as_text);
 | 
				
			||||||
extern bool to_jsonb_is_immutable(Oid typoid);
 | 
					extern bool to_jsonb_is_immutable(Oid typoid);
 | 
				
			||||||
extern Datum jsonb_build_object_worker(int nargs, const Datum *args, const bool *nulls,
 | 
					extern Datum jsonb_build_object_worker(int nargs, const Datum *args, const bool *nulls,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,8 +71,8 @@ extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern xmltype *xmlconcat(List *args);
 | 
					extern xmltype *xmlconcat(List *args);
 | 
				
			||||||
extern xmltype *xmlelement(XmlExpr *xexpr,
 | 
					extern xmltype *xmlelement(XmlExpr *xexpr,
 | 
				
			||||||
						   Datum *named_argvalue, bool *named_argnull,
 | 
											   const Datum *named_argvalue, const bool *named_argnull,
 | 
				
			||||||
						   Datum *argvalue, bool *argnull);
 | 
											   const Datum *argvalue, const bool *argnull);
 | 
				
			||||||
extern xmltype *xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace);
 | 
					extern xmltype *xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace);
 | 
				
			||||||
extern xmltype *xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null);
 | 
					extern xmltype *xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null);
 | 
				
			||||||
extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
 | 
					extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,7 +94,7 @@ commonPrefix(const char *a, const char *b, int lena, int lenb)
 | 
				
			|||||||
 * On success, *i gets the match location; on failure, it gets where to insert
 | 
					 * On success, *i gets the match location; on failure, it gets where to insert
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
searchChar(Datum *nodeLabels, int nNodes, int16 c, int *i)
 | 
					searchChar(const Datum *nodeLabels, int nNodes, int16 c, int *i)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			StopLow = 0,
 | 
						int			StopLow = 0,
 | 
				
			||||||
				StopHigh = nNodes;
 | 
									StopHigh = nNodes;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user