perltidy run not included.
BloomFillMetapage(index, metapage);
/*
- * Write the page and log it. It might seem that an immediate sync
- * would be sufficient to guarantee that the file exists on disk, but
- * recovery itself might remove it while replaying, for example, an
- * XLOG_DBASE_CREATE or XLOG_TBLSPC_CREATE record. Therefore, we
- * need this even when wal_level=minimal.
+ * Write the page and log it. It might seem that an immediate sync would
+ * be sufficient to guarantee that the file exists on disk, but recovery
+ * itself might remove it while replaying, for example, an
+ * XLOG_DBASE_CREATE or XLOG_TBLSPC_CREATE record. Therefore, we need
+ * this even when wal_level=minimal.
*/
PageSetChecksumInplace(metapage, BLOOM_METAPAGE_BLKNO);
smgrwrite(index->rd_smgr, INIT_FORKNUM, BLOOM_METAPAGE_BLKNO,
bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
buf);
bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
- bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) + sizeof(int) * i;
+ bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) +sizeof(int) * i;
}
}
cmp;
cmp = DatumGetInt32(CallerFInfoFunctionCall2(
- data->typecmp,
- fcinfo->flinfo,
- PG_GET_COLLATION(),
- (data->strategy == BTLessStrategyNumber ||
- data->strategy == BTLessEqualStrategyNumber)
- ? data->datum : a,
- b));
+ data->typecmp,
+ fcinfo->flinfo,
+ PG_GET_COLLATION(),
+ (data->strategy == BTLessStrategyNumber ||
+ data->strategy == BTLessEqualStrategyNumber)
+ ? data->datum : a,
+ b));
switch (data->strategy)
{
*/
-#define ENUM_IS_LEFTMOST(x) ((x) == InvalidOid)
+#define ENUM_IS_LEFTMOST(x) ((x) == InvalidOid)
PG_FUNCTION_INFO_V1(gin_enum_cmp);
Datum
gin_enum_cmp(PG_FUNCTION_ARGS)
{
- Oid a = PG_GETARG_OID(0);
- Oid b = PG_GETARG_OID(1);
- int res = 0;
+ Oid a = PG_GETARG_OID(0);
+ Oid b = PG_GETARG_OID(1);
+ int res = 0;
if (ENUM_IS_LEFTMOST(a))
{
else
{
res = DatumGetInt32(CallerFInfoFunctionCall2(
- enum_cmp,
- fcinfo->flinfo,
- PG_GET_COLLATION(),
- ObjectIdGetDatum(a),
- ObjectIdGetDatum(b)));
+ enum_cmp,
+ fcinfo->flinfo,
+ PG_GET_COLLATION(),
+ ObjectIdGetDatum(a),
+ ObjectIdGetDatum(b)));
}
PG_RETURN_INT32(res);
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
gbt_enumgt(const void *a, const void *b, FmgrInfo *flinfo)
{
return DatumGetBool(
- CallerFInfoFunctionCall2(enum_gt, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
+ CallerFInfoFunctionCall2(enum_gt, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
);
}
static bool
gbt_enumge(const void *a, const void *b, FmgrInfo *flinfo)
{
return DatumGetBool(
- CallerFInfoFunctionCall2(enum_ge, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
+ CallerFInfoFunctionCall2(enum_ge, flinfo, InvalidOid, ObjectIdGetDatum(*((const Oid *) a)), ObjectIdGetDatum(*((const Oid *) b)))
);
}
static bool
return 0;
return DatumGetInt32(
- CallerFInfoFunctionCall2(enum_cmp, flinfo, InvalidOid, ObjectIdGetDatum(ia->upper), ObjectIdGetDatum(ib->upper))
+ CallerFInfoFunctionCall2(enum_cmp, flinfo, InvalidOid, ObjectIdGetDatum(ia->upper), ObjectIdGetDatum(ib->upper))
);
}
return DatumGetInt32(
- CallerFInfoFunctionCall2(enum_cmp, flinfo, InvalidOid, ObjectIdGetDatum(ia->lower), ObjectIdGetDatum(ib->lower))
+ CallerFInfoFunctionCall2(enum_cmp, flinfo, InvalidOid, ObjectIdGetDatum(ia->lower), ObjectIdGetDatum(ib->lower))
);
}
gbt_enumle,
gbt_enumlt,
gbt_enumkey_cmp,
- NULL /* no KNN support at least for now */
+ NULL /* no KNN support at least for now */
};
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_BOOL(gbt_num_consistent(&key, (void *) &query,
- &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
+ &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo));
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
qqq = tstz_to_ts_gmt(query);
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
/* Methods */
- bool (*f_gt) (const void *, const void *, FmgrInfo *); /* greater than */
- bool (*f_ge) (const void *, const void *, FmgrInfo *); /* greater or equal */
- bool (*f_eq) (const void *, const void *, FmgrInfo *); /* equal */
- bool (*f_le) (const void *, const void *, FmgrInfo *); /* less or equal */
- bool (*f_lt) (const void *, const void *, FmgrInfo *); /* less than */
- int (*f_cmp) (const void *, const void *, FmgrInfo *); /* key compare function */
- float8 (*f_dist) (const void *, const void *, FmgrInfo *); /* key distance function */
+ bool (*f_gt) (const void *, const void *, FmgrInfo *); /* greater than */
+ bool (*f_ge) (const void *, const void *, FmgrInfo *); /* greater or equal */
+ bool (*f_eq) (const void *, const void *, FmgrInfo *); /* equal */
+ bool (*f_le) (const void *, const void *, FmgrInfo *); /* less or equal */
+ bool (*f_lt) (const void *, const void *, FmgrInfo *); /* less than */
+ int (*f_cmp) (const void *, const void *, FmgrInfo *); /* key compare function */
+ float8 (*f_dist) (const void *, const void *, FmgrInfo *); /* key distance function */
} gbtree_ninfo;
{
const gbtree_vinfo *tinfo;
Oid collation;
- FmgrInfo *flinfo;
+ FmgrInfo *flinfo;
} gbt_vsrt_arg;
*res = 0.0;
else if (!(((*tinfo->f_cmp) (nk.lower, ok.lower, collation, flinfo) >= 0 ||
gbt_bytea_pf_match(ok.lower, nk.lower, tinfo)) &&
- ((*tinfo->f_cmp) (nk.upper, ok.upper, collation, flinfo) <= 0 ||
- gbt_bytea_pf_match(ok.upper, nk.upper, tinfo))))
+ ((*tinfo->f_cmp) (nk.upper, ok.upper, collation, flinfo) <= 0 ||
+ gbt_bytea_pf_match(ok.upper, nk.upper, tinfo))))
{
Datum d = PointerGetDatum(0);
double dres;
/* Methods */
- bool (*f_gt) (const void *, const void *, Oid, FmgrInfo *); /* greater than */
- bool (*f_ge) (const void *, const void *, Oid, FmgrInfo *); /* greater equal */
- bool (*f_eq) (const void *, const void *, Oid, FmgrInfo *); /* equal */
- bool (*f_le) (const void *, const void *, Oid, FmgrInfo *); /* less equal */
- bool (*f_lt) (const void *, const void *, Oid, FmgrInfo *); /* less than */
- int32 (*f_cmp) (const void *, const void *, Oid, FmgrInfo *); /* compare */
+ bool (*f_gt) (const void *, const void *, Oid, FmgrInfo *); /* greater than */
+ bool (*f_ge) (const void *, const void *, Oid, FmgrInfo *); /* greater equal */
+ bool (*f_eq) (const void *, const void *, Oid, FmgrInfo *); /* equal */
+ bool (*f_le) (const void *, const void *, Oid, FmgrInfo *); /* less equal */
+ bool (*f_lt) (const void *, const void *, Oid, FmgrInfo *); /* less than */
+ int32 (*f_cmp) (const void *, const void *, Oid, FmgrInfo *); /* compare */
GBT_VARKEY *(*f_l2n) (GBT_VARKEY *, FmgrInfo *flinfo); /* convert leaf to node */
} gbtree_vinfo;
PG_RETURN_BOOL(
gbt_num_consistent(&key, (void *) query, &strategy,
- GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
+ GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
);
}
static void dblink_connstr_check(const char *connstr);
static void dblink_security_check(PGconn *conn, remoteConn *rconn);
static void dblink_res_error(PGconn *conn, const char *conname, PGresult *res,
- const char *dblink_context_msg, bool fail);
+ const char *dblink_context_msg, bool fail);
static char *get_connect_string(const char *servername);
static char *escape_param_str(const char *from);
static void validate_pkattnums(Relation rel,
return pstrdup(in);
}
-static void pg_attribute_noreturn()
+static void
+pg_attribute_noreturn()
dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2)
{
char *msg = pchomp(PQerrorMessage(conn));
+
if (res)
PQclear(res);
elog(ERROR, "%s: %s", p2, msg);
}
-static void pg_attribute_noreturn()
+static void
+pg_attribute_noreturn()
dblink_conn_not_avail(const char *conname)
{
if (conname)
static void
dblink_get_conn(char *conname_or_str,
- PGconn * volatile *conn_p, char **conname_p, volatile bool *freeconn_p)
+ PGconn *volatile * conn_p, char **conname_p, volatile bool *freeconn_p)
{
remoteConn *rconn = getConnectionByName(conname_or_str);
PGconn *conn;
if (PQstatus(conn) == CONNECTION_BAD)
{
char *msg = pchomp(PQerrorMessage(conn));
+
PQfinish(conn);
ereport(ERROR,
- (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
- errmsg("could not establish connection"),
- errdetail_internal("%s", msg)));
+ (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
+ errmsg("could not establish connection"),
+ errdetail_internal("%s", msg)));
}
dblink_security_check(conn, rconn);
if (PQclientEncoding(conn) != GetDatabaseEncoding())
dblink_get_named_conn(const char *conname)
{
remoteConn *rconn = getConnectionByName(conname);
+
if (rconn)
return rconn->conn;
dblink_conn_not_avail(conname);
- return NULL; /* keep compiler quiet */
+ return NULL; /* keep compiler quiet */
}
static void
message_context = xpstrdup(pg_diag_context);
/*
- * If we don't get a message from the PGresult, try the PGconn. This
- * is needed because for connection-level failures, PQexec may just
- * return NULL, not a PGresult at all.
+ * If we don't get a message from the PGresult, try the PGconn. This is
+ * needed because for connection-level failures, PQexec may just return
+ * NULL, not a PGresult at all.
*/
if (message_primary == NULL)
message_primary = pchomp(PQerrorMessage(conn));
ForeignServer *foreign_server = NULL;
UserMapping *user_mapping;
ListCell *cell;
- StringInfoData buf;
+ StringInfoData buf;
ForeignDataWrapper *fdw;
AclResult aclresult;
char *srvname;
escape_param_str(const char *str)
{
const char *cp;
- StringInfoData buf;
+ StringInfoData buf;
initStringInfo(&buf);
todo = psprintf(
"SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s\n"
"FROM pg_catalog.pg_class c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"
" LEFT JOIN pg_catalog.pg_database d ON d.datname = pg_catalog.current_database(),\n"
" pg_catalog.pg_tablespace t\n"
"WHERE relkind IN (" CppAsString2(RELKIND_RELATION) ","
if (ItemIdIsUsed(itemId))
{
dtup = brin_deform_tuple(bdesc,
- (BrinTuple *) PageGetItem(page, itemId),
- NULL);
+ (BrinTuple *) PageGetItem(page, itemId),
+ NULL);
attno = 1;
unusedItem = false;
}
*/
typedef struct HashPageStat
{
- int live_items;
- int dead_items;
- int page_size;
- int free_size;
+ int live_items;
+ int dead_items;
+ int page_size;
+ int free_size;
/* opaque data */
BlockNumber hasho_prevblkno;
Bucket hasho_bucket;
uint16 hasho_flag;
uint16 hasho_page_id;
-} HashPageStat;
+} HashPageStat;
/*
case LH_BUCKET_PAGE | LH_OVERFLOW_PAGE:
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("page is not a hash bucket or overflow page")));
+ errmsg("page is not a hash bucket or overflow page")));
case LH_OVERFLOW_PAGE:
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
default:
elog(ERROR,
"hash page of type %08x not in mask %08x",
- pagetype, flags);
+ pagetype, flags);
}
}
* -------------------------------------------------
*/
static void
-GetHashPageStatistics(Page page, HashPageStat * stat)
+GetHashPageStatistics(Page page, HashPageStat *stat)
{
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
HashPageOpaque opaque = (HashPageOpaque) PageGetSpecialPointer(page);
j;
Datum values[16];
bool nulls[16];
- Datum spares[HASH_MAX_SPLITPOINTS];
- Datum mapp[HASH_MAX_BITMAPS];
+ Datum spares[HASH_MAX_SPLITPOINTS];
+ Datum mapp[HASH_MAX_BITMAPS];
if (!superuser())
ereport(ERROR,
if (raw_page_size != BLCKSZ)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("incorrect size of input page (%d bytes)", raw_page_size)));
+ errmsg("incorrect size of input page (%d bytes)", raw_page_size)));
page = (PageHeader) VARDATA(raw_page);
- PG_RETURN_INT16(pg_checksum_page((char *)page, blkno));
+ PG_RETURN_INT16(pg_checksum_page((char *) page, blkno));
}
char *nextWALFileName; /* the file we need to get from archive */
char *restartWALFileName; /* the file from which we can restart restore */
char *priorWALFileName; /* the file we need to get from archive */
-char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
+char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
char restoreCommand[MAXPGPATH]; /* run this to restore */
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the file we need to
* get from archive */
rel->rd_rel->relkind != RELKIND_TOASTVALUE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, materialized view, or TOAST table",
- RelationGetRelationName(rel))));
+ errmsg("\"%s\" is not a table, materialized view, or TOAST table",
+ RelationGetRelationName(rel))));
}
* prototype for the EVP functions that return an algorithm, e.g.
* EVP_aes_128_cbc().
*/
-typedef const EVP_CIPHER *(*ossl_EVP_cipher_func)(void);
+typedef const EVP_CIPHER *(*ossl_EVP_cipher_func) (void);
/*
* ossl_cipher contains the static information about each cipher.
static const struct ossl_cipher ossl_aes_ecb = {
ossl_aes_ecb_init,
- NULL, /* EVP_aes_XXX_ecb(), determined in init function */
+ NULL, /* EVP_aes_XXX_ecb(), determined in init
+ * function */
128 / 8, 256 / 8
};
static const struct ossl_cipher ossl_aes_cbc = {
ossl_aes_cbc_init,
- NULL, /* EVP_aes_XXX_cbc(), determined in init function */
+ NULL, /* EVP_aes_XXX_cbc(), determined in init
+ * function */
128 / 8, 256 / 8
};
uint8 *buf = (uint8 *) palloc(UUID_LEN);
/*
- * Generate random bits. pg_backend_random() will do here, we don't
- * promis UUIDs to be cryptographically random, when built with
+ * Generate random bits. pg_backend_random() will do here, we don't promis
+ * UUIDs to be cryptographically random, when built with
* --disable-strong-random.
*/
if (!pg_backend_random((char *) buf, UUID_LEN))
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = heap_openrv(relrv, AccessShareLock);
- /* check permissions: must have SELECT on table or be in pg_stat_scan_tables */
+ /*
+ * check permissions: must have SELECT on table or be in
+ * pg_stat_scan_tables
+ */
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
if (aclresult != ACLCHECK_OK)
PG_FUNCTION_INFO_V1(pgstattuple_approx);
PG_FUNCTION_INFO_V1(pgstattuple_approx_v1_5);
-Datum pgstattuple_approx_internal(Oid relid, FunctionCallInfo fcinfo);
+Datum pgstattuple_approx_internal(Oid relid, FunctionCallInfo fcinfo);
typedef struct output_type
{
PG_FUNCTION_INFO_V1(pg_relpagesbyid_v1_5);
PG_FUNCTION_INFO_V1(pgstatginindex_v1_5);
-Datum pgstatginindex_internal(Oid relid, FunctionCallInfo fcinfo);
+Datum pgstatginindex_internal(Oid relid, FunctionCallInfo fcinfo);
#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
#define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
*/
typedef struct HashIndexStat
{
- int32 version;
- int32 space_per_page;
+ int32 version;
+ int32 space_per_page;
- BlockNumber bucket_pages;
+ BlockNumber bucket_pages;
BlockNumber overflow_pages;
BlockNumber bitmap_pages;
BlockNumber unused_pages;
- int64 live_items;
- int64 dead_items;
- uint64 free_space;
+ int64 live_items;
+ int64 dead_items;
+ uint64 free_space;
} HashIndexStat;
static Datum pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo);
pgstathashindex(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
- BlockNumber nblocks;
- BlockNumber blkno;
+ BlockNumber nblocks;
+ BlockNumber blkno;
Relation rel;
HashIndexStat stats;
BufferAccessStrategy bstrategy;
Datum values[8];
bool nulls[8];
Buffer metabuf;
- HashMetaPage metap;
+ HashMetaPage metap;
float8 free_percent;
uint64 total_space;
MAXALIGN(sizeof(HashPageOpaqueData)))
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("index \"%s\" contains corrupted page at block %u",
- RelationGetRelationName(rel),
- BufferGetBlockNumber(buf))));
+ errmsg("index \"%s\" contains corrupted page at block %u",
+ RelationGetRelationName(rel),
+ BufferGetBlockNumber(buf))));
else
{
- HashPageOpaque opaque;
- int pagetype;
+ HashPageOpaque opaque;
+ int pagetype;
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
pagetype = opaque->hasho_flag & LH_PAGE_TYPE;
else
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("unexpected page type 0x%04X in HASH index \"%s\" block %u",
+ errmsg("unexpected page type 0x%04X in HASH index \"%s\" block %u",
opaque->hasho_flag, RelationGetRelationName(rel),
- BufferGetBlockNumber(buf))));
+ BufferGetBlockNumber(buf))));
}
UnlockReleaseBuffer(buf);
}
GetHashPageStats(Page page, HashIndexStat *stats)
{
OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
- int off;
+ int off;
/* count live and dead tuples, and free space */
for (off = FirstOffsetNumber; off <= maxoff; off++)
{
- ItemId id = PageGetItemId(page, off);
+ ItemId id = PageGetItemId(page, off);
if (!ItemIdIsDead(id))
stats->live_items++;
RelOptInfo *joinrel, bool use_alias, List **params_list);
static void deparseFromExpr(List *quals, deparse_expr_cxt *context);
static void deparseRangeTblRef(StringInfo buf, PlannerInfo *root,
- RelOptInfo *foreignrel, bool make_subquery,
- List **params_list);
+ RelOptInfo *foreignrel, bool make_subquery,
+ List **params_list);
static void deparseAggref(Aggref *node, deparse_expr_cxt *context);
static void appendGroupByClause(List *tlist, deparse_expr_cxt *context);
static void appendAggOrderBy(List *orderList, List *targetList,
* Helper functions
*/
static bool is_subquery_var(Var *node, RelOptInfo *foreignrel,
- int *relno, int *colno);
+ int *relno, int *colno);
static void get_relation_column_alias_ids(Var *node, RelOptInfo *foreignrel,
- int *relno, int *colno);
+ int *relno, int *colno);
/*
{
/*
* For a relation that is deparsed as a subquery, emit expressions
- * specified in the relation's reltarget. Note that since this is
- * for the subquery, no need to care about *retrieved_attrs.
+ * specified in the relation's reltarget. Note that since this is for
+ * the subquery, no need to care about *retrieved_attrs.
*/
deparseSubqueryTargetList(context);
}
/*
* If the Var belongs to the foreign relation that is deparsed as a
- * subquery, use the relation and column alias to the Var provided
- * by the subquery, instead of the remote name.
+ * subquery, use the relation and column alias to the Var provided by the
+ * subquery, instead of the remote name.
*/
if (is_subquery_var(node, context->scanrel, &relno, &colno))
{
static void apply_server_options(PgFdwRelationInfo *fpinfo);
static void apply_table_options(PgFdwRelationInfo *fpinfo);
static void merge_fdw_options(PgFdwRelationInfo *fpinfo,
- const PgFdwRelationInfo *fpinfo_o,
- const PgFdwRelationInfo *fpinfo_i);
+ const PgFdwRelationInfo *fpinfo_o,
+ const PgFdwRelationInfo *fpinfo_i);
/*
fpinfo->jointype = jointype;
/*
- * By default, both the input relations are not required to be deparsed
- * as subqueries, but there might be some relations covered by the input
+ * By default, both the input relations are not required to be deparsed as
+ * subqueries, but there might be some relations covered by the input
* relations that are required to be deparsed as subqueries, so save the
* relids of those relations for later use by the deparser.
*/
case JOIN_FULL:
/*
- * In this case, if any of the input relations has conditions,
- * we need to deparse that relation as a subquery so that the
+ * In this case, if any of the input relations has conditions, we
+ * need to deparse that relation as a subquery so that the
* conditions can be evaluated before the join. Remember it in
* the fpinfo of this relation so that the deparser can take
* appropriate action. Also, save the relids of base relations
* Note that since this joinrel is at the end of the join_rel_list list
* when we are called, we can get the position by list_length.
*/
- Assert(fpinfo->relation_index == 0); /* shouldn't be set yet */
+ Assert(fpinfo->relation_index == 0); /* shouldn't be set yet */
fpinfo->relation_index =
list_length(root->parse->rtable) + list_length(root->join_rel_list);
static void
apply_server_options(PgFdwRelationInfo *fpinfo)
{
- ListCell *lc;
+ ListCell *lc;
foreach(lc, fpinfo->server->options)
{
static void
apply_table_options(PgFdwRelationInfo *fpinfo)
{
- ListCell *lc;
+ ListCell *lc;
foreach(lc, fpinfo->table->options)
{
* best.
*/
fpinfo->use_remote_estimate = fpinfo_o->use_remote_estimate ||
- fpinfo_i->use_remote_estimate;
+ fpinfo_i->use_remote_estimate;
/*
* Set fetch size to maximum of the joining sides, since we are
fpinfo->table = ifpinfo->table;
fpinfo->server = ifpinfo->server;
fpinfo->user = ifpinfo->user;
- merge_fdw_options(fpinfo, ifpinfo , NULL);
+ merge_fdw_options(fpinfo, ifpinfo, NULL);
/* Assess if it is safe to push down aggregation and grouping. */
if (!foreign_grouping_ok(root, grouped_rel))
List *grouped_tlist;
/* Subquery information */
- bool make_outerrel_subquery; /* do we deparse outerrel as a
+ bool make_outerrel_subquery; /* do we deparse outerrel as a
* subquery? */
- bool make_innerrel_subquery; /* do we deparse innerrel as a
+ bool make_innerrel_subquery; /* do we deparse innerrel as a
* subquery? */
Relids lower_subquery_rels; /* all relids appearing in lower
* subqueries */
MemoryContext oldcxt;
MemoryContext perRangeCxt;
BrinMemTuple *dtup;
- BrinTuple *btup = NULL;
+ BrinTuple *btup = NULL;
Size btupsz = 0;
opaque = (BrinOpaque *) scan->opaque;
Datum
brin_desummarize_range(PG_FUNCTION_ARGS)
{
- Oid indexoid = PG_GETARG_OID(0);
- int64 heapBlk64 = PG_GETARG_INT64(1);
+ Oid indexoid = PG_GETARG_OID(0);
+ int64 heapBlk64 = PG_GETARG_INT64(1);
BlockNumber heapBlk;
- Oid heapoid;
- Relation heapRel;
- Relation indexRel;
- bool done;
+ Oid heapoid;
+ Relation heapRel;
+ Relation indexRel;
+ bool done;
if (heapBlk64 > MaxBlockNumber || heapBlk64 < 0)
{
RelationGetRelationName(indexRel))));
/* the revmap does the hard work */
- do {
+ do
+ {
done = brinRevmapDesummarizeRange(indexRel, heapBlk);
}
while (!done);
brinRevmapDesummarizeRange(Relation idxrel, BlockNumber heapBlk)
{
BrinRevmap *revmap;
- BlockNumber pagesPerRange;
+ BlockNumber pagesPerRange;
RevmapContents *contents;
ItemPointerData *iptr;
- ItemPointerData invalidIptr;
- BlockNumber revmapBlk;
+ ItemPointerData invalidIptr;
+ BlockNumber revmapBlk;
Buffer revmapBuf;
Buffer regBuf;
Page revmapPg;
if (RelationNeedsWAL(idxrel))
{
xl_brin_desummarize xlrec;
- XLogRecPtr recptr;
+ XLogRecPtr recptr;
xlrec.pagesPerRange = revmap->rm_pagesPerRange;
xlrec.heapBlk = heapBlk;
action = XLogReadBufferForRedo(record, 0, &buffer);
if (action == BLK_NEEDS_REDO)
{
- ItemPointerData iptr;
+ ItemPointerData iptr;
ItemPointerSetInvalid(&iptr);
brinSetHeapBlockItemptr(buffer, xlrec->pagesPerRange, xlrec->heapBlk, iptr);
action = XLogReadBufferForRedo(record, 1, &buffer);
if (action == BLK_NEEDS_REDO)
{
- Page regPg = BufferGetPage(buffer);
+ Page regPg = BufferGetPage(buffer);
PageIndexTupleDeleteNoCompact(regPg, xlrec->regOffset);
case INT4OID:
{
- int32 num = DatumGetInt32(value);
- char str[12]; /* sign, 10 digits and '\0' */
+ int32 num = DatumGetInt32(value);
+ char str[12]; /* sign, 10 digits and '\0' */
pg_ltoa(num, str);
pq_sendcountedtext(&buf, str, strlen(str), false);
case INT8OID:
{
- int64 num = DatumGetInt64(value);
- char str[23]; /* sign, 21 digits and '\0' */
+ int64 num = DatumGetInt64(value);
+ char str[23]; /* sign, 21 digits and '\0' */
pg_lltoa(num, str);
pq_sendcountedtext(&buf, str, strlen(str), false);
* exclusive cleanup lock. This guarantees that no insertions currently
* happen in this subtree. Caller also acquire Exclusive lock on deletable
* page and is acquiring and releasing exclusive lock on left page before.
- * Left page was locked and released. Then parent and this page are locked.
- * We acquire left page lock here only to mark page dirty after changing
- * right pointer.
+ * Left page was locked and released. Then parent and this page are
+ * locked. We acquire left page lock here only to mark page dirty after
+ * changing right pointer.
*/
lBuffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, leftBlkno,
RBM_NORMAL, gvs->strategy);
buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno,
RBM_NORMAL, gvs->strategy);
- if(!isRoot)
+ if (!isRoot)
LockBuffer(buffer, GIN_EXCLUSIVE);
page = BufferGetPage(buffer);
}
}
- if(!isRoot)
- LockBuffer(buffer, GIN_UNLOCK);
+ if (!isRoot)
+ LockBuffer(buffer, GIN_UNLOCK);
ReleaseBuffer(buffer);
RBM_NORMAL, gvs->strategy);
page = BufferGetPage(buffer);
- ginTraverseLock(buffer,false);
+ ginTraverseLock(buffer, false);
Assert(GinPageIsData(page));
}
else
{
- OffsetNumber i;
- bool hasEmptyChild = FALSE;
- bool hasNonEmptyChild = FALSE;
- OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
- BlockNumber* children = palloc(sizeof(BlockNumber) * (maxoff + 1));
+ OffsetNumber i;
+ bool hasEmptyChild = FALSE;
+ bool hasNonEmptyChild = FALSE;
+ OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
+ BlockNumber *children = palloc(sizeof(BlockNumber) * (maxoff + 1));
/*
- * Read all children BlockNumbers.
- * Not sure it is safe if there are many concurrent vacuums.
+ * Read all children BlockNumbers. Not sure it is safe if there are
+ * many concurrent vacuums.
*/
for (i = FirstOffsetNumber; i <= maxoff; i++)
vacuum_delay_point();
/*
- * All subtree is empty - just return TRUE to indicate that parent must
- * do a cleanup. Unless we are ROOT an there is way to go upper.
+ * All subtree is empty - just return TRUE to indicate that parent
+ * must do a cleanup. Unless we are ROOT an there is way to go upper.
*/
- if(hasEmptyChild && !hasNonEmptyChild && !isRoot)
+ if (hasEmptyChild && !hasNonEmptyChild && !isRoot)
return TRUE;
- if(hasEmptyChild)
+ if (hasEmptyChild)
{
DataPageDeleteStack root,
*ptr,
*tmp;
buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno,
- RBM_NORMAL, gvs->strategy);
+ RBM_NORMAL, gvs->strategy);
LockBufferForCleanup(buffer);
memset(&root, 0, sizeof(DataPageDeleteStack));
- root.leftBlkno = InvalidBlockNumber;
- root.isRoot = TRUE;
+ root.leftBlkno = InvalidBlockNumber;
+ root.isRoot = TRUE;
ginScanToDelete(gvs, blkno, TRUE, &root, InvalidOffsetNumber);
if (scan->kill_prior_tuple)
{
/*
- * Yes, so remember it for later. (We'll deal with all such
- * tuples at once right after leaving the index page or at
- * end of scan.) In case if caller reverses the indexscan
- * direction it is quite possible that the same item might
- * get entered multiple times. But, we don't detect that;
- * instead, we just forget any excess entries.
+ * Yes, so remember it for later. (We'll deal with all such tuples
+ * at once right after leaving the index page or at end of scan.)
+ * In case if caller reverses the indexscan direction it is quite
+ * possible that the same item might get entered multiple times.
+ * But, we don't detect that; instead, we just forget any excess
+ * entries.
*/
if (so->killedItems == NULL)
so->killedItems = palloc(MaxIndexTuplesPerPage *
{
so->killedItems[so->numKilled].heapTid = so->hashso_heappos;
so->killedItems[so->numKilled].indexOffset =
- ItemPointerGetOffsetNumber(&(so->hashso_curpos));
+ ItemPointerGetOffsetNumber(&(so->hashso_curpos));
so->numKilled++;
}
}
Relation rel = scan->indexRelation;
/*
- * Before leaving current page, deal with any killed items.
- * Also, ensure that we acquire lock on current page before
- * calling _hash_kill_items.
+ * Before leaving current page, deal with any killed items. Also, ensure
+ * that we acquire lock on current page before calling _hash_kill_items.
*/
if (so->numKilled > 0)
{
Relation rel = scan->indexRelation;
/*
- * Before leaving current page, deal with any killed items.
- * Also, ensure that we acquire lock on current page before
- * calling _hash_kill_items.
+ * Before leaving current page, deal with any killed items. Also, ensure
+ * that we acquire lock on current page before calling _hash_kill_items.
*/
if (so->numKilled > 0)
{
/*
* Let us mark the page as clean if vacuum removes the DEAD tuples
- * from an index page. We do this by clearing LH_PAGE_HAS_DEAD_TUPLES
- * flag.
+ * from an index page. We do this by clearing
+ * LH_PAGE_HAS_DEAD_TUPLES flag.
*/
if (tuples_removed && *tuples_removed > 0 &&
H_HAS_DEAD_TUPLES(opaque))
static TransactionId
hash_xlog_vacuum_get_latestRemovedXid(XLogReaderState *record)
{
- xl_hash_vacuum_one_page *xlrec;
- OffsetNumber *unused;
+ xl_hash_vacuum_one_page *xlrec;
+ OffsetNumber *unused;
Buffer ibuffer,
hbuffer;
Page ipage,
hpage;
- RelFileNode rnode;
- BlockNumber blkno;
+ RelFileNode rnode;
+ BlockNumber blkno;
ItemId iitemid,
hitemid;
IndexTuple itup;
- HeapTupleHeader htuphdr;
- BlockNumber hblkno;
- OffsetNumber hoffnum;
- TransactionId latestRemovedXid = InvalidTransactionId;
- int i;
+ HeapTupleHeader htuphdr;
+ BlockNumber hblkno;
+ OffsetNumber hoffnum;
+ TransactionId latestRemovedXid = InvalidTransactionId;
+ int i;
xlrec = (xl_hash_vacuum_one_page *) XLogRecGetData(record);
return latestRemovedXid;
/*
- * Check if WAL replay has reached a consistent database state. If not,
- * we must PANIC. See the definition of btree_xlog_delete_get_latestRemovedXid
- * for more details.
+ * Check if WAL replay has reached a consistent database state. If not, we
+ * must PANIC. See the definition of
+ * btree_xlog_delete_get_latestRemovedXid for more details.
*/
if (!reachedConsistency)
elog(PANIC, "hash_xlog_vacuum_get_latestRemovedXid: cannot operate with inconsistent data");
static void
hash_xlog_vacuum_one_page(XLogReaderState *record)
{
- XLogRecPtr lsn = record->EndRecPtr;
+ XLogRecPtr lsn = record->EndRecPtr;
xl_hash_vacuum_one_page *xldata;
- Buffer buffer;
- Buffer metabuf;
- Page page;
+ Buffer buffer;
+ Buffer metabuf;
+ Page page;
XLogRedoAction action;
HashPageOpaque pageopaque;
if (InHotStandby)
{
TransactionId latestRemovedXid =
- hash_xlog_vacuum_get_latestRemovedXid(record);
+ hash_xlog_vacuum_get_latestRemovedXid(record);
RelFileNode rnode;
XLogRecGetBlockTag(record, 0, &rnode, NULL, NULL);
}
/*
- * Mark the page as not containing any LP_DEAD items. See comments
- * in _hash_vacuum_one_page() for details.
+ * Mark the page as not containing any LP_DEAD items. See comments in
+ * _hash_vacuum_one_page() for details.
*/
pageopaque = (HashPageOpaque) PageGetSpecialPointer(page);
pageopaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
if (XLogReadBufferForRedo(record, 1, &metabuf) == BLK_NEEDS_REDO)
{
- Page metapage;
+ Page metapage;
HashMetaPage metap;
metapage = BufferGetPage(metabuf);
#include "storage/buf_internals.h"
static void _hash_vacuum_one_page(Relation rel, Buffer metabuf, Buffer buf,
- RelFileNode hnode);
+ RelFileNode hnode);
/*
* _hash_doinsert() -- Handle insertion of a single index tuple.
/*
* Read the metapage. We don't lock it yet; HashMaxItemSize() will
- * examine pd_pagesize_version, but that can't change so we can examine
- * it without a lock.
+ * examine pd_pagesize_version, but that can't change so we can examine it
+ * without a lock.