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.
*/
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_NOLOCK, LH_META_PAGE);
metapage = BufferGetPage(metabuf);
BlockNumber nextblkno;
/*
- * Check if current page has any DEAD tuples. If yes,
- * delete these tuples and see if we can get a space for
- * the new item to be inserted before moving to the next
- * page in the bucket chain.
+ * Check if current page has any DEAD tuples. If yes, delete these
+ * tuples and see if we can get a space for the new item to be
+ * inserted before moving to the next page in the bucket chain.
*/
if (H_HAS_DEAD_TUPLES(pageopaque))
{
_hash_vacuum_one_page(rel, metabuf, buf, heapRel->rd_node);
if (PageGetFreeSpace(page) >= itemsz)
- break; /* OK, now we have enough space */
+ break; /* OK, now we have enough space */
}
}
_hash_vacuum_one_page(Relation rel, Buffer metabuf, Buffer buf,
RelFileNode hnode)
{
- OffsetNumber deletable[MaxOffsetNumber];
- int ndeletable = 0;
+ OffsetNumber deletable[MaxOffsetNumber];
+ int ndeletable = 0;
OffsetNumber offnum,
- maxoff;
- Page page = BufferGetPage(buf);
- HashPageOpaque pageopaque;
- HashMetaPage metap;
+ maxoff;
+ Page page = BufferGetPage(buf);
+ HashPageOpaque pageopaque;
+ HashMetaPage metap;
/* Scan each tuple in page to see if it is marked as LP_DEAD */
maxoff = PageGetMaxOffsetNumber(page);
offnum <= maxoff;
offnum = OffsetNumberNext(offnum))
{
- ItemId itemId = PageGetItemId(page, offnum);
+ ItemId itemId = PageGetItemId(page, offnum);
if (ItemIdIsDead(itemId))
deletable[ndeletable++] = offnum;
if (ndeletable > 0)
{
/*
- * Write-lock the meta page so that we can decrement
- * tuple count.
+ * Write-lock the meta page so that we can decrement tuple count.
*/
LockBuffer(metabuf, BUFFER_LOCK_EXCLUSIVE);
* Mark the page as not containing any LP_DEAD items. This is not
* certainly true (there might be some that have recently been marked,
* but weren't included in our target-item list), but it will almost
- * always be true and it doesn't seem worth an additional page scan
- * to check it. Remember that LH_PAGE_HAS_DEAD_TUPLES is only a hint
+ * always be true and it doesn't seem worth an additional page scan to
+ * check it. Remember that LH_PAGE_HAS_DEAD_TUPLES is only a hint
* anyway.
*/
pageopaque = (HashPageOpaque) PageGetSpecialPointer(page);
/* XLOG stuff */
if (RelationNeedsWAL(rel))
{
- xl_hash_vacuum_one_page xlrec;
+ xl_hash_vacuum_one_page xlrec;
XLogRecPtr recptr;
xlrec.hnode = hnode;
XLogRegisterData((char *) &xlrec, SizeOfHashVacuumOnePage);
/*
- * We need the target-offsets array whether or not we store the whole
- * buffer, to allow us to find the latestRemovedXid on a standby
- * server.
+ * We need the target-offsets array whether or not we store the
+ * whole buffer, to allow us to find the latestRemovedXid on a
+ * standby server.
*/
XLogRegisterData((char *) deletable,
- ndeletable * sizeof(OffsetNumber));
+ ndeletable * sizeof(OffsetNumber));
XLogRegisterBuffer(1, metabuf, REGBUF_STANDARD);
}
END_CRIT_SECTION();
+
/*
- * Releasing write lock on meta page as we have updated
- * the tuple count.
+ * Releasing write lock on meta page as we have updated the tuple
+ * count.
*/
LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
}
pageopaque = (HashPageOpaque) PageGetSpecialPointer(page);
/*
- * Set hasho_prevblkno with current hashm_maxbucket. This value will
- * be used to validate cached HashMetaPageData. See
+ * Set hasho_prevblkno with current hashm_maxbucket. This value will be
+ * used to validate cached HashMetaPageData. See
* _hash_getbucketbuf_from_hashkey().
*/
pageopaque->hasho_prevblkno = max_bucket;
* Choose the number of initial bucket pages to match the fill factor
* given the estimated number of tuples. We round up the result to the
* total number of buckets which has to be allocated before using its
- * _hashm_spare element. However always force at least 2 bucket pages.
- * The upper limit is determined by considerations explained in
+ * _hashm_spare element. However always force at least 2 bucket pages. The
+ * upper limit is determined by considerations explained in
* _hash_expandtable().
*/
dnumbuckets = num_tuples / ffactor;
metap->hashm_maxbucket = num_buckets - 1;
/*
- * Set highmask as next immediate ((2 ^ x) - 1), which should be sufficient
- * to cover num_buckets.
+ * Set highmask as next immediate ((2 ^ x) - 1), which should be
+ * sufficient to cover num_buckets.
*/
metap->hashm_highmask = (1 << (_hash_log2(num_buckets + 1))) - 1;
metap->hashm_lowmask = (metap->hashm_highmask >> 1);
{
/*
* Copy bucket mapping info now; refer to the comment in code below
- * where we copy this information before calling _hash_splitbucket
- * to see why this is okay.
+ * where we copy this information before calling _hash_splitbucket to
+ * see why this is okay.
*/
maxbucket = metap->hashm_maxbucket;
highmask = metap->hashm_highmask;
* We treat allocation of buckets as a separate WAL-logged action.
* Even if we fail after this operation, won't leak bucket pages;
* rather, the next split will consume this space. In any case, even
- * without failure we don't use all the space in one split
- * operation.
+ * without failure we don't use all the space in one split operation.
*/
buckets_to_add = _hash_get_totalbuckets(spare_ndx) - new_bucket;
if (!_hash_alloc_buckets(rel, start_nblkno, buckets_to_add))
/*
* Mark the old bucket to indicate that split is in progress. (At
- * operation end, we will clear the split-in-progress flag.) Also,
- * for a primary bucket page, hasho_prevblkno stores the number of
- * buckets that existed as of the last split, so we must update that
- * value here.
+ * operation end, we will clear the split-in-progress flag.) Also, for a
+ * primary bucket page, hasho_prevblkno stores the number of buckets that
+ * existed as of the last split, so we must update that value here.
*/
oopaque->hasho_flag |= LH_BUCKET_BEING_SPLIT;
oopaque->hasho_prevblkno = maxbucket;
/*
* Initialize the page. Just zeroing the page won't work; see
- * _hash_freeovflpage for similar usage. We take care to make the
- * special space valid for the benefit of tools such as pageinspect.
+ * _hash_freeovflpage for similar usage. We take care to make the special
+ * space valid for the benefit of tools such as pageinspect.
*/
_hash_pageinit(page, BLCKSZ);
* _hash_getcachedmetap() -- Returns cached metapage data.
*
* If metabuf is not InvalidBuffer, caller must hold a pin, but no lock, on
- * the metapage. If not set, we'll set it before returning if we have to
- * refresh the cache, and return with a pin but no lock on it; caller is
- * responsible for releasing the pin.
+ * the metapage. If not set, we'll set it before returning if we have to
+ * refresh the cache, and return with a pin but no lock on it; caller is
+ * responsible for releasing the pin.
*
- * We refresh the cache if it's not initialized yet or force_refresh is true.
+ * We refresh the cache if it's not initialized yet or force_refresh is true.
*/
HashMetaPage
_hash_getcachedmetap(Relation rel, Buffer *metabuf, bool force_refresh)
Assert(metabuf);
if (force_refresh || rel->rd_amcache == NULL)
{
- char *cache = NULL;
+ char *cache = NULL;
/*
- * It's important that we don't set rd_amcache to an invalid
- * value. Either MemoryContextAlloc or _hash_getbuf could fail,
- * so don't install a pointer to the newly-allocated storage in the
- * actual relcache entry until both have succeeeded.
+ * It's important that we don't set rd_amcache to an invalid value.
+ * Either MemoryContextAlloc or _hash_getbuf could fail, so don't
+ * install a pointer to the newly-allocated storage in the actual
+ * relcache entry until both have succeeeded.
*/
if (rel->rd_amcache == NULL)
cache = MemoryContextAlloc(rel->rd_indexcxt,
* us an opportunity to use the previously saved metapage contents to reach
* the target bucket buffer, instead of reading from the metapage every time.
* This saves one buffer access every time we want to reach the target bucket
- * buffer, which is very helpful savings in bufmgr traffic and contention.
+ * buffer, which is very helpful savings in bufmgr traffic and contention.
*
* The access type parameter (HASH_READ or HASH_WRITE) indicates whether the
* bucket buffer has to be locked for reading or writing.
void
_hash_kill_items(IndexScanDesc scan)
{
- HashScanOpaque so = (HashScanOpaque) scan->opaque;
- Page page;
- HashPageOpaque opaque;
- OffsetNumber offnum, maxoff;
- int numKilled = so->numKilled;
- int i;
- bool killedsomething = false;
+ HashScanOpaque so = (HashScanOpaque) scan->opaque;
+ Page page;
+ HashPageOpaque opaque;
+ OffsetNumber offnum,
+ maxoff;
+ int numKilled = so->numKilled;
+ int i;
+ bool killedsomething = false;
Assert(so->numKilled > 0);
Assert(so->killedItems != NULL);
/*
- * Always reset the scan state, so we don't look for same
- * items on other pages.
+ * Always reset the scan state, so we don't look for same items on other
+ * pages.
*/
so->numKilled = 0;
while (offnum <= maxoff)
{
- ItemId iid = PageGetItemId(page, offnum);
+ ItemId iid = PageGetItemId(page, offnum);
IndexTuple ituple = (IndexTuple) PageGetItem(page, iid);
if (ItemPointerEquals(&ituple->t_tid, &so->killedItems[i].heapTid))
/* found the item */
ItemIdMarkDead(iid);
killedsomething = true;
- break; /* out of inner search loop */
+ break; /* out of inner search loop */
}
offnum = OffsetNumberNext(offnum);
}
}
/*
- * Since this can be redone later if needed, mark as dirty hint.
- * Whenever we mark anything LP_DEAD, we also set the page's
+ * Since this can be redone later if needed, mark as dirty hint. Whenever
+ * we mark anything LP_DEAD, we also set the page's
* LH_PAGE_HAS_DEAD_TUPLES flag, which is likewise just a hint.
*/
if (killedsomething)
*
* For HOT considerations, this is wasted effort if we fail to update or
* have to put the new tuple on a different page. But we must compute the
- * list before obtaining buffer lock --- in the worst case, if we are doing
- * an update on one of the relevant system catalogs, we could deadlock if
- * we try to fetch the list later. In any case, the relcache caches the
- * data so this is usually pretty cheap.
+ * list before obtaining buffer lock --- in the worst case, if we are
+ * doing an update on one of the relevant system catalogs, we could
+ * deadlock if we try to fetch the list later. In any case, the relcache
+ * caches the data so this is usually pretty cheap.
*
* We also need columns used by the replica identity and columns that are
* considered the "key" of rows in the table.
page = BufferGetPage(buffer);
interesting_attrs = NULL;
+
/*
* If the page is already full, there is hardly any chance of doing a HOT
* update on this page. It might be wasteful effort to look for index
- * column updates only to later reject HOT updates for lack of space in the
- * same page. So we be conservative and only fetch hot_attrs if the page is
- * not already full. Since we are already holding a pin on the buffer,
- * there is no chance that the buffer can get cleaned up concurrently and
- * even if that was possible, in the worst case we lose a chance to do a
- * HOT update.
+ * column updates only to later reject HOT updates for lack of space in
+ * the same page. So we be conservative and only fetch hot_attrs if the
+ * page is not already full. Since we are already holding a pin on the
+ * buffer, there is no chance that the buffer can get cleaned up
+ * concurrently and even if that was possible, in the worst case we lose a
+ * chance to do a HOT update.
*/
if (!PageIsFull(page))
{
* logged.
*/
old_key_tuple = ExtractReplicaIdentity(relation, &oldtup,
- bms_overlap(modified_attrs, id_attrs),
+ bms_overlap(modified_attrs, id_attrs),
&old_key_copied);
/* NO EREPORT(ERROR) from here till changes are logged */
HeapDetermineModifiedColumns(Relation relation, Bitmapset *interesting_cols,
HeapTuple oldtup, HeapTuple newtup)
{
- int attnum;
- Bitmapset *modified = NULL;
+ int attnum;
+ Bitmapset *modified = NULL;
while ((attnum = bms_first_member(interesting_cols)) >= 0)
{
attnum += FirstLowInvalidHeapAttributeNumber;
if (!heap_tuple_attr_equals(RelationGetDescr(relation),
- attnum, oldtup, newtup))
+ attnum, oldtup, newtup))
modified = bms_add_member(modified,
- attnum - FirstLowInvalidHeapAttributeNumber);
+ attnum - FirstLowInvalidHeapAttributeNumber);
}
return modified;
* scan */
slock_t btps_mutex; /* protects above variables */
ConditionVariable btps_cv; /* used to synchronize parallel scan */
-} BTParallelScanDescData;
+} BTParallelScanDescData;
typedef struct BTParallelScanDescData *BTParallelScanDesc;
_bt_initmetapage(metapage, P_NONE, 0);
/*
- * 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, BTREE_METAPAGE);
smgrwrite(index->rd_smgr, INIT_FORKNUM, BTREE_METAPAGE,
xl_brin_desummarize *xlrec = (xl_brin_desummarize *) rec;
appendStringInfo(buf, "pagesPerRange %u, heapBlk %u, page offset %u",
- xlrec->pagesPerRange, xlrec->heapBlk, xlrec->regOffset);
+ xlrec->pagesPerRange, xlrec->heapBlk, xlrec->regOffset);
}
}
memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
appendStringInfo(buf, "page %d; oldestXact %u",
- xlrec.pageno, xlrec.oldestXact);
+ xlrec.pageno, xlrec.oldestXact);
}
}
if (!(xlrec->flags & GIN_INSERT_ISDATA))
appendStringInfo(buf, " isdelete: %c",
- (((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
+ (((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
else if (xlrec->flags & GIN_INSERT_ISLEAF)
desc_recompress_leaf(buf, (ginxlogRecompressDataLeaf *) payload);
else
{
ginxlogInsertDataInternal *insertData =
- (ginxlogInsertDataInternal *) payload;
+ (ginxlogInsertDataInternal *) payload;
appendStringInfo(buf, " pitem: %u-%u/%u",
- PostingItemGetBlockNumber(&insertData->newitem),
- ItemPointerGetBlockNumber(&insertData->newitem.key),
- ItemPointerGetOffsetNumber(&insertData->newitem.key));
+ PostingItemGetBlockNumber(&insertData->newitem),
+ ItemPointerGetBlockNumber(&insertData->newitem.key),
+ ItemPointerGetOffsetNumber(&insertData->newitem.key));
}
}
}
else
{
ginxlogVacuumDataLeafPage *xlrec =
- (ginxlogVacuumDataLeafPage *) XLogRecGetBlockData(record, 0, NULL);
+ (ginxlogVacuumDataLeafPage *) XLogRecGetBlockData(record, 0, NULL);
desc_recompress_leaf(buf, &xlrec->data);
}
/*
* Write the page and log it unconditionally. This is important
- * particularly for indexes created on tablespaces and databases
- * whose creation happened after the last redo pointer as recovery
- * removes any of their existing content when the corresponding
- * create records are replayed.
+ * particularly for indexes created on tablespaces and databases whose
+ * creation happened after the last redo pointer as recovery removes any
+ * of their existing content when the corresponding create records are
+ * replayed.
*/
PageSetChecksumInplace(page, SPGIST_METAPAGE_BLKNO);
smgrwrite(index->rd_smgr, INIT_FORKNUM, SPGIST_METAPAGE_BLKNO,
static bool CLOGPagePrecedes(int page1, int page2);
static void WriteZeroPageXlogRec(int pageno);
static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact,
- Oid oldestXidDb);
+ Oid oldestXidDb);
static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
TransactionId *subxids, XidStatus status,
XLogRecPtr lsn, int pageno);
/* vac_truncate_clog already advanced oldestXid */
Assert(TransactionIdPrecedesOrEquals(oldestXact,
- ShmemVariableCache->oldestXid));
+ ShmemVariableCache->oldestXid));
/*
- * Write XLOG record and flush XLOG to disk. We record the oldest xid we're
- * keeping information about here so we can ensure that it's always ahead
- * of clog truncation in case we crash, and so a standby finds out the new
- * valid xid before the next checkpoint.
+ * Write XLOG record and flush XLOG to disk. We record the oldest xid
+ * we're keeping information about here so we can ensure that it's always
+ * ahead of clog truncation in case we crash, and so a standby finds out
+ * the new valid xid before the next checkpoint.
*/
WriteTruncateXlogRec(cutoffPage, oldestXact, oldestxid_datoid);
SimpleLruFlush(CommitTsCtl, false);
/*
- * fsync pg_commit_ts to ensure that any files flushed previously are durably
- * on disk.
+ * fsync pg_commit_ts to ensure that any files flushed previously are
+ * durably on disk.
*/
fsync_fname("pg_commit_ts", true);
}
SimpleLruFlush(CommitTsCtl, true);
/*
- * fsync pg_commit_ts to ensure that any files flushed previously are durably
- * on disk.
+ * fsync pg_commit_ts to ensure that any files flushed previously are
+ * durably on disk.
*/
fsync_fname("pg_commit_ts", true);
}
ptr += entryno;
/*
- * It's possible we'll try to set the parent xid multiple times
- * but we shouldn't ever be changing the xid from one valid xid
- * to another valid xid, which would corrupt the data structure.
+ * It's possible we'll try to set the parent xid multiple times but we
+ * shouldn't ever be changing the xid from one valid xid to another valid
+ * xid, which would corrupt the data structure.
*/
if (*ptr != parent)
{
parentXid = SubTransGetParent(parentXid);
/*
- * By convention the parent xid gets allocated first, so should
- * always precede the child xid. Anything else points to a corrupted
- * data structure that could lead to an infinite loop, so exit.
+ * By convention the parent xid gets allocated first, so should always
+ * precede the child xid. Anything else points to a corrupted data
+ * structure that could lead to an infinite loop, so exit.
*/
if (!TransactionIdPrecedes(parentXid, previousXid))
elog(ERROR, "pg_subtrans contains invalid entry: xid %u points to parent xid %u",
- previousXid, parentXid);
+ previousXid, parentXid);
}
Assert(TransactionIdIsValid(previousXid));
*/
XLogRecPtr prepare_start_lsn; /* XLOG offset of prepare record start */
XLogRecPtr prepare_end_lsn; /* XLOG offset of prepare record end */
- TransactionId xid; /* The GXACT id */
+ TransactionId xid; /* The GXACT id */
Oid owner; /* ID of user that executed the xact */
BackendId locking_backend; /* backend currently working on the xact */
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len);
static char *ProcessTwoPhaseBuffer(TransactionId xid,
- XLogRecPtr prepare_start_lsn,
- bool fromdisk, bool setParent, bool setNextXid);
+ XLogRecPtr prepare_start_lsn,
+ bool fromdisk, bool setParent, bool setNextXid);
static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid,
- const char *gid, TimestampTz prepared_at, Oid owner,
- Oid databaseid);
+ const char *gid, TimestampTz prepared_at, Oid owner,
+ Oid databaseid);
static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning);
static void RecreateTwoPhaseFile(TransactionId xid, void *content, int len);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
- errdetail("Failed while allocating a WAL reading processor.")));
+ errdetail("Failed while allocating a WAL reading processor.")));
record = XLogReadRecord(xlogreader, lsn, &errormsg);
if (record == NULL)
(XLogRecGetInfo(xlogreader) & XLOG_XACT_OPMASK) != XLOG_XACT_PREPARE)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("expected two-phase state data is not present in WAL at %X/%X",
- (uint32) (lsn >> 32),
- (uint32) lsn)));
+ errmsg("expected two-phase state data is not present in WAL at %X/%X",
+ (uint32) (lsn >> 32),
+ (uint32) lsn)));
if (len != NULL)
*len = XLogRecGetDataLen(xlogreader);
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
- /* Note that we are using gxact not pgxact so this works in recovery also */
+ /*
+ * Note that we are using gxact not pgxact so this works in recovery
+ * also
+ */
GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
if ((gxact->valid || gxact->inredo) &&
void
restoreTwoPhaseData(void)
{
- DIR *cldir;
- struct dirent *clde;
+ DIR *cldir;
+ struct dirent *clde;
cldir = AllocateDir(TWOPHASE_DIR);
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
xid = gxact->xid;
buf = ProcessTwoPhaseBuffer(xid,
- gxact->prepare_start_lsn,
- gxact->ondisk, false, true);
+ gxact->prepare_start_lsn,
+ gxact->ondisk, false, true);
if (buf == NULL)
continue;
xid = gxact->xid;
buf = ProcessTwoPhaseBuffer(xid,
- gxact->prepare_start_lsn,
- gxact->ondisk, false, false);
+ gxact->prepare_start_lsn,
+ gxact->ondisk, false, false);
if (buf != NULL)
pfree(buf);
}
xid = gxact->xid;
/*
- * Reconstruct subtrans state for the transaction --- needed
- * because pg_subtrans is not preserved over a restart. Note that
- * we are linking all the subtransactions directly to the
- * top-level XID; there may originally have been a more complex
- * hierarchy, but there's no need to restore that exactly.
- * It's possible that SubTransSetParent has been set before, if
- * the prepared transaction generated xid assignment records.
+ * Reconstruct subtrans state for the transaction --- needed because
+ * pg_subtrans is not preserved over a restart. Note that we are
+ * linking all the subtransactions directly to the top-level XID;
+ * there may originally have been a more complex hierarchy, but
+ * there's no need to restore that exactly. It's possible that
+ * SubTransSetParent has been set before, if the prepared transaction
+ * generated xid assignment records.
*/
buf = ProcessTwoPhaseBuffer(xid,
- gxact->prepare_start_lsn,
- gxact->ondisk, true, false);
+ gxact->prepare_start_lsn,
+ gxact->ondisk, true, false);
if (buf == NULL)
continue;
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
/*
- * Recreate its GXACT and dummy PGPROC. But, check whether
- * it was added in redo and already has a shmem entry for
- * it.
+ * Recreate its GXACT and dummy PGPROC. But, check whether it was
+ * added in redo and already has a shmem entry for it.
*/
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
MarkAsPreparingGuts(gxact, xid, gid,
StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids);
/*
- * We're done with recovering this transaction. Clear
- * MyLockedGxact, like we do in PrepareTransaction() during normal
- * operation.
+ * We're done with recovering this transaction. Clear MyLockedGxact,
+ * like we do in PrepareTransaction() during normal operation.
*/
PostPrepare_Twophase();
else
{
ereport(WARNING,
- (errmsg("removing future two-phase state from memory for \"%u\"",
- xid)));
+ (errmsg("removing future two-phase state from memory for \"%u\"",
+ xid)));
PrepareRedoRemove(xid, true);
}
return NULL;
if (buf == NULL)
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state file for \"%u\"",
- xid)));
+ (errmsg("removing corrupt two-phase state file for \"%u\"",
+ xid)));
RemoveTwoPhaseFile(xid, true);
return NULL;
}
if (fromdisk)
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state file for \"%u\"",
- xid)));
+ (errmsg("removing corrupt two-phase state file for \"%u\"",
+ xid)));
RemoveTwoPhaseFile(xid, true);
}
else
{
ereport(WARNING,
- (errmsg("removing corrupt two-phase state from memory for \"%u\"",
- xid)));
+ (errmsg("removing corrupt two-phase state from memory for \"%u\"",
+ xid)));
PrepareRedoRemove(xid, true);
}
pfree(buf);
}
/*
- * Examine subtransaction XIDs ... they should all follow main
- * XID, and they may force us to advance nextXid.
+ * Examine subtransaction XIDs ... they should all follow main XID, and
+ * they may force us to advance nextXid.
*/
subxids = (TransactionId *) (buf +
MAXALIGN(sizeof(TwoPhaseFileHeader)) +
*/
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
if (TransactionIdFollowsOrEquals(subxid,
- ShmemVariableCache->nextXid))
+ ShmemVariableCache->nextXid))
{
ShmemVariableCache->nextXid = subxid;
TransactionIdAdvance(ShmemVariableCache->nextXid);
MyPgXact->delayChkpt = true;
/*
- * Emit the XLOG commit record. Note that we mark 2PC commits as potentially
- * having AccessExclusiveLocks since we don't know whether or not they do.
+ * Emit the XLOG commit record. Note that we mark 2PC commits as
+ * potentially having AccessExclusiveLocks since we don't know whether or
+ * not they do.
*/
recptr = XactLogCommitRecord(committs,
nchildren, children, nrels, rels,
ninvalmsgs, invalmsgs,
initfileinval, false,
- MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
+ MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
xid);
START_CRIT_SECTION();
/*
- * Emit the XLOG commit record. Note that we mark 2PC aborts as potentially
- * having AccessExclusiveLocks since we don't know whether or not they do.
+ * Emit the XLOG commit record. Note that we mark 2PC aborts as
+ * potentially having AccessExclusiveLocks since we don't know whether or
+ * not they do.
*/
recptr = XactLogAbortRecord(GetCurrentTimestamp(),
nchildren, children,
nrels, rels,
- MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
+ MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK,
xid);
/* Always flush, since we're about to remove the 2PC state file */
PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
{
TwoPhaseFileHeader *hdr = (TwoPhaseFileHeader *) buf;
- char *bufptr;
- const char *gid;
+ char *bufptr;
+ const char *gid;
GlobalTransaction gxact;
Assert(RecoveryInProgress());
*
* This creates a gxact struct and puts it into the active array.
*
- * In redo, this struct is mainly used to track PREPARE/COMMIT entries
- * in shared memory. Hence, we only fill up the bare minimum contents here.
+ * In redo, this struct is mainly used to track PREPARE/COMMIT entries in
+ * shared memory. Hence, we only fill up the bare minimum contents here.
* The gxact also gets marked with gxact->inredo set to true to indicate
* that it got added in the redo phase
*/
gxact->locking_backend = InvalidBackendId;
gxact->valid = false;
gxact->ondisk = XLogRecPtrIsInvalid(start_lsn);
- gxact->inredo = true; /* yes, added in redo */
+ gxact->inredo = true; /* yes, added in redo */
strcpy(gxact->gid, gid);
/* And insert it into the active array */
{
LWLockAcquire(CLogTruncationLock, LW_EXCLUSIVE);
if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid,
- oldest_datfrozenxid))
+ oldest_datfrozenxid))
{
ShmemVariableCache->oldestClogXid = oldest_datfrozenxid;
}
* globally accessible, so can be set from anywhere in the code that requires
* recording flags.
*/
-int MyXactFlags;
+int MyXactFlags;
/*
* transaction states - transaction state from server perspective
* do abort cleanup processing
*/
AtCleanup_Portals(); /* now safe to release portal memory */
- AtEOXact_Snapshot(false, true); /* and release the transaction's snapshots */
+ AtEOXact_Snapshot(false, true); /* and release the transaction's
+ * snapshots */
CurrentResourceOwner = NULL; /* and resource owner */
if (TopTransactionResourceOwner)
else if (info == XLOG_XACT_PREPARE)
{
/*
- * Store xid and start/end pointers of the WAL record in
- * TwoPhaseState gxact entry.
+ * Store xid and start/end pointers of the WAL record in TwoPhaseState
+ * gxact entry.
*/
PrepareRedoAdd(XLogRecGetData(record),
record->ReadRecPtr,
bool fullPageWrites;
/*
- * exclusiveBackupState indicates the state of an exclusive backup
- * (see comments of ExclusiveBackupState for more details).
- * nonExclusiveBackups is a counter indicating the number of streaming
- * base backups currently in progress. forcePageWrites is set to true
- * when either of these is non-zero. lastBackupStart is the latest
- * checkpoint redo location used as a starting point for an online
- * backup.
+ * exclusiveBackupState indicates the state of an exclusive backup (see
+ * comments of ExclusiveBackupState for more details). nonExclusiveBackups
+ * is a counter indicating the number of streaming base backups currently
+ * in progress. forcePageWrites is set to true when either of these is
+ * non-zero. lastBackupStart is the latest checkpoint redo location used
+ * as a starting point for an online backup.
*/
ExclusiveBackupState exclusiveBackupState;
int nonExclusiveBackups;
*/
if ((flags & XLOG_MARK_UNIMPORTANT) == 0)
{
- int lockno = holdingAllLocks ? 0 : MyLockNo;
+ int lockno = holdingAllLocks ? 0 : MyLockNo;
WALInsertLocks[lockno].l.lastImportantAt = StartPos;
}
/*
* If the block LSN is already ahead of this WAL record, we can't
- * expect contents to match. This can happen if recovery is restarted.
+ * expect contents to match. This can happen if recovery is
+ * restarted.
*/
if (PageGetLSN(replay_image_masked) > record->EndRecPtr)
continue;
sysidentifier |= getpid() & 0xFFF;
/*
- * Generate a random nonce. This is used for authentication requests
- * that will fail because the user does not exist. The nonce is used to
- * create a genuine-looking password challenge for the non-existent user,
- * in lieu of an actual stored password.
+ * Generate a random nonce. This is used for authentication requests that
+ * will fail because the user does not exist. The nonce is used to create
+ * a genuine-looking password challenge for the non-existent user, in lieu
+ * of an actual stored password.
*/
if (!pg_backend_random(mock_auth_nonce, MOCK_AUTH_NONCE_LEN))
ereport(PANIC,
- (errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("could not generate secret authorization token")));
+ (errcode(ERRCODE_INTERNAL_ERROR),
+ errmsg("could not generate secret authorization token")));
/* First timeline ID is always 1 */
ThisTimeLineID = 1;
DatumGetLSN(DirectFunctionCall3(pg_lsn_in,
CStringGetDatum(item->value),
ObjectIdGetDatum(InvalidOid),
- Int32GetDatum(-1)));
+ Int32GetDatum(-1)));
ereport(DEBUG2,
(errmsg_internal("recovery_target_lsn = '%X/%X'",
(uint32) (recoveryTargetLSN >> 32),
recoveryStopTime = 0;
recoveryStopName[0] = '\0';
ereport(LOG,
- (errmsg("recovery stopping before WAL location (LSN) \"%X/%X\"",
- (uint32) (recoveryStopLSN >> 32),
- (uint32) recoveryStopLSN)));
+ (errmsg("recovery stopping before WAL location (LSN) \"%X/%X\"",
+ (uint32) (recoveryStopLSN >> 32),
+ (uint32) recoveryStopLSN)));
return true;
}
recoveryStopTime = 0;
recoveryStopName[0] = '\0';
ereport(LOG,
- (errmsg("recovery stopping after WAL location (LSN) \"%X/%X\"",
- (uint32) (recoveryStopLSN >> 32),
- (uint32) recoveryStopLSN)));
+ (errmsg("recovery stopping after WAL location (LSN) \"%X/%X\"",
+ (uint32) (recoveryStopLSN >> 32),
+ (uint32) recoveryStopLSN)));
return true;
}
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
- errdetail("Failed while allocating a WAL reading processor.")));
+ errdetail("Failed while allocating a WAL reading processor.")));
xlogreader->system_identifier = ControlFile->system_identifier;
/*
- * Allocate pages dedicated to WAL consistency checks, those had better
- * be aligned.
+ * Allocate pages dedicated to WAL consistency checks, those had better be
+ * aligned.
*/
replay_image_masked = (char *) palloc(BLCKSZ);
master_image_masked = (char *) palloc(BLCKSZ);
/*
* Copy any missing timeline history files between 'now' and the recovery
- * target timeline from archive to pg_wal. While we don't need those
- * files ourselves - the history file of the recovery target timeline
- * covers all the previous timelines in the history too - a cascading
- * standby server might be interested in them. Or, if you archive the WAL
- * from this server to a different archive than the master, it'd be good
- * for all the history files to get archived there after failover, so that
- * you can use one of the old timelines as a PITR target. Timeline history
- * files are small, so it's better to copy them unnecessarily than not
- * copy them and regret later.
+ * target timeline from archive to pg_wal. While we don't need those files
+ * ourselves - the history file of the recovery target timeline covers all
+ * the previous timelines in the history too - a cascading standby server
+ * might be interested in them. Or, if you archive the WAL from this
+ * server to a different archive than the master, it'd be good for all the
+ * history files to get archived there after failover, so that you can use
+ * one of the old timelines as a PITR target. Timeline history files are
+ * small, so it's better to copy them unnecessarily than not copy them and
+ * regret later.
*/
restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI);
/*
- * Before running in recovery, scan pg_twophase and fill in its status
- * to be able to work on entries generated by redo. Doing a scan before
+ * Before running in recovery, scan pg_twophase and fill in its status to
+ * be able to work on entries generated by redo. Doing a scan before
* taking any recovery action has the merit to discard any 2PC files that
* are newer than the first record to replay, saving from any conflicts at
* replay. This avoids as well any subsequent scans when doing recovery
snprintf(reason, sizeof(reason),
"%s LSN %X/%X\n",
recoveryStopAfter ? "after" : "before",
- (uint32 ) (recoveryStopLSN >> 32),
+ (uint32) (recoveryStopLSN >> 32),
(uint32) recoveryStopLSN);
else if (recoveryTarget == RECOVERY_TARGET_NAME)
snprintf(reason, sizeof(reason),
MultiXactAdvanceOldest(checkPoint.oldestMulti,
checkPoint.oldestMultiDB);
+
/*
* No need to set oldestClogXid here as well; it'll be set when we
* redo an xl_clog_truncate if it changed since initialization.
if (exclusive)
{
/*
- * At first, mark that we're now starting an exclusive backup,
- * to ensure that there are no other sessions currently running
+ * At first, mark that we're now starting an exclusive backup, to
+ * ensure that there are no other sessions currently running
* pg_start_backup() or pg_stop_backup().
*/
if (XLogCtl->Insert.exclusiveBackupState != EXCLUSIVE_BACKUP_NONE)
{
/*
* Check for existing backup label --- implies a backup is already
- * running. (XXX given that we checked exclusiveBackupState above,
- * maybe it would be OK to just unlink any such label file?)
+ * running. (XXX given that we checked exclusiveBackupState
+ * above, maybe it would be OK to just unlink any such label
+ * file?)
*/
if (stat(BACKUP_LABEL_FILE, &stat_buf) != 0)
{
if (exclusive)
{
/*
- * At first, mark that we're now stopping an exclusive backup,
- * to ensure that there are no other sessions currently running
+ * At first, mark that we're now stopping an exclusive backup, to
+ * ensure that there are no other sessions currently running
* pg_start_backup() or pg_stop_backup().
*/
WALInsertLockAcquireExclusive();
durable_unlink(BACKUP_LABEL_FILE, ERROR);
/*
- * Remove tablespace_map file if present, it is created only if there
- * are tablespaces.
+ * Remove tablespace_map file if present, it is created only if
+ * there are tablespaces.
*/
durable_unlink(TABLESPACE_MAP, DEBUG1);
}
* archived before returning. If archiving isn't enabled, the required WAL
* needs to be transported via streaming replication (hopefully with
* wal_keep_segments set high enough), or some more exotic mechanism like
- * polling and copying files from pg_wal with script. We have no
- * knowledge of those mechanisms, so it's up to the user to ensure that he
- * gets all the required WAL.
+ * polling and copying files from pg_wal with script. We have no knowledge
+ * of those mechanisms, so it's up to the user to ensure that he gets all
+ * the required WAL.
*
* We wait until both the last WAL file filled during backup and the
* history file have been archived, and assume that the alphabetic sorting
* We wait forever, since archive_command is supposed to work and we
* assume the admin wanted his backup to work completely. If you don't
* wish to wait, then either waitforarchive should be passed in as false,
- * or you can set statement_timeout. Also, some notices are
- * issued to clue in anyone who might be doing this interactively.
+ * or you can set statement_timeout. Also, some notices are issued to
+ * clue in anyone who might be doing this interactively.
*/
if (waitforarchive && XLogArchivingActive())
{
* little chance that the problem will just go away, but
* PANIC is not good for availability either, especially
* in hot standby mode. So, we treat that the same as
- * disconnection, and retry from archive/pg_wal again.
- * The WAL in the archive should be identical to what was
+ * disconnection, and retry from archive/pg_wal again. The
+ * WAL in the archive should be identical to what was
* streamed, so it's unlikely that it helps, but one can
* hope...
*/
* not open already. Also read the timeline history
* file if we haven't initialized timeline history
* yet; it should be streamed over and present in
- * pg_wal by now. Use XLOG_FROM_STREAM so that
- * source info is set correctly and XLogReceiptTime
- * isn't changed.
+ * pg_wal by now. Use XLOG_FROM_STREAM so that source
+ * info is set correctly and XLogReceiptTime isn't
+ * changed.
*/
if (readFile < 0)
{
* Exclusive backups were typically started in a different connection, so
* don't try to verify that status of backup is set to
* SESSION_BACKUP_EXCLUSIVE in this function. Actual verification that an
- * exclusive backup is in fact running is handled inside do_pg_stop_backup.
+ * exclusive backup is in fact running is handled inside
+ * do_pg_stop_backup.
*/
stoppoint = do_pg_stop_backup(NULL, true, NULL);
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("recovery is in progress"),
- errhint("pg_walfile_name() cannot be executed during recovery.")));
+ errhint("pg_walfile_name() cannot be executed during recovery.")));
XLByteToPrevSeg(locationpoint, xlogsegno);
XLogFileName(xlogfilename, ThisTimeLineID, xlogsegno);
*
* The flags that can be used here are:
* - XLOG_INCLUDE_ORIGIN, to determine if the replication origin should be
- * included in the record.
+ * included in the record.
* - XLOG_MARK_UNIMPORTANT, to signal that the record is not important for
- * durability, which allows to avoid triggering WAL archiving and other
- * background activity.
+ * durability, which allows to avoid triggering WAL archiving and other
+ * background activity.
*/
void
XLogSetRecordFlags(uint8 flags)
hdr_rdt.data = hdr_scratch;
/*
- * Enforce consistency checks for this record if user is looking for
- * it. Do this before at the beginning of this routine to give the
- * possibility for callers of XLogInsert() to pass XLR_CHECK_CONSISTENCY
- * directly for a record.
+ * Enforce consistency checks for this record if user is looking for it.
+ * Do this before at the beginning of this routine to give the possibility
+ * for callers of XLogInsert() to pass XLR_CHECK_CONSISTENCY directly for
+ * a record.
*/
if (wal_consistency_checking[rmid])
info |= XLR_CHECK_CONSISTENCY;
bkpb.fork_flags |= BKPBLOCK_WILL_INIT;
/*
- * If needs_backup is true or WAL checking is enabled for
- * current resource manager, log a full-page write for the current
- * block.
+ * If needs_backup is true or WAL checking is enabled for current
+ * resource manager, log a full-page write for the current block.
*/
include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
bimg.bimg_info = (cbimg.hole_length == 0) ? 0 : BKPIMAGE_HAS_HOLE;
/*
- * If WAL consistency checking is enabled for the resource manager of
- * this WAL record, a full-page image is included in the record
+ * If WAL consistency checking is enabled for the resource manager
+ * of this WAL record, a full-page image is included in the record
* for the block modified. During redo, the full-page is replayed
* only if BKPIMAGE_APPLY is set.
*/
* that, except when caller has explicitly specified the offset that
* falls somewhere there or when we are skipping multi-page
* continuation record. It doesn't matter though because
- * ReadPageInternal() is prepared to handle that and will read at least
- * short page-header worth of data
+ * ReadPageInternal() is prepared to handle that and will read at
+ * least short page-header worth of data
*/
targetRecOff = tmpRecPtr % XLOG_BLCKSZ;
Assert(state->readLen == 0 || state->readLen <= XLOG_BLCKSZ);
/*
- * If the desired page is currently read in and valid, we have nothing to do.
+ * If the desired page is currently read in and valid, we have nothing to
+ * do.
*
* The caller should've ensured that it didn't previously advance readOff
- * past the valid limit of this timeline, so it doesn't matter if the current
- * TLI has since become historical.
+ * past the valid limit of this timeline, so it doesn't matter if the
+ * current TLI has since become historical.
*/
if (lastReadPage == wantPage &&
state->readLen != 0 &&
- lastReadPage + state->readLen >= wantPage + Min(wantLength,XLOG_BLCKSZ-1))
+ lastReadPage + state->readLen >= wantPage + Min(wantLength, XLOG_BLCKSZ - 1))
return;
/*
* If we're reading from the current timeline, it hasn't become historical
* and the page we're reading is after the last page read, we can again
- * just carry on. (Seeking backwards requires a check to make sure the older
- * page isn't on a prior timeline).
+ * just carry on. (Seeking backwards requires a check to make sure the
+ * older page isn't on a prior timeline).
*
* ThisTimeLineID might've become historical since we last looked, but the
* caller is required not to read past the flush limit it saw at the time
/*
* If we're just reading pages from a previously validated historical
- * timeline and the timeline we're reading from is valid until the
- * end of the current segment we can just keep reading.
+ * timeline and the timeline we're reading from is valid until the end of
+ * the current segment we can just keep reading.
*/
if (state->currTLIValidUntil != InvalidXLogRecPtr &&
state->currTLI != ThisTimeLineID &&
return;
/*
- * If we reach this point we're either looking up a page for random access,
- * the current timeline just became historical, or we're reading from a new
- * segment containing a timeline switch. In all cases we need to determine
- * the newest timeline on the segment.
+ * If we reach this point we're either looking up a page for random
+ * access, the current timeline just became historical, or we're reading
+ * from a new segment containing a timeline switch. In all cases we need
+ * to determine the newest timeline on the segment.
*
* If it's the current timeline we can just keep reading from here unless
* we detect a timeline switch that makes the current timeline historical.
* We need to re-read the timeline history in case it's been changed
* by a promotion or replay from a cascaded replica.
*/
- List *timelineHistory = readTimeLineHistory(ThisTimeLineID);
+ List *timelineHistory = readTimeLineHistory(ThisTimeLineID);
- XLogRecPtr endOfSegment = (((wantPage / XLogSegSize) + 1) * XLogSegSize) - 1;
+ XLogRecPtr endOfSegment = (((wantPage / XLogSegSize) + 1) * XLogSegSize) - 1;
Assert(wantPage / XLogSegSize == endOfSegment / XLogSegSize);
- /* Find the timeline of the last LSN on the segment containing wantPage. */
+ /*
+ * Find the timeline of the last LSN on the segment containing
+ * wantPage.
+ */
state->currTLI = tliOfPointInHistory(endOfSegment, timelineHistory);
state->currTLIValidUntil = tliSwitchPoint(state->currTLI, timelineHistory,
- &state->nextTLI);
+ &state->nextTLI);
Assert(state->currTLIValidUntil == InvalidXLogRecPtr ||
- wantPage + wantLength < state->currTLIValidUntil);
+ wantPage + wantLength < state->currTLIValidUntil);
list_free_deep(timelineHistory);
elog(DEBUG3, "switched to timeline %u valid until %X/%X",
- state->currTLI,
- (uint32)(state->currTLIValidUntil >> 32),
- (uint32)(state->currTLIValidUntil));
+ state->currTLI,
+ (uint32) (state->currTLIValidUntil >> 32),
+ (uint32) (state->currTLIValidUntil));
}
}
*
* We have to do it each time through the loop because if we're in
* recovery as a cascading standby, the current timeline might've
- * become historical. We can't rely on RecoveryInProgress() because
- * in a standby configuration like
+ * become historical. We can't rely on RecoveryInProgress() because in
+ * a standby configuration like
*
- * A => B => C
+ * A => B => C
*
* if we're a logical decoding session on C, and B gets promoted, our
* timeline will change while we remain in recovery.
*
* We can't just keep reading from the old timeline as the last WAL
- * archive in the timeline will get renamed to .partial by StartupXLOG().
+ * archive in the timeline will get renamed to .partial by
+ * StartupXLOG().
*
* If that happens after our caller updated ThisTimeLineID but before
* we actually read the xlog page, we might still try to read from the
- * old (now renamed) segment and fail. There's not much we can do about
- * this, but it can only happen when we're a leaf of a cascading
+ * old (now renamed) segment and fail. There's not much we can do
+ * about this, but it can only happen when we're a leaf of a cascading
* standby whose master gets promoted while we're decoding, so a
* one-off ERROR isn't too bad.
*/
heap_drop_with_catalog(object->objectId);
}
- /* for a sequence, in addition to dropping the heap, also
- * delete pg_sequence tuple */
+ /*
+ * for a sequence, in addition to dropping the heap, also
+ * delete pg_sequence tuple
+ */
if (relKind == RELKIND_SEQUENCE)
DeleteSequenceTuple(object->objectId);
break;
}
else if (IsA(node, NextValueExpr))
{
- NextValueExpr *nve = (NextValueExpr *) node;
+ NextValueExpr *nve = (NextValueExpr *) node;
add_object_address(OCLASS_CLASS, nve->seqid, 0,
context->addrs);
/*
* To drop a partition safely, we must grab exclusive lock on its parent,
* because another backend might be about to execute a query on the parent
- * table. If it relies on previously cached partition descriptor, then
- * it could attempt to access the just-dropped relation as its partition.
- * We must therefore take a table lock strong enough to prevent all
- * queries on the table from proceeding until we commit and send out a
+ * table. If it relies on previously cached partition descriptor, then it
+ * could attempt to access the just-dropped relation as its partition. We
+ * must therefore take a table lock strong enough to prevent all queries
+ * on the table from proceeding until we commit and send out a
* shared-cache-inval notice that will make them update their index lists.
*/
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
objlist = castNode(List, object);
domaddr = get_object_address_type(OBJECT_DOMAIN,
- linitial_node(TypeName, objlist),
+ linitial_node(TypeName, objlist),
missing_ok);
constrname = strVal(lsecond(objlist));
case OBJECT_PUBLICATION:
case OBJECT_SUBSCRIPTION:
address = get_object_address_unqualified(objtype,
- (Value *) object, missing_ok);
+ (Value *) object, missing_ok);
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
if (relation != NULL)
heap_close(relation, AccessShareLock);
- relation = NULL; /* department of accident prevention */
+ relation = NULL; /* department of accident prevention */
return address;
}
relname = linitial(object);
relation = relation_openrv_extended(makeRangeVarFromNameList(relname),
- AccessShareLock, missing_ok);
+ AccessShareLock, missing_ok);
if (!relation)
return address;
if (list_length(name) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("name list length must be exactly %d", 1)));
+ errmsg("name list length must be exactly %d", 1)));
objnode = linitial(name);
break;
case OBJECT_TYPE:
case OBJECT_FUNCTION:
case OBJECT_AGGREGATE:
case OBJECT_OPERATOR:
- {
- ObjectWithArgs *owa = makeNode(ObjectWithArgs);
+ {
+ ObjectWithArgs *owa = makeNode(ObjectWithArgs);
- owa->objname = name;
- owa->objargs = args;
- objnode = (Node *) owa;
- break;
- }
+ owa->objname = name;
+ owa->objargs = args;
+ objnode = (Node *) owa;
+ break;
+ }
case OBJECT_LARGEOBJECT:
/* already handled above */
break;
- /* no default, to let compiler warn about missing case */
+ /* no default, to let compiler warn about missing case */
}
if (objnode == NULL)
{
HeapTuple tup;
char *pubname;
- Form_pg_publication_rel prform;
+ Form_pg_publication_rel prform;
tup = SearchSysCache1(PUBLICATIONREL,
ObjectIdGetDatum(object->objectId));
{
HeapTuple tup;
char *pubname;
- Form_pg_publication_rel prform;
+ Form_pg_publication_rel prform;
tup = SearchSysCache1(PUBLICATIONREL,
ObjectIdGetDatum(object->objectId));
if (object)
*object = list_make3(pstrdup(NameStr(amForm->amname)),
- pstrdup(schema),
- pstrdup(NameStr(opfForm->opfname)));
+ pstrdup(schema),
+ pstrdup(NameStr(opfForm->opfname)));
ReleaseSysCache(amTup);
ReleaseSysCache(opfTup);
if (if_not_exists)
{
ereport(NOTICE,
- (errcode(ERRCODE_DUPLICATE_OBJECT),
- collencoding == -1
- ? errmsg("collation \"%s\" already exists, skipping",
- collname)
- : errmsg("collation \"%s\" for encoding \"%s\" already exists, skipping",
- collname, pg_encoding_to_char(collencoding))));
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ collencoding == -1
+ ? errmsg("collation \"%s\" already exists, skipping",
+ collname)
+ : errmsg("collation \"%s\" for encoding \"%s\" already exists, skipping",
+ collname, pg_encoding_to_char(collencoding))));
return InvalidOid;
}
else
collencoding == -1
? errmsg("collation \"%s\" already exists",
collname)
- : errmsg("collation \"%s\" for encoding \"%s\" already exists",
- collname, pg_encoding_to_char(collencoding))));
+ : errmsg("collation \"%s\" for encoding \"%s\" already exists",
+ collname, pg_encoding_to_char(collencoding))));
}
/* open pg_collation; see below about the lock level */
{
heap_close(rel, NoLock);
ereport(NOTICE,
- (errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("collation \"%s\" already exists, skipping",
- collname)));
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("collation \"%s\" already exists, skipping",
+ collname)));
return InvalidOid;
}
else
ereport(ERROR,
- (errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("collation \"%s\" already exists",
- collname)));
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("collation \"%s\" already exists",
+ collname)));
}
tupDesc = RelationGetDescr(rel);
Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup);
/*
- * We assume any auto or internal dependency of a sequence on a column must be
- * what we are looking for. (We need the relkind test because indexes
- * can also have auto dependencies on columns.)
+ * We assume any auto or internal dependency of a sequence on a column
+ * must be what we are looking for. (We need the relkind test because
+ * indexes can also have auto dependencies on columns.)
*/
if (deprec->classid == RelationRelationId &&
deprec->objsubid == 0 &&
*/
typedef struct SeenRelsEntry
{
- Oid rel_id; /* relation oid */
- ListCell *numparents_cell; /* corresponding list cell */
+ Oid rel_id; /* relation oid */
+ ListCell *numparents_cell; /* corresponding list cell */
} SeenRelsEntry;
/*
find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
{
/* hash table for O(1) rel_oid -> rel_numparents cell lookup */
- HTAB *seen_rels;
- HASHCTL ctl;
+ HTAB *seen_rels;
+ HASHCTL ctl;
List *rels_list,
*rel_numparents;
ListCell *l;
foreach(lc, currentchildren)
{
Oid child_oid = lfirst_oid(lc);
- bool found;
- SeenRelsEntry *hash_entry;
+ bool found;
+ SeenRelsEntry *hash_entry;
hash_entry = hash_search(seen_rels, &child_oid, HASH_ENTER, &found);
if (found)
TupleDesc tupDesc;
ObjectAddress myself;
int i;
- Acl *nspacl;
+ Acl *nspacl;
/* sanity checks */
if (!nspName)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"%s\" is a system table",
RelationGetRelationName(targetrel)),
- errdetail("System tables cannot be added to publications.")));
+ errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
if (!RelationNeedsWAL(targetrel))
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
RelationGetRelationName(targetrel)),
- errdetail("Temporary and unlogged relations cannot be replicated.")));
+ errdetail("Temporary and unlogged relations cannot be replicated.")));
}
/*
Oid relid = RelationGetRelid(targetrel);
Oid prrelid;
Publication *pub = GetPublication(pubid);
- ObjectAddress myself,
- referenced;
+ ObjectAddress myself,
+ referenced;
rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("relation \"%s\" is already member of publication \"%s\"",
- RelationGetRelationName(targetrel), pub->name)));
+ errmsg("relation \"%s\" is already member of publication \"%s\"",
+ RelationGetRelationName(targetrel), pub->name)));
}
check_publication_add_relation(targetrel);
List *
GetRelationPublications(Oid relid)
{
- List *result = NIL;
- CatCList *pubrellist;
- int i;
+ List *result = NIL;
+ CatCList *pubrellist;
+ int i;
/* Find all publications associated with the relation. */
pubrellist = SearchSysCacheList1(PUBLICATIONRELMAP,
List *
GetPublicationRelations(Oid pubid)
{
- List *result;
- Relation pubrelsrel;
- ScanKeyData scankey;
- SysScanDesc scan;
- HeapTuple tup;
+ List *result;
+ Relation pubrelsrel;
+ ScanKeyData scankey;
+ SysScanDesc scan;
+ HeapTuple tup;
/* Find all publications associated with the relation. */
pubrelsrel = heap_open(PublicationRelRelationId, AccessShareLock);
result = NIL;
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_publication_rel pubrel;
+ Form_pg_publication_rel pubrel;
pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
List *
GetAllTablesPublications(void)
{
- List *result;
- Relation rel;
- ScanKeyData scankey;
- SysScanDesc scan;
- HeapTuple tup;
+ List *result;
+ Relation rel;
+ ScanKeyData scankey;
+ SysScanDesc scan;
+ HeapTuple tup;
/* Find all publications that are marked as for all tables. */
rel = heap_open(PublicationRelationId, AccessShareLock);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
- Oid relid = HeapTupleGetOid(tuple);
- Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
+ Oid relid = HeapTupleGetOid(tuple);
+ Form_pg_class relForm = (Form_pg_class) GETSTRUCT(tuple);
if (is_publishable_class(relid, relForm))
result = lappend_oid(result, relid);
Publication *
GetPublication(Oid pubid)
{
- HeapTuple tup;
- Publication *pub;
- Form_pg_publication pubform;
+ HeapTuple tup;
+ Publication *pub;
+ Form_pg_publication pubform;
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
char *
get_publication_name(Oid pubid)
{
- HeapTuple tup;
- char *pubname;
- Form_pg_publication pubform;
+ HeapTuple tup;
+ char *pubname;
+ Form_pg_publication pubform;
tup = SearchSysCache1(PUBLICATIONOID, ObjectIdGetDatum(pubid));
pg_get_publication_tables(PG_FUNCTION_ARGS)
{
FuncCallContext *funcctx;
- char *pubname = text_to_cstring(PG_GETARG_TEXT_PP(0));
- Publication *publication;
- List *tables;
- ListCell **lcp;
+ char *pubname = text_to_cstring(PG_GETARG_TEXT_PP(0));
+ Publication *publication;
+ List *tables;
+ ListCell **lcp;
/* stuff done only on the first call of the function */
if (SRF_IS_FIRSTCALL())
while (*lcp != NULL)
{
- Oid relid = lfirst_oid(*lcp);
+ Oid relid = lfirst_oid(*lcp);
*lcp = lnext(*lcp);
SRF_RETURN_NEXT(funcctx, ObjectIdGetDatum(relid));
Subscription *
GetSubscription(Oid subid, bool missing_ok)
{
- HeapTuple tup;
- Subscription *sub;
- Form_pg_subscription subform;
- Datum datum;
- bool isnull;
+ HeapTuple tup;
+ Subscription *sub;
+ Form_pg_subscription subform;
+ Datum datum;
+ bool isnull;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
int
CountDBSubscriptions(Oid dbid)
{
- int nsubs = 0;
- Relation rel;
- ScanKeyData scankey;
- SysScanDesc scan;
- HeapTuple tup;
+ int nsubs = 0;
+ Relation rel;
+ ScanKeyData scankey;
+ SysScanDesc scan;
+ HeapTuple tup;
rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
char *
get_subscription_name(Oid subid)
{
- HeapTuple tup;
- char *subname;
+ HeapTuple tup;
+ char *subname;
Form_pg_subscription subform;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
static List *
textarray_to_stringlist(ArrayType *textarray)
{
- Datum *elems;
- int nelems, i;
- List *res = NIL;
+ Datum *elems;
+ int nelems,
+ i;
+ List *res = NIL;
deconstruct_array(textarray,
TEXTOID, -1, false, 'i',
*/
Oid
SetSubscriptionRelState(Oid subid, Oid relid, char state,
- XLogRecPtr sublsn)
+ XLogRecPtr sublsn)
{
Relation rel;
HeapTuple tup;
ObjectIdGetDatum(subid));
/*
- * If the record for given table does not exist yet create new
- * record, otherwise update the existing one.
+ * If the record for given table does not exist yet create new record,
+ * otherwise update the existing one.
*/
if (!HeapTupleIsValid(tup))
{
Relation rel;
HeapTuple tup;
int nkeys = 0;
- ScanKeyData skey[2];
- SysScanDesc scan;
+ ScanKeyData skey[2];
+ SysScanDesc scan;
rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
- SubscriptionRelState *relstate;
+ Form_pg_subscription_rel subrel;
+ SubscriptionRelState *relstate;
subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
- relstate = (SubscriptionRelState *)palloc(sizeof(SubscriptionRelState));
+ relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
relstate->lsn = subrel->srsublsn;
Relation rel;
HeapTuple tup;
int nkeys = 0;
- ScanKeyData skey[2];
- SysScanDesc scan;
+ ScanKeyData skey[2];
+ SysScanDesc scan;
rel = heap_open(SubscriptionRelRelationId, AccessShareLock);
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
- SubscriptionRelState *relstate;
+ Form_pg_subscription_rel subrel;
+ SubscriptionRelState *relstate;
subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
- relstate = (SubscriptionRelState *)palloc(sizeof(SubscriptionRelState));
+ relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
relstate->lsn = subrel->srsublsn;
address =
get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
- &rel, AccessExclusiveLock, false);
+ &rel, AccessExclusiveLock, false);
/*
* If a relation was involved, it would have been opened and locked. We
nrels,
i;
ListCell *lc;
- bool has_child;
+ bool has_child;
/*
* Find all members of inheritance set. We only need AccessShareLock on
elog(ERROR, "invalid collation version change");
else if (oldversion && newversion && strcmp(newversion, oldversion) != 0)
{
- bool nulls[Natts_pg_collation];
- bool replaces[Natts_pg_collation];
- Datum values[Natts_pg_collation];
+ bool nulls[Natts_pg_collation];
+ bool replaces[Natts_pg_collation];
+ Datum values[Natts_pg_collation];
ereport(NOTICE,
(errmsg("changing version from %s to %s",
uloc_toLanguageTag(localename, buf, sizeof(buf), TRUE, &status);
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("could not convert locale name \"%s\" to language tag: %s",
- localename, u_errorName(status))));
+ (errmsg("could not convert locale name \"%s\" to language tag: %s",
+ localename, u_errorName(status))));
return pstrdup(buf);
}
return result;
}
-#endif /* USE_ICU */
+#endif /* USE_ICU */
Datum
CollationCreate(localebuf, nspid, GetUserId(), COLLPROVIDER_LIBC, enc,
localebuf, localebuf,
- get_collation_actual_version(COLLPROVIDER_LIBC, localebuf),
+ get_collation_actual_version(COLLPROVIDER_LIBC, localebuf),
if_not_exists);
CommandCounterIncrement();
CollationCreate(alias, nspid, GetUserId(), COLLPROVIDER_LIBC, enc,
locale, locale,
- get_collation_actual_version(COLLPROVIDER_LIBC, locale),
+ get_collation_actual_version(COLLPROVIDER_LIBC, locale),
true);
CommandCounterIncrement();
}
}
else
{
- int i;
+ int i;
/*
* Start the loop at -1 to sneak in the root locale without too much
Oid collid;
if (i == -1)
- name = ""; /* ICU root locale */
+ name = ""; /* ICU root locale */
else
name = ucol_getAvailable(i);
collid = CollationCreate(psprintf("%s-x-icu", langtag),
nspid, GetUserId(), COLLPROVIDER_ICU, -1,
collcollate, collcollate,
- get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
+ get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
if_not_exists);
CreateComments(collid, CollationRelationId, 0,
en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status);
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("could not get keyword values for locale \"%s\": %s",
- name, u_errorName(status))));
+ (errmsg("could not get keyword values for locale \"%s\": %s",
+ name, u_errorName(status))));
status = U_ZERO_ERROR;
uenum_reset(en, &status);
while ((val = uenum_next(en, NULL, &status)))
{
- char *localeid = psprintf("%s@collation=%s", name, val);
+ char *localeid = psprintf("%s@collation=%s", name, val);
- langtag = get_icu_language_tag(localeid);
+ langtag = get_icu_language_tag(localeid);
collcollate = U_ICU_VERSION_MAJOR_NUM >= 54 ? langtag : localeid;
collid = CollationCreate(psprintf("%s-x-icu", langtag),
- nspid, GetUserId(), COLLPROVIDER_ICU, -1,
+ nspid, GetUserId(), COLLPROVIDER_ICU, -1,
collcollate, collcollate,
- get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
+ get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
if_not_exists);
CreateComments(collid, CollationRelationId, 0,
get_icu_locale_comment(localeid));
}
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("could not get keyword values for locale \"%s\": %s",
- name, u_errorName(status))));
+ (errmsg("could not get keyword values for locale \"%s\": %s",
+ name, u_errorName(status))));
uenum_close(en);
}
}
List *attnumlist; /* integer list of attnums to copy */
char *filename; /* filename, or NULL for STDIN/STDOUT */
bool is_program; /* is 'filename' a program to popen? */
- copy_data_source_cb data_source_cb; /* function for reading data*/
+ copy_data_source_cb data_source_cb; /* function for reading data */
bool binary; /* binary format? */
bool oids; /* include OIDs? */
bool freeze; /* freeze rows on loading? */
(void) pq_putmessage('d', fe_msgbuf->data, fe_msgbuf->len);
break;
case COPY_CALLBACK:
- Assert(false); /* Not yet supported. */
+ Assert(false); /* Not yet supported. */
break;
}
{
ereport(ERROR,
(errcode(ERRCODE_OBJECT_IN_USE),
- errmsg("database \"%s\" is used by an active logical replication slot",
- dbname),
+ errmsg("database \"%s\" is used by an active logical replication slot",
+ dbname),
errdetail_plural("There is %d active slot",
"There are %d active slots",
nslots_active, nslots_active)));
* which can happen in some cases.
*
* This will lock out walsenders trying to connect to db-specific
- * slots for logical decoding too, so it's safe for us to drop slots.
+ * slots for logical decoding too, so it's safe for us to drop
+ * slots.
*/
LockSharedObjectForSession(DatabaseRelationId, xlrec->db_id, 0, AccessExclusiveLock);
ResolveRecoveryConflictWithDatabase(xlrec->db_id);
if (nodeTag(def->arg) != T_List)
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
- foreach(cell, (List *)def->arg)
+ foreach(cell, (List *) def->arg)
{
Node *str = (Node *) lfirst(cell);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an aggregate function",
- NameListToString(castNode(ObjectWithArgs, object)->objname)),
+ NameListToString(castNode(ObjectWithArgs, object)->objname)),
errhint("Use DROP AGGREGATE to drop aggregate functions.")));
ReleaseSysCache(tup);
RangeVar *parent_rel;
parent_object = list_truncate(list_copy(object),
- list_length(object) - 1);
+ list_length(object) - 1);
if (schema_does_not_exist_skipping(parent_object, msg, name))
return true;
case OBJECT_FUNCTION:
{
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
{
case OBJECT_AGGREGATE:
{
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
{
case OBJECT_OPERATOR:
{
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
{
msg = gettext_noop("trigger \"%s\" for relation \"%s\" does not exist, skipping");
name = strVal(llast(castNode(List, object)));
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
- list_length(castNode(List, object)) - 1));
+ list_length(castNode(List, object)) - 1));
}
break;
case OBJECT_POLICY:
msg = gettext_noop("policy \"%s\" for relation \"%s\" does not exist, skipping");
name = strVal(llast(castNode(List, object)));
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
- list_length(castNode(List, object)) - 1));
+ list_length(castNode(List, object)) - 1));
}
break;
case OBJECT_EVENT_TRIGGER:
msg = gettext_noop("rule \"%s\" for relation \"%s\" does not exist, skipping");
name = strVal(llast(castNode(List, object)));
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
- list_length(castNode(List, object)) - 1));
+ list_length(castNode(List, object)) - 1));
}
break;
case OBJECT_FDW:
}
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
- return "???"; /* keep compiler quiet */
+ return "???"; /* keep compiler quiet */
}
/*
}
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
- return "???"; /* keep compiler quiet */
+ return "???"; /* keep compiler quiet */
}
ownerId = GetUserId();
/*
- * Check that there is no other foreign server by this name.
- * Do nothing if IF NOT EXISTS was enforced.
+ * Check that there is no other foreign server by this name. Do nothing if
+ * IF NOT EXISTS was enforced.
*/
if (GetForeignServerByName(stmt->servername, true) != NULL)
{
if (stmt->if_not_exists)
{
ereport(NOTICE,
- (errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("user mapping for \"%s\" already exists for server %s, skipping",
- MappingUserName(useId),
- stmt->servername)));
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("user mapping for \"%s\" already exists for server %s, skipping",
+ MappingUserName(useId),
+ stmt->servername)));
heap_close(rel, RowExclusiveLock);
return InvalidObjectAddress;
}
else
ereport(ERROR,
- (errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("user mapping for \"%s\" already exists for server %s",
- MappingUserName(useId),
- stmt->servername)));
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("user mapping for \"%s\" already exists for server %s",
+ MappingUserName(useId),
+ stmt->servername)));
}
fdw = GetForeignDataWrapper(srv->fdwid);
if (!OidIsValid(umId))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("user mapping for \"%s\" does not exist for the server",
- MappingUserName(useId))));
+ errmsg("user mapping for \"%s\" does not exist for the server",
+ MappingUserName(useId))));
user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);
if (!stmt->missing_ok)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("user mapping for \"%s\" does not exist for the server",
- MappingUserName(useId))));
+ errmsg("user mapping for \"%s\" does not exist for the server",
+ MappingUserName(useId))));
/* IF EXISTS specified, just note it */
ereport(NOTICE,
- (errmsg("user mapping for \"%s\" does not exist for the server, skipping",
- MappingUserName(useId))));
+ (errmsg("user mapping for \"%s\" does not exist for the server, skipping",
+ MappingUserName(useId))));
return InvalidOid;
}
*publish_delete = true;
/* Parse options */
- foreach (lc, options)
+ foreach(lc, options)
{
DefElem *defel = (DefElem *) lfirst(lc);
errmsg("invalid publish list")));
/* Process the option list. */
- foreach (lc, publish_list)
+ foreach(lc, publish_list)
{
- char *publish_opt = (char *)lfirst(lc);
+ char *publish_opt = (char *) lfirst(lc);
if (strcmp(publish_opt, "insert") == 0)
*publish_insert = true;
if (stmt->for_all_tables && !superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser to create FOR ALL TABLES publication"))));
+ (errmsg("must be superuser to create FOR ALL TABLES publication"))));
rel = heap_open(PublicationRelationId, RowExclusiveLock);
*/
static void
AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
- HeapTuple tup)
+ HeapTuple tup)
{
bool nulls[Natts_pg_publication];
bool replaces[Natts_pg_publication];
bool publish_insert;
bool publish_update;
bool publish_delete;
- ObjectAddress obj;
+ ObjectAddress obj;
parse_publication_options(stmt->options,
&publish_given, &publish_insert,
}
else
{
- List *relids = GetPublicationRelations(HeapTupleGetOid(tup));
+ List *relids = GetPublicationRelations(HeapTupleGetOid(tup));
/*
* We don't want to send too many individual messages, at some point
*/
if (list_length(relids) < MAX_RELCACHE_INVAL_MSGS)
{
- ListCell *lc;
+ ListCell *lc;
- foreach (lc, relids)
+ foreach(lc, relids)
{
- Oid relid = lfirst_oid(lc);
+ Oid relid = lfirst_oid(lc);
CacheInvalidateRelcacheByRelid(relid);
}
PublicationAddTables(pubid, rels, false, stmt);
else if (stmt->tableAction == DEFELEM_DROP)
PublicationDropTables(pubid, rels, false);
- else /* DEFELEM_SET */
+ else /* DEFELEM_SET */
{
List *oldrelids = GetPublicationRelations(pubid);
List *delrels = NIL;
{
Relation oldrel = heap_open(oldrelid,
ShareUpdateExclusiveLock);
+
delrels = lappend(delrels, oldrel);
}
}
PublicationDropTables(pubid, delrels, true);
/*
- * Don't bother calculating the difference for adding, we'll catch
- * and skip existing ones when doing catalog update.
+ * Don't bother calculating the difference for adding, we'll catch and
+ * skip existing ones when doing catalog update.
*/
PublicationAddTables(pubid, rels, true, stmt);
void
AlterPublication(AlterPublicationStmt *stmt)
{
- Relation rel;
- HeapTuple tup;
+ Relation rel;
+ HeapTuple tup;
rel = heap_open(PublicationRelationId, RowExclusiveLock);
void
RemovePublicationRelById(Oid proid)
{
- Relation rel;
- HeapTuple tup;
- Form_pg_publication_rel pubrel;
+ Relation rel;
+ HeapTuple tup;
+ Form_pg_publication_rel pubrel;
rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
AlterPublicationStmt *stmt)
{
- ListCell *lc;
+ ListCell *lc;
Assert(!stmt || !stmt->for_all_tables);
foreach(lc, rels)
{
Relation rel = (Relation) lfirst(lc);
- ObjectAddress obj;
+ ObjectAddress obj;
/* Must be owner of the table or superuser. */
if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
static void
PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
{
- ObjectAddress obj;
- ListCell *lc;
- Oid prid;
+ ObjectAddress obj;
+ ListCell *lc;
+ Oid prid;
foreach(lc, rels)
{
/*
* Internal workhorse for changing a publication owner
*/
- static void
+static void
AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
Form_pg_publication form;
if (form->puballtables && !superuser_arg(newOwnerId))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to change owner of publication \"%s\"",
- NameStr(form->pubname)),
+ errmsg("permission denied to change owner of publication \"%s\"",
+ NameStr(form->pubname)),
errhint("The owner of a FOR ALL TABLES publication must be a superuser.")));
}
ObjectAddress
AlterPublicationOwner(const char *name, Oid newOwnerId)
{
- Oid subid;
- HeapTuple tup;
- Relation rel;
+ Oid subid;
+ HeapTuple tup;
+ Relation rel;
ObjectAddress address;
rel = heap_open(PublicationRelationId, RowExclusiveLock);
void
AlterPublicationOwner_oid(Oid subid, Oid newOwnerId)
{
- HeapTuple tup;
- Relation rel;
+ HeapTuple tup;
+ Relation rel;
rel = heap_open(PublicationRelationId, RowExclusiveLock);
Buffer *buf, HeapTuple seqdatatuple);
static LOCKMODE alter_sequence_get_lock_level(List *options);
static void init_params(ParseState *pstate, List *options, bool for_identity,
- bool isInit,
- Form_pg_sequence seqform,
- bool *changed_seqform,
- Form_pg_sequence_data seqdataform, List **owned_by);
+ bool isInit,
+ Form_pg_sequence seqform,
+ bool *changed_seqform,
+ Form_pg_sequence_data seqdataform, List **owned_by);
static void do_setval(Oid relid, int64 next, bool iscalled);
static void process_owned_by(Relation seqrel, List *owned_by, bool for_identity);
{
FormData_pg_sequence seqform;
FormData_pg_sequence_data seqdataform;
- bool changed_seqform = false; /* not used here */
+ bool changed_seqform = false; /* not used here */
List *owned_by;
CreateStmt *stmt = makeNode(CreateStmt);
Oid seqoid;
snprintf(buf, sizeof(buf), INT64_FORMAT, maxv);
ereport(ERROR,
- (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
- errmsg("nextval: reached maximum value of sequence \"%s\" (%s)",
- RelationGetRelationName(seqrel), buf)));
+ (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
+ errmsg("nextval: reached maximum value of sequence \"%s\" (%s)",
+ RelationGetRelationName(seqrel), buf)));
}
next = minv;
}
snprintf(buf, sizeof(buf), INT64_FORMAT, minv);
ereport(ERROR,
- (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
- errmsg("nextval: reached minimum value of sequence \"%s\" (%s)",
- RelationGetRelationName(seqrel), buf)));
+ (errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
+ errmsg("nextval: reached minimum value of sequence \"%s\" (%s)",
+ RelationGetRelationName(seqrel), buf)));
}
next = maxv;
}
/* AS type */
if (as_type != NULL)
{
- Oid newtypid = typenameTypeId(pstate, defGetTypeName(as_type));
+ Oid newtypid = typenameTypeId(pstate, defGetTypeName(as_type));
if (newtypid != INT2OID &&
newtypid != INT4OID &&
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
for_identity
? errmsg("identity column type must be smallint, integer, or bigint")
- : errmsg("sequence type must be smallint, integer, or bigint")));
+ : errmsg("sequence type must be smallint, integer, or bigint")));
if (!isInit)
{
*/
if ((seqform->seqtypid == INT2OID && seqform->seqmax == PG_INT16_MAX) ||
(seqform->seqtypid == INT4OID && seqform->seqmax == PG_INT32_MAX) ||
- (seqform->seqtypid == INT8OID && seqform->seqmax == PG_INT64_MAX))
+ (seqform->seqtypid == INT8OID && seqform->seqmax == PG_INT64_MAX))
reset_max_value = true;
if ((seqform->seqtypid == INT2OID && seqform->seqmin == PG_INT16_MIN) ||
(seqform->seqtypid == INT4OID && seqform->seqmin == PG_INT32_MIN) ||
- (seqform->seqtypid == INT8OID && seqform->seqmin == PG_INT64_MIN))
+ (seqform->seqtypid == INT8OID && seqform->seqmin == PG_INT64_MIN))
reset_min_value = true;
}
seqform->seqmax = PG_INT64_MAX;
}
else
- seqform->seqmax = -1; /* descending seq */
+ seqform->seqmax = -1; /* descending seq */
*changed_seqform = true;
seqdataform->log_cnt = 0;
}
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("MAXVALUE (%s) is out of range for sequence data type %s",
- bufx, format_type_be(seqform->seqtypid))));
+ errmsg("MAXVALUE (%s) is out of range for sequence data type %s",
+ bufx, format_type_be(seqform->seqtypid))));
}
/* MINVALUE (null arg means NO MINVALUE) */
seqform->seqmin = PG_INT64_MIN;
}
else
- seqform->seqmin = 1; /* ascending seq */
+ seqform->seqmin = 1; /* ascending seq */
*changed_seqform = true;
seqdataform->log_cnt = 0;
}
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("MINVALUE (%s) is out of range for sequence data type %s",
- bufm, format_type_be(seqform->seqtypid))));
+ errmsg("MINVALUE (%s) is out of range for sequence data type %s",
+ bufm, format_type_be(seqform->seqtypid))));
}
/* crosscheck min/max */
else if (isInit)
{
if (seqform->seqincrement > 0)
- seqform->seqstart = seqform->seqmin; /* ascending seq */
+ seqform->seqstart = seqform->seqmin; /* ascending seq */
else
- seqform->seqstart = seqform->seqmax; /* descending seq */
+ seqform->seqstart = seqform->seqmax; /* descending seq */
*changed_seqform = true;
}
{
ereport(NOTICE,
(errcode(ERRCODE_DUPLICATE_OBJECT),
- errmsg("statistics object \"%s\" already exists, skipping",
- namestr)));
+ errmsg("statistics object \"%s\" already exists, skipping",
+ namestr)));
return InvalidObjectAddress;
}
*synchronous_commit = NULL;
/* Parse options */
- foreach (lc, options)
+ foreach(lc, options)
{
DefElem *defel = (DefElem *) lfirst(lc);
}
/*
- * Do additional checking for disallowed combination when
- * slot_name = NONE was used.
+ * Do additional checking for disallowed combination when slot_name = NONE
+ * was used.
*/
if (slot_name && *slot_name_given && !*slot_name)
{
values[Anum_pg_subscription_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
values[Anum_pg_subscription_subpublications - 1] =
- publicationListToArray(publications);
+ publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
*/
if (connect)
{
- XLogRecPtr lsn;
- char *err;
- WalReceiverConn *wrconn;
- List *tables;
- ListCell *lc;
- char table_state;
+ XLogRecPtr lsn;
+ char *err;
+ WalReceiverConn *wrconn;
+ List *tables;
+ ListCell *lc;
+ char table_state;
/* Try to connect to the publisher. */
wrconn = walrcv_connect(conninfo, true, stmt->subname, &err);
* info.
*/
tables = fetch_table_list(wrconn, publications);
- foreach (lc, tables)
+ foreach(lc, tables)
{
RangeVar *rv = (RangeVar *) lfirst(lc);
Oid relid;
(errmsg("synchronized table states")));
/*
- * If requested, create permanent slot for the subscription.
- * We won't use the initial snapshot for anything, so no need
- * to export it.
+ * If requested, create permanent slot for the subscription. We
+ * won't use the initial snapshot for anything, so no need to
+ * export it.
*/
if (create_slot)
{
walrcv_create_slot(wrconn, slotname, false,
CRS_NOEXPORT_SNAPSHOT, &lsn);
ereport(NOTICE,
- (errmsg("created replication slot \"%s\" on publisher",
- slotname)));
+ (errmsg("created replication slot \"%s\" on publisher",
+ slotname)));
}
}
PG_CATCH();
static void
AlterSubscription_refresh(Subscription *sub, bool copy_data)
{
- char *err;
+ char *err;
List *pubrel_names;
List *subrel_states;
Oid *subrel_local_oids;
subrel_states = GetSubscriptionRelations(sub->oid);
/*
- * Build qsorted array of local table oids for faster lookup.
- * This can potentially contain all tables in the database so
- * speed of lookup is important.
+ * Build qsorted array of local table oids for faster lookup. This can
+ * potentially contain all tables in the database so speed of lookup is
+ * important.
*/
subrel_local_oids = palloc(list_length(subrel_states) * sizeof(Oid));
off = 0;
foreach(lc, subrel_states)
{
SubscriptionRelState *relstate = (SubscriptionRelState *) lfirst(lc);
+
subrel_local_oids[off++] = relstate->relid;
}
qsort(subrel_local_oids, list_length(subrel_states),
sizeof(Oid), oid_cmp);
/*
- * Walk over the remote tables and try to match them to locally
- * known tables. If the table is not known locally create a new state
- * for it.
+ * Walk over the remote tables and try to match them to locally known
+ * tables. If the table is not known locally create a new state for it.
*
* Also builds array of local oids of remote tables for the next step.
*/
off = 0;
pubrel_local_oids = palloc(list_length(pubrel_names) * sizeof(Oid));
- foreach (lc, pubrel_names)
+ foreach(lc, pubrel_names)
{
RangeVar *rv = (RangeVar *) lfirst(lc);
Oid relid;
list_length(subrel_states), sizeof(Oid), oid_cmp))
{
SetSubscriptionRelState(sub->oid, relid,
- copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY,
+ copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY,
InvalidXLogRecPtr);
ereport(NOTICE,
(errmsg("added subscription for table %s.%s",
}
/*
- * Next remove state for tables we should not care about anymore using
- * the data we collected above
+ * Next remove state for tables we should not care about anymore using the
+ * data we collected above
*/
qsort(pubrel_local_oids, list_length(pubrel_names),
sizeof(Oid), oid_cmp);
for (off = 0; off < list_length(subrel_states); off++)
{
- Oid relid = subrel_local_oids[off];
+ Oid relid = subrel_local_oids[off];
if (!bsearch(&relid, pubrel_local_oids,
list_length(pubrel_names), sizeof(Oid), oid_cmp))
{
- char *namespace;
+ char *namespace;
RemoveSubscriptionRel(sub->oid, relid);
HeapTuple tup;
Oid subid;
bool update_tuple = false;
- Subscription *sub;
+ Subscription *sub;
rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
if (slotname)
values[Anum_pg_subscription_subslotname - 1] =
- DirectFunctionCall1(namein, CStringGetDatum(slotname));
+ DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
nulls[Anum_pg_subscription_subslotname - 1] = true;
replaces[Anum_pg_subscription_subslotname - 1] = true;
case ALTER_SUBSCRIPTION_ENABLED:
{
- bool enabled,
- enabled_given;
+ bool enabled,
+ enabled_given;
parse_subscription_options(stmt->options, NULL,
&enabled_given, &enabled, NULL,
case ALTER_SUBSCRIPTION_PUBLICATION:
case ALTER_SUBSCRIPTION_PUBLICATION_REFRESH:
{
- bool copy_data;
+ bool copy_data;
parse_subscription_options(stmt->options, NULL, NULL, NULL,
NULL, NULL, NULL, ©_data,
NULL);
values[Anum_pg_subscription_subpublications - 1] =
- publicationListToArray(stmt->publication);
+ publicationListToArray(stmt->publication);
replaces[Anum_pg_subscription_subpublications - 1] = true;
update_tuple = true;
case ALTER_SUBSCRIPTION_REFRESH:
{
- bool copy_data;
+ bool copy_data;
if (!sub->enabled)
ereport(ERROR,
char *slotname;
char originname[NAMEDATALEN];
char *err = NULL;
- RepOriginId originid;
- WalReceiverConn *wrconn = NULL;
- StringInfoData cmd;
+ RepOriginId originid;
+ WalReceiverConn *wrconn = NULL;
+ StringInfoData cmd;
/*
- * Lock pg_subscription with AccessExclusiveLock to ensure
- * that the launcher doesn't restart new worker during dropping
- * the subscription
+ * Lock pg_subscription with AccessExclusiveLock to ensure that the
+ * launcher doesn't restart new worker during dropping the subscription
*/
rel = heap_open(SubscriptionRelationId, AccessExclusiveLock);
InvokeObjectDropHook(SubscriptionRelationId, subid, 0);
/*
- * Lock the subscription so nobody else can do anything with it
- * (including the replication workers).
+ * Lock the subscription so nobody else can do anything with it (including
+ * the replication workers).
*/
LockSharedObject(SubscriptionRelationId, subid, 0, AccessExclusiveLock);
if (originid != InvalidRepOriginId)
replorigin_drop(originid);
- /* If there is no slot associated with the subscription, we can finish here. */
+ /*
+ * If there is no slot associated with the subscription, we can finish
+ * here.
+ */
if (!slotname)
{
heap_close(rel, NoLock);
}
/*
- * Otherwise drop the replication slot at the publisher node using
- * the replication connection.
+ * Otherwise drop the replication slot at the publisher node using the
+ * replication connection.
*/
load_file("libpqwalreceiver", false);
PG_TRY();
{
- WalRcvExecResult *res;
+ WalRcvExecResult *res;
+
res = walrcv_exec(wrconn, cmd.data, 0, NULL);
if (res->status != WALRCV_OK_COMMAND)
ereport(ERROR,
- (errmsg("could not drop the replication slot \"%s\" on publisher",
- slotname),
- errdetail("The error was: %s", res->err)));
+ (errmsg("could not drop the replication slot \"%s\" on publisher",
+ slotname),
+ errdetail("The error was: %s", res->err)));
else
ereport(NOTICE,
(errmsg("dropped replication slot \"%s\" on publisher",
if (!superuser_arg(newOwnerId))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to change owner of subscription \"%s\"",
- NameStr(form->subname)),
- errhint("The owner of a subscription must be a superuser.")));
+ errmsg("permission denied to change owner of subscription \"%s\"",
+ NameStr(form->subname)),
+ errhint("The owner of a subscription must be a superuser.")));
form->subowner = newOwnerId;
CatalogTupleUpdate(rel, &tup->t_self, tup);
static List *
fetch_table_list(WalReceiverConn *wrconn, List *publications)
{
- WalRcvExecResult *res;
- StringInfoData cmd;
- TupleTableSlot *slot;
- Oid tableRow[2] = {TEXTOID, TEXTOID};
- ListCell *lc;
- bool first;
- List *tablelist = NIL;
+ WalRcvExecResult *res;
+ StringInfoData cmd;
+ TupleTableSlot *slot;
+ Oid tableRow[2] = {TEXTOID, TEXTOID};
+ ListCell *lc;
+ bool first;
+ List *tablelist = NIL;
Assert(list_length(publications) > 0);
initStringInfo(&cmd);
appendStringInfo(&cmd, "SELECT DISTINCT t.schemaname, t.tablename\n"
- " FROM pg_catalog.pg_publication_tables t\n"
- " WHERE t.pubname IN (");
+ " FROM pg_catalog.pg_publication_tables t\n"
+ " WHERE t.pubname IN (");
first = true;
- foreach (lc, publications)
+ foreach(lc, publications)
{
- char *pubname = strVal(lfirst(lc));
+ char *pubname = strVal(lfirst(lc));
if (first)
first = false;
static ObjectAddress ATExecColumnDefault(Relation rel, const char *colName,
Node *newDefault, LOCKMODE lockmode);
static ObjectAddress ATExecAddIdentity(Relation rel, const char *colName,
- Node *def, LOCKMODE lockmode);
+ Node *def, LOCKMODE lockmode);
static ObjectAddress ATExecSetIdentity(Relation rel, const char *colName,
- Node *def, LOCKMODE lockmode);
+ Node *def, LOCKMODE lockmode);
static ObjectAddress ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode);
static void ATPrepSetStatistics(Relation rel, const char *colName,
Node *newValue, LOCKMODE lockmode);
descriptor->tdhasoid = (localHasOids || parentOidCount > 0);
/*
- * If a partitioned table doesn't have the system OID column, then none
- * of its partitions should have it.
+ * If a partitioned table doesn't have the system OID column, then none of
+ * its partitions should have it.
*/
if (stmt->partbound && parentOidCount == 0 && localHasOids)
ereport(ERROR,
}
/*
- * Similarly, if we previously locked some other partition's heap, and
- * the name we're looking up no longer refers to that relation, release
- * the now-useless lock.
+ * Similarly, if we previously locked some other partition's heap, and the
+ * name we're looking up no longer refers to that relation, release the
+ * now-useless lock.
*/
if (relOid != oldRelOid && OidIsValid(state->partParentOid))
{
else
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
- errmsg("column \"%s\" specified more than once",
- coldef->colname)));
+ errmsg("column \"%s\" specified more than once",
+ coldef->colname)));
}
prev = rest;
rest = next;
values[ex->attnum - 1] = ExecEvalExpr(ex->exprstate,
econtext,
- &isnull[ex->attnum - 1]);
+ &isnull[ex->attnum - 1]);
}
/*
ATPrepDropNotNull(Relation rel, bool recurse, bool recursing)
{
/*
- * If the parent is a partitioned table, like check constraints, we do
- * not support removing the NOT NULL while partitions exist.
+ * If the parent is a partitioned table, like check constraints, we do not
+ * support removing the NOT NULL while partitions exist.
*/
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
- PartitionDesc partdesc = RelationGetPartitionDesc(rel);
+ PartitionDesc partdesc = RelationGetPartitionDesc(rel);
Assert(partdesc != NULL);
if (partdesc->nparts > 0 && !recurse && !recursing)
if (get_attidentity(RelationGetRelid(rel), attnum))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("column \"%s\" of relation \"%s\" is an identity column",
- colName, RelationGetRelationName(rel))));
+ errmsg("column \"%s\" of relation \"%s\" is an identity column",
+ colName, RelationGetRelationName(rel))));
/*
* Check that the attribute is not in a primary key
*/
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
- PartitionDesc partdesc = RelationGetPartitionDesc(rel);
+ PartitionDesc partdesc = RelationGetPartitionDesc(rel);
if (partdesc && partdesc->nparts > 0 && !recurse && !recursing)
ereport(ERROR,
if (get_attidentity(RelationGetRelid(rel), attnum))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("column \"%s\" of relation \"%s\" is an identity column",
- colName, RelationGetRelationName(rel)),
+ errmsg("column \"%s\" of relation \"%s\" is an identity column",
+ colName, RelationGetRelationName(rel)),
newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
/*
if (attTup->atthasdef)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("column \"%s\" of relation \"%s\" already has a default value",
- colName, RelationGetRelationName(rel))));
+ errmsg("column \"%s\" of relation \"%s\" already has a default value",
+ colName, RelationGetRelationName(rel))));
attTup->attidentity = cdef->identity;
CatalogTupleUpdate(attrelation, &tuple->t_self, tuple);
ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmode)
{
ListCell *option;
- DefElem *generatedEl = NULL;
+ DefElem *generatedEl = NULL;
HeapTuple tuple;
Form_pg_attribute attTup;
AttrNumber attnum;
foreach(option, castNode(List, def))
{
- DefElem *defel = lfirst_node(DefElem, option);
+ DefElem *defel = lfirst_node(DefElem, option);
if (strcmp(defel->defname, "generated") == 0)
{
if (!attTup->attidentity)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("column \"%s\" of relation \"%s\" is not an identity column",
- colName, RelationGetRelationName(rel))));
+ errmsg("column \"%s\" of relation \"%s\" is not an identity column",
+ colName, RelationGetRelationName(rel))));
if (generatedEl)
{
inhseqno + 1,
catalogRelation,
parent_rel->rd_rel->relkind ==
- RELKIND_PARTITIONED_TABLE);
+ RELKIND_PARTITIONED_TABLE);
/* Now we're done with pg_inherits */
heap_close(catalogRelation, RowExclusiveLock);
foreach(lc, varList)
{
- TriggerTransition *tt = lfirst_node(TriggerTransition, lc);
+ TriggerTransition *tt = lfirst_node(TriggerTransition, lc);
if (!(tt->isTable))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a partitioned table",
RelationGetRelationName(rel)),
- errdetail("Triggers on partitioned tables cannot have transition tables.")));
+ errdetail("Triggers on partitioned tables cannot have transition tables.")));
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a foreign table",
RelationGetRelationName(rel)),
- errdetail("Triggers on foreign tables cannot have transition tables.")));
+ errdetail("Triggers on foreign tables cannot have transition tables.")));
if (rel->rd_rel->relkind == RELKIND_VIEW)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a view",
RelationGetRelationName(rel)),
- errdetail("Triggers on views cannot have transition tables.")));
+ errdetail("Triggers on views cannot have transition tables.")));
if (stmt->timing != TRIGGER_TYPE_AFTER)
ereport(ERROR,
if (newtablename != NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("NEW TABLE cannot be specified multiple times")));
+ errmsg("NEW TABLE cannot be specified multiple times")));
newtablename = tt->name;
}
if (oldtablename != NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("OLD TABLE cannot be specified multiple times")));
+ errmsg("OLD TABLE cannot be specified multiple times")));
oldtablename = tt->name;
}
strcmp(newtablename, oldtablename) == 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("OLD TABLE name and NEW TABLE name cannot be the same")));
+ errmsg("OLD TABLE name and NEW TABLE name cannot be the same")));
}
/*
if (oldtablename)
values[Anum_pg_trigger_tgoldtable - 1] = DirectFunctionCall1(namein,
- CStringGetDatum(oldtablename));
+ CStringGetDatum(oldtablename));
else
nulls[Anum_pg_trigger_tgoldtable - 1] = true;
if (newtablename)
values[Anum_pg_trigger_tgnewtable - 1] = DirectFunctionCall1(namein,
- CStringGetDatum(newtablename));
+ CStringGetDatum(newtablename));
else
nulls[Anum_pg_trigger_tgnewtable - 1] = true;
AfterTriggerEventList events; /* deferred-event list */
int query_depth; /* current query list index */
AfterTriggerEventList *query_stack; /* events pending from each query */
- Tuplestorestate **fdw_tuplestores; /* foreign tuples for one row from each query */
+ Tuplestorestate **fdw_tuplestores; /* foreign tuples for one row from
+ * each query */
Tuplestorestate **old_tuplestores; /* all old tuples from each query */
Tuplestorestate **new_tuplestores; /* all new tuples from each query */
int maxquerydepth; /* allocated len of above array */
case AFTER_TRIGGER_FDW_FETCH:
{
Tuplestorestate *fdw_tuplestore =
- GetTriggerTransitionTuplestore
- (afterTriggers.fdw_tuplestores);
+ GetTriggerTransitionTuplestore
+ (afterTriggers.fdw_tuplestores);
if (!tuplestore_gettupleslot(fdw_tuplestore, true, false,
trig_tuple_slot1))
Assert(oldtup != NULL);
old_tuplestore =
GetTriggerTransitionTuplestore
- (afterTriggers.old_tuplestores);
+ (afterTriggers.old_tuplestores);
tuplestore_puttuple(old_tuplestore, oldtup);
}
if ((event == TRIGGER_EVENT_INSERT &&
Assert(newtup != NULL);
new_tuplestore =
GetTriggerTransitionTuplestore
- (afterTriggers.new_tuplestores);
+ (afterTriggers.new_tuplestores);
tuplestore_puttuple(new_tuplestore, newtup);
}
/* If transition tables are the only reason we're here, return. */
if ((event == TRIGGER_EVENT_DELETE && !trigdesc->trig_delete_after_row) ||
- (event == TRIGGER_EVENT_INSERT && !trigdesc->trig_insert_after_row) ||
- (event == TRIGGER_EVENT_UPDATE && !trigdesc->trig_update_after_row))
+ (event == TRIGGER_EVENT_INSERT && !trigdesc->trig_insert_after_row) ||
+ (event == TRIGGER_EVENT_UPDATE && !trigdesc->trig_update_after_row))
return;
}
{
fdw_tuplestore =
GetTriggerTransitionTuplestore
- (afterTriggers.fdw_tuplestores);
+ (afterTriggers.fdw_tuplestores);
new_event.ate_flags = AFTER_TRIGGER_FDW_FETCH;
}
else
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue)), -1));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
}
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue)), -1));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
}
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue)), -1));
+ (Node *) makeString(pstrdup(startvalue)), -1));
state = CS_WAITKEY;
}
else
*wsptr++ = '\0';
result = lappend(result,
makeDefElem(pstrdup(workspace),
- (Node *) makeString(pstrdup(startvalue)), -1));
+ (Node *) makeString(pstrdup(startvalue)), -1));
}
else if (state != CS_WAITKEY)
ereport(ERROR,
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
(errmsg("role \"%s\" is a member of role \"%s\"",
- rolename, get_rolespec_name(memberRole)))));
+ rolename, get_rolespec_name(memberRole)))));
/*
* Check if entry for this role/member already exists; if so, give
{
ereport(NOTICE,
(errmsg("role \"%s\" is already a member of role \"%s\"",
- get_rolespec_name(memberRole), rolename)));
+ get_rolespec_name(memberRole), rolename)));
ReleaseSysCache(authmem_tuple);
continue;
}
{
ereport(WARNING,
(errmsg("role \"%s\" is not a member of role \"%s\"",
- get_rolespec_name(memberRole), rolename)));
+ get_rolespec_name(memberRole), rolename)));
continue;
}
*/
initStringInfo(&buf);
appendStringInfo(&buf,
- _("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),
+ _("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),
nkeep, OldestXmin);
appendStringInfo(&buf, _("There were %.0f unused item pointers.\n"),
nunused);
/* If we haven't prefetched this lot yet, do so now. */
if (prefetchedUntil > blkno)
{
- BlockNumber prefetchStart;
- BlockNumber pblkno;
+ BlockNumber prefetchStart;
+ BlockNumber pblkno;
prefetchStart = blkno & ~(PREFETCH_SIZE - 1);
for (pblkno = prefetchStart; pblkno <= blkno; pblkno++)
if (stmt->withCheckOption == LOCAL_CHECK_OPTION)
stmt->options = lappend(stmt->options,
makeDefElem("check_option",
- (Node *) makeString("local"), -1));
+ (Node *) makeString("local"), -1));
else if (stmt->withCheckOption == CASCADED_CHECK_OPTION)
stmt->options = lappend(stmt->options,
makeDefElem("check_option",
- (Node *) makeString("cascaded"), -1));
+ (Node *) makeString("cascaded"), -1));
/*
* Check that the view is auto-updatable if WITH CHECK OPTION was
return true;
case T_CustomScan:
- {
- CustomPath *customPath = castNode(CustomPath, pathnode);
- if (customPath->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)
- return true;
- return false;
- }
+ {
+ CustomPath *customPath = castNode(CustomPath, pathnode);
+
+ if (customPath->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)
+ return true;
+ return false;
+ }
case T_Result:
/*
hashtable->in_hash_funcs = hashtable->tab_hash_funcs;
hashtable->cur_eq_funcs = hashtable->tab_eq_funcs;
- key = NULL; /* flag to reference inputslot */
+ key = NULL; /* flag to reference inputslot */
if (isnew)
{
estate->es_num_root_result_relations = 0;
if (plannedstmt->nonleafResultRelations)
{
- int num_roots = list_length(plannedstmt->rootResultRelations);
+ int num_roots = list_length(plannedstmt->rootResultRelations);
/*
* Firstly, build ResultRelInfos for all the partitioned table
* triggers, if any.
*/
resultRelInfos = (ResultRelInfo *)
- palloc(num_roots * sizeof(ResultRelInfo));
+ palloc(num_roots * sizeof(ResultRelInfo));
resultRelInfo = resultRelInfos;
foreach(l, plannedstmt->rootResultRelations)
{
/* Simply lock the rest of them. */
foreach(l, plannedstmt->nonleafResultRelations)
{
- Index resultRelIndex = lfirst_int(l);
+ Index resultRelIndex = lfirst_int(l);
/* We locked the roots above. */
if (!list_member_int(plannedstmt->rootResultRelations,
if (resultRelInfo->ri_PartitionRoot)
{
HeapTuple tuple = ExecFetchSlotTuple(slot);
- TupleConversionMap *map;
+ TupleConversionMap *map;
rel = resultRelInfo->ri_PartitionRoot;
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name(orig_tupdesc, tupdesc,
- gettext_noop("could not convert row type"));
+ gettext_noop("could not convert row type"));
if (map != NULL)
{
tuple = do_convert_tuple(tuple, map);
{
HeapTuple tuple = ExecFetchSlotTuple(slot);
TupleDesc old_tupdesc = RelationGetDescr(rel);
- TupleConversionMap *map;
+ TupleConversionMap *map;
rel = resultRelInfo->ri_PartitionRoot;
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name(old_tupdesc, tupdesc,
- gettext_noop("could not convert row type"));
+ gettext_noop("could not convert row type"));
if (map != NULL)
{
tuple = do_convert_tuple(tuple, map);
{
HeapTuple tuple = ExecFetchSlotTuple(slot);
TupleDesc old_tupdesc = RelationGetDescr(rel);
- TupleConversionMap *map;
+ TupleConversionMap *map;
rel = resultRelInfo->ri_PartitionRoot;
tupdesc = RelationGetDescr(rel);
/* a reverse map */
map = convert_tuples_by_name(old_tupdesc, tupdesc,
- gettext_noop("could not convert row type"));
+ gettext_noop("could not convert row type"));
if (map != NULL)
{
tuple = do_convert_tuple(tuple, map);
(errcode(ERRCODE_CHECK_VIOLATION),
errmsg("no partition of relation \"%s\" found for row",
RelationGetRelationName(failed_rel)),
- val_desc ? errdetail("Partition key of the failing row contains %s.", val_desc) : 0));
+ val_desc ? errdetail("Partition key of the failing row contains %s.", val_desc) : 0));
}
return result;
bool *isnull,
int maxfieldlen)
{
- StringInfoData buf;
- PartitionKey key = RelationGetPartitionKey(rel);
+ StringInfoData buf;
+ PartitionKey key = RelationGetPartitionKey(rel);
int partnatts = get_partition_natts(key);
int i;
Oid relid = RelationGetRelid(rel);
/*
* Also store the per-worker detail.
*
- * Worker instrumentation should be allocated in the same context as
- * the regular instrumentation information, which is the per-query
- * context. Switch into per-query memory context.
+ * Worker instrumentation should be allocated in the same context as the
+ * regular instrumentation information, which is the per-query context.
+ * Switch into per-query memory context.
*/
oldcontext = MemoryContextSwitchTo(planstate->state->es_query_cxt);
ibytes = mul_size(instrumentation->num_workers, sizeof(Instrumentation));
case T_NamedTuplestoreScan:
result = (PlanState *) ExecInitNamedTuplestoreScan((NamedTuplestoreScan *) node,
- estate, eflags);
+ estate, eflags);
break;
case T_WorkTableScan:
TupleTableSlot *searchslot,
TupleTableSlot *outslot)
{
- HeapTuple scantuple;
- ScanKeyData skey[INDEX_MAX_KEYS];
- IndexScanDesc scan;
- SnapshotData snap;
- TransactionId xwait;
- Relation idxrel;
- bool found;
-
- /* Open the index.*/
+ HeapTuple scantuple;
+ ScanKeyData skey[INDEX_MAX_KEYS];
+ IndexScanDesc scan;
+ SnapshotData snap;
+ TransactionId xwait;
+ Relation idxrel;
+ bool found;
+
+ /* Open the index. */
idxrel = index_open(idxoid, RowExclusiveLock);
/* Start an index scan. */
snap.xmin : snap.xmax;
/*
- * If the tuple is locked, wait for locking transaction to finish
- * and retry.
+ * If the tuple is locked, wait for locking transaction to finish and
+ * retry.
*/
if (TransactionIdIsValid(xwait))
{
/* Found tuple, try to lock it in the lockmode. */
if (found)
{
- Buffer buf;
+ Buffer buf;
HeapUpdateFailureData hufd;
HTSU_Result res;
HeapTupleData locktup;
res = heap_lock_tuple(rel, &locktup, GetCurrentCommandId(false),
lockmode,
LockWaitBlock,
- false /* don't follow updates */,
+ false /* don't follow updates */ ,
&buf, &hufd);
/* the tuple slot already has the buffer pinned */
ReleaseBuffer(buf);
* to use.
*/
static bool
-tuple_equals_slot(TupleDesc desc, HeapTuple tup, TupleTableSlot *slot)
+tuple_equals_slot(TupleDesc desc, HeapTuple tup, TupleTableSlot *slot)
{
Datum values[MaxTupleAttributeNumber];
bool isnull[MaxTupleAttributeNumber];
RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
TupleTableSlot *searchslot, TupleTableSlot *outslot)
{
- HeapTuple scantuple;
- HeapScanDesc scan;
- SnapshotData snap;
- TransactionId xwait;
- bool found;
- TupleDesc desc = RelationGetDescr(rel);
+ HeapTuple scantuple;
+ HeapScanDesc scan;
+ SnapshotData snap;
+ TransactionId xwait;
+ bool found;
+ TupleDesc desc = RelationGetDescr(rel);
Assert(equalTupleDescs(desc, outslot->tts_tupleDescriptor));
snap.xmin : snap.xmax;
/*
- * If the tuple is locked, wait for locking transaction to finish
- * and retry.
+ * If the tuple is locked, wait for locking transaction to finish and
+ * retry.
*/
if (TransactionIdIsValid(xwait))
{
/* Found tuple, try to lock it in the lockmode. */
if (found)
{
- Buffer buf;
+ Buffer buf;
HeapUpdateFailureData hufd;
HTSU_Result res;
HeapTupleData locktup;
res = heap_lock_tuple(rel, &locktup, GetCurrentCommandId(false),
lockmode,
LockWaitBlock,
- false /* don't follow updates */,
+ false /* don't follow updates */ ,
&buf, &hufd);
/* the tuple slot already has the buffer pinned */
ReleaseBuffer(buf);
void
ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
{
- bool skip_tuple = false;
- HeapTuple tuple;
- ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
- Relation rel = resultRelInfo->ri_RelationDesc;
+ bool skip_tuple = false;
+ HeapTuple tuple;
+ ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
+ Relation rel = resultRelInfo->ri_RelationDesc;
/* For now we support only tables. */
Assert(rel->rd_rel->relkind == RELKIND_RELATION);
{
slot = ExecBRInsertTriggers(estate, resultRelInfo, slot);
- if (slot == NULL) /* "do nothing" */
+ if (slot == NULL) /* "do nothing" */
skip_tuple = true;
}
ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
TupleTableSlot *searchslot, TupleTableSlot *slot)
{
- bool skip_tuple = false;
- HeapTuple tuple;
- ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
- Relation rel = resultRelInfo->ri_RelationDesc;
+ bool skip_tuple = false;
+ HeapTuple tuple;
+ ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
+ Relation rel = resultRelInfo->ri_RelationDesc;
/* For now we support only tables. */
Assert(rel->rd_rel->relkind == RELKIND_RELATION);
&searchslot->tts_tuple->t_self,
NULL, slot);
- if (slot == NULL) /* "do nothing" */
+ if (slot == NULL) /* "do nothing" */
skip_tuple = true;
}
ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
TupleTableSlot *searchslot)
{
- bool skip_tuple = false;
- ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
- Relation rel = resultRelInfo->ri_RelationDesc;
+ bool skip_tuple = false;
+ ResultRelInfo *resultRelInfo = estate->es_result_relation_info;
+ Relation rel = resultRelInfo->ri_RelationDesc;
/* For now we support only tables. */
Assert(rel->rd_rel->relkind == RELKIND_RELATION);
if (relkind != RELKIND_RELATION)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("logical replication target relation \"%s.%s\" is not a table",
- nspname, relname)));
+ errmsg("logical replication target relation \"%s.%s\" is not a table",
+ nspname, relname)));
}
ExecLockNonLeafAppendTables(List *partitioned_rels, EState *estate)
{
PlannedStmt *stmt = estate->es_plannedstmt;
- ListCell *lc;
+ ListCell *lc;
foreach(lc, partitioned_rels)
{
ListCell *l;
- Index rti = lfirst_int(lc);
- bool is_result_rel = false;
- Oid relid = getrelid(rti, estate->es_range_table);
+ Index rti = lfirst_int(lc);
+ bool is_result_rel = false;
+ Oid relid = getrelid(rti, estate->es_range_table);
/* If this is a result relation, already locked in InitPlan */
foreach(l, stmt->nonleafResultRelations)
* NULL and not auto-replace it with a later input value. Only the first
* non-NULL input will be auto-substituted.
*/
-} AggStatePerGroupData;
+} AggStatePerGroupData;
/*
* AggStatePerPhaseData - per-grouping-set-phase state
AttrNumber *hashGrpColIdxInput; /* hash col indices in input slot */
AttrNumber *hashGrpColIdxHash; /* indices in hashtbl tuples */
Agg *aggnode; /* original Agg node, for numGroups etc. */
-} AggStatePerHashData;
+} AggStatePerHashData;
static void select_current_set(AggState *aggstate, int setno, bool is_hash);
Assert(!(eflags & EXEC_FLAG_MARK));
/*
- * Lock the non-leaf tables in the partition tree controlled by this
- * node. It's a no-op for non-partitioned parent tables.
+ * Lock the non-leaf tables in the partition tree controlled by this node.
+ * It's a no-op for non-partitioned parent tables.
*/
ExecLockNonLeafAppendTables(node->partitioned_rels, estate);
* In case of shared mode, we can not ensure that the current
* blockno of the main iterator and that of the prefetch iterator
* are same. It's possible that whatever blockno we are
- * prefetching will be processed by another process. Therefore, we
- * don't validate the blockno here as we do in non-parallel case.
+ * prefetching will be processed by another process. Therefore,
+ * we don't validate the blockno here as we do in non-parallel
+ * case.
*/
if (prefetch_iterator)
tbm_shared_iterate(prefetch_iterator);
void
ExecEndGather(GatherState *node)
{
- ExecEndNode(outerPlanState(node)); /* let children clean up first */
+ ExecEndNode(outerPlanState(node)); /* let children clean up first */
ExecShutdownGather(node);
ExecFreeExprContext(&node->ps);
ExecClearTuple(node->ps.ps_ResultTupleSlot);
int readCounter;
int nTuples;
bool done;
-} GMReaderTupleBuffer;
+} GMReaderTupleBuffer;
/*
* When we read tuples from workers, it's a good idea to read several at once
ResetExprContext(econtext);
/*
- * Get next tuple, either from one of our workers, or by running the
- * plan ourselves.
+ * Get next tuple, either from one of our workers, or by running the plan
+ * ourselves.
*/
slot = gather_merge_getnext(node);
if (TupIsNull(slot))
return NULL;
/*
- * form the result tuple using ExecProject(), and return it --- unless
- * the projection produces an empty set, in which case we must loop
- * back around for another tuple
+ * form the result tuple using ExecProject(), and return it --- unless the
+ * projection produces an empty set, in which case we must loop back
+ * around for another tuple
*/
econtext->ecxt_outertuple = slot;
return ExecProject(node->ps.ps_ProjInfo);
void
ExecEndGatherMerge(GatherMergeState *node)
{
- ExecEndNode(outerPlanState(node)); /* let children clean up first */
+ ExecEndNode(outerPlanState(node)); /* let children clean up first */
ExecShutdownGatherMerge(node);
ExecFreeExprContext(&node->ps);
ExecClearTuple(node->ps.ps_ResultTupleSlot);
HeapTuple tup = NULL;
/*
- * If we're being asked to generate a tuple from the leader, then we
- * just call ExecProcNode as normal to produce one.
+ * If we're being asked to generate a tuple from the leader, then we just
+ * call ExecProcNode as normal to produce one.
*/
if (gm_state->nreaders == reader)
{
&tuple_buffer->done));
/*
- * Attempt to read more tuples in nowait mode and store them in
- * the tuple array.
+ * Attempt to read more tuples in nowait mode and store them in the
+ * tuple array.
*/
if (HeapTupleIsValid(tup))
form_tuple_array(gm_state, reader);
Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
/*
- * Lock the non-leaf tables in the partition tree controlled by this
- * node. It's a no-op for non-partitioned parent tables.
+ * Lock the non-leaf tables in the partition tree controlled by this node.
+ * It's a no-op for non-partitioned parent tables.
*/
ExecLockNonLeafAppendTables(node->partitioned_rels, estate);
static void
fireBSTriggers(ModifyTableState *node)
{
- ResultRelInfo *resultRelInfo = node->resultRelInfo;
+ ResultRelInfo *resultRelInfo = node->resultRelInfo;
/*
* If the node modifies a partitioned table, we must fire its triggers.
static void
fireASTriggers(ModifyTableState *node)
{
- ResultRelInfo *resultRelInfo = node->resultRelInfo;
+ ResultRelInfo *resultRelInfo = node->resultRelInfo;
/*
* If the node modifies a partitioned table, we must fire its triggers.
/* If modifying a partitioned table, initialize the root table info */
if (node->rootResultRelIndex >= 0)
mtstate->rootResultRelInfo = estate->es_root_result_relations +
- node->rootResultRelIndex;
+ node->rootResultRelIndex;
mtstate->mt_arowmarks = (List **) palloc0(sizeof(List *) * nplans);
mtstate->mt_nplans = nplans;
/* The root table RT index is at the head of the partitioned_rels list */
if (node->partitioned_rels)
{
- Index root_rti;
- Oid root_oid;
+ Index root_rti;
+ Oid root_oid;
root_rti = linitial_int(node->partitioned_rels);
root_oid = getrelid(root_rti, estate->es_range_table);
- rel = heap_open(root_oid, NoLock); /* locked by InitPlan */
+ rel = heap_open(root_oid, NoLock); /* locked by InitPlan */
}
else
rel = mtstate->resultRelInfo->ri_RelationDesc;
}
/*
- * Build WITH CHECK OPTION constraints for each leaf partition rel.
- * Note that we didn't build the withCheckOptionList for each partition
- * within the planner, but simple translation of the varattnos for each
- * partition will suffice. This only occurs for the INSERT case;
- * UPDATE/DELETE cases are handled above.
+ * Build WITH CHECK OPTION constraints for each leaf partition rel. Note
+ * that we didn't build the withCheckOptionList for each partition within
+ * the planner, but simple translation of the varattnos for each partition
+ * will suffice. This only occurs for the INSERT case; UPDATE/DELETE
+ * cases are handled above.
*/
if (node->withCheckOptionLists != NIL && mtstate->mt_num_partitions > 0)
{
- List *wcoList;
+ List *wcoList;
Assert(operation == CMD_INSERT);
resultRelInfo = mtstate->mt_partitions;
{
TupleTableSlot *resultSlot = node->ps.ps_ResultTupleSlot;
ExprContext *econtext = node->ps.ps_ExprContext;
- bool hassrf PG_USED_FOR_ASSERTS_ONLY;
+ bool hassrf PG_USED_FOR_ASSERTS_ONLY;
bool hasresult;
int argno;
{
long numLeft; /* number of left-input dups in group */
long numRight; /* number of right-input dups in group */
-} SetOpStatePerGroupData;
+} SetOpStatePerGroupData;
static TupleTableSlot *setop_retrieve_direct(SetOpState *setopstate);
PG_TRY();
{
routine->InitOpaque(tstate,
- tstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->natts);
+ tstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor->natts);
/*
* If evaluating the document expression returns NULL, the table
int colno;
Datum value;
int ordinalitycol =
- ((TableFuncScan *) (tstate->ss.ps.plan))->tablefunc->ordinalitycol;
+ ((TableFuncScan *) (tstate->ss.ps.plan))->tablefunc->ordinalitycol;
/*
* Install the document as a possibly-toasted Datum into the tablefunc
ExecClearTuple(tstate->ss.ss_ScanTupleSlot);
/*
- * Obtain the value of each column for this row, installing them into the
- * slot; then add the tuple to the tuplestore.
+ * Obtain the value of each column for this row, installing them into
+ * the slot; then add the tuple to the tuplestore.
*/
for (colno = 0; colno < natts; colno++)
{
}
else
{
- bool isnull;
+ bool isnull;
values[colno] = routine->GetValue(tstate,
colno,
- tupdesc->attrs[colno]->atttypid,
- tupdesc->attrs[colno]->atttypmod,
+ tupdesc->attrs[colno]->atttypid,
+ tupdesc->attrs[colno]->atttypmod,
&isnull);
/* No value? Evaluate and apply the default, if any */
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("null is not allowed in column \"%s\"",
- NameStr(tupdesc->attrs[colno]->attname))));
+ NameStr(tupdesc->attrs[colno]->attname))));
nulls[colno] = isnull;
}
if (!(portal->cursorOptions & (CURSOR_OPT_SCROLL | CURSOR_OPT_NO_SCROLL)))
{
if (list_length(stmt_list) == 1 &&
- linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
+ linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
linitial_node(PlannedStmt, stmt_list)->rowMarks == NIL &&
ExecSupportsBackwardScan(linitial_node(PlannedStmt, stmt_list)->planTree))
portal->cursorOptions |= CURSOR_OPT_SCROLL;
if (portal->cursorOptions & CURSOR_OPT_SCROLL)
{
if (list_length(stmt_list) == 1 &&
- linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
+ linitial_node(PlannedStmt, stmt_list)->commandType != CMD_UTILITY &&
linitial_node(PlannedStmt, stmt_list)->rowMarks != NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
stmt_list = pg_analyze_and_rewrite_params(parsetree,
src,
plan->parserSetup,
- plan->parserSetupArg,
- _SPI_current->queryEnv);
+ plan->parserSetupArg,
+ _SPI_current->queryEnv);
}
else
{
if (enr == NULL || enr->md.name == NULL)
return SPI_ERROR_ARGUMENT;
- res = _SPI_begin_call(false); /* keep current memory context */
+ res = _SPI_begin_call(false); /* keep current memory context */
if (res < 0)
return res;
if (name == NULL)
return SPI_ERROR_ARGUMENT;
- res = _SPI_begin_call(false); /* keep current memory context */
+ res = _SPI_begin_call(false); /* keep current memory context */
if (res < 0)
return res;
if (tdata->tg_newtable)
{
EphemeralNamedRelation enr =
- palloc(sizeof(EphemeralNamedRelationData));
- int rc;
+ palloc(sizeof(EphemeralNamedRelationData));
+ int rc;
enr->md.name = tdata->tg_trigger->tgnewtable;
enr->md.reliddesc = tdata->tg_relation->rd_id;
if (tdata->tg_oldtable)
{
EphemeralNamedRelation enr =
- palloc(sizeof(EphemeralNamedRelationData));
- int rc;
+ palloc(sizeof(EphemeralNamedRelationData));
+ int rc;
enr->md.name = tdata->tg_trigger->tgoldtable;
enr->md.reliddesc = tdata->tg_relation->rd_id;
if (current == NULL)
{
iter->is_over = true;
- break; /* end of iteration */
+ break; /* end of iteration */
}
else if (came_from == current->right)
{
* If the user does not exist, or has no password or it's expired, we
* still go through the motions of authentication, to avoid revealing to
* the client that the user didn't exist. If 'md5' is allowed, we choose
- * whether to use 'md5' or 'scram-sha-256' authentication based on
- * current password_encryption setting. The idea is that most genuine
- * users probably have a password of that type, and if we pretend that
- * this user had a password of that type, too, it "blends in" best.
+ * whether to use 'md5' or 'scram-sha-256' authentication based on current
+ * password_encryption setting. The idea is that most genuine users
+ * probably have a password of that type, and if we pretend that this user
+ * had a password of that type, too, it "blends in" best.
*/
if (!shadow_pass)
pwtype = Password_encryption;
/*
* If 'md5' authentication is allowed, decide whether to perform 'md5' or
* 'scram-sha-256' authentication based on the type of password the user
- * has. If it's an MD5 hash, we must do MD5 authentication, and if it's
- * a SCRAM verifier, we must do SCRAM authentication.
+ * has. If it's an MD5 hash, we must do MD5 authentication, and if it's a
+ * SCRAM verifier, we must do SCRAM authentication.
*
* If MD5 authentication is not allowed, always use SCRAM. If the user
* had an MD5 password, CheckSCRAMAuth() will fail.
{
*logdetail = psprintf(_("Role \"%s\" does not exist."),
role);
- return NULL; /* no such user */
+ return NULL; /* no such user */
}
datum = SysCacheGetAttr(AUTHNAME, roleTup,
ReleaseSysCache(roleTup);
*logdetail = psprintf(_("User \"%s\" has no password assigned."),
role);
- return NULL; /* user has no password */
+ return NULL; /* user has no password */
}
shadow_pass = TextDatumGetCString(datum);
*logdetail = psprintf(_("User \"%s\" has an empty password."),
role);
pfree(shadow_pass);
- return NULL; /* empty password */
+ return NULL; /* empty password */
}
/*
if (guessed_type != PASSWORD_TYPE_PLAINTEXT)
{
/*
- * Cannot convert an already-encrypted password from one
- * format to another, so return it as it is.
+ * Cannot convert an already-encrypted password from one format to
+ * another, so return it as it is.
*/
return pstrdup(password);
}
break;
case PASSWORD_TYPE_PLAINTEXT:
+
/*
* We never store passwords in plaintext, so this shouldn't
* happen.
tok = lfirst(cell);
if (am_walsender && !am_db_walsender)
{
- /* physical replication walsender connections can only match replication keyword */
+ /*
+ * physical replication walsender connections can only match
+ * replication keyword
+ */
if (token_is_keyword(tok, "replication"))
return true;
}
int ret;
List *parsed_servers;
ListCell *l;
- char *dupval = pstrdup(val);
+ char *dupval = pstrdup(val);
REQUIRE_AUTH_OPTION(uaRADIUS, "radiusservers", "radius");
{
List *parsed_ports;
ListCell *l;
- char *dupval = pstrdup(val);
+ char *dupval = pstrdup(val);
REQUIRE_AUTH_OPTION(uaRADIUS, "radiusports", "radius");
else if (strcmp(name, "radiussecrets") == 0)
{
List *parsed_secrets;
- char *dupval = pstrdup(val);
+ char *dupval = pstrdup(val);
REQUIRE_AUTH_OPTION(uaRADIUS, "radiussecrets", "radius");
else if (strcmp(name, "radiusidentifiers") == 0)
{
List *parsed_identifiers;
- char *dupval = pstrdup(val);
+ char *dupval = pstrdup(val);
REQUIRE_AUTH_OPTION(uaRADIUS, "radiusidentifiers", "radius");
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
-#ifdef _MSC_VER /* mstcpip.h is missing on mingw */
+#ifdef _MSC_VER /* mstcpip.h is missing on mingw */
#include <mstcpip.h>
#endif
static GatherMerge *
_copyGatherMerge(const GatherMerge *from)
{
- GatherMerge *newnode = makeNode(GatherMerge);
+ GatherMerge *newnode = makeNode(GatherMerge);
/*
* copy node superclass fields
static NamedTuplestoreScan *
_copyNamedTuplestoreScan(const NamedTuplestoreScan *from)
{
- NamedTuplestoreScan *newnode = makeNode(NamedTuplestoreScan);
+ NamedTuplestoreScan *newnode = makeNode(NamedTuplestoreScan);
/*
* copy node superclass fields
Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_NextValueExpr:
- Assert(!OidIsValid(collation)); /* result is always an integer type */
+ Assert(!OidIsValid(collation)); /* result is always an integer
+ * type */
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
static void
_outGatherMerge(StringInfo str, const GatherMerge *node)
{
- int i;
+ int i;
WRITE_NODE_TYPE("GATHERMERGE");
*/
typedef struct PTEntryArray
{
- pg_atomic_uint32 refcount; /* no. of iterator attached */
+ pg_atomic_uint32 refcount; /* no. of iterator attached */
PagetableEntry ptentry[FLEXIBLE_ARRAY_MEMBER];
} PTEntryArray;
*/
typedef struct PTIterationArray
{
- pg_atomic_uint32 refcount; /* no. of iterator attached */
+ pg_atomic_uint32 refcount; /* no. of iterator attached */
int index[FLEXIBLE_ARRAY_MEMBER]; /* index array */
} PTIterationArray;
/*
* For every shared iterator, referring to pagetable and iterator array,
- * increase the refcount by 1 so that while freeing the shared iterator
- * we don't free pagetable and iterator array until its refcount becomes 0.
+ * increase the refcount by 1 so that while freeing the shared iterator we
+ * don't free pagetable and iterator array until its refcount becomes 0.
*/
if (ptbase != NULL)
pg_atomic_add_fetch_u32(&ptbase->refcount, 1);
static void set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static void set_namedtuplestore_pathlist(PlannerInfo *root, RelOptInfo *rel,
- RangeTblEntry *rte);
+ RangeTblEntry *rte);
static void set_worktable_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static RelOptInfo *make_rel_from_joinlist(PlannerInfo *root, List *joinlist);
return;
case RTE_NAMEDTUPLESTORE:
+
/*
* tuplestore cannot be shared, at least without more
* infrastructure to support that.
total_subpaths,
pathkeys,
NULL,
- partitioned_rels));
+ partitioned_rels));
}
}
* For each useful ordering, we can consider an order-preserving Gather
* Merge.
*/
- foreach (lc, rel->partial_pathlist)
+ foreach(lc, rel->partial_pathlist)
{
- Path *subpath = (Path *) lfirst(lc);
- GatherMergePath *path;
+ Path *subpath = (Path *) lfirst(lc);
+ GatherMergePath *path;
if (subpath->pathkeys == NIL)
continue;
{
/*
* For index only scans compute workers based on number of index pages
- * fetched; the number of heap pages we fetch might be so small as
- * to effectively rule out parallelism, which we don't want to do.
+ * fetched; the number of heap pages we fetch might be so small as to
+ * effectively rule out parallelism, which we don't want to do.
*/
if (indexonly)
rand_heap_pages = -1;
/* For partial paths, scale row estimate. */
if (path->path.parallel_workers > 0)
{
- double parallel_divisor = get_parallel_divisor(&path->path);
+ double parallel_divisor = get_parallel_divisor(&path->path);
path->path.rows =
clamp_row_est(path->path.rows / parallel_divisor);
/* For partial paths, scale row estimate. */
if (path->jpath.path.parallel_workers > 0)
{
- double parallel_divisor = get_parallel_divisor(&path->jpath.path);
+ double parallel_divisor = get_parallel_divisor(&path->jpath.path);
path->jpath.path.rows =
clamp_row_est(path->jpath.path.rows / parallel_divisor);
/* For partial paths, scale row estimate. */
if (path->jpath.path.parallel_workers > 0)
{
- double parallel_divisor = get_parallel_divisor(&path->jpath.path);
+ double parallel_divisor = get_parallel_divisor(&path->jpath.path);
path->jpath.path.rows =
clamp_row_est(path->jpath.path.rows / parallel_divisor);
true);
/*
- * if, after costing the path, we find that it's not worth
- * using parallel workers, just free it.
+ * if, after costing the path, we find that it's not worth using
+ * parallel workers, just free it.
*/
if (ipath->path.parallel_workers > 0)
add_partial_path(rel, (Path *) ipath);
static CteScan *create_ctescan_plan(PlannerInfo *root, Path *best_path,
List *tlist, List *scan_clauses);
static NamedTuplestoreScan *create_namedtuplestorescan_plan(PlannerInfo *root,
- Path *best_path, List *tlist, List *scan_clauses);
+ Path *best_path, List *tlist, List *scan_clauses);
static WorkTableScan *create_worktablescan_plan(PlannerInfo *root, Path *best_path,
List *tlist, List *scan_clauses);
static ForeignScan *create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path,
static CteScan *make_ctescan(List *qptlist, List *qpqual,
Index scanrelid, int ctePlanId, int cteParam);
static NamedTuplestoreScan *make_namedtuplestorescan(List *qptlist, List *qpqual,
- Index scanrelid, char *enrname);
+ Index scanrelid, char *enrname);
static WorkTableScan *make_worktablescan(List *qptlist, List *qpqual,
Index scanrelid, int wtParam);
static Append *make_append(List *appendplans, List *tlist, List *partitioned_rels);
/*
* bitmap_subplan_mark_shared
- * Set isshared flag in bitmap subplan so that it will be created in
+ * Set isshared flag in bitmap subplan so that it will be created in
* shared memory.
*/
static void
node->partitioned_rels = partitioned_rels;
node->resultRelations = resultRelations;
node->resultRelIndex = -1; /* will be set correctly in setrefs.c */
- node->rootResultRelIndex = -1; /* will be set correctly in setrefs.c */
+ node->rootResultRelIndex = -1; /* will be set correctly in setrefs.c */
node->plans = subplans;
if (!onconflict)
{
#define EXPRKIND_QUAL 0
#define EXPRKIND_TARGET 1
#define EXPRKIND_RTFUNC 2
-#define EXPRKIND_RTFUNC_LATERAL 3
+#define EXPRKIND_RTFUNC_LATERAL 3
#define EXPRKIND_VALUES 4
-#define EXPRKIND_VALUES_LATERAL 5
+#define EXPRKIND_VALUES_LATERAL 5
#define EXPRKIND_LIMIT 6
#define EXPRKIND_APPINFO 7
#define EXPRKIND_PHV 8
ListCell *lc;
Index rti;
RangeTblEntry *parent_rte;
- List *partitioned_rels = NIL;
+ List *partitioned_rels = NIL;
Assert(parse->commandType != CMD_INSERT);
/*
* If the parent RTE is a partitioned table, we should use that as the
* nominal relation, because the RTEs added for partitioned tables
- * (including the root parent) as child members of the inheritance set
- * do not appear anywhere else in the plan. The situation is exactly
- * the opposite in the case of non-partitioned inheritance parent as
- * described below.
+ * (including the root parent) as child members of the inheritance set do
+ * not appear anywhere else in the plan. The situation is exactly the
+ * opposite in the case of non-partitioned inheritance parent as described
+ * below.
*/
parent_rte = rt_fetch(parentRTindex, root->parse->rtable);
if (parent_rte->relkind == RELKIND_PARTITIONED_TABLE)
* is used elsewhere in the plan, so using the original parent RTE
* would give rise to confusing use of multiple aliases in EXPLAIN
* output for what the user will think is the "same" table. OTOH,
- * it's not a problem in the partitioned inheritance case, because
- * the duplicate child RTE added for the parent does not appear
- * anywhere else in the plan tree.
+ * it's not a problem in the partitioned inheritance case, because the
+ * duplicate child RTE added for the parent does not appear anywhere
+ * else in the plan tree.
*/
if (nominalRelation < 0)
nominalRelation = appinfo->child_relid;
ListCell *lc;
ListCell *lc2;
- Assert(gd); /* keep Coverity happy */
+ Assert(gd); /* keep Coverity happy */
dNumGroups = 0;
/*
* We treat this as a knapsack problem: the knapsack capacity
* represents work_mem, the item weights are the estimated memory
- * usage of the hashtables needed to implement a single rollup, and
- * we really ought to use the cost saving as the item value;
+ * usage of the hashtables needed to implement a single rollup,
+ * and we really ought to use the cost saving as the item value;
* however, currently the costs assigned to sort nodes don't
* reflect the comparison costs well, and so we treat all items as
* of equal value (each rollup we hash instead saves us one sort).
foreach(l, root->pcinfo_list)
{
- PartitionedChildRelInfo *pc = lfirst(l);
+ PartitionedChildRelInfo *pc = lfirst(l);
if (pc->parent_relid == rti)
{
* If the main target relation is a partitioned table, the
* following list contains the RT indexes of partitioned child
* relations including the root, which are not included in the
- * above list. We also keep RT indexes of the roots separately
- * to be identitied as such during the executor initialization.
+ * above list. We also keep RT indexes of the roots
+ * separately to be identitied as such during the executor
+ * initialization.
*/
if (splan->partitioned_rels != NIL)
{
list_copy(splan->partitioned_rels));
/* Remember where this root will be in the global list. */
splan->rootResultRelIndex =
- list_length(root->glob->rootResultRelations);
+ list_length(root->glob->rootResultRelations);
root->glob->rootResultRelations =
- lappend_int(root->glob->rootResultRelations,
+ lappend_int(root->glob->rootResultRelations,
linitial_int(splan->partitioned_rels));
}
}
newrc->waitPolicy = oldrc->waitPolicy;
/*
- * We mark RowMarks for partitioned child tables as parent RowMarks
- * so that the executor ignores them (except their existence means
- * that the child tables be locked using appropriate mode).
+ * We mark RowMarks for partitioned child tables as parent
+ * RowMarks so that the executor ignores them (except their
+ * existence means that the child tables be locked using
+ * appropriate mode).
*/
newrc->isParent = (childrte->relkind == RELKIND_PARTITIONED_TABLE);
* parent RT index to the list of RT indexes of its partitioned child
* tables. When creating an Append or a ModifyTable path for the parent,
* we copy the child RT index list verbatim to the path so that it could
- * be carried over to the executor so that the latter could identify
- * the partitioned child tables.
+ * be carried over to the executor so that the latter could identify the
+ * partitioned child tables.
*/
if (partitioned_child_rels != NIL)
{
Relids required_outer, double *rows)
{
GatherMergePath *pathnode = makeNode(GatherMergePath);
- Cost input_startup_cost = 0;
- Cost input_total_cost = 0;
+ Cost input_startup_cost = 0;
+ Cost input_total_cost = 0;
Assert(subpath->parallel_safe);
Assert(pathkeys);
else
{
/* We'll need to insert a Sort node, so include cost for that */
- Path sort_path; /* dummy for result of cost_sort */
+ Path sort_path; /* dummy for result of cost_sort */
cost_sort(&sort_path,
root,
Index varno = rel->relid;
Relation relation;
TupleConstr *constr;
- List *pcqual;
+ List *pcqual;
/*
* We assume the relation has already been safely locked.
/*
* Pass top parent's relids down the inheritance hierarchy. If the parent
- * has top_parent_relids set, it's a direct or an indirect child of the top
- * parent indicated by top_parent_relids. By extension this child is also
- * an indirect child of that parent.
+ * has top_parent_relids set, it's a direct or an indirect child of the
+ * top parent indicated by top_parent_relids. By extension this child is
+ * also an indirect child of that parent.
*/
if (parent)
{
* Recursively transform the components of the tree.
*/
sostmt = castNode(SetOperationStmt,
- transformSetOperationTree(pstate, stmt, true, NULL));
+ transformSetOperationTree(pstate, stmt, true, NULL));
Assert(sostmt);
qry->setOperations = (Node *) sostmt;
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
/*------
translator: %s is a SQL row locking clause such as FOR UPDATE */
- errmsg("%s cannot be applied to a named tuplestore",
- LCS_asString(lc->strength)),
+ errmsg("%s cannot be applied to a named tuplestore",
+ LCS_asString(lc->strength)),
parser_errposition(pstate, thisrel->location)));
break;
default:
static Node *transformJoinOnClause(ParseState *pstate, JoinExpr *j,
List *namespace);
static RangeTblEntry *getRTEForSpecialRelationTypes(ParseState *pstate,
- RangeVar *rv);
+ RangeVar *rv);
static RangeTblEntry *transformTableEntry(ParseState *pstate, RangeVar *r);
static RangeTblEntry *transformCTEReference(ParseState *pstate, RangeVar *r,
CommonTableExpr *cte, Index levelsup);
static RangeTblEntry *transformRangeFunction(ParseState *pstate,
RangeFunction *r);
static RangeTblEntry *transformRangeTableFunc(ParseState *pstate,
- RangeTableFunc *t);
+ RangeTableFunc *t);
static TableSampleClause *transformRangeTableSample(ParseState *pstate,
RangeTableSample *rts);
static Node *transformFromClauseItem(ParseState *pstate, Node *n,
/* Now create the lvar = rvar join condition */
e = makeSimpleA_Expr(AEXPR_OP, "=",
- (Node *) copyObject(lvar), (Node *) copyObject(rvar),
+ (Node *) copyObject(lvar), (Node *) copyObject(rvar),
-1);
/* Prepare to combine into an AND clause, if multiple join columns */
/* Transform and apply typecast to the row-generating expression ... */
Assert(rtf->rowexpr != NULL);
tf->rowexpr = coerce_to_specific_type(pstate,
- transformExpr(pstate, rtf->rowexpr, EXPR_KIND_FROM_FUNCTION),
+ transformExpr(pstate, rtf->rowexpr, EXPR_KIND_FROM_FUNCTION),
TEXTOID,
constructName);
assign_expr_collations(pstate, tf->rowexpr);
/* ... and to the document itself */
Assert(rtf->docexpr != NULL);
tf->docexpr = coerce_to_specific_type(pstate,
- transformExpr(pstate, rtf->docexpr, EXPR_KIND_FROM_FUNCTION),
+ transformExpr(pstate, rtf->docexpr, EXPR_KIND_FROM_FUNCTION),
docType,
constructName);
assign_expr_collations(pstate, tf->docexpr);
makeString(pstrdup(rawc->colname)));
/*
- * Determine the type and typmod for the new column. FOR
- * ORDINALITY columns are INTEGER per spec; the others are
- * user-specified.
+ * Determine the type and typmod for the new column. FOR ORDINALITY
+ * columns are INTEGER per spec; the others are user-specified.
*/
if (rawc->for_ordinality)
{
tf->coltypes = lappend_oid(tf->coltypes, typid);
tf->coltypmods = lappend_int(tf->coltypmods, typmod);
tf->colcollations = lappend_oid(tf->colcollations,
- type_is_collatable(typid) ? DEFAULT_COLLATION_OID : InvalidOid);
+ type_is_collatable(typid) ? DEFAULT_COLLATION_OID : InvalidOid);
/* Transform the PATH and DEFAULT expressions */
if (rawc->colexpr)
{
colexpr = coerce_to_specific_type(pstate,
- transformExpr(pstate, rawc->colexpr,
- EXPR_KIND_FROM_FUNCTION),
+ transformExpr(pstate, rawc->colexpr,
+ EXPR_KIND_FROM_FUNCTION),
TEXTOID,
constructName);
assign_expr_collations(pstate, colexpr);
if (rawc->coldefexpr)
{
coldefexpr = coerce_to_specific_type_typmod(pstate,
- transformExpr(pstate, rawc->coldefexpr,
- EXPR_KIND_FROM_FUNCTION),
+ transformExpr(pstate, rawc->coldefexpr,
+ EXPR_KIND_FROM_FUNCTION),
typid, typmod,
constructName);
assign_expr_collations(pstate, coldefexpr);
static RangeTblEntry *
getRTEForSpecialRelationTypes(ParseState *pstate, RangeVar *rv)
{
-
CommonTableExpr *cte;
Index levelsup;
RangeTblEntry *rte = NULL;
/* ROW() op ROW() is handled specially */
cmp = make_row_comparison_op(pstate,
a->name,
- copyObject(((RowExpr *) lexpr)->args),
+ copyObject(((RowExpr *) lexpr)->args),
((RowExpr *) rexpr)->args,
a->location);
}
*/
if (get_visible_ENR_metadata(pstate->p_queryEnv, relation->relname))
rel = NULL;
+
/*
* An unqualified name might have been meant as a reference to
* some not-yet-in-scope CTE. The bare "does not exist" message
default:
elog(ERROR, "unexpected enrtype: %d", enrmd->enrtype);
- return NULL; /* for fussy compilers */
+ return NULL; /* for fussy compilers */
}
/*
char **snamespace_p, char **sname_p)
{
ListCell *option;
- DefElem *nameEl = NULL;
+ DefElem *nameEl = NULL;
Oid snamespaceid;
char *snamespace;
char *sname;
* used by pg_dump. Else, generate a name.
*
* Although we use ChooseRelationName, it's not guaranteed that the
- * selected sequence name won't conflict; given sufficiently long
- * field names, two different serial columns in the same table could
- * be assigned the same sequence name, and we'd not notice since we
- * aren't creating the sequence quite yet. In practice this seems
- * quite unlikely to be a problem, especially since few people would
- * need two serial columns in one table.
+ * selected sequence name won't conflict; given sufficiently long field
+ * names, two different serial columns in the same table could be assigned
+ * the same sequence name, and we'd not notice since we aren't creating
+ * the sequence quite yet. In practice this seems quite unlikely to be a
+ * problem, especially since few people would need two serial columns in
+ * one table.
*/
foreach(option, seqoptions)
if (nameEl)
{
- RangeVar *rv = makeRangeVarFromNameList(castNode(List, nameEl->arg));
+ RangeVar *rv = makeRangeVarFromNameList(castNode(List, nameEl->arg));
+
snamespace = rv->schemaname;
sname = rv->relname;
seqoptions = list_delete_ptr(seqoptions, nameEl);
cxt->relation->relname, column->colname)));
/*
- * Build a CREATE SEQUENCE command to create the sequence object, and
- * add it to the list of things to be done before this CREATE/ALTER
- * TABLE.
+ * Build a CREATE SEQUENCE command to create the sequence object, and add
+ * it to the list of things to be done before this CREATE/ALTER TABLE.
*/
seqstmt = makeNode(CreateSeqStmt);
seqstmt->for_identity = for_identity;
seqstmt->sequence = makeRangeVar(snamespace, sname, -1);
seqstmt->options = seqoptions;
+
/*
* If a sequence data type was specified, add it to the options. Prepend
* to the list rather than append; in case a user supplied their own AS
seqstmt->options);
/*
- * If this is ALTER ADD COLUMN, make sure the sequence will be owned
- * by the table's owner. The current user might be someone else
- * (perhaps a superuser, or someone who's only a member of the owning
- * role), but the SEQUENCE OWNED BY mechanisms will bleat unless table
- * and sequence have exactly the same owning role.
+ * If this is ALTER ADD COLUMN, make sure the sequence will be owned by
+ * the table's owner. The current user might be someone else (perhaps a
+ * superuser, or someone who's only a member of the owning role), but the
+ * SEQUENCE OWNED BY mechanisms will bleat unless table and sequence have
+ * exactly the same owning role.
*/
if (cxt->rel)
seqstmt->ownerId = cxt->rel->rd_rel->relowner;
cxt->blist = lappend(cxt->blist, seqstmt);
/*
- * Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence
- * as owned by this column, and add it to the list of things to be
- * done after this CREATE/ALTER TABLE.
+ * Build an ALTER SEQUENCE ... OWNED BY command to mark the sequence as
+ * owned by this column, and add it to the list of things to be done after
+ * this CREATE/ALTER TABLE.
*/
altseqstmt = makeNode(AlterSeqStmt);
altseqstmt->sequence = makeRangeVar(snamespace, sname, -1);
break;
case CONSTR_IDENTITY:
- {
- Type ctype;
- Oid typeOid;
+ {
+ Type ctype;
+ Oid typeOid;
- ctype = typenameType(cxt->pstate, column->typeName, NULL);
- typeOid = HeapTupleGetOid(ctype);
- ReleaseSysCache(ctype);
+ ctype = typenameType(cxt->pstate, column->typeName, NULL);
+ typeOid = HeapTupleGetOid(ctype);
+ ReleaseSysCache(ctype);
- if (saw_identity)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("multiple identity specifications for column \"%s\" of table \"%s\"",
+ if (saw_identity)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("multiple identity specifications for column \"%s\" of table \"%s\"",
column->colname, cxt->relation->relname),
- parser_errposition(cxt->pstate,
- constraint->location)));
+ parser_errposition(cxt->pstate,
+ constraint->location)));
- generateSerialExtraStmts(cxt, column,
- typeOid, constraint->options, true,
- NULL, NULL);
+ generateSerialExtraStmts(cxt, column,
+ typeOid, constraint->options, true,
+ NULL, NULL);
- column->identity = constraint->generated_when;
- saw_identity = true;
- column->is_not_null = TRUE;
- break;
- }
+ column->identity = constraint->generated_when;
+ saw_identity = true;
+ column->is_not_null = TRUE;
+ break;
+ }
case CONSTR_CHECK:
cxt->ckconstraints = lappend(cxt->ckconstraints, constraint);
if (attribute->attidentity &&
(table_like_clause->options & CREATE_TABLE_LIKE_IDENTITY))
{
- Oid seq_relid;
+ Oid seq_relid;
List *seq_options;
/*
stmt->objtype = OBJECT_COLUMN;
stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
- makeString(cxt->relation->relname),
+ makeString(cxt->relation->relname),
makeString(def->colname));
stmt->comment = comment;
stmt->objtype = OBJECT_TABCONSTRAINT;
stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
- makeString(cxt->relation->relname),
+ makeString(cxt->relation->relname),
makeString(n->conname));
stmt->comment = comment;
* change the data type of the sequence.
*/
attnum = get_attnum(relid, cmd->name);
- /* if attribute not found, something will error about it later */
+
+ /*
+ * if attribute not found, something will error about it
+ * later
+ */
if (attnum != InvalidAttrNumber && get_attidentity(relid, attnum))
{
Oid seq_relid = getOwnedSequence(relid, attnum);
AlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt);
altseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),
- get_rel_name(seq_relid),
+ get_rel_name(seq_relid),
-1);
altseqstmt->options = list_make1(makeDefElem("as", (Node *) makeTypeNameFromOid(typeOid, -1), -1));
altseqstmt->for_identity = true;
case AT_AddIdentity:
{
- Constraint *def = castNode(Constraint, cmd->def);
- ColumnDef *newdef = makeNode(ColumnDef);
+ Constraint *def = castNode(Constraint, cmd->def);
+ ColumnDef *newdef = makeNode(ColumnDef);
AttrNumber attnum;
newdef->colname = cmd->name;
cmd->def = (Node *) newdef;
attnum = get_attnum(relid, cmd->name);
- /* if attribute not found, something will error about it later */
+
+ /*
+ * if attribute not found, something will error about it
+ * later
+ */
if (attnum != InvalidAttrNumber)
generateSerialExtraStmts(&cxt, newdef,
get_atttype(relid, attnum),
*/
foreach(lc, castNode(List, cmd->def))
{
- DefElem *def = lfirst_node(DefElem, lc);
+ DefElem *def = lfirst_node(DefElem, lc);
if (strcmp(def->defname, "generated") == 0)
newdef = lappend(newdef, def);
seqstmt = makeNode(AlterSeqStmt);
seq_relid = linitial_oid(seqlist);
seqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)),
- get_rel_name(seq_relid), -1);
+ get_rel_name(seq_relid), -1);
seqstmt->options = newseqopts;
seqstmt->for_identity = true;
seqstmt->missing_ok = false;
cxt.alist = lappend(cxt.alist, seqstmt);
}
}
- /* If column was not found or was not an identity column, we
- * just let the ALTER TABLE command error out later. */
+
+ /*
+ * If column was not found or was not an identity column,
+ * we just let the ALTER TABLE command error out later.
+ */
cmd->def = (Node *) newdef;
newcmds = lappend(newcmds, cmd);
else if (seen_unbounded)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot specify finite value after UNBOUNDED"),
- parser_errposition(pstate, exprLocation((Node *) ldatum))));
+ errmsg("cannot specify finite value after UNBOUNDED"),
+ parser_errposition(pstate, exprLocation((Node *) ldatum))));
}
seen_unbounded = false;
foreach(cell1, spec->upperdatums)
else if (seen_unbounded)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot specify finite value after UNBOUNDED"),
- parser_errposition(pstate, exprLocation((Node *) rdatum))));
+ errmsg("cannot specify finite value after UNBOUNDED"),
+ parser_errposition(pstate, exprLocation((Node *) rdatum))));
}
i = j = 0;
* Attempt to create a new unnamed semaphore.
*/
static void
-PosixSemaphoreCreate(sem_t * sem)
+PosixSemaphoreCreate(sem_t *sem)
{
if (sem_init(sem, 1, 1) < 0)
elog(FATAL, "sem_init failed: %m");
* PosixSemaphoreKill - removes a semaphore
*/
static void
-PosixSemaphoreKill(sem_t * sem)
+PosixSemaphoreKill(sem_t *sem)
{
#ifdef USE_NAMED_POSIX_SEMAPHORES
/* Got to use sem_close for named semaphores */
{
RegisteredBgWorker *rw;
BackgroundWorkerSlot *slot;
- int notify_pid;
+ int notify_pid;
rw = slist_container(RegisteredBgWorker, rw_lnode, cur->cur);
* check whether there has been any WAL inserted since the last time
* we've logged a running xacts.
*
- * We do this logging in the bgwriter as it is the only process that is
- * run regularly and returns to its mainloop all the time. E.g.
+ * We do this logging in the bgwriter as it is the only process that
+ * is run regularly and returns to its mainloop all the time. E.g.
* Checkpointer, when active, is barely ever in its mainloop and thus
* makes it hard to log regularly.
*/
*/
rc = WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
- BgWriterDelay /* ms */, WAIT_EVENT_BGWRITER_MAIN);
+ BgWriterDelay /* ms */ , WAIT_EVENT_BGWRITER_MAIN);
/*
* If no latch event and BgBufferSync says nothing's happening, extend
rc = WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
- cur_timeout * 1000L /* convert to ms */,
+ cur_timeout * 1000L /* convert to ms */ ,
WAIT_EVENT_CHECKPOINTER_MAIN);
/*
*/
typedef struct TabStatHashEntry
{
- Oid t_id;
- PgStat_TableStatus* tsa_entry;
+ Oid t_id;
+ PgStat_TableStatus *tsa_entry;
} TabStatHashEntry;
/*
static PgStat_TableStatus *
get_tabstat_entry(Oid rel_id, bool isshared)
{
- TabStatHashEntry* hash_entry;
+ TabStatHashEntry *hash_entry;
PgStat_TableStatus *entry;
TabStatusArray *tsa;
- bool found;
+ bool found;
/*
* Create hash table if we don't have it already.
*/
if (pgStatTabHash == NULL)
{
- HASHCTL ctl;
+ HASHCTL ctl;
memset(&ctl, 0, sizeof(ctl));
ctl.keysize = sizeof(Oid);
PgStat_TableStatus *
find_tabstat_entry(Oid rel_id)
{
- TabStatHashEntry* hash_entry;
+ TabStatHashEntry *hash_entry;
/* If hashtable doesn't exist, there are no entries at all */
- if(!pgStatTabHash)
+ if (!pgStatTabHash)
return NULL;
hash_entry = hash_search(pgStatTabHash, &rel_id, HASH_FIND, NULL);
- if(!hash_entry)
+ if (!hash_entry)
return NULL;
/* Note that this step could also return NULL, but that's correct */
break;
default:
elog(FATAL, "unrecognized process type: %d",
- (int) MyAuxProcType);
+ (int) MyAuxProcType);
proc_exit(1);
}
}
/* We have userid for client-backends, wal-sender and bgworker processes */
if (beentry->st_backendType == B_BACKEND
- || beentry->st_backendType == B_WAL_SENDER
- || beentry->st_backendType == B_BG_WORKER)
+ || beentry->st_backendType == B_WAL_SENDER
+ || beentry->st_backendType == B_BG_WORKER)
beentry->st_userid = GetSessionUserId();
else
beentry->st_userid = InvalidOid;
break;
case PG_WAIT_ACTIVITY:
{
- WaitEventActivity w = (WaitEventActivity) wait_event_info;
+ WaitEventActivity w = (WaitEventActivity) wait_event_info;
event_name = pgstat_get_wait_activity(w);
break;
}
case PG_WAIT_CLIENT:
{
- WaitEventClient w = (WaitEventClient) wait_event_info;
+ WaitEventClient w = (WaitEventClient) wait_event_info;
event_name = pgstat_get_wait_client(w);
break;
break;
case PG_WAIT_IPC:
{
- WaitEventIPC w = (WaitEventIPC) wait_event_info;
+ WaitEventIPC w = (WaitEventIPC) wait_event_info;
event_name = pgstat_get_wait_ipc(w);
break;
}
case PG_WAIT_TIMEOUT:
{
- WaitEventTimeout w = (WaitEventTimeout) wait_event_info;
+ WaitEventTimeout w = (WaitEventTimeout) wait_event_info;
event_name = pgstat_get_wait_timeout(w);
break;
case WAIT_EVENT_LOGICAL_APPLY_MAIN:
event_name = "LogicalApplyMain";
break;
- /* no default case, so that compiler will warn */
+ /* no default case, so that compiler will warn */
}
return event_name;
case WAIT_EVENT_WAL_SENDER_WRITE_DATA:
event_name = "WalSenderWriteData";
break;
- /* no default case, so that compiler will warn */
+ /* no default case, so that compiler will warn */
}
return event_name;
case WAIT_EVENT_LOGICAL_SYNC_STATE_CHANGE:
event_name = "LogicalSyncStateChange";
break;
- /* no default case, so that compiler will warn */
+ /* no default case, so that compiler will warn */
}
return event_name;
case WAIT_EVENT_RECOVERY_APPLY_DELAY:
event_name = "RecoveryApplyDelay";
break;
- /* no default case, so that compiler will warn */
+ /* no default case, so that compiler will warn */
}
return event_name;
return backendDesc;
}
+
/* ------------------------------------------------------------
* Local support functions follow
* ------------------------------------------------------------
wr = WaitLatchOrSocket(MyLatch,
WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE | WL_TIMEOUT,
pgStatSock,
- 2 * 1000L /* msec */,
+ 2 * 1000L /* msec */ ,
WAIT_EVENT_PGSTAT_MAIN);
#endif
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not remove file \"%s\": %m",
- LOG_METAINFO_DATAFILE)));
+ LOG_METAINFO_DATAFILE)));
/*
* If enabled, start up syslogger collection subprocess
int exitstatus) /* child's exit status */
{
char namebuf[MAXPGPATH];
- slist_mutable_iter iter;
+ slist_mutable_iter iter;
slist_foreach_modify(iter, &BackgroundWorkerList)
{
rw->rw_backend = NULL;
rw->rw_pid = 0;
rw->rw_child_slot = 0;
- ReportBackgroundWorkerExit(&iter); /* report child death */
+ ReportBackgroundWorkerExit(&iter); /* report child death */
LogChildExit(EXIT_STATUS_0(exitstatus) ? DEBUG1 : LOG,
namebuf, pid, exitstatus);
#ifdef HAVE_STRONG_RANDOM
return pg_strong_random((char *) cancel_key, sizeof(int32));
#else
+
/*
* If built with --disable-strong-random, use plain old erand48.
*
- * We cannot use pg_backend_random() in postmaster, because it stores
- * its state in shared memory.
+ * We cannot use pg_backend_random() in postmaster, because it stores its
+ * state in shared memory.
*/
static unsigned short seed[3];
if (canAcceptConnections() == CAC_OK)
{
/*
- * Compute the cancel key that will be assigned to this session.
- * We probably don't need cancel keys for autovac workers, but
- * we'd better have something random in the field to prevent
- * unfriendly people from sending cancels to them.
+ * Compute the cancel key that will be assigned to this session. We
+ * probably don't need cancel keys for autovac workers, but we'd
+ * better have something random in the field to prevent unfriendly
+ * people from sending cancels to them.
*/
if (!RandomCancelKey(&MyCancelKey))
{
static void
update_metainfo_datafile(void)
{
- FILE *fh;
+ FILE *fh;
if (!(Log_destination & LOG_DESTINATION_STDERR) &&
!(Log_destination & LOG_DESTINATION_CSVLOG))
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not remove file \"%s\": %m",
- LOG_METAINFO_DATAFILE)));
+ LOG_METAINFO_DATAFILE)));
return;
}
ereport(LOG,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m",
- LOG_METAINFO_DATAFILE_TMP)));
+ LOG_METAINFO_DATAFILE_TMP)));
return;
}
{
ereport(LOG,
(errcode_for_file_access(),
- errmsg("could not write file \"%s\": %m",
+ errmsg("could not write file \"%s\": %m",
LOG_METAINFO_DATAFILE_TMP)));
fclose(fh);
return;
{
ereport(LOG,
(errcode_for_file_access(),
- errmsg("could not write file \"%s\": %m",
+ errmsg("could not write file \"%s\": %m",
LOG_METAINFO_DATAFILE_TMP)));
fclose(fh);
return;
if (rename(LOG_METAINFO_DATAFILE_TMP, LOG_METAINFO_DATAFILE) != 0)
ereport(LOG,
(errcode_for_file_access(),
- errmsg("could not rename file \"%s\" to \"%s\": %m",
- LOG_METAINFO_DATAFILE_TMP, LOG_METAINFO_DATAFILE)));
+ errmsg("could not rename file \"%s\" to \"%s\": %m",
+ LOG_METAINFO_DATAFILE_TMP, LOG_METAINFO_DATAFILE)));
}
/* --------------------------------
static void sendFileWithContent(const char *filename, const char *content);
static int64 _tarWriteHeader(const char *filename, const char *linktarget,
struct stat * statbuf, bool sizeonly);
-static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
- bool sizeonly);
+static int64 _tarWriteDir(const char *pathbuf, int basepathlen, struct stat * statbuf,
+ bool sizeonly);
static void send_int8_string(StringInfoData *buf, int64 intval);
static void SendBackupHeader(List *tablespaces);
static void base_backup_cleanup(int code, Datum arg);
{
/*
* Skip temporary statistics files. PG_STAT_TMP_DIR must be skipped even
- * when stats_temp_directory is set because PGSS_TEXT_FILE is always created
- * there.
+ * when stats_temp_directory is set because PGSS_TEXT_FILE is always
+ * created there.
*/
PG_STAT_TMP_DIR,
/*
- * It is generally not useful to backup the contents of this directory even
- * if the intention is to restore to another master. See backup.sgml for a
- * more detailed description.
+ * It is generally not useful to backup the contents of this directory
+ * even if the intention is to restore to another master. See backup.sgml
+ * for a more detailed description.
*/
"pg_replslot",
dir = AllocateDir("pg_wal");
if (!dir)
ereport(ERROR,
- (errmsg("could not open directory \"%s\": %m", "pg_wal")));
+ (errmsg("could not open directory \"%s\": %m", "pg_wal")));
while ((de = ReadDir(dir, "pg_wal")) != NULL)
{
/* Does it look like a WAL segment, and is it in the range? */
qsort(walFiles, nWalFiles, sizeof(char *), compareWalFileNames);
/*
- * There must be at least one xlog file in the pg_wal directory,
- * since we are doing backup-including-xlog.
+ * There must be at least one xlog file in the pg_wal directory, since
+ * we are doing backup-including-xlog.
*/
if (nWalFiles < 1)
ereport(ERROR,
if (strcmp(de->d_name, excludeDirContents[excludeIdx]) == 0)
{
elog(DEBUG1, "contents of directory \"%s\" excluded from backup", de->d_name);
- size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
+ size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
excludeFound = true;
break;
}
if (!sizeonly)
{
rc = tarCreateHeader(h, filename, linktarget, statbuf->st_size,
- statbuf->st_mode, statbuf->st_uid, statbuf->st_gid,
+ statbuf->st_mode, statbuf->st_uid, statbuf->st_gid,
statbuf->st_mtime);
switch (rc)
break;
case TAR_SYMLINK_TOO_LONG:
ereport(ERROR,
- (errmsg("symbolic link target too long for tar format: "
- "file name \"%s\", target \"%s\"",
- filename, linktarget)));
+ (errmsg("symbolic link target too long for tar format: "
+ "file name \"%s\", target \"%s\"",
+ filename, linktarget)));
break;
default:
elog(ERROR, "unrecognized tar error: %d", rc);
* write it as a directory anyway.
*/
static int64
-_tarWriteDir(const char *pathbuf, int basepathlen, struct stat *statbuf,
+_tarWriteDir(const char *pathbuf, int basepathlen, struct stat * statbuf,
bool sizeonly)
{
/* If symlink, write it as a directory anyway */
struct WalReceiverConn
{
/* Current connection to the primary, if any */
- PGconn *streamConn;
+ PGconn *streamConn;
/* Used to remember if the connection is logical or physical */
- bool logical;
+ bool logical;
/* Buffer for currently read records */
- char *recvBuf;
+ char *recvBuf;
};
/* Prototypes for interface functions */
static WalReceiverConn *libpqrcv_connect(const char *conninfo,
- bool logical, const char *appname,
- char **err);
+ bool logical, const char *appname,
+ char **err);
static void libpqrcv_check_conninfo(const char *conninfo);
static char *libpqrcv_get_conninfo(WalReceiverConn *conn);
static char *libpqrcv_identify_system(WalReceiverConn *conn,
- TimeLineID *primary_tli,
- int *server_version);
+ TimeLineID *primary_tli,
+ int *server_version);
static void libpqrcv_readtimelinehistoryfile(WalReceiverConn *conn,
TimeLineID tli, char **filename,
char **content, int *len);
static bool libpqrcv_startstreaming(WalReceiverConn *conn,
- const WalRcvStreamOptions *options);
+ const WalRcvStreamOptions *options);
static void libpqrcv_endstreaming(WalReceiverConn *conn,
- TimeLineID *next_tli);
-static int libpqrcv_receive(WalReceiverConn *conn, char **buffer,
- pgsocket *wait_fd);
+ TimeLineID *next_tli);
+static int libpqrcv_receive(WalReceiverConn *conn, char **buffer,
+ pgsocket *wait_fd);
static void libpqrcv_send(WalReceiverConn *conn, const char *buffer,
- int nbytes);
+ int nbytes);
static char *libpqrcv_create_slot(WalReceiverConn *conn,
- const char *slotname,
- bool temporary,
- CRSSnapshotAction snapshot_action,
- XLogRecPtr *lsn);
+ const char *slotname,
+ bool temporary,
+ CRSSnapshotAction snapshot_action,
+ XLogRecPtr *lsn);
static WalRcvExecResult *libpqrcv_exec(WalReceiverConn *conn,
- const char *query,
- const int nRetTypes,
- const Oid *retTypes);
+ const char *query,
+ const int nRetTypes,
+ const Oid *retTypes);
static void libpqrcv_disconnect(WalReceiverConn *conn);
static WalReceiverFunctionsType PQWalReceiverFunctions = {
conn = palloc0(sizeof(WalReceiverConn));
conn->streamConn = PQconnectStartParams(keys, vals,
- /* expand_dbname = */ true);
+ /* expand_dbname = */ true);
if (PQstatus(conn->streamConn) == CONNECTION_BAD)
{
*err = pchomp(PQerrorMessage(conn->streamConn));
static void
libpqrcv_check_conninfo(const char *conninfo)
{
- PQconninfoOption *opts = NULL;
- char *err = NULL;
+ PQconninfoOption *opts = NULL;
+ char *err = NULL;
opts = PQconninfoParse(conninfo, &err);
if (opts == NULL)
*/
if (options->logical)
{
- char *pubnames_str;
- List *pubnames;
- char *pubnames_literal;
+ char *pubnames_str;
+ List *pubnames;
+ char *pubnames_literal;
appendStringInfoString(&cmd, " (");
* next timeline's ID, or just CommandComplete if the server was shut
* down.
*
- * If we had not yet received CopyDone from the backend, PGRES_COPY_OUT
- * is also possible in case we aborted the copy in mid-stream.
+ * If we had not yet received CopyDone from the backend, PGRES_COPY_OUT is
+ * also possible in case we aborted the copy in mid-stream.
*/
res = PQgetResult(conn->streamConn);
if (PQresultStatus(res) == PGRES_TUPLES_OK)
/*
* PQexec() silently discards any prior query results on the connection.
- * This is not required for this function as it's expected that the
- * caller (which is this library in all cases) will behave correctly and
- * we don't have to be backwards compatible with old libpq.
+ * This is not required for this function as it's expected that the caller
+ * (which is this library in all cases) will behave correctly and we don't
+ * have to be backwards compatible with old libpq.
*/
/*
bool temporary, CRSSnapshotAction snapshot_action,
XLogRecPtr *lsn)
{
- PGresult *res;
- StringInfoData cmd;
- char *snapshot;
+ PGresult *res;
+ StringInfoData cmd;
+ char *snapshot;
initStringInfo(&cmd);
}
*lsn = DatumGetLSN(DirectFunctionCall1Coll(pg_lsn_in, InvalidOid,
- CStringGetDatum(PQgetvalue(res, 0, 1))));
+ CStringGetDatum(PQgetvalue(res, 0, 1))));
if (!PQgetisnull(res, 0, 2))
snapshot = pstrdup(PQgetvalue(res, 0, 2));
else
*/
static void
libpqrcv_processTuples(PGresult *pgres, WalRcvExecResult *walres,
- const int nRetTypes, const Oid *retTypes)
+ const int nRetTypes, const Oid *retTypes)
{
- int tupn;
- int coln;
- int nfields = PQnfields(pgres);
- HeapTuple tuple;
- AttInMetadata *attinmeta;
- MemoryContext rowcontext;
- MemoryContext oldcontext;
+ int tupn;
+ int coln;
+ int nfields = PQnfields(pgres);
+ HeapTuple tuple;
+ AttInMetadata *attinmeta;
+ MemoryContext rowcontext;
+ MemoryContext oldcontext;
/* Make sure we got expected number of fields. */
if (nfields != nRetTypes)
/* Process returned rows. */
for (tupn = 0; tupn < PQntuples(pgres); tupn++)
{
- char *cstrs[MaxTupleAttributeNumber];
+ char *cstrs[MaxTupleAttributeNumber];
CHECK_FOR_INTERRUPTS();
if (MyDatabaseId == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("the query interface requires a database connection")));
+ errmsg("the query interface requires a database connection")));
pgres = libpqrcv_PQexec(conn->streamConn, query);
walres->status = WALRCV_OK_COMMAND;
break;
- /* Empty query is considered error. */
+ /* Empty query is considered error. */
case PGRES_EMPTY_QUERY:
walres->status = WALRCV_ERROR;
walres->err = _("empty query");
static char *
stringlist_to_identifierstr(PGconn *conn, List *strings)
{
- ListCell *lc;
+ ListCell *lc;
StringInfoData res;
- bool first = true;
+ bool first = true;
initStringInfo(&res);
- foreach (lc, strings)
+ foreach(lc, strings)
{
- char *val = strVal(lfirst(lc));
- char *val_escaped;
+ char *val = strVal(lfirst(lc));
+ char *val_escaped;
if (first)
first = false;
/* max sleep time between cycles (3min) */
#define DEFAULT_NAPTIME_PER_CYCLE 180000L
-int max_logical_replication_workers = 4;
-int max_sync_workers_per_subscription = 2;
+int max_logical_replication_workers = 4;
+int max_sync_workers_per_subscription = 2;
LogicalRepWorker *MyLogicalRepWorker = NULL;
pid_t launcher_pid;
/* Background workers. */
- LogicalRepWorker workers[FLEXIBLE_ARRAY_MEMBER];
+ LogicalRepWorker workers[FLEXIBLE_ARRAY_MEMBER];
} LogicalRepCtxStruct;
LogicalRepCtxStruct *LogicalRepCtx;
volatile sig_atomic_t got_SIGHUP = false;
volatile sig_atomic_t got_SIGTERM = false;
-static bool on_commit_launcher_wakeup = false;
+static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
/*
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
- Subscription *sub;
- MemoryContext oldcxt;
+ Subscription *sub;
+ MemoryContext oldcxt;
/*
* Allocate our results in the caller's context, not the
LogicalRepWorker *
logicalrep_worker_find(Oid subid, Oid relid, bool only_running)
{
- int i;
- LogicalRepWorker *res = NULL;
+ int i;
+ LogicalRepWorker *res = NULL;
Assert(LWLockHeldByMe(LogicalRepWorkerLock));
/* Search for attached worker for a given subscription id. */
for (i = 0; i < max_logical_replication_workers; i++)
{
- LogicalRepWorker *w = &LogicalRepCtx->workers[i];
+ LogicalRepWorker *w = &LogicalRepCtx->workers[i];
+
if (w->in_use && w->subid == subid && w->relid == relid &&
(!only_running || w->proc))
{
logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
Oid relid)
{
- BackgroundWorker bgw;
+ BackgroundWorker bgw;
BackgroundWorkerHandle *bgw_handle;
- int i;
- int slot = 0;
- LogicalRepWorker *worker = NULL;
- int nsyncworkers;
- TimestampTz now;
+ int i;
+ int slot = 0;
+ LogicalRepWorker *worker = NULL;
+ int nsyncworkers;
+ TimestampTz now;
ereport(LOG,
- (errmsg("starting logical replication worker for subscription \"%s\"",
- subname)));
+ (errmsg("starting logical replication worker for subscription \"%s\"",
+ subname)));
/* Report this after the initial starting message for consistency. */
if (max_replication_slots == 0)
*/
if (worker == NULL || nsyncworkers >= max_sync_workers_per_subscription)
{
- bool did_cleanup = false;
+ bool did_cleanup = false;
for (i = 0; i < max_logical_replication_workers; i++)
{
/* Register the new dynamic worker. */
memset(&bgw, 0, sizeof(bgw));
- bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
+ bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
BGWORKER_BACKEND_DATABASE_CONNECTION;
bgw.bgw_start_time = BgWorkerStart_RecoveryFinished;
snprintf(bgw.bgw_library_name, BGW_MAXLEN, "postgres");
ereport(WARNING,
(errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
errmsg("out of background worker slots"),
- errhint("You might need to increase max_worker_processes.")));
+ errhint("You might need to increase max_worker_processes.")));
return;
}
logicalrep_worker_stop(Oid subid, Oid relid)
{
LogicalRepWorker *worker;
- uint16 generation;
+ uint16 generation;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
*/
while (worker->in_use && !worker->proc)
{
- int rc;
+ int rc;
LWLockRelease(LogicalRepWorkerLock);
/* ... and wait for it to die. */
for (;;)
{
- int rc;
+ int rc;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
if (!worker->proc || worker->generation != generation)
void
logicalrep_worker_wakeup(Oid subid, Oid relid)
{
- LogicalRepWorker *worker;
+ LogicalRepWorker *worker;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
worker = logicalrep_worker_find(subid, relid, true);
{
LWLockRelease(LogicalRepWorkerLock);
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("logical replication worker slot %d is empty, cannot attach",
- slot)));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("logical replication worker slot %d is empty, cannot attach",
+ slot)));
}
if (MyLogicalRepWorker->proc)
{
LWLockRelease(LogicalRepWorkerLock);
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("logical replication worker slot %d is already used by "
- "another worker, cannot attach", slot)));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("logical replication worker slot %d is already used by "
+ "another worker, cannot attach", slot)));
}
MyLogicalRepWorker->proc = MyProc;
void
logicalrep_worker_sigterm(SIGNAL_ARGS)
{
- int save_errno = errno;
+ int save_errno = errno;
got_SIGTERM = true;
void
logicalrep_worker_sighup(SIGNAL_ARGS)
{
- int save_errno = errno;
+ int save_errno = errno;
got_SIGHUP = true;
int
logicalrep_sync_worker_count(Oid subid)
{
- int i;
- int res = 0;
+ int i;
+ int res = 0;
Assert(LWLockHeldByMe(LogicalRepWorkerLock));
/* Search for attached worker for a given subscription id. */
for (i = 0; i < max_logical_replication_workers; i++)
{
- LogicalRepWorker *w = &LogicalRepCtx->workers[i];
+ LogicalRepWorker *w = &LogicalRepCtx->workers[i];
+
if (w->subid == subid && OidIsValid(w->relid))
res++;
}
return;
memset(&bgw, 0, sizeof(bgw));
- bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
+ bgw.bgw_flags = BGWORKER_SHMEM_ACCESS |
BGWORKER_BACKEND_DATABASE_CONNECTION;
bgw.bgw_start_time = BgWorkerStart_RecoveryFinished;
snprintf(bgw.bgw_library_name, BGW_MAXLEN, "postgres");
if (!found)
{
- int slot;
+ int slot;
memset(LogicalRepCtx, 0, ApplyLauncherShmemSize());
void
ApplyLauncherMain(Datum main_arg)
{
- TimestampTz last_start_time = 0;
+ TimestampTz last_start_time = 0;
ereport(DEBUG1,
(errmsg("logical replication launcher started")));
int rc;
List *sublist;
ListCell *lc;
- MemoryContext subctx;
- MemoryContext oldctx;
- TimestampTz now;
- long wait_time = DEFAULT_NAPTIME_PER_CYCLE;
+ MemoryContext subctx;
+ MemoryContext oldctx;
+ TimestampTz now;
+ long wait_time = DEFAULT_NAPTIME_PER_CYCLE;
now = GetCurrentTimestamp();
{
/* Use temporary context for the database list and worker info. */
subctx = AllocSetContextCreate(TopMemoryContext,
- "Logical Replication Launcher sublist",
+ "Logical Replication Launcher sublist",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
/* Start the missing workers for enabled subscriptions. */
foreach(lc, sublist)
{
- Subscription *sub = (Subscription *) lfirst(lc);
- LogicalRepWorker *w;
+ Subscription *sub = (Subscription *) lfirst(lc);
+ LogicalRepWorker *w;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
w = logicalrep_worker_find(sub->oid, InvalidOid, false);
{
/*
* The wait in previous cycle was interrupted in less than
- * wal_retrieve_retry_interval since last worker was started,
- * this usually means crash of the worker, so we should retry
- * in wal_retrieve_retry_interval again.
+ * wal_retrieve_retry_interval since last worker was started, this
+ * usually means crash of the worker, so we should retry in
+ * wal_retrieve_retry_interval again.
*/
wait_time = wal_retrieve_retry_interval;
}
Datum values[PG_STAT_GET_SUBSCRIPTION_COLS];
bool nulls[PG_STAT_GET_SUBSCRIPTION_COLS];
int worker_pid;
- LogicalRepWorker worker;
+ LogicalRepWorker worker;
memcpy(&worker, &LogicalRepCtx->workers[i],
sizeof(LogicalRepWorker));
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
- /* If only a single subscription was requested, and we found it, break. */
+ /*
+ * If only a single subscription was requested, and we found it,
+ * break.
+ */
if (OidIsValid(subid))
break;
}
XLogPageReadCB read_page,
LogicalOutputPluginWriterPrepareWrite prepare_write,
LogicalOutputPluginWriterWrite do_write,
- LogicalOutputPluginWriterUpdateProgress update_progress)
+ LogicalOutputPluginWriterUpdateProgress update_progress)
{
ReplicationSlot *slot;
MemoryContext context,
* plugin contains the name of the output plugin
* output_plugin_options contains options passed to the output plugin
* read_page, prepare_write, do_write, update_progress
- * callbacks that have to be filled to perform the use-case dependent,
- * actual, work.
+ * callbacks that have to be filled to perform the use-case dependent,
+ * actual, work.
*
* Needs to be called while in a memory context that's at least as long lived
* as the decoding context because further memory contexts will be created
XLogPageReadCB read_page,
LogicalOutputPluginWriterPrepareWrite prepare_write,
LogicalOutputPluginWriterWrite do_write,
- LogicalOutputPluginWriterUpdateProgress update_progress)
+ LogicalOutputPluginWriterUpdateProgress update_progress)
{
TransactionId xmin_horizon = InvalidTransactionId;
ReplicationSlot *slot;
if (ctx->reader->EndRecPtr != InvalidXLogRecPtr && confirm)
{
LogicalConfirmReceivedLocation(ctx->reader->EndRecPtr);
+
/*
* If only the confirmed_flush_lsn has changed the slot won't get
- * marked as dirty by the above. Callers on the walsender interface
- * are expected to keep track of their own progress and don't need
- * it written out. But SQL-interface users cannot specify their own
- * start positions and it's harder for them to keep track of their
- * progress, so we should make more of an effort to save it for them.
+ * marked as dirty by the above. Callers on the walsender
+ * interface are expected to keep track of their own progress and
+ * don't need it written out. But SQL-interface users cannot
+ * specify their own start positions and it's harder for them to
+ * keep track of their progress, so we should make more of an
+ * effort to save it for them.
*
- * Dirty the slot so it's written out at the next checkpoint. We'll
- * still lose its position on crash, as documented, but it's better
- * than always losing the position even on clean restart.
+ * Dirty the slot so it's written out at the next checkpoint.
+ * We'll still lose its position on crash, as documented, but it's
+ * better than always losing the position even on clean restart.
*/
ReplicationSlotMarkDirty();
}
static void logicalrep_write_attrs(StringInfo out, Relation rel);
static void logicalrep_write_tuple(StringInfo out, Relation rel,
- HeapTuple tuple);
+ HeapTuple tuple);
static void logicalrep_read_attrs(StringInfo in, LogicalRepRelation *rel);
static void logicalrep_read_tuple(StringInfo in, LogicalRepTupleData *tuple);
logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn,
XLogRecPtr commit_lsn)
{
- uint8 flags = 0;
+ uint8 flags = 0;
pq_sendbyte(out, 'C'); /* sending COMMIT */
logicalrep_read_commit(StringInfo in, LogicalRepCommitData *commit_data)
{
/* read flags (unused for now) */
- uint8 flags = pq_getmsgbyte(in);
+ uint8 flags = pq_getmsgbyte(in);
if (flags != 0)
elog(ERROR, "unrecognized flags %u in commit message", flags);
* Write INSERT to the output stream.
*/
void
-logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
+logicalrep_write_insert(StringInfo out, Relation rel, HeapTuple newtuple)
{
pq_sendbyte(out, 'I'); /* action INSERT */
logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup)
{
char action;
- LogicalRepRelId relid;
+ LogicalRepRelId relid;
/* read the relation id */
relid = pq_getmsgint(in, 4);
*/
void
logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
- HeapTuple newtuple)
+ HeapTuple newtuple)
{
pq_sendbyte(out, 'U'); /* action UPDATE */
if (oldtuple != NULL)
{
if (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
- pq_sendbyte(out, 'O'); /* old tuple follows */
+ pq_sendbyte(out, 'O'); /* old tuple follows */
else
- pq_sendbyte(out, 'K'); /* old key follows */
+ pq_sendbyte(out, 'K'); /* old key follows */
logicalrep_write_tuple(out, rel, oldtuple);
}
LogicalRepTupleData *newtup)
{
char action;
- LogicalRepRelId relid;
+ LogicalRepRelId relid;
/* read the relation id */
relid = pq_getmsgint(in, 4);
logicalrep_read_delete(StringInfo in, LogicalRepTupleData *oldtup)
{
char action;
- LogicalRepRelId relid;
+ LogicalRepRelId relid;
/* read the relation id */
relid = pq_getmsgint(in, 4);
LogicalRepRelation *
logicalrep_read_rel(StringInfo in)
{
- LogicalRepRelation *rel = palloc(sizeof(LogicalRepRelation));
+ LogicalRepRelation *rel = palloc(sizeof(LogicalRepRelation));
rel->remoteid = pq_getmsgint(in, 4);
if (isnull[i])
{
- pq_sendbyte(out, 'n'); /* null column */
+ pq_sendbyte(out, 'n'); /* null column */
continue;
}
else if (att->attlen == -1 && VARATT_IS_EXTERNAL_ONDISK(values[i]))
{
- pq_sendbyte(out, 'u'); /* unchanged toast column */
+ pq_sendbyte(out, 'u'); /* unchanged toast column */
continue;
}
switch (kind)
{
- case 'n': /* null */
+ case 'n': /* null */
tuple->values[i] = NULL;
tuple->changed[i] = true;
break;
- case 'u': /* unchanged column */
+ case 'u': /* unchanged column */
/* we don't receive the value of an unchanged column */
tuple->values[i] = NULL;
break;
- case 't': /* text formatted value */
+ case 't': /* text formatted value */
{
int len;
tuple->changed[i] = true;
- len = pq_getmsgint(in, 4); /* read length */
+ len = pq_getmsgint(in, 4); /* read length */
/* and data */
tuple->values[i] = palloc(len + 1);
for (i = 0; i < desc->natts; i++)
{
Form_pg_attribute att = desc->attrs[i];
- uint8 flags = 0;
+ uint8 flags = 0;
if (att->attisdropped)
continue;
pq_sendbyte(out, '\0');
else
{
- char *nspname = get_namespace_name(nspid);
+ char *nspname = get_namespace_name(nspid);
if (nspname == NULL)
elog(ERROR, "cache lookup failed for namespace %u",
#include "utils/memutils.h"
#include "utils/syscache.h"
-static MemoryContext LogicalRepRelMapContext = NULL;
+static MemoryContext LogicalRepRelMapContext = NULL;
-static HTAB *LogicalRepRelMap = NULL;
-static HTAB *LogicalRepTypMap = NULL;
+static HTAB *LogicalRepRelMap = NULL;
+static HTAB *LogicalRepTypMap = NULL;
static void logicalrep_typmap_invalidate_cb(Datum arg, int cacheid,
- uint32 hashvalue);
+ uint32 hashvalue);
/*
* Relcache invalidation callback for our relation map cache.
static void
logicalrep_relmap_invalidate_cb(Datum arg, Oid reloid)
{
- LogicalRepRelMapEntry *entry;
+ LogicalRepRelMapEntry *entry;
/* Just to be sure. */
if (LogicalRepRelMap == NULL)
/* This will usually be small. */
LogicalRepTypMap = hash_create("logicalrep type map cache", 2, &ctl,
- HASH_ELEM | HASH_BLOBS |HASH_CONTEXT);
+ HASH_ELEM | HASH_BLOBS | HASH_CONTEXT);
/* Watch for invalidation events. */
CacheRegisterRelcacheCallback(logicalrep_relmap_invalidate_cb,
if (remoterel->natts > 0)
{
- int i;
+ int i;
for (i = 0; i < remoterel->natts; i++)
pfree(remoterel->attnames[i]);
void
logicalrep_relmap_update(LogicalRepRelation *remoterel)
{
- MemoryContext oldctx;
- LogicalRepRelMapEntry *entry;
- bool found;
- int i;
+ MemoryContext oldctx;
+ LogicalRepRelMapEntry *entry;
+ bool found;
+ int i;
if (LogicalRepRelMap == NULL)
logicalrep_relmap_init();
static int
logicalrep_rel_att_by_name(LogicalRepRelation *remoterel, const char *attname)
{
- int i;
+ int i;
for (i = 0; i < remoterel->natts; i++)
{
LogicalRepRelMapEntry *
logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
{
- LogicalRepRelMapEntry *entry;
+ LogicalRepRelMapEntry *entry;
bool found;
if (LogicalRepRelMap == NULL)
Bitmapset *idkey;
TupleDesc desc;
LogicalRepRelation *remoterel;
- MemoryContext oldctx;
+ MemoryContext oldctx;
+
remoterel = &entry->remoterel;
/* Try to find and lock the relation by name. */
/*
* Build the mapping of local attribute numbers to remote attribute
- * numbers and validate that we don't miss any replicated columns
- * as that would result in potentially unwanted data loss.
+ * numbers and validate that we don't miss any replicated columns as
+ * that would result in potentially unwanted data loss.
*/
desc = RelationGetDescr(entry->localrel);
oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
found = 0;
for (i = 0; i < desc->natts; i++)
{
- int attnum = logicalrep_rel_att_by_name(remoterel,
- NameStr(desc->attrs[i]->attname));
+ int attnum = logicalrep_rel_att_by_name(remoterel,
+ NameStr(desc->attrs[i]->attname));
+
entry->attrmap[i] = attnum;
if (attnum >= 0)
found++;
if (found < remoterel->natts)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("logical replication target relation \"%s.%s\" is missing "
- "some replicated columns",
- remoterel->nspname, remoterel->relname)));
+ errmsg("logical replication target relation \"%s.%s\" is missing "
+ "some replicated columns",
+ remoterel->nspname, remoterel->relname)));
/*
* Check that replica identity matches. We allow for stricter replica
* but in the opposite scenario it will.
*
* Don't throw any error here just mark the relation entry as not
- * updatable, as replica identity is only for updates and deletes
- * but inserts can be replicated even without it.
+ * updatable, as replica identity is only for updates and deletes but
+ * inserts can be replicated even without it.
*/
entry->updatable = true;
idkey = RelationGetIndexAttrBitmap(entry->localrel,
{
idkey = RelationGetIndexAttrBitmap(entry->localrel,
INDEX_ATTR_BITMAP_PRIMARY_KEY);
+
/*
* If no replica identity index and no PK, the published table
* must have replica identity FULL.
i = -1;
while ((i = bms_next_member(idkey, i)) >= 0)
{
- int attnum = i + FirstLowInvalidHeapAttributeNumber;
+ int attnum = i + FirstLowInvalidHeapAttributeNumber;
if (!AttrNumberIsForUserDefinedAttr(attnum))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("logical replication target relation \"%s.%s\" uses "
- "system columns in REPLICA IDENTITY index",
- remoterel->nspname, remoterel->relname)));
+ errmsg("logical replication target relation \"%s.%s\" uses "
+ "system columns in REPLICA IDENTITY index",
+ remoterel->nspname, remoterel->relname)));
attnum = AttrNumberGetAttrOffset(attnum);
logicalrep_typmap_invalidate_cb(Datum arg, int cacheid, uint32 hashvalue)
{
HASH_SEQ_STATUS status;
- LogicalRepTyp *entry;
+ LogicalRepTyp *entry;
/* Just to be sure. */
if (LogicalRepTypMap == NULL)
void
logicalrep_typmap_update(LogicalRepTyp *remotetyp)
{
- MemoryContext oldctx;
- LogicalRepTyp *entry;
- bool found;
+ MemoryContext oldctx;
+ LogicalRepTyp *entry;
+ bool found;
if (LogicalRepTypMap == NULL)
logicalrep_relmap_init();
Oid
logicalrep_typmap_getid(Oid remoteid)
{
- LogicalRepTyp *entry;
- bool found;
- Oid nspoid;
+ LogicalRepTyp *entry;
+ bool found;
+ Oid nspoid;
/* Internal types are mapped directly. */
if (remoteid < FirstNormalObjectId)
* by the following graph describing the SnapBuild->state transitions:
*
* +-------------------------+
- * +----| START |-------------+
+ * +----| START |-------------+
* | +-------------------------+ |
* | | |
* | | |
* | | |
* | v |
* | +-------------------------+ v
- * | | BUILDING_SNAPSHOT |------------>|
+ * | | BUILDING_SNAPSHOT |------------>|
* | +-------------------------+ |
* | | |
* | | |
- * | running_xacts #2, xacts from #1 finished |
+ * | running_xacts #2, xacts from #1 finished |
* | | |
* | | |
* | v |
* | +-------------------------+ v
- * | | FULL_SNAPSHOT |------------>|
+ * | | FULL_SNAPSHOT |------------>|
* | +-------------------------+ |
* | | |
* running_xacts | saved snapshot
* with zero xacts | at running_xacts's lsn
* | | |
- * | running_xacts with xacts from #2 finished |
+ * | running_xacts with xacts from #2 finished |
* | | |
* | v |
* | +-------------------------+ |
TransactionId was_xmin;
TransactionId was_xmax;
- size_t was_xcnt; /* number of used xip entries */
- size_t was_xcnt_space; /* allocated size of xip */
- TransactionId *was_xip; /* running xacts array, xidComparator-sorted */
+ size_t was_xcnt; /* number of used xip entries */
+ size_t was_xcnt_space; /* allocated size of xip */
+ TransactionId *was_xip; /* running xacts array, xidComparator-sorted */
} was_running;
/*
{
if (newxcnt >= GetMaxSnapshotXidCount())
ereport(ERROR,
- (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
- errmsg("initial slot snapshot too large")));
+ (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
+ errmsg("initial slot snapshot too large")));
newxip[newxcnt++] = xid;
}
if (NormalTransactionIdFollows(subxid, xmax))
xmax = subxid;
}
+
/*
* If we're forcing timetravel we also need visibility information
* about subtransaction, so keep track of subtransaction's state, even
/*
* Adjust xmax of the snapshot builder, we only do that for committed,
- * catalog modifying, transactions, everything else isn't interesting
- * for us since we'll never look at the respective rows.
+ * catalog modifying, transactions, everything else isn't interesting for
+ * us since we'll never look at the respective rows.
*/
if (needs_timetravel &&
(!TransactionIdIsValid(builder->xmax) ||
running->oldestRunningXid);
/*
- * Increase shared memory limits, so vacuum can work on tuples we prevented
- * from being pruned till now.
+ * Increase shared memory limits, so vacuum can work on tuples we
+ * prevented from being pruned till now.
*/
LogicalIncreaseXminForSlot(lsn, running->oldestRunningXid);
* modifying transactions.
*
* c) First incrementally build a snapshot for catalog tuples
- * (BUILDING_SNAPSHOT), that requires all, already in-progress,
- * transactions to finish. Every transaction starting after that
- * (FULL_SNAPSHOT state), has enough information to be decoded. But
- * for older running transactions no viable snapshot exists yet, so
- * CONSISTENT will only be reached once all of those have finished.
+ * (BUILDING_SNAPSHOT), that requires all, already in-progress,
+ * transactions to finish. Every transaction starting after that
+ * (FULL_SNAPSHOT state), has enough information to be decoded. But
+ * for older running transactions no viable snapshot exists yet, so
+ * CONSISTENT will only be reached once all of those have finished.
* ---
*/
/* there won't be any state to cleanup */
return false;
}
+
/*
* c) transition from START to BUILDING_SNAPSHOT.
*
SnapBuildWaitSnapshot(running, running->nextXid);
}
+
/*
* c) transition from BUILDING_SNAPSHOT to FULL_SNAPSHOT.
*
SnapBuildStartNextPhaseAt(builder, running->nextXid);
ereport(LOG,
- (errmsg("logical decoding found initial consistent point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
- errdetail("Waiting for transactions (approximately %d) older than %u to end.",
- running->xcnt, running->nextXid)));
+ (errmsg("logical decoding found initial consistent point at %X/%X",
+ (uint32) (lsn >> 32), (uint32) lsn),
+ errdetail("Waiting for transactions (approximately %d) older than %u to end.",
+ running->xcnt, running->nextXid)));
SnapBuildWaitSnapshot(running, running->nextXid);
}
+
/*
* c) transition from FULL_SNAPSHOT to CONSISTENT.
*
*
* This isn't required for the correctness of decoding, but to:
* a) allow isolationtester to notice that we're currently waiting for
- * something.
+ * something.
* b) log a new xl_running_xacts record where it'd be helpful, without having
- * to write for bgwriter or checkpointer.
+ * to write for bgwriter or checkpointer.
* ---
*/
static void
TransactionId xid = running->xids[off];
/*
- * Upper layers should prevent that we ever need to wait on
- * ourselves. Check anyway, since failing to do so would either
- * result in an endless wait or an Assert() failure.
+ * Upper layers should prevent that we ever need to wait on ourselves.
+ * Check anyway, since failing to do so would either result in an
+ * endless wait or an Assert() failure.
*/
if (TransactionIdIsCurrentTransactionId(xid))
elog(ERROR, "waiting for ourselves");
char path[MAXPGPATH + 21];
/*
- * We start off with a minimum of the last redo pointer. No new replication
- * slot will start before that, so that's a safe upper bound for removal.
+ * We start off with a minimum of the last redo pointer. No new
+ * replication slot will start before that, so that's a safe upper bound
+ * for removal.
*/
redo = GetRedoRecPtr();
/*
* Exit routine for synchronization worker.
*/
-static void pg_attribute_noreturn()
+static void
+pg_attribute_noreturn()
finish_sync_worker(void)
{
/*
static bool
wait_for_sync_status_change(Oid relid, char origstate)
{
- int rc;
- char state = origstate;
+ int rc;
+ char state = origstate;
while (!got_SIGTERM)
{
- LogicalRepWorker *worker;
+ LogicalRepWorker *worker;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
worker = logicalrep_worker_find(MyLogicalRepWorker->subid,
struct tablesync_start_time_mapping
{
Oid relid;
- TimestampTz last_start_time;
+ TimestampTz last_start_time;
};
static List *table_states = NIL;
static HTAB *last_start_times = NULL;
/* We need up to date sync state info for subscription tables here. */
if (!table_states_valid)
{
- MemoryContext oldctx;
- List *rstates;
- ListCell *lc;
+ MemoryContext oldctx;
+ List *rstates;
+ ListCell *lc;
SubscriptionRelState *rstate;
/* Clean the old list. */
started_tx = true;
/* Fetch all non-ready tables. */
- rstates = GetSubscriptionNotReadyRelations(MySubscription->oid);
+ rstates = GetSubscriptionNotReadyRelations(MySubscription->oid);
/* Allocate the tracking info in a permanent memory context. */
oldctx = MemoryContextSwitchTo(CacheMemoryContext);
last_start_times = hash_create("Logical replication table sync worker start times",
256, &ctl, HASH_ELEM | HASH_BLOBS);
}
+
/*
* Clean up the hash table when we're done with all tables (just to
* release the bit of memory).
/* Process all tables that are being synchronized. */
foreach(lc, table_states)
{
- SubscriptionRelState *rstate = (SubscriptionRelState *)lfirst(lc);
+ SubscriptionRelState *rstate = (SubscriptionRelState *) lfirst(lc);
if (rstate->state == SUBREL_STATE_SYNCDONE)
{
/*
- * Apply has caught up to the position where the table sync
- * has finished. Time to mark the table as ready so that
- * apply will just continue to replicate it normally.
+ * Apply has caught up to the position where the table sync has
+ * finished. Time to mark the table as ready so that apply will
+ * just continue to replicate it normally.
*/
if (current_lsn >= rstate->lsn)
{
}
else
{
- LogicalRepWorker *syncworker;
- int nsyncworkers = 0;
+ LogicalRepWorker *syncworker;
+ int nsyncworkers = 0;
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
syncworker = logicalrep_worker_find(MyLogicalRepWorker->subid,
SpinLockRelease(&syncworker->relmutex);
}
else
+
/*
* If no sync worker for this table yet, count running sync
* workers for this subscription, while we have the lock, for
* There are three possible synchronization situations here.
*
* a) Apply is in front of the table sync: We tell the table
- * sync to CATCHUP.
+ * sync to CATCHUP.
*
* b) Apply is behind the table sync: We tell the table sync
- * to mark the table as SYNCDONE and finish.
-
+ * to mark the table as SYNCDONE and finish.
+ *
* c) Apply and table sync are at the same position: We tell
- * table sync to mark the table as READY and finish.
+ * table sync to mark the table as READY and finish.
*
- * In any case we'll need to wait for table sync to change
- * the state in catalog and only then continue ourselves.
+ * In any case we'll need to wait for table sync to change the
+ * state in catalog and only then continue ourselves.
*/
if (current_lsn > rstate->lsn)
{
logicalrep_worker_wakeup_ptr(syncworker);
/*
- * Enter busy loop and wait for synchronization status
- * change.
+ * Enter busy loop and wait for synchronization status change.
*/
wait_for_sync_status_change(rstate->relid, rstate->state);
}
/*
- * If there is no sync worker registered for the table and
- * there is some free sync worker slot, start new sync worker
- * for the table.
+ * If there is no sync worker registered for the table and there
+ * is some free sync worker slot, start new sync worker for the
+ * table.
*/
else if (!syncworker && nsyncworkers < max_sync_workers_per_subscription)
{
- TimestampTz now = GetCurrentTimestamp();
+ TimestampTz now = GetCurrentTimestamp();
struct tablesync_start_time_mapping *hentry;
bool found;
for (i = 0; i < desc->natts; i++)
{
- int remoteattnum = rel->attrmap[i];
+ int remoteattnum = rel->attrmap[i];
/* Skip dropped attributes. */
if (desc->attrs[i]->attisdropped)
continue;
attnamelist = lappend(attnamelist,
- makeString(rel->remoterel.attnames[remoteattnum]));
+ makeString(rel->remoterel.attnames[remoteattnum]));
}
return attnamelist;
static int
copy_read_data(void *outbuf, int minread, int maxread)
{
- int bytesread = 0;
- int avail;
+ int bytesread = 0;
+ int avail;
/* If there are some leftover data from previous read, use them. */
avail = copybuf->len - copybuf->cursor;
fetch_remote_table_info(char *nspname, char *relname,
LogicalRepRelation *lrel)
{
- WalRcvExecResult *res;
- StringInfoData cmd;
- TupleTableSlot *slot;
- Oid tableRow[2] = {OIDOID, CHAROID};
- Oid attrRow[4] = {TEXTOID, OIDOID, INT4OID, BOOLOID};
- bool isnull;
- int natt;
+ WalRcvExecResult *res;
+ StringInfoData cmd;
+ TupleTableSlot *slot;
+ Oid tableRow[2] = {OIDOID, CHAROID};
+ Oid attrRow[4] = {TEXTOID, OIDOID, INT4OID, BOOLOID};
+ bool isnull;
+ int natt;
lrel->nspname = nspname;
lrel->relname = relname;
/* First fetch Oid and replica identity. */
initStringInfo(&cmd);
appendStringInfo(&cmd, "SELECT c.oid, c.relreplident"
- " FROM pg_catalog.pg_class c"
- " INNER JOIN pg_catalog.pg_namespace n"
- " ON (c.relnamespace = n.oid)"
- " WHERE n.nspname = %s"
- " AND c.relname = %s"
- " AND c.relkind = 'r'",
- quote_literal_cstr(nspname),
- quote_literal_cstr(relname));
+ " FROM pg_catalog.pg_class c"
+ " INNER JOIN pg_catalog.pg_namespace n"
+ " ON (c.relnamespace = n.oid)"
+ " WHERE n.nspname = %s"
+ " AND c.relname = %s"
+ " AND c.relkind = 'r'",
+ quote_literal_cstr(nspname),
+ quote_literal_cstr(relname));
res = walrcv_exec(wrconn, cmd.data, 2, tableRow);
if (res->status != WALRCV_OK_TUPLES)
" a.attnum = ANY(i.indkey)"
" FROM pg_catalog.pg_attribute a"
" LEFT JOIN pg_catalog.pg_index i"
- " ON (i.indexrelid = pg_get_replica_identity_index(%u))"
+ " ON (i.indexrelid = pg_get_replica_identity_index(%u))"
" WHERE a.attnum > 0::pg_catalog.int2"
" AND NOT a.attisdropped"
" AND a.attrelid = %u"
/* Should never happen. */
if (++natt >= MaxTupleAttributeNumber)
elog(ERROR, "too many columns in remote table \"%s.%s\"",
- nspname, relname);
+ nspname, relname);
ExecClearTuple(slot);
}
copy_table(Relation rel)
{
LogicalRepRelMapEntry *relmapentry;
- LogicalRepRelation lrel;
- WalRcvExecResult *res;
- StringInfoData cmd;
+ LogicalRepRelation lrel;
+ WalRcvExecResult *res;
+ StringInfoData cmd;
CopyState cstate;
List *attnamelist;
ParseState *pstate;
char *
LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
{
- char *slotname;
- char *err;
+ char *slotname;
+ char *err;
char relstate;
XLogRecPtr relstate_lsn;
* NAMEDATALEN on the remote that matters, but this scheme will also work
* reasonably if that is different.)
*/
- StaticAssertStmt(NAMEDATALEN >= 32, "NAMEDATALEN too small"); /* for sanity */
+ StaticAssertStmt(NAMEDATALEN >= 32, "NAMEDATALEN too small"); /* for sanity */
slotname = psprintf("%.*s_%u_sync_%u",
NAMEDATALEN - 28,
MySubscription->slotname,
case SUBREL_STATE_DATASYNC:
{
Relation rel;
- WalRcvExecResult *res;
+ WalRcvExecResult *res;
SpinLockAcquire(&MyLogicalRepWorker->relmutex);
MyLogicalRepWorker->relstate = SUBREL_STATE_DATASYNC;
pgstat_report_stat(false);
/*
- * We want to do the table data sync in single
- * transaction.
+ * We want to do the table data sync in single transaction.
*/
StartTransactionCommand();
/*
* Use standard write lock here. It might be better to
- * disallow access to table while it's being synchronized.
- * But we don't want to block the main apply process from
- * working and it has to open relation in RowExclusiveLock
- * when remapping remote relation id to local one.
+ * disallow access to table while it's being synchronized. But
+ * we don't want to block the main apply process from working
+ * and it has to open relation in RowExclusiveLock when
+ * remapping remote relation id to local one.
*/
rel = heap_open(MyLogicalRepWorker->relid, RowExclusiveLock);
/*
- * Create temporary slot for the sync process.
- * We do this inside transaction so that we can use the
- * snapshot made by the slot to get existing data.
+ * Create temporary slot for the sync process. We do this
+ * inside transaction so that we can use the snapshot made by
+ * the slot to get existing data.
*/
res = walrcv_exec(wrconn,
"BEGIN READ ONLY ISOLATION LEVEL "
/*
* Create new temporary logical decoding slot.
*
- * We'll use slot for data copy so make sure the snapshot
- * is used for the transaction, that way the COPY will get
- * data that is consistent with the lsn used by the slot
- * to start decoding.
+ * We'll use slot for data copy so make sure the snapshot is
+ * used for the transaction, that way the COPY will get data
+ * that is consistent with the lsn used by the slot to start
+ * decoding.
*/
walrcv_create_slot(wrconn, slotname, true,
CRS_USE_SNAPSHOT, origin_startpos);
CommandCounterIncrement();
/*
- * We are done with the initial data synchronization,
- * update the state.
+ * We are done with the initial data synchronization, update
+ * the state.
*/
SpinLockAcquire(&MyLogicalRepWorker->relmutex);
MyLogicalRepWorker->relstate = SUBREL_STATE_SYNCWAIT;
SpinLockRelease(&MyLogicalRepWorker->relmutex);
/*
- * Wait for main apply worker to either tell us to
- * catchup or that we are done.
+ * Wait for main apply worker to either tell us to catchup or
+ * that we are done.
*/
wait_for_sync_status_change(MyLogicalRepWorker->relid,
MyLogicalRepWorker->relstate);
typedef struct FlushPosition
{
- dlist_node node;
- XLogRecPtr local_end;
- XLogRecPtr remote_end;
+ dlist_node node;
+ XLogRecPtr local_end;
+ XLogRecPtr remote_end;
} FlushPosition;
static dlist_head lsn_mapping = DLIST_STATIC_INIT(lsn_mapping);
typedef struct SlotErrCallbackArg
{
- LogicalRepRelation *rel;
+ LogicalRepRelation *rel;
int attnum;
} SlotErrCallbackArg;
-static MemoryContext ApplyMessageContext = NULL;
-MemoryContext ApplyContext = NULL;
+static MemoryContext ApplyMessageContext = NULL;
+MemoryContext ApplyContext = NULL;
-WalReceiverConn *wrconn = NULL;
+WalReceiverConn *wrconn = NULL;
-Subscription *MySubscription = NULL;
-bool MySubscriptionValid = false;
+Subscription *MySubscription = NULL;
+bool MySubscriptionValid = false;
-bool in_remote_transaction = false;
-static XLogRecPtr remote_final_lsn = InvalidXLogRecPtr;
+bool in_remote_transaction = false;
+static XLogRecPtr remote_final_lsn = InvalidXLogRecPtr;
static void send_feedback(XLogRecPtr recvpos, bool force, bool requestReply);
*/
static void
slot_fill_defaults(LogicalRepRelMapEntry *rel, EState *estate,
- TupleTableSlot *slot)
+ TupleTableSlot *slot)
{
TupleDesc desc = RelationGetDescr(rel->localrel);
int num_phys_attrs = desc->natts;
static void
slot_store_error_callback(void *arg)
{
- SlotErrCallbackArg *errarg = (SlotErrCallbackArg *) arg;
- Oid remotetypoid,
- localtypoid;
+ SlotErrCallbackArg *errarg = (SlotErrCallbackArg *) arg;
+ Oid remotetypoid,
+ localtypoid;
if (errarg->attnum < 0)
return;
*/
static void
slot_store_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
- char **values)
+ char **values)
{
- int natts = slot->tts_tupleDescriptor->natts;
- int i;
- SlotErrCallbackArg errarg;
- ErrorContextCallback errcallback;
+ int natts = slot->tts_tupleDescriptor->natts;
+ int i;
+ SlotErrCallbackArg errarg;
+ ErrorContextCallback errcallback;
ExecClearTuple(slot);
/* Call the "in" function for each non-dropped attribute */
for (i = 0; i < natts; i++)
{
- Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i];
- int remoteattnum = rel->attrmap[i];
+ Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i];
+ int remoteattnum = rel->attrmap[i];
if (!att->attisdropped && remoteattnum >= 0 &&
values[remoteattnum] != NULL)
{
- Oid typinput;
- Oid typioparam;
+ Oid typinput;
+ Oid typioparam;
errarg.attnum = remoteattnum;
*/
static void
slot_modify_cstrings(TupleTableSlot *slot, LogicalRepRelMapEntry *rel,
- char **values, bool *replaces)
+ char **values, bool *replaces)
{
- int natts = slot->tts_tupleDescriptor->natts;
- int i;
- SlotErrCallbackArg errarg;
- ErrorContextCallback errcallback;
+ int natts = slot->tts_tupleDescriptor->natts;
+ int i;
+ SlotErrCallbackArg errarg;
+ ErrorContextCallback errcallback;
slot_getallattrs(slot);
ExecClearTuple(slot);
/* Call the "in" function for each replaced attribute */
for (i = 0; i < natts; i++)
{
- Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i];
- int remoteattnum = rel->attrmap[i];
+ Form_pg_attribute att = slot->tts_tupleDescriptor->attrs[i];
+ int remoteattnum = rel->attrmap[i];
if (remoteattnum >= 0 && !replaces[remoteattnum])
continue;
if (remoteattnum >= 0 && values[remoteattnum] != NULL)
{
- Oid typinput;
- Oid typioparam;
+ Oid typinput;
+ Oid typioparam;
errarg.attnum = remoteattnum;
static void
apply_handle_begin(StringInfo s)
{
- LogicalRepBeginData begin_data;
+ LogicalRepBeginData begin_data;
logicalrep_read_begin(s, &begin_data);
static void
apply_handle_commit(StringInfo s)
{
- LogicalRepCommitData commit_data;
+ LogicalRepCommitData commit_data;
logicalrep_read_commit(s, &commit_data);
apply_handle_origin(StringInfo s)
{
/*
- * ORIGIN message can only come inside remote transaction and before
- * any actual writes.
+ * ORIGIN message can only come inside remote transaction and before any
+ * actual writes.
*/
if (!in_remote_transaction ||
(IsTransactionState() && !am_tablesync_worker()))
static void
apply_handle_relation(StringInfo s)
{
- LogicalRepRelation *rel;
+ LogicalRepRelation *rel;
rel = logicalrep_read_rel(s);
logicalrep_relmap_update(rel);
static void
apply_handle_type(StringInfo s)
{
- LogicalRepTyp typ;
+ LogicalRepTyp typ;
logicalrep_read_typ(s, &typ);
logicalrep_typmap_update(&typ);
static Oid
GetRelationIdentityOrPK(Relation rel)
{
- Oid idxoid;
+ Oid idxoid;
idxoid = RelationGetReplicaIndex(rel);
apply_handle_insert(StringInfo s)
{
LogicalRepRelMapEntry *rel;
- LogicalRepTupleData newtup;
- LogicalRepRelId relid;
- EState *estate;
- TupleTableSlot *remoteslot;
- MemoryContext oldctx;
+ LogicalRepTupleData newtup;
+ LogicalRepRelId relid;
+ EState *estate;
+ TupleTableSlot *remoteslot;
+ MemoryContext oldctx;
ensure_transaction();
return;
/*
- * We are in error mode so it's fine this is somewhat slow.
- * It's better to give user correct error.
+ * We are in error mode so it's fine this is somewhat slow. It's better to
+ * give user correct error.
*/
if (OidIsValid(GetRelationIdentityOrPK(rel->localrel)))
{
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("publisher does not send replica identity column "
- "expected by the logical replication target relation \"%s.%s\"",
+ "expected by the logical replication target relation \"%s.%s\"",
rel->remoterel.nspname, rel->remoterel.relname)));
}
apply_handle_update(StringInfo s)
{
LogicalRepRelMapEntry *rel;
- LogicalRepRelId relid;
- Oid idxoid;
- EState *estate;
- EPQState epqstate;
- LogicalRepTupleData oldtup;
- LogicalRepTupleData newtup;
- bool has_oldtup;
- TupleTableSlot *localslot;
- TupleTableSlot *remoteslot;
- bool found;
- MemoryContext oldctx;
+ LogicalRepRelId relid;
+ Oid idxoid;
+ EState *estate;
+ EPQState epqstate;
+ LogicalRepTupleData oldtup;
+ LogicalRepTupleData newtup;
+ bool has_oldtup;
+ TupleTableSlot *localslot;
+ TupleTableSlot *remoteslot;
+ bool found;
+ MemoryContext oldctx;
ensure_transaction();
MemoryContextSwitchTo(oldctx);
/*
- * Try to find tuple using either replica identity index, primary key
- * or if needed, sequential scan.
+ * Try to find tuple using either replica identity index, primary key or
+ * if needed, sequential scan.
*/
idxoid = GetRelationIdentityOrPK(rel->localrel);
Assert(OidIsValid(idxoid) ||
apply_handle_delete(StringInfo s)
{
LogicalRepRelMapEntry *rel;
- LogicalRepTupleData oldtup;
- LogicalRepRelId relid;
- Oid idxoid;
- EState *estate;
- EPQState epqstate;
- TupleTableSlot *remoteslot;
- TupleTableSlot *localslot;
- bool found;
- MemoryContext oldctx;
+ LogicalRepTupleData oldtup;
+ LogicalRepRelId relid;
+ Oid idxoid;
+ EState *estate;
+ EPQState epqstate;
+ TupleTableSlot *remoteslot;
+ TupleTableSlot *localslot;
+ bool found;
+ MemoryContext oldctx;
ensure_transaction();
MemoryContextSwitchTo(oldctx);
/*
- * Try to find tuple using either replica identity index, primary key
- * or if needed, sequential scan.
+ * Try to find tuple using either replica identity index, primary key or
+ * if needed, sequential scan.
*/
idxoid = GetRelationIdentityOrPK(rel->localrel);
Assert(OidIsValid(idxoid) ||
}
else
{
- /* The tuple to be deleted could not be found.*/
+ /* The tuple to be deleted could not be found. */
ereport(DEBUG1,
(errmsg("logical replication could not find row for delete "
"in replication target %s",
static void
apply_dispatch(StringInfo s)
{
- char action = pq_getmsgbyte(s);
+ char action = pq_getmsgbyte(s);
switch (action)
{
- /* BEGIN */
+ /* BEGIN */
case 'B':
apply_handle_begin(s);
break;
- /* COMMIT */
+ /* COMMIT */
case 'C':
apply_handle_commit(s);
break;
- /* INSERT */
+ /* INSERT */
case 'I':
apply_handle_insert(s);
break;
- /* UPDATE */
+ /* UPDATE */
case 'U':
apply_handle_update(s);
break;
- /* DELETE */
+ /* DELETE */
case 'D':
apply_handle_delete(s);
break;
- /* RELATION */
+ /* RELATION */
case 'R':
apply_handle_relation(s);
break;
- /* TYPE */
+ /* TYPE */
case 'Y':
apply_handle_type(s);
break;
- /* ORIGIN */
+ /* ORIGIN */
case 'O':
apply_handle_origin(s);
break;
default:
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid logical replication message type %c", action)));
+ errmsg("invalid logical replication message type %c", action)));
}
}
dlist_foreach_modify(iter, &lsn_mapping)
{
FlushPosition *pos =
- dlist_container(FlushPosition, node, iter.cur);
+ dlist_container(FlushPosition, node, iter.cur);
*write = pos->remote_end;
LogicalRepApplyLoop(XLogRecPtr last_received)
{
/*
- * Init the ApplyMessageContext which we clean up after each
- * replication protocol message.
+ * Init the ApplyMessageContext which we clean up after each replication
+ * protocol message.
*/
ApplyMessageContext = AllocSetContextCreate(ApplyContext,
- "ApplyMessageContext",
- ALLOCSET_DEFAULT_SIZES);
+ "ApplyMessageContext",
+ ALLOCSET_DEFAULT_SIZES);
/* mark as idle, before starting to loop */
pgstat_report_activity(STATE_IDLE, NULL);
}
else
{
- int c;
+ int c;
StringInfoData s;
/* Reset timeout. */
{
/*
* If we didn't get any transactions for a while there might be
- * unconsumed invalidation messages in the queue, consume them now.
+ * unconsumed invalidation messages in the queue, consume them
+ * now.
*/
AcceptInvalidationMessages();
if (!MySubscriptionValid)
if (endofstream)
{
TimeLineID tli;
+
walrcv_endstreaming(wrconn, &tli);
break;
}
if (rc & WL_TIMEOUT)
{
/*
- * We didn't receive anything new. If we haven't heard
- * anything from the server for more than
- * wal_receiver_timeout / 2, ping the server. Also, if
- * it's been longer than wal_receiver_status_interval
- * since the last update we sent, send a status update to
- * the master anyway, to report any progress in applying
- * WAL.
+ * We didn't receive anything new. If we haven't heard anything
+ * from the server for more than wal_receiver_timeout / 2, ping
+ * the server. Also, if it's been longer than
+ * wal_receiver_status_interval since the last update we sent,
+ * send a status update to the master anyway, to report any
+ * progress in applying WAL.
*/
bool requestReply = false;
/*
- * Check if time since last receive from standby has
- * reached the configured limit.
+ * Check if time since last receive from standby has reached the
+ * configured limit.
*/
if (wal_receiver_timeout > 0)
{
(errmsg("terminating logical replication worker due to timeout")));
/*
- * We didn't receive anything new, for half of
- * receiver replication timeout. Ping the server.
+ * We didn't receive anything new, for half of receiver
+ * replication timeout. Ping the server.
*/
if (!ping_sent)
{
timeout = TimestampTzPlusMilliseconds(last_recv_timestamp,
- (wal_receiver_timeout / 2));
+ (wal_receiver_timeout / 2));
if (now >= timeout)
{
requestReply = true;
static void
send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
{
- static StringInfo reply_message = NULL;
- static TimestampTz send_time = 0;
+ static StringInfo reply_message = NULL;
+ static TimestampTz send_time = 0;
static XLogRecPtr last_recvpos = InvalidXLogRecPtr;
static XLogRecPtr last_writepos = InvalidXLogRecPtr;
static XLogRecPtr last_flushpos = InvalidXLogRecPtr;
- XLogRecPtr writepos;
- XLogRecPtr flushpos;
+ XLogRecPtr writepos;
+ XLogRecPtr flushpos;
TimestampTz now;
- bool have_pending_txes;
+ bool have_pending_txes;
/*
* If the user doesn't want status to be reported to the publisher, be
get_flush_position(&writepos, &flushpos, &have_pending_txes);
/*
- * No outstanding transactions to flush, we can report the latest
- * received position. This is important for synchronous replication.
+ * No outstanding transactions to flush, we can report the latest received
+ * position. This is important for synchronous replication.
*/
if (!have_pending_txes)
flushpos = writepos = recvpos;
if (!reply_message)
{
- MemoryContext oldctx = MemoryContextSwitchTo(ApplyContext);
+ MemoryContext oldctx = MemoryContextSwitchTo(ApplyContext);
+
reply_message = makeStringInfo();
MemoryContextSwitchTo(oldctx);
}
pq_sendint64(reply_message, recvpos); /* write */
pq_sendint64(reply_message, flushpos); /* flush */
pq_sendint64(reply_message, writepos); /* apply */
- pq_sendint64(reply_message, now); /* sendTime */
+ pq_sendint64(reply_message, now); /* sendTime */
pq_sendbyte(reply_message, requestReply); /* replyRequested */
elog(DEBUG2, "sending feedback (force %d) to recv %X/%X, write %X/%X, flush %X/%X",
static void
reread_subscription(void)
{
- MemoryContext oldctx;
- Subscription *newsub;
- bool started_tx = false;
+ MemoryContext oldctx;
+ Subscription *newsub;
+ bool started_tx = false;
/* This function might be called inside or outside of transaction. */
if (!IsTransactionState())
newsub = GetSubscription(MyLogicalRepWorker->subid, true);
/*
- * Exit if the subscription was removed.
- * This normally should not happen as the worker gets killed
- * during DROP SUBSCRIPTION.
+ * Exit if the subscription was removed. This normally should not happen
+ * as the worker gets killed during DROP SUBSCRIPTION.
*/
if (!newsub)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "stop because the subscription was removed",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "stop because the subscription was removed",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
}
/*
- * Exit if the subscription was disabled.
- * This normally should not happen as the worker gets killed
- * during ALTER SUBSCRIPTION ... DISABLE.
+ * Exit if the subscription was disabled. This normally should not happen
+ * as the worker gets killed during ALTER SUBSCRIPTION ... DISABLE.
*/
if (!newsub->enabled)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "stop because the subscription was disabled",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "stop because the subscription was disabled",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
}
/*
- * Exit if connection string was changed. The launcher will start
- * new worker.
+ * Exit if connection string was changed. The launcher will start new
+ * worker.
*/
if (strcmp(newsub->conninfo, MySubscription->conninfo) != 0)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "restart because the connection information was changed",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "restart because the connection information was changed",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
if (strcmp(newsub->name, MySubscription->name) != 0)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "restart because subscription was renamed",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "restart because subscription was renamed",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
Assert(newsub->slotname);
/*
- * We need to make new connection to new slot if slot name has changed
- * so exit here as well if that's the case.
+ * We need to make new connection to new slot if slot name has changed so
+ * exit here as well if that's the case.
*/
if (strcmp(newsub->slotname, MySubscription->slotname) != 0)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "restart because the replication slot name was changed",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "restart because the replication slot name was changed",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
}
/*
- * Exit if publication list was changed. The launcher will start
- * new worker.
+ * Exit if publication list was changed. The launcher will start new
+ * worker.
*/
if (!equal(newsub->publications, MySubscription->publications))
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will "
- "restart because subscription's publications were changed",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will "
+ "restart because subscription's publications were changed",
+ MySubscription->name)));
walrcv_disconnect(wrconn);
proc_exit(0);
void
ApplyWorkerMain(Datum main_arg)
{
- int worker_slot = DatumGetInt32(main_arg);
- MemoryContext oldctx;
- char originname[NAMEDATALEN];
- XLogRecPtr origin_startpos;
- char *myslotname;
+ int worker_slot = DatumGetInt32(main_arg);
+ MemoryContext oldctx;
+ char originname[NAMEDATALEN];
+ XLogRecPtr origin_startpos;
+ char *myslotname;
WalRcvStreamOptions options;
/* Attach to slot */
/* Load the subscription into persistent memory context. */
ApplyContext = AllocSetContextCreate(TopMemoryContext,
- "ApplyContext",
- ALLOCSET_DEFAULT_SIZES);
+ "ApplyContext",
+ ALLOCSET_DEFAULT_SIZES);
StartTransactionCommand();
oldctx = MemoryContextSwitchTo(ApplyContext);
MySubscription = GetSubscription(MyLogicalRepWorker->subid, false);
if (!MySubscription->enabled)
{
ereport(LOG,
- (errmsg("logical replication worker for subscription \"%s\" will not "
- "start because the subscription was disabled during startup",
- MySubscription->name)));
+ (errmsg("logical replication worker for subscription \"%s\" will not "
+ "start because the subscription was disabled during startup",
+ MySubscription->name)));
proc_exit(0);
}
if (am_tablesync_worker())
{
- char *syncslotname;
+ char *syncslotname;
/* This is table synchroniation worker, call initial sync. */
syncslotname = LogicalRepSyncTableStart(&origin_startpos);
else
{
/* This is main apply worker */
- RepOriginId originid;
- TimeLineID startpointTLI;
- char *err;
- int server_version;
+ RepOriginId originid;
+ TimeLineID startpointTLI;
+ char *err;
+ int server_version;
myslotname = MySubscription->slotname;
(errmsg("could not connect to the publisher: %s", err)));
/*
- * We don't really use the output identify_system for anything
- * but it does some initializations on the upstream so let's still
- * call it.
+ * We don't really use the output identify_system for anything but it
+ * does some initializations on the upstream so let's still call it.
*/
(void) walrcv_identify_system(wrconn, &startpointTLI,
&server_version);
}
/*
- * Setup callback for syscache so that we know when something
- * changes in the subscription relation state.
+ * Setup callback for syscache so that we know when something changes in
+ * the subscription relation state.
*/
CacheRegisterSyscacheCallback(SUBSCRIPTIONRELMAP,
invalidate_syncing_table_states,
extern void _PG_output_plugin_init(OutputPluginCallbacks *cb);
-static void pgoutput_startup(LogicalDecodingContext * ctx,
- OutputPluginOptions *opt, bool is_init);
-static void pgoutput_shutdown(LogicalDecodingContext * ctx);
+static void pgoutput_startup(LogicalDecodingContext *ctx,
+ OutputPluginOptions *opt, bool is_init);
+static void pgoutput_shutdown(LogicalDecodingContext *ctx);
static void pgoutput_begin_txn(LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn);
+ ReorderBufferTXN *txn);
static void pgoutput_commit_txn(LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn, XLogRecPtr commit_lsn);
+ ReorderBufferTXN *txn, XLogRecPtr commit_lsn);
static void pgoutput_change(LogicalDecodingContext *ctx,
- ReorderBufferTXN *txn, Relation rel,
- ReorderBufferChange *change);
+ ReorderBufferTXN *txn, Relation rel,
+ ReorderBufferChange *change);
static bool pgoutput_origin_filter(LogicalDecodingContext *ctx,
- RepOriginId origin_id);
+ RepOriginId origin_id);
static bool publications_valid;
static List *LoadPublications(List *pubnames);
static void publication_invalidation_cb(Datum arg, int cacheid,
- uint32 hashvalue);
+ uint32 hashvalue);
/* Entry in the map used to remember which relation schemas we sent. */
typedef struct RelationSyncEntry
{
- Oid relid; /* relation oid */
- bool schema_sent; /* did we send the schema? */
- bool replicate_valid;
+ Oid relid; /* relation oid */
+ bool schema_sent; /* did we send the schema? */
+ bool replicate_valid;
PublicationActions pubactions;
} RelationSyncEntry;
static RelationSyncEntry *get_rel_sync_entry(PGOutputData *data, Oid relid);
static void rel_sync_cache_relation_cb(Datum arg, Oid relid);
static void rel_sync_cache_publication_cb(Datum arg, int cacheid,
- uint32 hashvalue);
+ uint32 hashvalue);
/*
* Specify output plugin callbacks
if (!SplitIdentifierString(strVal(defel->arg), ',',
publication_names))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_NAME),
- errmsg("invalid publication_names syntax")));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_NAME),
+ errmsg("invalid publication_names syntax")));
}
else
elog(ERROR, "unrecognized pgoutput option: %s", defel->defname);
* Initialize this plugin
*/
static void
-pgoutput_startup(LogicalDecodingContext * ctx, OutputPluginOptions *opt,
- bool is_init)
+pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
+ bool is_init)
{
- PGOutputData *data = palloc0(sizeof(PGOutputData));
+ PGOutputData *data = palloc0(sizeof(PGOutputData));
/* Create our memory context for private allocations. */
data->context = AllocSetContextCreate(ctx->context,
- "logical replication output context",
+ "logical replication output context",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
/* Check if we support requested protocol */
if (data->protocol_version != LOGICALREP_PROTO_VERSION_NUM)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("client sent proto_version=%d but we only support protocol %d or lower",
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("client sent proto_version=%d but we only support protocol %d or lower",
data->protocol_version, LOGICALREP_PROTO_VERSION_NUM)));
if (data->protocol_version < LOGICALREP_PROTO_MIN_VERSION_NUM)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("client sent proto_version=%d but we only support protocol %d or higher",
- data->protocol_version, LOGICALREP_PROTO_MIN_VERSION_NUM)));
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("client sent proto_version=%d but we only support protocol %d or higher",
+ data->protocol_version, LOGICALREP_PROTO_MIN_VERSION_NUM)));
if (list_length(data->publication_names) < 1)
ereport(ERROR,
static void
pgoutput_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
{
- bool send_replication_origin = txn->origin_id != InvalidRepOriginId;
+ bool send_replication_origin = txn->origin_id != InvalidRepOriginId;
OutputPluginPrepareWrite(ctx, !send_replication_origin);
logicalrep_write_begin(ctx->out, txn);
if (send_replication_origin)
{
- char *origin;
+ char *origin;
/* Message boundary */
OutputPluginWrite(ctx, false);
* XXX: which behaviour do we want here?
*
* Alternatives:
- * - don't send origin message if origin name not found
- * (that's what we do now)
- * - throw error - that will break replication, not good
- * - send some special "unknown" origin
+ * - don't send origin message if origin name not found
+ * (that's what we do now)
+ * - throw error - that will break replication, not good
+ * - send some special "unknown" origin
*----------
*/
if (replorigin_by_oid(txn->origin_id, true, &origin))
*/
static void
pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
- XLogRecPtr commit_lsn)
+ XLogRecPtr commit_lsn)
{
OutputPluginUpdateProgress(ctx);
pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
Relation relation, ReorderBufferChange *change)
{
- PGOutputData *data = (PGOutputData *) ctx->output_plugin_private;
- MemoryContext old;
- RelationSyncEntry *relentry;
+ PGOutputData *data = (PGOutputData *) ctx->output_plugin_private;
+ MemoryContext old;
+ RelationSyncEntry *relentry;
relentry = get_rel_sync_entry(data, RelationGetRelid(relation));
break;
case REORDER_BUFFER_CHANGE_UPDATE:
{
- HeapTuple oldtuple = change->data.tp.oldtuple ?
- &change->data.tp.oldtuple->tuple : NULL;
+ HeapTuple oldtuple = change->data.tp.oldtuple ?
+ &change->data.tp.oldtuple->tuple : NULL;
OutputPluginPrepareWrite(ctx, true);
logicalrep_write_update(ctx->out, relation, oldtuple,
*/
static bool
pgoutput_origin_filter(LogicalDecodingContext *ctx,
- RepOriginId origin_id)
+ RepOriginId origin_id)
{
return false;
}
* of the ctx->context so it will be cleaned up by logical decoding machinery.
*/
static void
-pgoutput_shutdown(LogicalDecodingContext * ctx)
+pgoutput_shutdown(LogicalDecodingContext *ctx)
{
if (RelationSyncCache)
{
List *result = NIL;
ListCell *lc;
- foreach (lc, pubnames)
+ foreach(lc, pubnames)
{
- char *pubname = (char *) lfirst(lc);
- Publication *pub = GetPublicationByName(pubname, false);
+ char *pubname = (char *) lfirst(lc);
+ Publication *pub = GetPublicationByName(pubname, false);
result = lappend(result, pub);
}
publications_valid = false;
/*
- * Also invalidate per-relation cache so that next time the filtering
- * info is checked it will be updated with the new publication
- * settings.
+ * Also invalidate per-relation cache so that next time the filtering info
+ * is checked it will be updated with the new publication settings.
*/
rel_sync_cache_publication_cb(arg, cacheid, hashvalue);
}
static void
init_rel_sync_cache(MemoryContext cachectx)
{
- HASHCTL ctl;
+ HASHCTL ctl;
MemoryContext old_ctxt;
if (RelationSyncCache != NULL)
static RelationSyncEntry *
get_rel_sync_entry(PGOutputData *data, Oid relid)
{
- RelationSyncEntry *entry;
- bool found;
- MemoryContext oldctx;
+ RelationSyncEntry *entry;
+ bool found;
+ MemoryContext oldctx;
Assert(RelationSyncCache != NULL);
}
/*
- * Build publication cache. We can't use one provided by relcache
- * as relcache considers all publications given relation is in, but
- * here we only need to consider ones that the subscriber requested.
+ * Build publication cache. We can't use one provided by relcache as
+ * relcache considers all publications given relation is in, but here
+ * we only need to consider ones that the subscriber requested.
*/
entry->pubactions.pubinsert = entry->pubactions.pubupdate =
entry->pubactions.pubdelete = false;
static void
rel_sync_cache_relation_cb(Datum arg, Oid relid)
{
- RelationSyncEntry *entry;
+ RelationSyncEntry *entry;
/*
* We can get here if the plugin was used in SQL interface as the
* safe point.
*
* Getting invalidations for relations that aren't in the table is
- * entirely normal, since there's no way to unregister for an
- * invalidation event. So we don't care if it's found or not.
+ * entirely normal, since there's no way to unregister for an invalidation
+ * event. So we don't care if it's found or not.
*/
entry = (RelationSyncEntry *) hash_search(RelationSyncCache, &relid,
HASH_FIND, NULL);
/*
- * Reset schema sent status as the relation definition may have
- * changed.
+ * Reset schema sent status as the relation definition may have changed.
*/
if (entry != NULL)
entry->schema_sent = false;
static void
rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue)
{
- HASH_SEQ_STATUS status;
- RelationSyncEntry *entry;
+ HASH_SEQ_STATUS status;
+ RelationSyncEntry *entry;
/*
* We can get here if the plugin was used in SQL interface as the
return;
/*
- * There is no way to find which entry in our cache the hash belongs to
- * so mark the whole cache as invalid.
+ * There is no way to find which entry in our cache the hash belongs to so
+ * mark the whole cache as invalid.
*/
hash_seq_init(&status, RelationSyncCache);
while ((entry = (RelationSyncEntry *) hash_seq_search(&status)) != NULL)
/*
* Rename the slot directory on disk, so that we'll no longer recognize
* this as a valid slot. Note that if this fails, we've got to mark the
- * slot inactive before bailing out. If we're dropping an ephemeral or
- * a temporary slot, we better never fail hard as the caller won't expect
+ * slot inactive before bailing out. If we're dropping an ephemeral or a
+ * temporary slot, we better never fail hard as the caller won't expect
* the slot to survive and this might get called during error handling.
*/
if (rename(path, tmppath) == 0)
for (i = 0; i < max_replication_slots; i++)
{
ReplicationSlot *s;
- char *slotname;
- int active_pid;
+ char *slotname;
+ int active_pid;
s = &ReplicationSlotCtl->replication_slots[i];
/*
* Acquire a logical decoding slot, this will check for conflicting names.
- * Initially create persistent slot as ephemeral - that allows us to nicely
- * handle errors during initialization because it'll get dropped if this
- * transaction fails. We'll make it persistent at the end.
- * Temporary slots can be created as temporary from beginning as they get
- * dropped on error as well.
+ * Initially create persistent slot as ephemeral - that allows us to
+ * nicely handle errors during initialization because it'll get dropped if
+ * this transaction fails. We'll make it persistent at the end. Temporary
+ * slots can be created as temporary from beginning as they get dropped on
+ * error as well.
*/
ReplicationSlotCreate(NameStr(*name), true,
temporary ? RS_TEMPORARY : RS_EPHEMERAL);
* Create logical decoding context, to build the initial snapshot.
*/
ctx = CreateInitDecodingContext(NameStr(*plugin), NIL,
- false, /* do not build snapshot */
+ false, /* do not build snapshot */
logical_read_local_xlog_page, NULL, NULL,
NULL);
Datum values[PG_GET_REPLICATION_SLOTS_COLS];
bool nulls[PG_GET_REPLICATION_SLOTS_COLS];
- ReplicationSlotPersistency persistency;
+ ReplicationSlotPersistency persistency;
TransactionId xmin;
TransactionId catalog_xmin;
XLogRecPtr restart_lsn;
static int SyncRepWakeQueue(bool all, int mode);
static bool SyncRepGetSyncRecPtr(XLogRecPtr *writePtr,
- XLogRecPtr *flushPtr,
- XLogRecPtr *applyPtr,
- bool *am_sync);
+ XLogRecPtr *flushPtr,
+ XLogRecPtr *applyPtr,
+ bool *am_sync);
static void SyncRepGetOldestSyncRecPtr(XLogRecPtr *writePtr,
- XLogRecPtr *flushPtr,
- XLogRecPtr *applyPtr,
- List *sync_standbys);
+ XLogRecPtr *flushPtr,
+ XLogRecPtr *applyPtr,
+ List *sync_standbys);
static void SyncRepGetNthLatestSyncRecPtr(XLogRecPtr *writePtr,
- XLogRecPtr *flushPtr,
- XLogRecPtr *applyPtr,
- List *sync_standbys, uint8 nth);
+ XLogRecPtr *flushPtr,
+ XLogRecPtr *applyPtr,
+ List *sync_standbys, uint8 nth);
static int SyncRepGetStandbyPriority(void);
static List *SyncRepGetSyncStandbysPriority(bool *am_sync);
static List *SyncRepGetSyncStandbysQuorum(bool *am_sync);
if (SyncRepConfig->syncrep_method == SYNC_REP_PRIORITY)
ereport(LOG,
(errmsg("standby \"%s\" is now a synchronous standby with priority %u",
- application_name, MyWalSnd->sync_standby_priority)));
+ application_name, MyWalSnd->sync_standby_priority)));
else
ereport(LOG,
(errmsg("standby \"%s\" is now a candidate for quorum synchronous standby",
*/
static bool
SyncRepGetSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
- XLogRecPtr *applyPtr, bool *am_sync)
+ XLogRecPtr *applyPtr, bool *am_sync)
{
List *sync_standbys;
* oldest ones among sync standbys. In a quorum-based, they are the Nth
* latest ones.
*
- * SyncRepGetNthLatestSyncRecPtr() also can calculate the oldest positions.
- * But we use SyncRepGetOldestSyncRecPtr() for that calculation because
- * it's a bit more efficient.
+ * SyncRepGetNthLatestSyncRecPtr() also can calculate the oldest
+ * positions. But we use SyncRepGetOldestSyncRecPtr() for that calculation
+ * because it's a bit more efficient.
*
* XXX If the numbers of current and requested sync standbys are the same,
* we can use SyncRepGetOldestSyncRecPtr() to calculate the synced
SyncRepGetOldestSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
XLogRecPtr *applyPtr, List *sync_standbys)
{
- ListCell *cell;
+ ListCell *cell;
/*
- * Scan through all sync standbys and calculate the oldest
- * Write, Flush and Apply positions.
+ * Scan through all sync standbys and calculate the oldest Write, Flush
+ * and Apply positions.
*/
- foreach (cell, sync_standbys)
+ foreach(cell, sync_standbys)
{
- WalSnd *walsnd = &WalSndCtl->walsnds[lfirst_int(cell)];
+ WalSnd *walsnd = &WalSndCtl->walsnds[lfirst_int(cell)];
XLogRecPtr write;
XLogRecPtr flush;
XLogRecPtr apply;
*/
static void
SyncRepGetNthLatestSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
- XLogRecPtr *applyPtr, List *sync_standbys, uint8 nth)
+ XLogRecPtr *applyPtr, List *sync_standbys, uint8 nth)
{
- ListCell *cell;
- XLogRecPtr *write_array;
- XLogRecPtr *flush_array;
- XLogRecPtr *apply_array;
- int len;
- int i = 0;
+ ListCell *cell;
+ XLogRecPtr *write_array;
+ XLogRecPtr *flush_array;
+ XLogRecPtr *apply_array;
+ int len;
+ int i = 0;
len = list_length(sync_standbys);
write_array = (XLogRecPtr *) palloc(sizeof(XLogRecPtr) * len);
flush_array = (XLogRecPtr *) palloc(sizeof(XLogRecPtr) * len);
apply_array = (XLogRecPtr *) palloc(sizeof(XLogRecPtr) * len);
- foreach (cell, sync_standbys)
+ foreach(cell, sync_standbys)
{
- WalSnd *walsnd = &WalSndCtl->walsnds[lfirst_int(cell)];
+ WalSnd *walsnd = &WalSndCtl->walsnds[lfirst_int(cell)];
SpinLockAcquire(&walsnd->mutex);
write_array[i] = walsnd->write;
static int
cmp_lsn(const void *a, const void *b)
{
- XLogRecPtr lsn1 = *((const XLogRecPtr *) a);
- XLogRecPtr lsn2 = *((const XLogRecPtr *) b);
+ XLogRecPtr lsn1 = *((const XLogRecPtr *) a);
+ XLogRecPtr lsn2 = *((const XLogRecPtr *) b);
if (lsn1 > lsn2)
return -1;
* sync standby. Otherwise it's set to false.
*/
List *
-SyncRepGetSyncStandbys(bool *am_sync)
+SyncRepGetSyncStandbys(bool *am_sync)
{
/* Set default result */
if (am_sync != NULL)
static List *
SyncRepGetSyncStandbysQuorum(bool *am_sync)
{
- List *result = NIL;
- int i;
+ List *result = NIL;
+ int i;
volatile WalSnd *walsnd; /* Use volatile pointer to prevent code
* rearrangement */
continue;
/*
- * Consider this standby as a candidate for quorum sync standbys
- * and append it to the result.
+ * Consider this standby as a candidate for quorum sync standbys and
+ * append it to the result.
*/
result = lappend_int(result, i);
if (am_sync != NULL && walsnd == MyWalSnd)
return 0;
/*
- * In quorum-based sync replication, all the standbys in the list
- * have the same priority, one.
+ * In quorum-based sync replication, all the standbys in the list have the
+ * same priority, one.
*/
return (SyncRepConfig->syncrep_method == SYNC_REP_PRIORITY) ? priority : 1;
}
{
TimestampTz now;
TransactionId nextXid;
- uint32 xmin_epoch, catalog_xmin_epoch;
- TransactionId xmin, catalog_xmin;
+ uint32 xmin_epoch,
+ catalog_xmin_epoch;
+ TransactionId xmin,
+ catalog_xmin;
static TimestampTz sendTime = 0;
+
/* initially true so we always send at least one feedback message */
static bool master_has_standby_xmin = true;
*
* Bailing out here also ensures that we don't send feedback until we've
* read our own replication slot state, so we don't tell the master to
- * discard needed xmin or catalog_xmin from any slots that may exist
- * on this replica.
+ * discard needed xmin or catalog_xmin from any slots that may exist on
+ * this replica.
*/
if (!HotStandbyActive())
return;
* excludes the catalog_xmin.
*/
xmin = GetOldestXmin(NULL,
- PROCARRAY_FLAGS_DEFAULT|PROCARRAY_SLOTS_XMIN);
+ PROCARRAY_FLAGS_DEFAULT | PROCARRAY_SLOTS_XMIN);
ProcArrayGetReplicationSlotXmin(&slot_xmin, &catalog_xmin);
GetNextXidAndEpoch(&nextXid, &xmin_epoch);
catalog_xmin_epoch = xmin_epoch;
if (nextXid < xmin)
- xmin_epoch --;
+ xmin_epoch--;
if (nextXid < catalog_xmin)
- catalog_xmin_epoch --;
+ catalog_xmin_epoch--;
elog(DEBUG2, "sending hot standby feedback xmin %u epoch %u catalog_xmin %u catalog_xmin_epoch %u",
xmin, xmin_epoch, catalog_xmin, catalog_xmin_epoch);
/* A sample associating a WAL location with the time it was written. */
typedef struct
{
- XLogRecPtr lsn;
+ XLogRecPtr lsn;
TimestampTz time;
} WalTimeSample;
/* A mechanism for tracking replication lag. */
static struct
{
- XLogRecPtr last_lsn;
+ XLogRecPtr last_lsn;
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE];
- int write_head;
- int read_heads[NUM_SYNC_REP_WAIT_MODE];
+ int write_head;
+ int read_heads[NUM_SYNC_REP_WAIT_MODE];
WalTimeSample last_read[NUM_SYNC_REP_WAIT_MODE];
-} LagTracker;
+} LagTracker;
/* Signal handlers */
static void WalSndSigHupHandler(SIGNAL_ARGS);
if (ThisTimeLineID == 0)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("IDENTIFY_SYSTEM has not been run before START_REPLICATION")));
+ errmsg("IDENTIFY_SYSTEM has not been run before START_REPLICATION")));
/*
* We assume here that we're logging enough information in the WAL for
sendTimeLineIsHistoric = true;
/*
- * Check that the timeline the client requested exists, and
- * the requested start location is on that timeline.
+ * Check that the timeline the client requested exists, and the
+ * requested start location is on that timeline.
*/
timeLineHistory = readTimeLineHistory(ThisTimeLineID);
switchpoint = tliSwitchPoint(cmd->timeline, timeLineHistory,
* request to start replication from the beginning of the WAL
* segment that contains switchpoint, but on the new timeline, so
* that it doesn't end up with a partial segment. If you ask for
- * too old a starting point, you'll get an error later when we fail
- * to find the requested WAL segment in pg_wal.
+ * too old a starting point, you'll get an error later when we
+ * fail to find the requested WAL segment in pg_wal.
*
* XXX: we could be more strict here and only allow a startpoint
* that's older than the switchpoint, if it's still in the same
MemSet(nulls, false, sizeof(nulls));
/*
- * Need a tuple descriptor representing two columns.
- * int8 may seem like a surprising data type for this, but in theory
- * int4 would not be wide enough for this, as TimeLineID is unsigned.
+ * Need a tuple descriptor representing two columns. int8 may seem
+ * like a surprising data type for this, but in theory int4 would not
+ * be wide enough for this, as TimeLineID is unsigned.
*/
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 1, "next_tli",
bool reserve_wal_given = false;
/* Parse options */
- foreach (lc, cmd->options)
+ foreach(lc, cmd->options)
{
DefElem *defel = (DefElem *) lfirst(lc);
if (cmd->kind == REPLICATION_KIND_LOGICAL)
{
LogicalDecodingContext *ctx;
- bool need_full_snapshot = false;
+ bool need_full_snapshot = false;
/*
* Do options check early so that we can bail before calling the
TimestampTz now = GetCurrentTimestamp();
/*
- * Track lag no more than once per WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS
- * to avoid flooding the lag tracker when we commit frequently.
+ * Track lag no more than once per WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS to
+ * avoid flooding the lag tracker when we commit frequently.
*/
-#define WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS 1000
+#define WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS 1000
if (!TimestampDifferenceExceeds(sendTime, now,
WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS))
return;
SnapBuildClearExportedSnapshot();
/*
- * For aborted transactions, don't allow anything except pure SQL,
- * the exec_simple_query() will handle it correctly.
+ * For aborted transactions, don't allow anything except pure SQL, the
+ * exec_simple_query() will handle it correctly.
*/
if (IsAbortedTransactionBlockState() && !IsA(cmd_node, SQLCmd))
ereport(ERROR,
bool clearLagTimes;
TimestampTz now;
- static bool fullyAppliedLastTime = false;
+ static bool fullyAppliedLastTime = false;
/* the caller already consumed the msgtype byte */
writePtr = pq_getmsgint64(&reply_message);
}
if (!TransactionIdPrecedesOrEquals(xid, nextXid))
- return false; /* epoch OK, but it's wrapped around */
+ return false; /* epoch OK, but it's wrapped around */
return true;
}
*
* If we're using a replication slot we reserve the xmin via that,
* otherwise via the walsender's PGXACT entry. We can only track the
- * catalog xmin separately when using a slot, so we store the least
- * of the two provided when not using a slot.
+ * catalog xmin separately when using a slot, so we store the least of the
+ * two provided when not using a slot.
*
* XXX: It might make sense to generalize the ephemeral slot concept and
* always use the slot mechanism to handle the feedback xmin.
}
/*
- * At the reception of SIGUSR2, switch the WAL sender to the stopping
- * state.
+ * At the reception of SIGUSR2, switch the WAL sender to the
+ * stopping state.
*/
if (got_SIGUSR2)
WalSndSetState(WALSNDSTATE_STOPPING);
* it seems good enough to capture the time here. We should reach this
* after XLogFlush() runs WalSndWakeupProcessRequests(), and although that
* may take some time, we read the WAL flush pointer and take the time
- * very close to together here so that we'll get a later position if it
- * is still moving.
+ * very close to together here so that we'll get a later position if it is
+ * still moving.
*
* Because LagTrackerWriter ignores samples when the LSN hasn't advanced,
* this gives us a cheap approximation for the WAL flush time for this
* LSN.
*
* Note that the LSN is not necessarily the LSN for the data contained in
- * the present message; it's the end of the WAL, which might be
- * further ahead. All the lag tracking machinery cares about is finding
- * out when that arbitrary LSN is eventually reported as written, flushed
- * and applied, so that it can measure the elapsed time.
+ * the present message; it's the end of the WAL, which might be further
+ * ahead. All the lag tracking machinery cares about is finding out when
+ * that arbitrary LSN is eventually reported as written, flushed and
+ * applied, so that it can measure the elapsed time.
*/
LagTrackerWrite(SendRqstPtr, GetCurrentTimestamp());
if (record != NULL)
{
/*
- * Note the lack of any call to LagTrackerWrite() which is handled
- * by WalSndUpdateProgress which is called by output plugin through
+ * Note the lack of any call to LagTrackerWrite() which is handled by
+ * WalSndUpdateProgress which is called by output plugin through
* logical decoding write api.
*/
LogicalDecodingProcessRecord(logical_decoding_ctx, logical_decoding_ctx->reader);
/*
* To figure out whether all WAL has successfully been replicated, check
- * flush location if valid, write otherwise. Tools like pg_receivewal
- * will usually (unless in synchronous mode) return an invalid flush
- * location.
+ * flush location if valid, write otherwise. Tools like pg_receivewal will
+ * usually (unless in synchronous mode) return an invalid flush location.
*/
replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
MyWalSnd->write : MyWalSnd->flush;
if (all_stopped)
return;
- pg_usleep(10000L); /* wait for 10 msec */
+ pg_usleep(10000L); /* wait for 10 msec */
}
}
static Interval *
offset_to_interval(TimeOffset offset)
{
- Interval *result = palloc(sizeof(Interval));
+ Interval *result = palloc(sizeof(Interval));
result->month = 0;
result->day = 0;
static void
LagTrackerWrite(XLogRecPtr lsn, TimestampTz local_flush_time)
{
- bool buffer_full;
- int new_write_head;
- int i;
+ bool buffer_full;
+ int new_write_head;
+ int i;
if (!am_walsender)
return;
/*
* We didn't cross a time. If there is a future sample that we
* haven't reached yet, and we've already reached at least one sample,
- * let's interpolate the local flushed time. This is mainly useful for
- * reporting a completely stuck apply position as having increasing
- * lag, since otherwise we'd have to wait for it to eventually start
- * moving again and cross one of our samples before we can show the
- * lag increasing.
+ * let's interpolate the local flushed time. This is mainly useful
+ * for reporting a completely stuck apply position as having
+ * increasing lag, since otherwise we'd have to wait for it to
+ * eventually start moving again and cross one of our samples before
+ * we can show the lag increasing.
*/
if (LagTracker.read_heads[head] != LagTracker.write_head &&
LagTracker.last_read[head].time != 0)
{
- double fraction;
+ double fraction;
WalTimeSample prev = LagTracker.last_read[head];
WalTimeSample next = LagTracker.buffer[LagTracker.read_heads[head]];
if (event_relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("could not convert partitioned table \"%s\" to a view",
- RelationGetRelationName(event_relation))));
+ errmsg("could not convert partitioned table \"%s\" to a view",
+ RelationGetRelationName(event_relation))));
snapshot = RegisterSnapshot(GetLatestSnapshot());
scanDesc = heap_beginscan(event_relation, snapshot, 0, NULL);
for (attrno = 1; attrno <= numattrs; attrno++)
{
TargetEntry *new_tle = new_tles[attrno - 1];
- bool apply_default;
+ bool apply_default;
att_tup = target_relation->rd_att->attrs[attrno - 1];
* tlist entry is a DEFAULT placeholder node.
*/
apply_default = ((new_tle == NULL && commandType == CMD_INSERT) ||
- (new_tle && new_tle->expr && IsA(new_tle->expr, SetToDefault)));
+ (new_tle && new_tle->expr && IsA(new_tle->expr, SetToDefault)));
if (commandType == CMD_INSERT)
{
errmsg("cannot insert into column \"%s\"", NameStr(att_tup->attname)),
errdetail("Column \"%s\" is an identity column defined as GENERATED ALWAYS.",
NameStr(att_tup->attname)),
- errhint("Use OVERRIDING SYSTEM VALUE to override.")));
+ errhint("Use OVERRIDING SYSTEM VALUE to override.")));
}
if (att_tup->attidentity == ATTRIBUTE_IDENTITY_BY_DEFAULT && override == OVERRIDING_USER_VALUE)
/* Process the main targetlist ... */
parsetree->targetList = rewriteTargetListIU(parsetree->targetList,
parsetree->commandType,
- parsetree->override,
+ parsetree->override,
rt_entry_relation,
parsetree->resultRelation,
&attrnos);
int current; /* next dependency to return (index) */
AttrNumber ndependencies; /* number of dependencies generated */
AttrNumber *dependencies; /* array of pre-generated dependencies */
-} DependencyGeneratorData;
+} DependencyGeneratorData;
typedef DependencyGeneratorData *DependencyGenerator;
static bool dependency_implies_attribute(MVDependency *dependency,
AttrNumber attnum);
static bool dependency_is_compatible_clause(Node *clause, Index relid,
- AttrNumber *attnum);
+ AttrNumber *attnum);
static MVDependency *find_strongest_dependency(StatisticExtInfo *stats,
MVDependencies *dependencies,
Bitmapset *attnums);
continue;
d = (MVDependency *) palloc0(offsetof(MVDependency, attributes)
- + k * sizeof(AttrNumber));
+ +k * sizeof(AttrNumber));
/* copy the dependency (and keep the indexes into stxkeys) */
d->degree = degree;
dependencies->ndeps++;
dependencies = (MVDependencies *) repalloc(dependencies,
offsetof(MVDependencies, deps)
- + dependencies->ndeps * sizeof(MVDependency));
+ +dependencies->ndeps * sizeof(MVDependency));
dependencies->deps[dependencies->ndeps - 1] = d;
}
* Serialize list of dependencies into a bytea value.
*/
bytea *
-statext_dependencies_serialize(MVDependencies * dependencies)
+statext_dependencies_serialize(MVDependencies *dependencies)
{
int i;
bytea *output;
/* allocate space for the MCV items */
dependencies = repalloc(dependencies, offsetof(MVDependencies, deps)
- + (dependencies->ndeps * sizeof(MVDependency *)));
+ +(dependencies->ndeps * sizeof(MVDependency *)));
for (i = 0; i < dependencies->ndeps; i++)
{
/* now that we know the number of attributes, allocate the dependency */
d = (MVDependency *) palloc0(offsetof(MVDependency, attributes)
- + (k * sizeof(AttrNumber)));
+ +(k * sizeof(AttrNumber)));
d->degree = degree;
d->nattributes = k;
* attributes (assuming the clauses are suitable equality clauses)
*/
static bool
-dependency_is_fully_matched(MVDependency * dependency, Bitmapset *attnums)
+dependency_is_fully_matched(MVDependency *dependency, Bitmapset *attnums)
{
int j;
* (see the comment in dependencies_clauselist_selectivity).
*/
static MVDependency *
-find_strongest_dependency(StatisticExtInfo * stats, MVDependencies * dependencies,
+find_strongest_dependency(StatisticExtInfo *stats, MVDependencies *dependencies,
Bitmapset *attnums)
{
int i;
*/
typedef struct StatExtEntry
{
- Oid statOid; /* OID of pg_statistic_ext entry */
- char *schema; /* statistics object's schema */
- char *name; /* statistics object's name */
- Bitmapset *columns; /* attribute numbers covered by the object */
- List *types; /* 'char' list of enabled statistic kinds */
+ Oid statOid; /* OID of pg_statistic_ext entry */
+ char *schema; /* statistics object's schema */
+ char *name; /* statistics object's name */
+ Bitmapset *columns; /* attribute numbers covered by the object */
+ List *types; /* 'char' list of enabled statistic kinds */
} StatExtEntry;
foreach(lc, stats)
{
- StatExtEntry *stat = (StatExtEntry *) lfirst(lc);
- MVNDistinct *ndistinct = NULL;
+ StatExtEntry *stat = (StatExtEntry *) lfirst(lc);
+ MVNDistinct *ndistinct = NULL;
MVDependencies *dependencies = NULL;
- VacAttrStats **stats;
- ListCell *lc2;
+ VacAttrStats **stats;
+ ListCell *lc2;
/*
- * Check if we can build these stats based on the column analyzed.
- * If not, report this fact (except in autovacuum) and move on.
+ * Check if we can build these stats based on the column analyzed. If
+ * not, report this fact (except in autovacuum) and move on.
*/
stats = lookup_var_attr_stats(onerel, stat->columns,
natts, vacattrstats);
/* compute statistic of each requested type */
foreach(lc2, stat->types)
{
- char t = (char) lfirst_int(lc2);
+ char t = (char) lfirst_int(lc2);
if (t == STATS_EXT_NDISTINCT)
ndistinct = statext_ndistinct_build(totalrows, numrows, rows,
bool
statext_is_kind_built(HeapTuple htup, char type)
{
- AttrNumber attnum;
+ AttrNumber attnum;
switch (type)
{
{
SysScanDesc scan;
ScanKeyData skey;
- HeapTuple htup;
- List *result = NIL;
+ HeapTuple htup;
+ List *result = NIL;
/*
* Prepare to scan pg_statistic_ext for entries having stxrelid = this
/* lookup VacAttrStats info for the requested columns (same attnum) */
while ((x = bms_next_member(attrs, x)) >= 0)
{
- int j;
+ int j;
stats[i] = NULL;
for (j = 0; j < nvacatts; j++)
return NULL;
}
- /*
- * Sanity check that the column is not dropped - stats should have
- * been removed in this case.
- */
+ /*
+ * Sanity check that the column is not dropped - stats should have
+ * been removed in this case.
+ */
Assert(!stats[i]->attr->attisdropped);
i++;
void
multi_sort_add_dimension(MultiSortSupport mss, int sortdim, Oid oper)
{
- SortSupport ssup = &mss->ssup[sortdim];
+ SortSupport ssup = &mss->ssup[sortdim];
ssup->ssup_cxt = CurrentMemoryContext;
ssup->ssup_collation = DEFAULT_COLLATION_OID;
static double ndistinct_for_combination(double totalrows, int numrows,
- HeapTuple *rows, VacAttrStats **stats,
- int k, int *combination);
+ HeapTuple *rows, VacAttrStats **stats,
+ int k, int *combination);
static double estimate_ndistinct(double totalrows, int numrows, int d, int f1);
static int n_choose_k(int n, int k);
static int num_combinations(int n);
/* internal state for generator of k-combinations of n elements */
typedef struct CombinationGenerator
{
- int k; /* size of the combination */
- int n; /* total number of elements */
- int current; /* index of the next combination to return */
- int ncombinations; /* number of combinations (size of array) */
- int *combinations; /* array of pre-built combinations */
+ int k; /* size of the combination */
+ int n; /* total number of elements */
+ int current; /* index of the next combination to return */
+ int ncombinations; /* number of combinations (size of array) */
+ int *combinations; /* array of pre-built combinations */
} CombinationGenerator;
static CombinationGenerator *generator_init(int n, int k);
itemcnt = 0;
for (k = 2; k <= numattrs; k++)
{
- int *combination;
+ int *combination;
CombinationGenerator *generator;
/* generate combinations of K out of N elements */
while ((combination = generator_next(generator)))
{
MVNDistinctItem *item = &result->items[itemcnt];
- int j;
+ int j;
item->attrs = NULL;
for (j = 0; j < k; j++)
item->attrs = bms_add_member(item->attrs,
- stats[combination[j]]->attr->attnum);
+ stats[combination[j]]->attr->attnum);
item->ndistinct =
ndistinct_for_combination(totalrows, numrows, rows,
stats, k, combination);
* for each item, including number of items for each.
*/
len = VARHDRSZ + SizeOfMVNDistinct +
- ndistinct->nitems * (offsetof(MVNDistinctItem, attrs) + sizeof(int));
+ ndistinct->nitems * (offsetof(MVNDistinctItem, attrs) +sizeof(int));
/* and also include space for the actual attribute numbers */
for (i = 0; i < ndistinct->nitems; i++)
{
- int nmembers;
+ int nmembers;
nmembers = bms_num_members(ndistinct->items[i].attrs);
Assert(nmembers >= 2);
for (i = 0; i < ndistinct->nitems; i++)
{
MVNDistinctItem item = ndistinct->items[i];
- int nmembers = bms_num_members(item.attrs);
- int x;
+ int nmembers = bms_num_members(item.attrs);
+ int x;
memcpy(tmp, &item.ndistinct, sizeof(double));
tmp += sizeof(double);
{
int i;
Size minimum_size;
- MVNDistinct ndist;
+ MVNDistinct ndist;
MVNDistinct *ndistinct;
char *tmp;
if (VARSIZE_ANY_EXHDR(data) < minimum_size)
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("invalid MVNDistinct size %zd (expected at least %zd)",
- VARSIZE_ANY_EXHDR(data), minimum_size)));
+ errmsg("invalid MVNDistinct size %zd (expected at least %zd)",
+ VARSIZE_ANY_EXHDR(data), minimum_size)));
/*
- * Allocate space for the ndistinct items (no space for each item's attnos:
- * those live in bitmapsets allocated separately)
+ * Allocate space for the ndistinct items (no space for each item's
+ * attnos: those live in bitmapsets allocated separately)
*/
ndistinct = palloc0(MAXALIGN(SizeOfMVNDistinct) +
(ndist.nitems * sizeof(MVNDistinctItem)));
for (i = 0; i < ndist->nitems; i++)
{
MVNDistinctItem item = ndist->items[i];
- int x = -1;
- bool first = true;
+ int x = -1;
+ bool first = true;
if (i > 0)
appendStringInfoString(&str, ", ");
}
/*
- * For each dimension, set up sort-support and fill in the values from
- * the sample data.
+ * For each dimension, set up sort-support and fill in the values from the
+ * sample data.
*/
for (i = 0; i < k; i++)
{
- VacAttrStats *colstat = stats[combination[i]];
+ VacAttrStats *colstat = stats[combination[i]];
TypeCacheEntry *type;
type = lookup_type_cache(colstat->attrtypid, TYPECACHE_LT_OPR);
- if (type->lt_opr == InvalidOid) /* shouldn't happen */
+ if (type->lt_opr == InvalidOid) /* shouldn't happen */
elog(ERROR, "cache lookup failed for ordering operator for type %u",
colstat->attrtypid);
denom,
ndistinct;
- numer = (double) numrows * (double) d;
+ numer = (double) numrows *(double) d;
denom = (double) (numrows - f1) +
(double) f1 *(double) numrows / totalrows;
state->ncombinations = n_choose_k(n, k);
- /* pre-allocate space for all combinations*/
+ /* pre-allocate space for all combinations */
state->combinations = (int *) palloc(sizeof(int) * k * state->ncombinations);
state->current = 0;
/* If we haven't filled all the elements, simply recurse. */
if (index < state->k)
{
- int i;
+ int i;
/*
* The values have to be in ascending order, so make sure we start
static void
generate_combinations(CombinationGenerator *state)
{
- int *current = (int *) palloc0(sizeof(int) * state->k);
+ int *current = (int *) palloc0(sizeof(int) * state->k);
generate_combinations_recurse(state, 0, 0, current);
}
/*
- * To guarantee that the removal of the file is persistent, fsync
- * its parent directory.
+ * To guarantee that the removal of the file is persistent, fsync its
+ * parent directory.
*/
if (fsync_parent_path(fname, elevel) != 0)
return -1;
void
ConditionVariablePrepareToSleep(ConditionVariable *cv)
{
- int pgprocno = MyProc->pgprocno;
+ int pgprocno = MyProc->pgprocno;
/*
* It's not legal to prepare a sleep until the previous sleep has been
* called in a predicate loop that tests for a specific exit condition and
* otherwise sleeps, like so:
*
- * ConditionVariablePrepareToSleep(cv); [optional]
- * while (condition for which we are waiting is not true)
- * ConditionVariableSleep(cv, wait_event_info);
- * ConditionVariableCancelSleep();
+ * ConditionVariablePrepareToSleep(cv); [optional]
+ * while (condition for which we are waiting is not true)
+ * ConditionVariableSleep(cv, wait_event_info);
+ * ConditionVariableCancelSleep();
*
* Supply a value from one of the WaitEventXXX enums defined in pgstat.h to
* control the contents of pg_stat_activity's wait_event_type and wait_event
void
ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
{
- WaitEvent event;
- bool done = false;
+ WaitEvent event;
+ bool done = false;
/*
* If the caller didn't prepare to sleep explicitly, then do so now and
bool
ConditionVariableSignal(ConditionVariable *cv)
{
- PGPROC *proc = NULL;
+ PGPROC *proc = NULL;
/* Remove the first process from the wakeup queue (if any). */
SpinLockAcquire(&cv->mutex);
int
ConditionVariableBroadcast(ConditionVariable *cv)
{
- int nwoken = 0;
+ int nwoken = 0;
/*
* Let's just do this the dumbest way possible. We could try to dequeue
* all the sleepers at once to save spinlock cycles, but it's a bit hard
- * to get that right in the face of possible sleep cancelations, and
- * we don't want to loop holding the mutex.
+ * to get that right in the face of possible sleep cancelations, and we
+ * don't want to loop holding the mutex.
*/
while (ConditionVariableSignal(cv))
++nwoken;
LWLockTranchesAllocated = 64;
LWLockTrancheArray = (char **)
MemoryContextAllocZero(TopMemoryContext,
- LWLockTranchesAllocated * sizeof(char *));
+ LWLockTranchesAllocated * sizeof(char *));
Assert(LWLockTranchesAllocated >= LWTRANCHE_FIRST_USER_DEFINED);
}
INSTR_TIME_SET_CURRENT(sync_start);
if (seg != NULL &&
- FileSync(seg->mdfd_vfd, WAIT_EVENT_DATA_FILE_SYNC) >= 0)
+ FileSync(seg->mdfd_vfd, WAIT_EVENT_DATA_FILE_SYNC) >= 0)
{
/* Success; update statistics about sync timing */
INSTR_TIME_SET_CURRENT(sync_end);
break;
case T_RefreshMatViewStmt:
+
/*
* REFRESH CONCURRENTLY executes some DDL commands internally.
* Inhibit DDL command collection here to avoid those commands
case T_AlterPublicationStmt:
AlterPublication((AlterPublicationStmt *) parsetree);
+
/*
* AlterPublication calls EventTriggerCollectSimpleCommand
* directly
typedef struct TSVectorBuildState
{
- ParsedText *prs;
+ ParsedText *prs;
TSVector result;
Oid cfgId;
} TSVectorBuildState;
Datum
jsonb_to_tsvector_byid(PG_FUNCTION_ARGS)
{
- Oid cfgId = PG_GETARG_OID(0);
- Jsonb *jb = PG_GETARG_JSONB(1);
- TSVectorBuildState state;
- ParsedText *prs = (ParsedText *) palloc(sizeof(ParsedText));
+ Oid cfgId = PG_GETARG_OID(0);
+ Jsonb *jb = PG_GETARG_JSONB(1);
+ TSVectorBuildState state;
+ ParsedText *prs = (ParsedText *) palloc(sizeof(ParsedText));
prs->words = NULL;
state.result = NULL;
if (state.result == NULL)
{
- /* There weren't any string elements in jsonb,
- * so wee need to return an empty vector */
+ /*
+ * There weren't any string elements in jsonb, so wee need to return
+ * an empty vector
+ */
if (prs->words != NULL)
pfree(prs->words);
Datum
jsonb_to_tsvector(PG_FUNCTION_ARGS)
{
- Jsonb *jb = PG_GETARG_JSONB(0);
- Oid cfgId;
+ Jsonb *jb = PG_GETARG_JSONB(0);
+ Oid cfgId;
cfgId = getTSCurrentConfig(true);
PG_RETURN_DATUM(DirectFunctionCall2(jsonb_to_tsvector_byid,
Datum
json_to_tsvector_byid(PG_FUNCTION_ARGS)
{
- Oid cfgId = PG_GETARG_OID(0);
- text *json = PG_GETARG_TEXT_P(1);
- TSVectorBuildState state;
- ParsedText *prs = (ParsedText *) palloc(sizeof(ParsedText));
+ Oid cfgId = PG_GETARG_OID(0);
+ text *json = PG_GETARG_TEXT_P(1);
+ TSVectorBuildState state;
+ ParsedText *prs = (ParsedText *) palloc(sizeof(ParsedText));
prs->words = NULL;
state.result = NULL;
PG_FREE_IF_COPY(json, 1);
if (state.result == NULL)
{
- /* There weren't any string elements in json,
- * so wee need to return an empty vector */
+ /*
+ * There weren't any string elements in json, so wee need to return an
+ * empty vector
+ */
if (prs->words != NULL)
pfree(prs->words);
Datum
json_to_tsvector(PG_FUNCTION_ARGS)
{
- text *json = PG_GETARG_TEXT_P(0);
- Oid cfgId;
+ text *json = PG_GETARG_TEXT_P(0);
+ Oid cfgId;
cfgId = getTSCurrentConfig(true);
PG_RETURN_DATUM(DirectFunctionCall2(json_to_tsvector_byid,
add_to_tsvector(void *_state, char *elem_value, int elem_len)
{
TSVectorBuildState *state = (TSVectorBuildState *) _state;
- ParsedText *prs = state->prs;
+ ParsedText *prs = state->prs;
TSVector item_vector;
int i;
item_vector = make_tsvector(prs);
state->result = (TSVector) DirectFunctionCall2(tsvector_concat,
- TSVectorGetDatum(state->result),
- PointerGetDatum(item_vector));
+ TSVectorGetDatum(state->result),
+ PointerGetDatum(item_vector));
}
else
state->result = make_tsvector(prs);
HeadlineParsedText *prs;
TSConfigCacheEntry *cfg;
TSParserCacheEntry *prsobj;
- TSQuery query;
- List *prsoptions;
- bool transformed;
+ TSQuery query;
+ List *prsoptions;
+ bool transformed;
} HeadlineJsonState;
-static text * headline_json_value(void *_state, char *elem_value, int elem_len);
+static text *headline_json_value(void *_state, char *elem_value, int elem_len);
static void
tt_setup_firstcall(FuncCallContext *funcctx, Oid prsid)
Datum
ts_headline_jsonb_byid_opt(PG_FUNCTION_ARGS)
{
- Oid tsconfig = PG_GETARG_OID(0);
- Jsonb *jb = PG_GETARG_JSONB(1);
- TSQuery query = PG_GETARG_TSQUERY(2);
- text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
- Jsonb *out;
+ Oid tsconfig = PG_GETARG_OID(0);
+ Jsonb *jb = PG_GETARG_JSONB(1);
+ TSQuery query = PG_GETARG_TSQUERY(2);
+ text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
+ Jsonb *out;
JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value;
HeadlineParsedText prs;
HeadlineJsonState *state = palloc0(sizeof(HeadlineJsonState));
Datum
ts_headline_json_byid_opt(PG_FUNCTION_ARGS)
{
- Oid tsconfig = PG_GETARG_OID(0);
- text *json = PG_GETARG_TEXT_P(1);
- TSQuery query = PG_GETARG_TSQUERY(2);
- text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
- text *out;
+ Oid tsconfig = PG_GETARG_OID(0);
+ text *json = PG_GETARG_TEXT_P(1);
+ TSQuery query = PG_GETARG_TSQUERY(2);
+ text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
+ text *out;
JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value;
HeadlineParsedText prs;
HeadlineParsedText *prs = state->prs;
TSConfigCacheEntry *cfg = state->cfg;
TSParserCacheEntry *prsobj = state->prsobj;
- TSQuery query = state->query;
- List *prsoptions = state->prsoptions;
+ TSQuery query = state->query;
+ List *prsoptions = state->prsoptions;
prs->curwords = 0;
hlparsetext(cfg->cfgId, prs, query, elem_value, elem_len);
/* than the required number of decimal places */
if (isdigit((unsigned char) *s) && (!seen_dot || dec < fpoint))
{
- Cash newvalue = (value * 10) - (*s - '0');
+ Cash newvalue = (value * 10) - (*s - '0');
if (newvalue / 10 != value)
ereport(ERROR,
/* round off if there's another digit */
if (isdigit((unsigned char) *s) && *s >= '5')
- value--; /* remember we build the value in the negative */
+ value--; /* remember we build the value in the negative */
if (value > 0)
ereport(ERROR,
/* adjust for less than required decimal places */
for (; dec < fpoint; dec++)
{
- Cash newvalue = value * 10;
+ Cash newvalue = value * 10;
if (newvalue / 10 != value)
ereport(ERROR,
"money", str)));
}
- /* If the value is supposed to be positive, flip the sign, but check for
- * the most negative number. */
+ /*
+ * If the value is supposed to be positive, flip the sign, but check for
+ * the most negative number.
+ */
if (sgn > 0)
{
result = -value;
AclResult aclresult;
/*
- * User must have connect privilege for target database
- * or be a member of pg_read_all_stats
+ * User must have connect privilege for target database or be a member of
+ * pg_read_all_stats
*/
aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT);
if (aclresult != ACLCHECK_OK &&
/*
* User must be a member of pg_read_all_stats or have CREATE privilege for
- * target tablespace, either explicitly granted or implicitly because
- * it is default for current database.
+ * target tablespace, either explicitly granted or implicitly because it
+ * is default for current database.
*/
if (tblspcOid != MyDatabaseTableSpace &&
!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS))
#ifdef USE_ICU
-typedef int32_t (*ICU_Convert_Func)(UChar *dest, int32_t destCapacity,
- const UChar *src, int32_t srcLength,
- const char *locale,
- UErrorCode *pErrorCode);
+typedef int32_t (*ICU_Convert_Func) (UChar *dest, int32_t destCapacity,
+ const UChar *src, int32_t srcLength,
+ const char *locale,
+ UErrorCode *pErrorCode);
static int32_t
icu_convert_case(ICU_Convert_Func func, pg_locale_t mylocale,
UErrorCode status;
int32_t len_dest;
- len_dest = len_source; /* try first with same length */
+ len_dest = len_source; /* try first with same length */
*buff_dest = palloc(len_dest * sizeof(**buff_dest));
status = U_ZERO_ERROR;
len_dest = func(*buff_dest, len_dest, buff_source, len_source,
NULL, locale, pErrorCode);
}
-#endif /* USE_ICU */
+#endif /* USE_ICU */
/*
* If the system provides the needed functions for wide-character manipulation
workspace[curr_char] = towlower(workspace[curr_char]);
}
- /* Make result large enough; case change might change number of bytes */
+ /*
+ * Make result large enough; case change might change number
+ * of bytes
+ */
result_size = curr_char * pg_database_encoding_max_length() + 1;
result = palloc(result_size);
result = pnstrdup(buff, nbytes);
/*
- * Note: we assume that tolower_l() will not be so broken as to need
- * an isupper_l() guard test. When using the default collation, we
- * apply the traditional Postgres behavior that forces ASCII-style
- * treatment of I/i, but in non-default collations you get exactly
- * what the collation says.
+ * Note: we assume that tolower_l() will not be so broken as
+ * to need an isupper_l() guard test. When using the default
+ * collation, we apply the traditional Postgres behavior that
+ * forces ASCII-style treatment of I/i, but in non-default
+ * collations you get exactly what the collation says.
*/
for (p = result; *p; p++)
{
#ifdef USE_ICU
if (mylocale && mylocale->provider == COLLPROVIDER_ICU)
{
- int32_t len_uchar, len_conv;
+ int32_t len_uchar,
+ len_conv;
UChar *buff_uchar;
UChar *buff_conv;
workspace[curr_char] = towupper(workspace[curr_char]);
}
- /* Make result large enough; case change might change number of bytes */
+ /*
+ * Make result large enough; case change might change number
+ * of bytes
+ */
result_size = curr_char * pg_database_encoding_max_length() + 1;
result = palloc(result_size);
result = pnstrdup(buff, nbytes);
/*
- * Note: we assume that toupper_l() will not be so broken as to need
- * an islower_l() guard test. When using the default collation, we
- * apply the traditional Postgres behavior that forces ASCII-style
- * treatment of I/i, but in non-default collations you get exactly
- * what the collation says.
+ * Note: we assume that toupper_l() will not be so broken as
+ * to need an islower_l() guard test. When using the default
+ * collation, we apply the traditional Postgres behavior that
+ * forces ASCII-style treatment of I/i, but in non-default
+ * collations you get exactly what the collation says.
*/
for (p = result; *p; p++)
{
#ifdef USE_ICU
if (mylocale && mylocale->provider == COLLPROVIDER_ICU)
{
- int32_t len_uchar, len_conv;
+ int32_t len_uchar,
+ len_conv;
UChar *buff_uchar;
UChar *buff_conv;
}
}
- /* Make result large enough; case change might change number of bytes */
+ /*
+ * Make result large enough; case change might change number
+ * of bytes
+ */
result_size = curr_char * pg_database_encoding_max_length() + 1;
result = palloc(result_size);
result = pnstrdup(buff, nbytes);
/*
- * Note: we assume that toupper_l()/tolower_l() will not be so broken
- * as to need guard tests. When using the default collation, we apply
- * the traditional Postgres behavior that forces ASCII-style treatment
- * of I/i, but in non-default collations you get exactly what the
- * collation says.
+ * Note: we assume that toupper_l()/tolower_l() will not be so
+ * broken as to need guard tests. When using the default
+ * collation, we apply the traditional Postgres behavior that
+ * forces ASCII-style treatment of I/i, but in non-default
+ * collations you get exactly what the collation says.
*/
for (p = result; *p; p++)
{
if (SRF_IS_FIRSTCALL())
{
MemoryContext oldcontext;
- TupleDesc tupdesc;
+ TupleDesc tupdesc;
funcctx = SRF_FIRSTCALL_INIT();
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
Datum values[3];
bool nulls[3];
char path[MAXPGPATH * 2];
- struct stat attrib;
+ struct stat attrib;
HeapTuple tuple;
/* Skip hidden files */
if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
|| typoid == RECORDARRAYOID)
*tcategory = JSONTYPE_ARRAY;
- else if (type_is_rowtype(typoid)) /* includes RECORDOID */
+ else if (type_is_rowtype(typoid)) /* includes RECORDOID */
*tcategory = JSONTYPE_COMPOSITE;
else
{
if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
|| typoid == RECORDARRAYOID)
*tcategory = JSONBTYPE_ARRAY;
- else if (type_is_rowtype(typoid)) /* includes RECORDOID */
+ else if (type_is_rowtype(typoid)) /* includes RECORDOID */
*tcategory = JSONBTYPE_COMPOSITE;
else
{
/* state for iterate_json_string_values function */
typedef struct IterateJsonStringValuesState
{
- JsonLexContext *lex;
- JsonIterateStringValuesAction action; /* an action that will be applied
- to each json value */
- void *action_state; /* any necessary context for iteration */
+ JsonLexContext *lex;
+ JsonIterateStringValuesAction action; /* an action that will be
+ * applied to each json value */
+ void *action_state; /* any necessary context for iteration */
} IterateJsonStringValuesState;
/* state for transform_json_string_values function */
typedef struct TransformJsonStringValuesState
{
- JsonLexContext *lex;
- StringInfo strval; /* resulting json */
- JsonTransformStringValuesAction action; /* an action that will be applied
- to each json value */
- void *action_state; /* any necessary context for transformation */
+ JsonLexContext *lex;
+ StringInfo strval; /* resulting json */
+ JsonTransformStringValuesAction action; /* an action that will be
+ * applied to each json value */
+ void *action_state; /* any necessary context for transformation */
} TransformJsonStringValuesState;
/* state for json_get* functions */
/* structure to cache metadata needed for populate_array() */
typedef struct ArrayIOData
{
- ColumnIOData *element_info; /* metadata cache */
- Oid element_type; /* array element type id */
- int32 element_typmod; /* array element type modifier */
+ ColumnIOData *element_info; /* metadata cache */
+ Oid element_type; /* array element type id */
+ int32 element_typmod; /* array element type modifier */
} ArrayIOData;
/* structure to cache metadata needed for populate_composite() */
typedef struct CompositeIOData
{
/*
- * We use pointer to a RecordIOData here because variable-length
- * struct RecordIOData can't be used directly in ColumnIOData.io union
+ * We use pointer to a RecordIOData here because variable-length struct
+ * RecordIOData can't be used directly in ColumnIOData.io union
*/
- RecordIOData *record_io; /* metadata cache for populate_record() */
- TupleDesc tupdesc; /* cached tuple descriptor */
+ RecordIOData *record_io; /* metadata cache for populate_record() */
+ TupleDesc tupdesc; /* cached tuple descriptor */
} CompositeIOData;
/* structure to cache metadata needed for populate_domain() */
typedef struct DomainIOData
{
- ColumnIOData *base_io; /* metadata cache */
- Oid base_typid; /* base type id */
- int32 base_typmod; /* base type modifier */
- void *domain_info; /* opaque cache for domain checks */
+ ColumnIOData *base_io; /* metadata cache */
+ Oid base_typid; /* base type id */
+ int32 base_typmod; /* base type modifier */
+ void *domain_info; /* opaque cache for domain checks */
} DomainIOData;
/* enumeration type categories */
/* structure to cache record metadata needed for populate_record_field() */
struct ColumnIOData
{
- Oid typid; /* column type id */
- int32 typmod; /* column type modifier */
- TypeCat typcat; /* column type category */
- ScalarIOData scalar_io; /* metadata cache for directi conversion
- * through input function */
+ Oid typid; /* column type id */
+ int32 typmod; /* column type modifier */
+ TypeCat typcat; /* column type category */
+ ScalarIOData scalar_io; /* metadata cache for directi conversion
+ * through input function */
union
{
- ArrayIOData array;
- CompositeIOData composite;
- DomainIOData domain;
- } io; /* metadata cache for various column type categories */
+ ArrayIOData array;
+ CompositeIOData composite;
+ DomainIOData domain;
+ } io; /* metadata cache for various column type
+ * categories */
};
/* structure to cache record metadata needed for populate_record() */
/* structure to cache metadata needed for populate_record_worker() */
typedef struct PopulateRecordCache
{
- Oid argtype; /* verified row type of the first argument */
+ Oid argtype; /* verified row type of the first argument */
CompositeIOData io; /* metadata cache for populate_composite() */
} PopulateRecordCache;
/* common data for populate_array_json() and populate_array_dim_jsonb() */
typedef struct PopulateArrayContext
{
- ArrayBuildState *astate; /* array build state */
- ArrayIOData *aio; /* metadata cache */
- MemoryContext acxt; /* array build memory context */
- MemoryContext mcxt; /* cache memory context */
- const char *colname; /* for diagnostics only */
- int *dims; /* dimensions */
- int *sizes; /* current dimension counters */
- int ndims; /* number of dimensions */
+ ArrayBuildState *astate; /* array build state */
+ ArrayIOData *aio; /* metadata cache */
+ MemoryContext acxt; /* array build memory context */
+ MemoryContext mcxt; /* cache memory context */
+ const char *colname; /* for diagnostics only */
+ int *dims; /* dimensions */
+ int *sizes; /* current dimension counters */
+ int ndims; /* number of dimensions */
} PopulateArrayContext;
/* state for populate_array_json() */
typedef struct PopulateArrayState
{
- JsonLexContext *lex; /* json lexer */
+ JsonLexContext *lex; /* json lexer */
PopulateArrayContext *ctx; /* context */
- char *element_start; /* start of the current array element */
- char *element_scalar; /* current array element token if it is a scalar */
- JsonTokenType element_type; /* current array element type */
+ char *element_start; /* start of the current array element */
+ char *element_scalar; /* current array element token if it is a
+ * scalar */
+ JsonTokenType element_type; /* current array element type */
} PopulateArrayState;
/* state for json_strip_nulls */
/* structure for generalized json/jsonb value passing */
typedef struct JsValue
{
- bool is_json; /* json/jsonb */
+ bool is_json; /* json/jsonb */
union
{
struct
{
- char *str; /* json string */
- int len; /* json string length or -1 if null-terminated */
- JsonTokenType type; /* json type */
- } json; /* json value */
+ char *str; /* json string */
+ int len; /* json string length or -1 if null-terminated */
+ JsonTokenType type; /* json type */
+ } json; /* json value */
JsonbValue *jsonb; /* jsonb value */
- } val;
+ } val;
} JsValue;
typedef struct JsObject
bool is_json; /* json/jsonb */
union
{
- HTAB *json_hash;
+ HTAB *json_hash;
JsonbContainer *jsonb_cont;
- } val;
+ } val;
} JsObject;
/* useful macros for testing JsValue properties */
static Datum populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
bool have_record_arg);
static Datum populate_record_worker(FunctionCallInfo fcinfo, const char *funcname,
- bool have_record_arg);
+ bool have_record_arg);
/* helper functions for populate_record[set] */
-static HeapTupleHeader populate_record(TupleDesc tupdesc, RecordIOData **record_info,
- HeapTupleHeader template, MemoryContext mcxt,
- JsObject *obj);
+static HeapTupleHeader populate_record(TupleDesc tupdesc, RecordIOData **record_info,
+ HeapTupleHeader template, MemoryContext mcxt,
+ JsObject *obj);
static Datum populate_record_field(ColumnIOData *col, Oid typid, int32 typmod,
- const char *colname, MemoryContext mcxt,
- Datum defaultval, JsValue *jsv, bool *isnull);
+ const char *colname, MemoryContext mcxt,
+ Datum defaultval, JsValue *jsv, bool *isnull);
static void JsValueToJsObject(JsValue *jsv, JsObject *jso);
static Datum populate_composite(CompositeIOData *io, Oid typid, int32 typmod,
- const char *colname, MemoryContext mcxt,
- HeapTupleHeader defaultval, JsValue *jsv);
+ const char *colname, MemoryContext mcxt,
+ HeapTupleHeader defaultval, JsValue *jsv);
static Datum populate_scalar(ScalarIOData *io, Oid typid, int32 typmod, JsValue *jsv);
static void prepare_column_cache(ColumnIOData *column, Oid typid, int32 typmod,
- MemoryContext mcxt, bool json);
+ MemoryContext mcxt, bool json);
static Datum populate_record_field(ColumnIOData *col, Oid typid, int32 typmod,
- const char *colname, MemoryContext mcxt, Datum defaultval,
- JsValue *jsv, bool *isnull);
-static RecordIOData * allocate_record_info(MemoryContext mcxt, int ncolumns);
+ const char *colname, MemoryContext mcxt, Datum defaultval,
+ JsValue *jsv, bool *isnull);
+static RecordIOData *allocate_record_info(MemoryContext mcxt, int ncolumns);
static bool JsObjectGetField(JsObject *obj, char *field, JsValue *jsv);
static void populate_recordset_record(PopulateRecordsetState *state, JsObject *obj);
static void populate_array_json(PopulateArrayContext *ctx, char *json, int len);
-static void populate_array_dim_jsonb(PopulateArrayContext *ctx, JsonbValue *jbv,
- int ndim);
+static void populate_array_dim_jsonb(PopulateArrayContext *ctx, JsonbValue *jbv,
+ int ndim);
static void populate_array_report_expected_array(PopulateArrayContext *ctx, int ndim);
static void populate_array_assign_ndims(PopulateArrayContext *ctx, int ndims);
static void populate_array_check_dimension(PopulateArrayContext *ctx, int ndim);
static void populate_array_element(PopulateArrayContext *ctx, int ndim, JsValue *jsv);
-static Datum populate_array(ArrayIOData *aio, const char *colname,
- MemoryContext mcxt, JsValue *jsv);
-static Datum populate_domain(DomainIOData *io, Oid typid, const char *colname,
- MemoryContext mcxt, JsValue *jsv, bool isnull);
+static Datum populate_array(ArrayIOData *aio, const char *colname,
+ MemoryContext mcxt, JsValue *jsv);
+static Datum populate_domain(DomainIOData *io, Oid typid, const char *colname,
+ MemoryContext mcxt, JsValue *jsv, bool isnull);
/* Worker that takes care of common setup for us */
static JsonbValue *findJsonbValueFromContainerLen(JsonbContainer *container,
}
else
{
- StringInfoData indices;
- int i;
+ StringInfoData indices;
+ int i;
initStringInfo(&indices);
static void
populate_array_assign_ndims(PopulateArrayContext *ctx, int ndims)
{
- int i;
+ int i;
Assert(ctx->ndims <= 0);
ctx->sizes = palloc0(sizeof(int) * ndims);
for (i = 0; i < ndims; i++)
- ctx->dims[i] = -1; /* dimensions are unknown yet */
+ ctx->dims[i] = -1; /* dimensions are unknown yet */
}
/* check the populated subarray dimension */
static void
populate_array_check_dimension(PopulateArrayContext *ctx, int ndim)
{
- int dim = ctx->sizes[ndim]; /* current dimension counter */
+ int dim = ctx->sizes[ndim]; /* current dimension counter */
if (ctx->dims[ndim] == -1)
- ctx->dims[ndim] = dim; /* assign dimension if not yet known */
+ ctx->dims[ndim] = dim; /* assign dimension if not yet known */
else if (ctx->dims[ndim] != dim)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
static void
populate_array_element(PopulateArrayContext *ctx, int ndim, JsValue *jsv)
{
- Datum element;
- bool element_isnull;
+ Datum element;
+ bool element_isnull;
/* populate the array element */
element = populate_record_field(ctx->aio->element_info,
jsv, &element_isnull);
accumArrayResult(ctx->astate, element, element_isnull,
- ctx->aio->element_type, ctx->acxt);
+ ctx->aio->element_type, ctx->acxt);
Assert(ndim > 0);
- ctx->sizes[ndim - 1]++; /* increment current dimension counter */
+ ctx->sizes[ndim - 1]++; /* increment current dimension counter */
}
/* json object start handler for populate_array_json() */
populate_array_object_start(void *_state)
{
PopulateArrayState *state = (PopulateArrayState *) _state;
- int ndim = state->lex->lex_level;
+ int ndim = state->lex->lex_level;
if (state->ctx->ndims <= 0)
populate_array_assign_ndims(state->ctx, ndim);
static void
populate_array_array_end(void *_state)
{
- PopulateArrayState *state = (PopulateArrayState *) _state;
- PopulateArrayContext *ctx = state->ctx;
- int ndim = state->lex->lex_level;
+ PopulateArrayState *state = (PopulateArrayState *) _state;
+ PopulateArrayContext *ctx = state->ctx;
+ int ndim = state->lex->lex_level;
if (ctx->ndims <= 0)
populate_array_assign_ndims(ctx, ndim + 1);
populate_array_element_start(void *_state, bool isnull)
{
PopulateArrayState *state = (PopulateArrayState *) _state;
- int ndim = state->lex->lex_level;
+ int ndim = state->lex->lex_level;
if (state->ctx->ndims <= 0 || ndim == state->ctx->ndims)
{
static void
populate_array_element_end(void *_state, bool isnull)
{
- PopulateArrayState *state = (PopulateArrayState *) _state;
- PopulateArrayContext *ctx = state->ctx;
- int ndim = state->lex->lex_level;
+ PopulateArrayState *state = (PopulateArrayState *) _state;
+ PopulateArrayContext *ctx = state->ctx;
+ int ndim = state->lex->lex_level;
Assert(ctx->ndims > 0);
else if (state->element_scalar)
{
jsv.val.json.str = state->element_scalar;
- jsv.val.json.len = -1; /* null-terminated */
+ jsv.val.json.len = -1; /* null-terminated */
}
else
{
static void
populate_array_scalar(void *_state, char *token, JsonTokenType tokentype)
{
- PopulateArrayState *state = (PopulateArrayState *) _state;
- PopulateArrayContext *ctx = state->ctx;
- int ndim = state->lex->lex_level;
+ PopulateArrayState *state = (PopulateArrayState *) _state;
+ PopulateArrayContext *ctx = state->ctx;
+ int ndim = state->lex->lex_level;
if (ctx->ndims <= 0)
populate_array_assign_ndims(ctx, ndim);
static void
populate_array_json(PopulateArrayContext *ctx, char *json, int len)
{
- PopulateArrayState state;
- JsonSemAction sem;
+ PopulateArrayState state;
+ JsonSemAction sem;
state.lex = makeJsonLexContextCstringLen(json, len, true);
state.ctx = ctx;
/*
* populate_array_dim_jsonb() -- Iterate recursively through jsonb sub-array
- * elements and accumulate result using given ArrayBuildState.
+ * elements and accumulate result using given ArrayBuildState.
*/
static void
-populate_array_dim_jsonb(PopulateArrayContext *ctx, /* context */
- JsonbValue *jbv, /* jsonb sub-array */
- int ndim) /* current dimension */
+populate_array_dim_jsonb(PopulateArrayContext *ctx, /* context */
+ JsonbValue *jbv, /* jsonb sub-array */
+ int ndim) /* current dimension */
{
- JsonbContainer *jbc = jbv->val.binary.data;
- JsonbIterator *it;
- JsonbIteratorToken tok;
- JsonbValue val;
- JsValue jsv;
+ JsonbContainer *jbc = jbv->val.binary.data;
+ JsonbIterator *it;
+ JsonbIteratorToken tok;
+ JsonbValue val;
+ JsValue jsv;
check_stack_depth();
tok = JsonbIteratorNext(&it, &val, true);
/*
- * If the number of dimensions is not yet known and
- * we have found end of the array, or the first child element is not
- * an array, then assign the number of dimensions now.
+ * If the number of dimensions is not yet known and we have found end of
+ * the array, or the first child element is not an array, then assign the
+ * number of dimensions now.
*/
if (ctx->ndims <= 0 &&
(tok == WJB_END_ARRAY ||
while (tok == WJB_ELEM)
{
/*
- * Recurse only if the dimensions of dimensions is still unknown or
- * if it is not the innermost dimension.
+ * Recurse only if the dimensions of dimensions is still unknown or if
+ * it is not the innermost dimension.
*/
if (ctx->ndims > 0 && ndim >= ctx->ndims)
populate_array_element(ctx, ndim, &jsv);
/* recursively populate an array from json/jsonb */
static Datum
-populate_array(ArrayIOData *aio,
- const char *colname,
- MemoryContext mcxt,
- JsValue *jsv)
-{
- PopulateArrayContext ctx;
- Datum result;
- int *lbs;
- int i;
+populate_array(ArrayIOData *aio,
+ const char *colname,
+ MemoryContext mcxt,
+ JsValue *jsv)
+{
+ PopulateArrayContext ctx;
+ Datum result;
+ int *lbs;
+ int i;
ctx.aio = aio;
ctx.mcxt = mcxt;
ctx.acxt = CurrentMemoryContext;
ctx.astate = initArrayResult(aio->element_type, ctx.acxt, true);
ctx.colname = colname;
- ctx.ndims = 0; /* unknown yet */
+ ctx.ndims = 0; /* unknown yet */
ctx.dims = NULL;
ctx.sizes = NULL;
if (jsv->is_json)
populate_array_json(&ctx, jsv->val.json.str,
jsv->val.json.len >= 0 ? jsv->val.json.len
- : strlen(jsv->val.json.str));
+ : strlen(jsv->val.json.str));
else
{
populate_array_dim_jsonb(&ctx, jsv->val.jsonb, 1);
Assert(ctx.ndims > 0);
- lbs = palloc(sizeof(int) * ctx.ndims);
+ lbs = palloc(sizeof(int) * ctx.ndims);
for (i = 0; i < ctx.ndims; i++)
lbs[i] = 1;
{
/* convert plain-text json into a hash table */
jso->val.json_hash =
- get_json_object_as_hash(jsv->val.json.str,
- jsv->val.json.len >= 0
- ? jsv->val.json.len
- : strlen(jsv->val.json.str),
- "populate_composite");
+ get_json_object_as_hash(jsv->val.json.str,
+ jsv->val.json.len >= 0
+ ? jsv->val.json.len
+ : strlen(jsv->val.json.str),
+ "populate_composite");
}
else
{
/* recursively populate a composite (row type) value from json/jsonb */
static Datum
populate_composite(CompositeIOData *io,
- Oid typid,
- int32 typmod,
- const char *colname,
- MemoryContext mcxt,
- HeapTupleHeader defaultval,
- JsValue *jsv)
+ Oid typid,
+ int32 typmod,
+ const char *colname,
+ MemoryContext mcxt,
+ HeapTupleHeader defaultval,
+ JsValue *jsv)
{
- HeapTupleHeader tuple;
- JsObject jso;
+ HeapTupleHeader tuple;
+ JsObject jso;
/* acquire cached tuple descriptor */
if (!io->tupdesc ||
io->tupdesc->tdtypeid != typid ||
io->tupdesc->tdtypmod != typmod)
{
- TupleDesc tupdesc = lookup_rowtype_tupdesc(typid, typmod);
- MemoryContext oldcxt;
+ TupleDesc tupdesc = lookup_rowtype_tupdesc(typid, typmod);
+ MemoryContext oldcxt;
if (io->tupdesc)
FreeTupleDesc(io->tupdesc);
jsv->val.json.type == JSON_TOKEN_STRING)
{
/*
- * Add quotes around string value (should be already escaped)
- * if converting to json/jsonb.
+ * Add quotes around string value (should be already escaped) if
+ * converting to json/jsonb.
*/
if (len < 0)
str[len] = '\0';
}
else
- str = json; /* null-terminated string */
+ str = json; /* null-terminated string */
}
else
{
if (typid == JSONBOID)
{
- Jsonb *jsonb = JsonbValueToJsonb(jbv); /* directly use jsonb */
+ Jsonb *jsonb = JsonbValueToJsonb(jbv); /* directly use jsonb */
+
return JsonbGetDatum(jsonb);
}
/* convert jsonb to string for typio call */
* Convert scalar jsonb (non-scalars are passed here as jbvBinary)
* to json string, preserving quotes around top-level strings.
*/
- Jsonb *jsonb = JsonbValueToJsonb(jbv);
+ Jsonb *jsonb = JsonbValueToJsonb(jbv);
+
str = JsonbToCString(NULL, &jsonb->root, VARSIZE(jsonb));
}
- else if (jbv->type == jbvString) /* quotes are stripped */
+ else if (jbv->type == jbvString) /* quotes are stripped */
str = pnstrdup(jbv->val.string.val, jbv->val.string.len);
else if (jbv->type == jbvBool)
str = pstrdup(jbv->val.boolean ? "true" : "false");
else if (jbv->type == jbvNumeric)
str = DatumGetCString(DirectFunctionCall1(numeric_out,
- PointerGetDatum(jbv->val.numeric)));
+ PointerGetDatum(jbv->val.numeric)));
else if (jbv->type == jbvBinary)
str = JsonbToCString(NULL, jbv->val.binary.data,
- jbv->val.binary.len);
+ jbv->val.binary.len);
else
elog(ERROR, "unrecognized jsonb type: %d", (int) jbv->type);
}
}
static Datum
-populate_domain(DomainIOData *io,
- Oid typid,
- const char *colname,
- MemoryContext mcxt,
- JsValue *jsv,
- bool isnull)
+populate_domain(DomainIOData *io,
+ Oid typid,
+ const char *colname,
+ MemoryContext mcxt,
+ JsValue *jsv,
+ bool isnull)
{
Datum res;
/* prepare column metadata cache for the given type */
static void
-prepare_column_cache(ColumnIOData *column,
- Oid typid,
- int32 typmod,
- MemoryContext mcxt,
- bool json)
+prepare_column_cache(ColumnIOData *column,
+ Oid typid,
+ int32 typmod,
+ MemoryContext mcxt,
+ bool json)
{
- HeapTuple tup;
- Form_pg_type type;
+ HeapTuple tup;
+ Form_pg_type type;
column->typid = typid;
column->typmod = typmod;
column->io.domain.base_typid = type->typbasetype;
column->io.domain.base_typmod = type->typtypmod;
column->io.domain.base_io = MemoryContextAllocZero(mcxt,
- sizeof(ColumnIOData));
+ sizeof(ColumnIOData));
column->io.domain.domain_info = NULL;
}
else if (type->typtype == TYPTYPE_COMPOSITE || typid == RECORDOID)
{
column->typcat = TYPECAT_ARRAY;
column->io.array.element_info = MemoryContextAllocZero(mcxt,
- sizeof(ColumnIOData));
+ sizeof(ColumnIOData));
column->io.array.element_type = type->typelem;
/* array element typemod stored in attribute's typmod */
column->io.array.element_typmod = typmod;
/* don't need input function when converting from jsonb to jsonb */
if (json || typid != JSONBOID)
{
- Oid typioproc;
+ Oid typioproc;
getTypeInputInfo(typid, &typioproc, &column->scalar_io.typioparam);
fmgr_info_cxt(typioproc, &column->scalar_io.typiofunc, mcxt);
/* recursively populate a record field or an array element from a json/jsonb value */
static Datum
populate_record_field(ColumnIOData *col,
- Oid typid,
- int32 typmod,
- const char *colname,
- MemoryContext mcxt,
- Datum defaultval,
- JsValue *jsv,
- bool *isnull)
+ Oid typid,
+ int32 typmod,
+ const char *colname,
+ MemoryContext mcxt,
+ Datum defaultval,
+ JsValue *jsv,
+ bool *isnull)
{
TypeCat typcat;
allocate_record_info(MemoryContext mcxt, int ncolumns)
{
RecordIOData *data = (RecordIOData *)
- MemoryContextAlloc(mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
+ MemoryContextAlloc(mcxt,
+ offsetof(RecordIOData, columns) +
+ ncolumns * sizeof(ColumnIOData));
data->record_type = InvalidOid;
data->record_typmod = 0;
jsv->val.json.type = hashentry ? hashentry->type : JSON_TOKEN_NULL;
jsv->val.json.str = jsv->val.json.type == JSON_TOKEN_NULL ? NULL :
- hashentry->val;
+ hashentry->val;
jsv->val.json.len = jsv->val.json.str ? -1 : 0; /* null-terminated */
return hashentry != NULL;
else
{
jsv->val.jsonb = !obj->val.jsonb_cont ? NULL :
- findJsonbValueFromContainerLen(obj->val.jsonb_cont, JB_FOBJECT,
- field, strlen(field));
+ findJsonbValueFromContainerLen(obj->val.jsonb_cont, JB_FOBJECT,
+ field, strlen(field));
return jsv->val.jsonb != NULL;
}
/* populate a record tuple from json/jsonb value */
static HeapTupleHeader
-populate_record(TupleDesc tupdesc,
- RecordIOData **precord,
- HeapTupleHeader defaultval,
- MemoryContext mcxt,
- JsObject *obj)
-{
- RecordIOData *record = *precord;
- Datum *values;
- bool *nulls;
- HeapTuple res;
- int ncolumns = tupdesc->natts;
- int i;
+populate_record(TupleDesc tupdesc,
+ RecordIOData **precord,
+ HeapTupleHeader defaultval,
+ MemoryContext mcxt,
+ JsObject *obj)
+{
+ RecordIOData *record = *precord;
+ Datum *values;
+ bool *nulls;
+ HeapTuple res;
+ int ncolumns = tupdesc->natts;
+ int i;
/*
- * if the input json is empty, we can only skip the rest if we were
- * passed in a non-null record, since otherwise there may be issues
- * with domain nulls.
+ * if the input json is empty, we can only skip the rest if we were passed
+ * in a non-null record, since otherwise there may be issues with domain
+ * nulls.
*/
if (defaultval && JsObjectIsEmpty(obj))
return defaultval;
record->record_typmod != tupdesc->tdtypmod)
{
MemSet(record, 0, offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
+ ncolumns * sizeof(ColumnIOData));
record->record_type = tupdesc->tdtypeid;
record->record_typmod = tupdesc->tdtypmod;
record->ncolumns = ncolumns;
for (i = 0; i < ncolumns; ++i)
{
- Form_pg_attribute att = tupdesc->attrs[i];
- char *colname = NameStr(att->attname);
- JsValue field = { 0 };
- bool found;
+ Form_pg_attribute att = tupdesc->attrs[i];
+ char *colname = NameStr(att->attname);
+ JsValue field = {0};
+ bool found;
/* Ignore dropped columns in datatype */
if (att->attisdropped)
{
int json_arg_num = have_record_arg ? 1 : 0;
Oid jtype = get_fn_expr_argtype(fcinfo->flinfo, json_arg_num);
- JsValue jsv = { 0 };
+ JsValue jsv = {0};
HeapTupleHeader rec = NULL;
Oid tupType;
int32 tupTypmod;
*/
if (!cache)
fcinfo->flinfo->fn_extra = cache =
- MemoryContextAllocZero(fnmcxt, sizeof(*cache));
+ MemoryContextAllocZero(fnmcxt, sizeof(*cache));
if (have_record_arg)
{
jsv.val.json.str = VARDATA_ANY(json);
jsv.val.json.len = VARSIZE_ANY_EXHDR(json);
- jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in populate_composite() */
+ jsv.val.json.type = JSON_TOKEN_INVALID; /* not used in
+ * populate_composite() */
}
else
{
static void
populate_recordset_record(PopulateRecordsetState *state, JsObject *obj)
{
- HeapTupleData tuple;
- HeapTupleHeader tuphead = populate_record(state->ret_tdesc,
+ HeapTupleData tuple;
+ HeapTupleHeader tuphead = populate_record(state->ret_tdesc,
state->my_extra,
state->rec,
state->fn_mcxt,
void
iterate_jsonb_string_values(Jsonb *jb, void *state, JsonIterateStringValuesAction action)
{
- JsonbIterator *it;
- JsonbValue v;
- JsonbIteratorToken type;
+ JsonbIterator *it;
+ JsonbValue v;
+ JsonbIteratorToken type;
it = JsonbIteratorInit(&jb->root);
{
JsonLexContext *lex = makeJsonLexContext(json, true);
JsonSemAction *sem = palloc0(sizeof(JsonSemAction));
- IterateJsonStringValuesState *state = palloc0(sizeof(IterateJsonStringValuesState));
+ IterateJsonStringValuesState *state = palloc0(sizeof(IterateJsonStringValuesState));
state->lex = lex;
state->action = action;
static void
iterate_string_values_scalar(void *state, char *token, JsonTokenType tokentype)
{
- IterateJsonStringValuesState *_state = (IterateJsonStringValuesState *) state;
+ IterateJsonStringValuesState *_state = (IterateJsonStringValuesState *) state;
+
if (tokentype == JSON_TOKEN_STRING)
(*_state->action) (_state->action_state, token, strlen(token));
}
*/
Jsonb *
transform_jsonb_string_values(Jsonb *jsonb, void *action_state,
- JsonTransformStringValuesAction transform_action)
+ JsonTransformStringValuesAction transform_action)
{
- JsonbIterator *it;
- JsonbValue v, *res = NULL;
- JsonbIteratorToken type;
- JsonbParseState *st = NULL;
- text *out;
- bool is_scalar = false;
+ JsonbIterator *it;
+ JsonbValue v,
+ *res = NULL;
+ JsonbIteratorToken type;
+ JsonbParseState *st = NULL;
+ text *out;
+ bool is_scalar = false;
it = JsonbIteratorInit(&jsonb->root);
is_scalar = it->isScalar;
transform_string_values_object_start(void *state)
{
TransformJsonStringValuesState *_state = (TransformJsonStringValuesState *) state;
+
appendStringInfoCharMacro(_state->strval, '{');
}
transform_string_values_object_end(void *state)
{
TransformJsonStringValuesState *_state = (TransformJsonStringValuesState *) state;
+
appendStringInfoCharMacro(_state->strval, '}');
}
transform_string_values_array_start(void *state)
{
TransformJsonStringValuesState *_state = (TransformJsonStringValuesState *) state;
+
appendStringInfoCharMacro(_state->strval, '[');
}
transform_string_values_array_end(void *state)
{
TransformJsonStringValuesState *_state = (TransformJsonStringValuesState *) state;
+
appendStringInfoCharMacro(_state->strval, ']');
}
if (tokentype == JSON_TOKEN_STRING)
{
- text *out = (*_state->action) (_state->action_state, token, strlen(token));
+ text *out = (*_state->action) (_state->action_state, token, strlen(token));
+
escape_json(_state->strval, text_to_cstring(out));
}
else
*/
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_COLLATION),
- errmsg("could not determine which collation to use for ILIKE"),
+ errmsg("could not determine which collation to use for ILIKE"),
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
locale = pg_newlocale_from_collation(collation);
/*
* For efficiency reasons, in the single byte case we don't call lower()
* on the pattern and text, but instead call SB_lower_char on each
- * character. In the multi-byte case we don't have much choice :-(.
- * Also, ICU does not support single-character case folding, so we go the
- * long way.
+ * character. In the multi-byte case we don't have much choice :-(. Also,
+ * ICU does not support single-character case folding, so we go the long
+ * way.
*/
if (pg_database_encoding_max_length() > 1 || (locale && locale->provider == COLLPROVIDER_ICU))
bool estimating; /* true if estimating cardinality */
hyperLogLogState abbr_card; /* cardinality estimator */
-} macaddr_sortsupport_state;
+} macaddr_sortsupport_state;
static int macaddr_cmp_internal(macaddr *a1, macaddr *a2);
static int macaddr_fast_cmp(Datum x, Datum y, SortSupport ssup);
Datum
macaddr8_in(PG_FUNCTION_ARGS)
{
- const unsigned char *str = (unsigned char*) PG_GETARG_CSTRING(0);
+ const unsigned char *str = (unsigned char *) PG_GETARG_CSTRING(0);
const unsigned char *ptr = str;
macaddr8 *result;
unsigned char a = 0,
Form_pg_collation collform;
const char *collcollate;
const char *collctype pg_attribute_unused();
- pg_locale_t result;
+ pg_locale_t result;
Datum collversion;
bool isnull;
collcollate = NameStr(collform->collcollate);
collctype = NameStr(collform->collctype);
- result = malloc(sizeof(* result));
- memset(result, 0, sizeof(* result));
+ result = malloc(sizeof(*result));
+ memset(result, 0, sizeof(*result));
result->provider = collform->collprovider;
if (collform->collprovider == COLLPROVIDER_LIBC)
/* Normal case where they're the same */
#ifndef WIN32
loc = newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, collcollate,
- NULL);
+ NULL);
#else
loc = _create_locale(LC_ALL, collcollate);
#endif
#else
/*
- * XXX The _create_locale() API doesn't appear to support this.
- * Could perhaps be worked around by changing pg_locale_t to
- * contain two separate fields.
+ * XXX The _create_locale() API doesn't appear to support
+ * this. Could perhaps be worked around by changing
+ * pg_locale_t to contain two separate fields.
*/
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
collator = ucol_open(collcollate, &status);
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("could not open collator for locale \"%s\": %s",
- collcollate, u_errorName(status))));
+ (errmsg("could not open collator for locale \"%s\": %s",
+ collcollate, u_errorName(status))));
result->info.icu.locale = strdup(collcollate);
result->info.icu.ucol = collator;
-#else /* not USE_ICU */
+#else /* not USE_ICU */
/* could get here if a collation was created by a build with ICU */
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ICU is not supported in this build"), \
- errhint("You need to rebuild PostgreSQL using --with-icu.")));
-#endif /* not USE_ICU */
+ errhint("You need to rebuild PostgreSQL using --with-icu.")));
+#endif /* not USE_ICU */
}
collversion = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collversion,
actual_versionstr = get_collation_actual_version(collform->collprovider, collcollate);
if (!actual_versionstr)
{
- /* This could happen when specifying a version in CREATE
- * COLLATION for a libc locale, or manually creating a mess
- * in the catalogs. */
+ /*
+ * This could happen when specifying a version in CREATE
+ * COLLATION for a libc locale, or manually creating a mess in
+ * the catalogs.
+ */
ereport(ERROR,
(errmsg("collation \"%s\" has no actual version, but a version was specified",
NameStr(collform->collname))));
(errmsg("collation \"%s\" has version mismatch",
NameStr(collform->collname)),
errdetail("The collation in the database was created using version %s, "
- "but the operating system provides version %s.",
+ "but the operating system provides version %s.",
collversionstr, actual_versionstr),
errhint("Rebuild all objects affected by this collation and run "
"ALTER COLLATION %s REFRESH VERSION, "
- "or build PostgreSQL with the right library version.",
+ "or build PostgreSQL with the right library version.",
quote_qualified_identifier(get_namespace_name(collform->collnamespace),
- NameStr(collform->collname)))));
+ NameStr(collform->collname)))));
}
ReleaseSysCache(tp);
conv = ucnv_open(icu_encoding_name, &status);
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("could not open ICU converter for encoding \"%s\": %s",
- icu_encoding_name, u_errorName(status))));
+ (errmsg("could not open ICU converter for encoding \"%s\": %s",
+ icu_encoding_name, u_errorName(status))));
icu_converter = conv;
}
init_icu_converter();
- len_uchar = 2 * nbytes; /* max length per docs */
+ len_uchar = 2 * nbytes; /* max length per docs */
*buff_uchar = palloc(len_uchar * sizeof(**buff_uchar));
status = U_ZERO_ERROR;
len_uchar = ucnv_toUChars(icu_converter, *buff_uchar, len_uchar, buff, nbytes, &status);
static char *
pg_get_statisticsobj_worker(Oid statextid, bool missing_ok)
{
- Form_pg_statistic_ext statextrec;
+ Form_pg_statistic_ext statextrec;
HeapTuple statexttup;
StringInfoData buf;
int colno;
nsp = get_namespace_name(statextrec->stxnamespace);
appendStringInfo(&buf, "CREATE STATISTICS %s",
quote_qualified_identifier(nsp,
- NameStr(statextrec->stxname)));
+ NameStr(statextrec->stxname)));
/*
* Decode the stxkind column so that we know which stats types to print.
Datum
pg_get_partition_constraintdef(PG_FUNCTION_ARGS)
{
- Oid relationId = PG_GETARG_OID(0);
- Expr *constr_expr;
- int prettyFlags;
- List *context;
- char *consrc;
+ Oid relationId = PG_GETARG_OID(0);
+ Expr *constr_expr;
+ int prettyFlags;
+ List *context;
+ char *consrc;
constr_expr = get_partition_qual_relid(relationId);
VariableStatData *vardata1, VariableStatData *vardata2,
RelOptInfo *inner_rel);
static bool estimate_multivariate_ndistinct(PlannerInfo *root,
- RelOptInfo *rel, List **varinfos, double *ndistinct);
+ RelOptInfo *rel, List **varinfos, double *ndistinct);
static bool convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
Datum lobound, Datum hibound, Oid boundstypid,
double *scaledlobound, double *scaledhibound);
List *relvarinfos = NIL;
/*
- * Split the list of varinfos in two - one for the current rel,
- * one for remaining Vars on other rels.
+ * Split the list of varinfos in two - one for the current rel, one
+ * for remaining Vars on other rels.
*/
relvarinfos = lcons(varinfo1, relvarinfos);
for_each_cell(l, lnext(list_head(varinfos)))
* Get the numdistinct estimate for the Vars of this rel. We
* iteratively search for multivariate n-distinct with maximum number
* of vars; assuming that each var group is independent of the others,
- * we multiply them together. Any remaining relvarinfos after
- * no more multivariate matches are found are assumed independent too,
- * so their individual ndistinct estimates are multiplied also.
+ * we multiply them together. Any remaining relvarinfos after no more
+ * multivariate matches are found are assumed independent too, so
+ * their individual ndistinct estimates are multiplied also.
*
* While iterating, count how many separate numdistinct values we
* apply. We apply a fudge factor below, but only if we multiplied
}
else
{
- foreach (l, relvarinfos)
+ foreach(l, relvarinfos)
{
GroupVarInfo *varinfo2 = (GroupVarInfo *) lfirst(l);
}
/* look for the ndistinct statistics matching the most vars */
- nmatches = 1; /* we require at least two matches */
+ nmatches = 1; /* we require at least two matches */
foreach(lc, rel->statlist)
{
StatisticExtInfo *info = (StatisticExtInfo *) lfirst(lc);
Bitmapset *shared;
- int nshared;
+ int nshared;
/* skip statistics of other kinds */
if (info->kind != STATS_EXT_NDISTINCT)
*/
if (stats)
{
- int i;
- List *newlist = NIL;
+ int i;
+ List *newlist = NIL;
MVNDistinctItem *item = NULL;
/* Find the specific item that exactly matches the combination */
*
* Because we can use all index quals equally when scanning, we can use
* the largest correlation (in absolute value) among columns used by the
- * query. Start at zero, the worst possible case. If we cannot find
- * any correlation statistics, we will keep it as 0.
+ * query. Start at zero, the worst possible case. If we cannot find any
+ * correlation statistics, we will keep it as 0.
*/
*indexCorrelation = 0;
*/
if (HeapTupleIsValid(vardata.statsTuple) && !vardata.freefunc)
elog(ERROR,
- "no function provided to release variable stats with");
+ "no function provided to release variable stats with");
}
else
{
attnum = qinfo->indexcol + 1;
if (get_index_stats_hook &&
- (*get_index_stats_hook) (root, index->indexoid, attnum, &vardata))
+ (*get_index_stats_hook) (root, index->indexoid, attnum, &vardata))
{
/*
- * The hook took control of acquiring a stats tuple. If it did
- * supply a tuple, it'd better have supplied a freefunc.
+ * The hook took control of acquiring a stats tuple. If it
+ * did supply a tuple, it'd better have supplied a freefunc.
*/
if (HeapTupleIsValid(vardata.statsTuple) &&
!vardata.freefunc)
else
{
vardata.statsTuple = SearchSysCache3(STATRELATTINH,
- ObjectIdGetDatum(index->indexoid),
+ ObjectIdGetDatum(index->indexoid),
Int16GetDatum(attnum),
BoolGetDatum(false));
vardata.freefunc = ReleaseSysCache;
/*
* Now estimate the number of ranges that we'll touch by using the
- * indexCorrelation from the stats. Careful not to divide by zero
- * (note we're using the absolute value of the correlation).
+ * indexCorrelation from the stats. Careful not to divide by zero (note
+ * we're using the absolute value of the correlation).
*/
if (*indexCorrelation < 1.0e-10)
estimatedRanges = indexRanges;
*indexSelectivity = selec;
/*
- * Compute the index qual costs, much as in genericcostestimate, to add
- * to the index costs.
+ * Compute the index qual costs, much as in genericcostestimate, to add to
+ * the index costs.
*/
qual_arg_cost = other_operands_eval_cost(root, qinfos) +
orderby_operands_eval_cost(root, path);
/*
* If the transaction ID has wrapped around, it's definitely too old to
* determine the commit status. Otherwise, we can compare it to
- * ShmemVariableCache->oldestClogXid to determine whether the relevant CLOG
- * entry is guaranteed to still exist.
+ * ShmemVariableCache->oldestClogXid to determine whether the relevant
+ * CLOG entry is guaranteed to still exist.
*/
if (xid_epoch + 1 < now_epoch
|| (xid_epoch + 1 == now_epoch && xid < now_epoch_last_xid)
{
txid val;
TxidEpoch state;
- TransactionId topxid = GetTopTransactionIdIfAny();
+ TransactionId topxid = GetTopTransactionIdIfAny();
if (topxid == InvalidTransactionId)
PG_RETURN_NULL();
Datum
txid_status(PG_FUNCTION_ARGS)
{
- const char *status;
- uint64 xid_with_epoch = PG_GETARG_INT64(0);
- TransactionId xid;
+ const char *status;
+ uint64 xid_with_epoch = PG_GETARG_INT64(0);
+ TransactionId xid;
/*
* We must protect against concurrent truncation of clog entries to avoid
* it's aborted if it isn't committed and is older than our
* snapshot xmin.
*
- * Otherwise it must be in-progress (or have been at the time
- * we checked commit/abort status).
+ * Otherwise it must be in-progress (or have been at the time we
+ * checked commit/abort status).
*/
if (TransactionIdPrecedes(xid, GetActiveSnapshot()->xmin))
status = gettext_noop("aborted");
else
#endif
{
- int32_t ulen1, ulen2;
- UChar *uchar1, *uchar2;
+ int32_t ulen1,
+ ulen2;
+ UChar *uchar1,
+ *uchar2;
ulen1 = icu_to_uchar(&uchar1, arg1, len1);
ulen2 = icu_to_uchar(&uchar2, arg2, len2);
uchar1, ulen1,
uchar2, ulen2);
}
-#else /* not USE_ICU */
+#else /* not USE_ICU */
/* shouldn't happen */
elog(ERROR, "unsupported collprovider: %c", mylocale->provider);
-#endif /* not USE_ICU */
+#endif /* not USE_ICU */
}
else
{
&status);
if (U_FAILURE(status))
ereport(ERROR,
- (errmsg("collation failed: %s", u_errorName(status))));
+ (errmsg("collation failed: %s", u_errorName(status))));
}
else
#endif
{
- int32_t ulen1, ulen2;
- UChar *uchar1, *uchar2;
+ int32_t ulen1,
+ ulen2;
+ UChar *uchar1,
+ *uchar2;
ulen1 = icu_to_uchar(&uchar1, a1p, len1);
ulen2 = icu_to_uchar(&uchar2, a2p, len2);
uchar1, ulen1,
uchar2, ulen2);
}
-#else /* not USE_ICU */
+#else /* not USE_ICU */
/* shouldn't happen */
elog(ERROR, "unsupported collprovider: %c", sss->locale->provider);
-#endif /* not USE_ICU */
+#endif /* not USE_ICU */
}
else
{
}
memcpy(sss->buf1, authoritative_data, len);
- /* Just like strcoll(), strxfrm() expects a NUL-terminated string.
- * Not necessary for ICU, but doesn't hurt. */
+
+ /*
+ * Just like strcoll(), strxfrm() expects a NUL-terminated string. Not
+ * necessary for ICU, but doesn't hurt.
+ */
sss->buf1[len] = '\0';
sss->last_len1 = len;
UErrorCode status;
uiter_setUTF8(&iter, sss->buf1, len);
- state[0] = state[1] = 0; /* won't need that again */
+ state[0] = state[1] = 0; /* won't need that again */
status = U_ZERO_ERROR;
bsize = ucol_nextSortKeyPart(sss->locale->info.icu.ucol,
&iter,
state,
(uint8_t *) sss->buf2,
- Min(sizeof(Datum), sss->buflen2),
+ Min(sizeof(Datum), sss->buflen2),
&status);
if (U_FAILURE(status))
ereport(ERROR,
else
bsize = ucol_getSortKey(sss->locale->info.icu.ucol,
uchar, ulen,
- (uint8_t *) sss->buf2, sss->buflen2);
+ (uint8_t *) sss->buf2, sss->buflen2);
}
else
#endif
CppAsString2(RELKIND_RELATION) ","
CppAsString2(RELKIND_MATVIEW) ","
CppAsString2(RELKIND_VIEW) ")"
- " AND pg_catalog.has_table_privilege(pg_class.oid, 'SELECT')"
- " AND relnamespace IN (" XML_VISIBLE_SCHEMAS ");");
+ " AND pg_catalog.has_table_privilege(pg_class.oid, 'SELECT')"
+ " AND relnamespace IN (" XML_VISIBLE_SCHEMAS ");");
}
* This line ensure mapping of empty tags to PostgreSQL
* value. Usually we would to map a empty tag to empty
* string. But this mapping can create empty string when
- * user doesn't expect it - when empty tag is enforced
- * by libxml2 - when user uses a text() function for
- * example.
+ * user doesn't expect it - when empty tag is enforced by
+ * libxml2 - when user uses a text() function for example.
*/
cstr = "";
}
SharedInvalidationMessage msg;
/*
- * Don't add a duplicate item.
- * We assume dbId need not be checked because it will never change.
- * InvalidOid for relId means all relations so we don't need to add
- * individual ones when it is present.
+ * Don't add a duplicate item. We assume dbId need not be checked because
+ * it will never change. InvalidOid for relId means all relations so we
+ * don't need to add individual ones when it is present.
*/
ProcessMessageList(hdr->rclist,
if (msg->rc.id == SHAREDINVALRELCACHE_ID &&
/*
* If the relation being invalidated is one of those cached in the local
- * relcache init file, mark that we need to zap that file at commit.
- * Same is true when we are invalidating whole relcache.
+ * relcache init file, mark that we need to zap that file at commit. Same
+ * is true when we are invalidating whole relcache.
*/
if (OidIsValid(dbId) &&
(RelationIdIsInInitFile(relId) || relId == InvalidOid))
RegisterCatcacheInvalidation);
/*
- * Now, is this tuple one of the primary definers of a relcache entry?
- * See comments in file header for deeper explanation.
+ * Now, is this tuple one of the primary definers of a relcache entry? See
+ * comments in file header for deeper explanation.
*
* Note we ignore newtuple here; we assume an update cannot move a tuple
* from being part of one relcache entry to being part of another.
if (HeapTupleIsValid(tp))
{
Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
- char result;
+ char result;
result = att_tup->attidentity;
ReleaseSysCache(tp);
static void ReleaseGenericPlan(CachedPlanSource *plansource);
static List *RevalidateCachedQuery(CachedPlanSource *plansource,
- QueryEnvironment *queryEnv);
+ QueryEnvironment *queryEnv);
static bool CheckCachedPlan(CachedPlanSource *plansource);
static CachedPlan *BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
ParamListInfo boundParams, QueryEnvironment *queryEnv);
* acquire a non-conflicting lock.
*/
if (list_member_int(plannedstmt->resultRelations, rt_index) ||
- list_member_int(plannedstmt->nonleafResultRelations, rt_index))
+ list_member_int(plannedstmt->nonleafResultRelations, rt_index))
lockmode = RowExclusiveLock;
else if ((rc = get_plan_rowmark(plannedstmt->rowMarks, rt_index)) != NULL &&
RowMarkRequiresRowShareLock(rc->markType))
*/
result = NIL;
- /* Prepare to scan pg_statistic_ext for entries having stxrelid = this rel. */
+ /*
+ * Prepare to scan pg_statistic_ext for entries having stxrelid = this
+ * rel.
+ */
ScanKeyInit(&skey,
Anum_pg_statistic_ext_stxrelid,
BTEqualStrategyNumber, F_OIDEQ,
list_free(relation->rd_indexlist);
relation->rd_indexlist = indexIds;
relation->rd_oidindex = oidIndex;
+
/*
- * For the moment, assume the target rel hasn't got a pk or replica
- * index. We'll load them on demand in the API that wraps access to them.
+ * For the moment, assume the target rel hasn't got a pk or replica index.
+ * We'll load them on demand in the API that wraps access to them.
*/
relation->rd_pkindex = InvalidOid;
relation->rd_replidindex = InvalidOid;
{
List *puboids;
ListCell *lc;
- MemoryContext oldcxt;
+ MemoryContext oldcxt;
PublicationActions *pubactions = palloc0(sizeof(PublicationActions));
if (relation->rd_pubactions)
ReleaseSysCache(tup);
/*
- * If we know everything is replicated, there is no point to check
- * for other publications.
+ * If we know everything is replicated, there is no point to check for
+ * other publications.
*/
if (pubactions->pubinsert && pubactions->pubupdate &&
pubactions->pubdelete)
},
16
},
- {PublicationRelationId, /* PUBLICATIONOID */
+ {PublicationRelationId, /* PUBLICATIONOID */
PublicationObjectIndexId,
1,
{
},
8
},
- {PublicationRelationId, /* PUBLICATIONNAME */
+ {PublicationRelationId, /* PUBLICATIONNAME */
PublicationNameIndexId,
1,
{
},
8
},
- {PublicationRelRelationId, /* PUBLICATIONREL */
+ {PublicationRelRelationId, /* PUBLICATIONREL */
PublicationRelObjectIndexId,
1,
{
},
64
},
- {PublicationRelRelationId, /* PUBLICATIONRELMAP */
+ {PublicationRelRelationId, /* PUBLICATIONRELMAP */
PublicationRelPrrelidPrpubidIndexId,
2,
{
},
8
},
- {SequenceRelationId, /* SEQRELID */
+ {SequenceRelationId, /* SEQRELID */
SequenceRelidIndexId,
1,
{
},
128
},
- {SubscriptionRelationId, /* SUBSCRIPTIONOID */
+ {SubscriptionRelationId, /* SUBSCRIPTIONOID */
SubscriptionObjectIndexId,
1,
{
},
4
},
- {SubscriptionRelationId, /* SUBSCRIPTIONNAME */
+ {SubscriptionRelationId, /* SUBSCRIPTIONNAME */
SubscriptionNameIndexId,
2,
{
},
4
},
- {SubscriptionRelRelationId, /* SUBSCRIPTIONRELMAP */
+ {SubscriptionRelRelationId, /* SUBSCRIPTIONRELMAP */
SubscriptionRelSrrelidSrsubidIndexId,
2,
{
static void *internal_load_library(const char *libname);
static void incompatible_module_error(const char *libname,
- const Pg_magic_struct *module_magic_data) pg_attribute_noreturn();
+ const Pg_magic_struct *module_magic_data) pg_attribute_noreturn();
static void internal_unload_library(const char *libname);
static bool file_exists(const char *name);
static char *expand_dynamic_library_name(const char *name);
{
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
- errmsg("could not find function information for function \"%s\"",
- funcname),
+ errmsg("could not find function information for function \"%s\"",
+ funcname),
errhint("SQL-callable functions need an accompanying PG_FUNCTION_INFO_V1(funcname).")));
- return NULL; /* silence compiler */
+ return NULL; /* silence compiler */
}
/* Found, so call it */
else
return rt->chars16[b4 + rt->b1root - rt->b1_lower];
}
- return 0; /* shouldn't happen */
+ return 0; /* shouldn't happen */
}
/*
/* Now check ordinary map */
if (map)
{
- uint32 converted = pg_mb_radix_conv(map, l, b1, b2, b3, b4);
+ uint32 converted = pg_mb_radix_conv(map, l, b1, b2, b3, b4);
+
if (converted)
{
iso = store_coded_char(iso, converted);
if (map)
{
- uint32 converted = pg_mb_radix_conv(map, l, b1, b2, b3, b4);
+ uint32 converted = pg_mb_radix_conv(map, l, b1, b2, b3, b4);
if (converted)
{
typedef struct
{
pg_enc encoding;
- const pg_mb_radix_tree *map1; /* to UTF8 map name */
- const pg_mb_radix_tree *map2; /* from UTF8 map name */
+ const pg_mb_radix_tree *map1; /* to UTF8 map name */
+ const pg_mb_radix_tree *map2; /* from UTF8 map name */
} pg_conv_map;
static const pg_conv_map maps[] = {
{PG_LATIN2, &iso8859_2_to_unicode_tree,
- &iso8859_2_from_unicode_tree}, /* ISO-8859-2 Latin 2 */
+ &iso8859_2_from_unicode_tree}, /* ISO-8859-2 Latin 2 */
{PG_LATIN3, &iso8859_3_to_unicode_tree,
- &iso8859_3_from_unicode_tree}, /* ISO-8859-3 Latin 3 */
+ &iso8859_3_from_unicode_tree}, /* ISO-8859-3 Latin 3 */
{PG_LATIN4, &iso8859_4_to_unicode_tree,
- &iso8859_4_from_unicode_tree}, /* ISO-8859-4 Latin 4 */
+ &iso8859_4_from_unicode_tree}, /* ISO-8859-4 Latin 4 */
{PG_LATIN5, &iso8859_9_to_unicode_tree,
- &iso8859_9_from_unicode_tree}, /* ISO-8859-9 Latin 5 */
+ &iso8859_9_from_unicode_tree}, /* ISO-8859-9 Latin 5 */
{PG_LATIN6, &iso8859_10_to_unicode_tree,
- &iso8859_10_from_unicode_tree}, /* ISO-8859-10 Latin 6 */
+ &iso8859_10_from_unicode_tree}, /* ISO-8859-10 Latin 6 */
{PG_LATIN7, &iso8859_13_to_unicode_tree,
- &iso8859_13_from_unicode_tree}, /* ISO-8859-13 Latin 7 */
+ &iso8859_13_from_unicode_tree}, /* ISO-8859-13 Latin 7 */
{PG_LATIN8, &iso8859_14_to_unicode_tree,
- &iso8859_14_from_unicode_tree}, /* ISO-8859-14 Latin 8 */
+ &iso8859_14_from_unicode_tree}, /* ISO-8859-14 Latin 8 */
{PG_LATIN9, &iso8859_15_to_unicode_tree,
- &iso8859_15_from_unicode_tree}, /* ISO-8859-15 Latin 9 */
+ &iso8859_15_from_unicode_tree}, /* ISO-8859-15 Latin 9 */
{PG_LATIN10, &iso8859_16_to_unicode_tree,
- &iso8859_16_from_unicode_tree}, /* ISO-8859-16 Latin 10 */
+ &iso8859_16_from_unicode_tree}, /* ISO-8859-16 Latin 10 */
{PG_ISO_8859_5, &iso8859_5_to_unicode_tree,
- &iso8859_5_from_unicode_tree}, /* ISO-8859-5 */
+ &iso8859_5_from_unicode_tree}, /* ISO-8859-5 */
{PG_ISO_8859_6, &iso8859_6_to_unicode_tree,
- &iso8859_6_from_unicode_tree}, /* ISO-8859-6 */
+ &iso8859_6_from_unicode_tree}, /* ISO-8859-6 */
{PG_ISO_8859_7, &iso8859_7_to_unicode_tree,
- &iso8859_7_from_unicode_tree}, /* ISO-8859-7 */
+ &iso8859_7_from_unicode_tree}, /* ISO-8859-7 */
{PG_ISO_8859_8, &iso8859_8_to_unicode_tree,
- &iso8859_8_from_unicode_tree}, /* ISO-8859-8 */
+ &iso8859_8_from_unicode_tree}, /* ISO-8859-8 */
};
Datum
typedef struct
{
pg_enc encoding;
- const pg_mb_radix_tree *map1; /* to UTF8 map name */
- const pg_mb_radix_tree *map2; /* from UTF8 map name */
+ const pg_mb_radix_tree *map1; /* to UTF8 map name */
+ const pg_mb_radix_tree *map2; /* from UTF8 map name */
} pg_conv_map;
static const pg_conv_map maps[] = {
- {PG_WIN866, &win866_to_unicode_tree, &win866_from_unicode_tree},
- {PG_WIN874, &win874_to_unicode_tree, &win874_from_unicode_tree},
+ {PG_WIN866, &win866_to_unicode_tree, &win866_from_unicode_tree},
+ {PG_WIN874, &win874_to_unicode_tree, &win874_from_unicode_tree},
{PG_WIN1250, &win1250_to_unicode_tree, &win1250_from_unicode_tree},
{PG_WIN1251, &win1251_to_unicode_tree, &win1251_from_unicode_tree},
{PG_WIN1252, &win1252_to_unicode_tree, &win1252_from_unicode_tree},
*
* NULL entries are not supported by ICU, or their mapping is unclear.
*/
-static const char * const pg_enc2icu_tbl[] =
+static const char *const pg_enc2icu_tbl[] =
{
- NULL, /* PG_SQL_ASCII */
- "EUC-JP", /* PG_EUC_JP */
- "EUC-CN", /* PG_EUC_CN */
- "EUC-KR", /* PG_EUC_KR */
- "EUC-TW", /* PG_EUC_TW */
- NULL, /* PG_EUC_JIS_2004 */
- "UTF-8", /* PG_UTF8 */
- NULL, /* PG_MULE_INTERNAL */
- "ISO-8859-1", /* PG_LATIN1 */
- "ISO-8859-2", /* PG_LATIN2 */
- "ISO-8859-3", /* PG_LATIN3 */
- "ISO-8859-4", /* PG_LATIN4 */
- "ISO-8859-9", /* PG_LATIN5 */
- "ISO-8859-10", /* PG_LATIN6 */
- "ISO-8859-13", /* PG_LATIN7 */
- "ISO-8859-14", /* PG_LATIN8 */
- "ISO-8859-15", /* PG_LATIN9 */
- NULL, /* PG_LATIN10 */
- "CP1256", /* PG_WIN1256 */
- "CP1258", /* PG_WIN1258 */
- "CP866", /* PG_WIN866 */
- NULL, /* PG_WIN874 */
- "KOI8-R", /* PG_KOI8R */
- "CP1251", /* PG_WIN1251 */
- "CP1252", /* PG_WIN1252 */
- "ISO-8859-5", /* PG_ISO_8859_5 */
- "ISO-8859-6", /* PG_ISO_8859_6 */
- "ISO-8859-7", /* PG_ISO_8859_7 */
- "ISO-8859-8", /* PG_ISO_8859_8 */
- "CP1250", /* PG_WIN1250 */
- "CP1253", /* PG_WIN1253 */
- "CP1254", /* PG_WIN1254 */
- "CP1255", /* PG_WIN1255 */
- "CP1257", /* PG_WIN1257 */
- "KOI8-U", /* PG_KOI8U */
+ NULL, /* PG_SQL_ASCII */
+ "EUC-JP", /* PG_EUC_JP */
+ "EUC-CN", /* PG_EUC_CN */
+ "EUC-KR", /* PG_EUC_KR */
+ "EUC-TW", /* PG_EUC_TW */
+ NULL, /* PG_EUC_JIS_2004 */
+ "UTF-8", /* PG_UTF8 */
+ NULL, /* PG_MULE_INTERNAL */
+ "ISO-8859-1", /* PG_LATIN1 */
+ "ISO-8859-2", /* PG_LATIN2 */
+ "ISO-8859-3", /* PG_LATIN3 */
+ "ISO-8859-4", /* PG_LATIN4 */
+ "ISO-8859-9", /* PG_LATIN5 */
+ "ISO-8859-10", /* PG_LATIN6 */
+ "ISO-8859-13", /* PG_LATIN7 */
+ "ISO-8859-14", /* PG_LATIN8 */
+ "ISO-8859-15", /* PG_LATIN9 */
+ NULL, /* PG_LATIN10 */
+ "CP1256", /* PG_WIN1256 */
+ "CP1258", /* PG_WIN1258 */
+ "CP866", /* PG_WIN866 */
+ NULL, /* PG_WIN874 */
+ "KOI8-R", /* PG_KOI8R */
+ "CP1251", /* PG_WIN1251 */
+ "CP1252", /* PG_WIN1252 */
+ "ISO-8859-5", /* PG_ISO_8859_5 */
+ "ISO-8859-6", /* PG_ISO_8859_6 */
+ "ISO-8859-7", /* PG_ISO_8859_7 */
+ "ISO-8859-8", /* PG_ISO_8859_8 */
+ "CP1250", /* PG_WIN1250 */
+ "CP1253", /* PG_WIN1253 */
+ "CP1254", /* PG_WIN1254 */
+ "CP1255", /* PG_WIN1255 */
+ "CP1257", /* PG_WIN1257 */
+ "KOI8-U", /* PG_KOI8U */
};
bool
return icu_encoding_name;
}
-#endif /* not FRONTEND */
+#endif /* not FRONTEND */
/* ----------
pg_backend_random(char *dst, int len)
{
/* should not be called in postmaster */
- Assert (IsUnderPostmaster || !IsPostmasterEnvironment);
+ Assert(IsUnderPostmaster || !IsPostmasterEnvironment);
return pg_strong_random(dst, len);
}
{
bool initialized;
unsigned short seed[3];
-} BackendRandomShmemStruct;
+} BackendRandomShmemStruct;
static BackendRandomShmemStruct *BackendRandomShmem;
char *end = dst + len;
/* should not be called in postmaster */
- Assert (IsUnderPostmaster || !IsPostmasterEnvironment);
+ Assert(IsUnderPostmaster || !IsPostmasterEnvironment);
LWLockAcquire(BackendRandomLock, LW_EXCLUSIVE);
BackendRandomShmem->seed[2] = (unsigned short) (now.tv_usec >> 16);
/*
- * Mix in the cancel key, generated by the postmaster. This adds
- * what little entropy the postmaster had to the seed.
+ * Mix in the cancel key, generated by the postmaster. This adds what
+ * little entropy the postmaster had to the seed.
*/
BackendRandomShmem->seed[0] ^= (MyCancelKey);
BackendRandomShmem->seed[1] ^= (MyCancelKey >> 16);
/*
* pg_jrand48 returns a 32-bit integer. Fill the next 4 bytes from it.
*/
- r = (uint32) pg_jrand48(BackendRandomShmem->seed);
+ r = (uint32) pg_jrand48(BackendRandomShmem->seed);
for (j = 0; j < 4 && dst < end; j++)
{
}
-#endif /* HAVE_STRONG_RANDOM */
+#endif /* HAVE_STRONG_RANDOM */
static void assign_log_destination(const char *newval, void *extra);
static bool check_wal_consistency_checking(char **newval, void **extra,
- GucSource source);
+ GucSource source);
static void assign_wal_consistency_checking(const char *newval, void *extra);
#ifdef HAVE_SYSLOG
{"max_pred_locks_per_page", PGC_SIGHUP, LOCK_MANAGEMENT,
gettext_noop("Sets the maximum number of predicate-locked tuples per page."),
gettext_noop("If more than this number of tuples on the same page are locked "
- "by a connection, those locks are replaced by a page level lock.")
+ "by a connection, those locks are replaced by a page level lock.")
},
&max_predicate_locks_per_page,
2, 0, INT_MAX,
GUC_UNIT_MB
},
&min_wal_size_mb,
- 5 * (XLOG_SEG_SIZE/ (1024 * 1024)), 2, MAX_KILOBYTES,
+ 5 * (XLOG_SEG_SIZE / (1024 * 1024)), 2, MAX_KILOBYTES,
NULL, NULL, NULL
},
GUC_UNIT_MB
},
&max_wal_size_mb,
- 64 * (XLOG_SEG_SIZE/ (1024 * 1024)), 2, MAX_KILOBYTES,
+ 64 * (XLOG_SEG_SIZE / (1024 * 1024)), 2, MAX_KILOBYTES,
NULL, assign_max_wal_size, NULL
},
NULL
},
&bgwriter_lru_maxpages,
- 100, 0, INT_MAX / 2, /* Same upper limit as shared_buffers */
+ 100, 0, INT_MAX / 2, /* Same upper limit as shared_buffers */
NULL, NULL, NULL
},
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
- name)));
+ name)));
switch (record->vartype)
{
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
- name)));
+ name)));
switch (record->vartype)
{
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
- name)));
+ name)));
if (varname)
*varname = record->name;
{
if ((conf->flags & GUC_NO_SHOW_ALL) ||
((conf->flags & GUC_SUPERUSER_ONLY) &&
- !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
+ !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
*noshow = true;
else
*noshow = false;
* which in turn can cause the same sort to need more runs, which makes
* merging slower even if it can still be done in a single pass. Also,
* high order merges are quite slow due to CPU cache effects; it can be
- * faster to pay the I/O cost of a polyphase merge than to perform a single
- * merge pass across many hundreds of tapes.
+ * faster to pay the I/O cost of a polyphase merge than to perform a
+ * single merge pass across many hundreds of tapes.
*/
mOrder = Max(mOrder, MINORDER);
mOrder = Min(mOrder, MAXORDER);
FirstSnapshotSet = false;
/*
- * During normal commit processing, we call
- * ProcArrayEndTransaction() to reset the PgXact->xmin. That call
- * happens prior to the call to AtEOXact_Snapshot(), so we need
- * not touch xmin here at all.
+ * During normal commit processing, we call ProcArrayEndTransaction() to
+ * reset the PgXact->xmin. That call happens prior to the call to
+ * AtEOXact_Snapshot(), so we need not touch xmin here at all.
*/
if (resetXmin)
SnapshotResetXmin();
{
"Russia TZ 9 Standard Time", "Russia TZ 9 Daylight Time",
"Asia/Vladivostok"
- }, /* (UTC+10:00) Vladivostok, Magadan
- * (RTZ 9) */
+ }, /* (UTC+10:00) Vladivostok, Magadan (RTZ 9) */
{
"Russia TZ 10 Standard Time", "Russia TZ 10 Daylight Time",
"Asia/Magadan"
{
"Russia TZ 11 Standard Time", "Russia TZ 11 Daylight Time",
"Asia/Anadyr"
- }, /* (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky
- * (RTZ 11) */
+ }, /* (UTC+12:00) Anadyr,
+ * Petropavlovsk-Kamchatsky (RTZ 11) */
{
"Russian Standard Time", "Russian Daylight Time",
"Europe/Moscow"
{
"SA Pacific Standard Time", "SA Pacific Daylight Time",
"America/Bogota"
- }, /* (UTC-05:00) Bogota, Lima, Quito, Rio
- * Branco */
+ }, /* (UTC-05:00) Bogota, Lima, Quito, Rio Branco */
{
"SA Western Standard Time", "SA Western Daylight Time",
"America/Caracas"
- }, /* (UTC-04:00) Georgetown, La Paz, Manaus,
- * San Juan */
+ }, /* (UTC-04:00) Georgetown, La Paz, Manaus, San
+ * Juan */
{
"Saint Pierre Standard Time", "Saint Pierre Daylight Time",
"America/Miquelon"
else if (found_existing_xlogdir)
{
fprintf(stderr,
- _("%s: removing contents of WAL directory \"%s\"\n"),
+ _("%s: removing contents of WAL directory \"%s\"\n"),
progname, xlog_dir);
if (!rmtree(xlog_dir, false))
fprintf(stderr, _("%s: failed to remove contents of WAL directory\n"),
if (made_new_xlogdir || found_existing_xlogdir)
fprintf(stderr,
- _("%s: WAL directory \"%s\" not removed at user's request\n"),
+ _("%s: WAL directory \"%s\" not removed at user's request\n"),
progname, xlog_dir);
}
{"version", no_argument, NULL, 'V'},
{"debug", no_argument, NULL, 'd'},
{"show", no_argument, NULL, 's'},
- {"noclean", no_argument, NULL, 'n'}, /* for backwards compatibility */
+ {"noclean", no_argument, NULL, 'n'}, /* for backwards compatibility */
{"no-clean", no_argument, NULL, 'n'},
- {"nosync", no_argument, NULL, 'N'}, /* for backwards compatibility */
+ {"nosync", no_argument, NULL, 'N'}, /* for backwards compatibility */
{"no-sync", no_argument, NULL, 'N'},
{"sync-only", no_argument, NULL, 'S'},
{"waldir", required_argument, NULL, 'X'},
char *archiveLocation; /* where to find the archive? */
char *restartWALFileName; /* the file from which we can restart restore */
-char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
+char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the oldest file we
* want to remain in
* archive */
if (made_new_xlogdir || found_existing_xlogdir)
fprintf(stderr,
- _("%s: WAL directory \"%s\" not removed at user's request\n"),
+ _("%s: WAL directory \"%s\" not removed at user's request\n"),
progname, xlog_dir);
}
if (made_tablespace_dirs || found_tablespace_dirs)
fprintf(stderr,
- _("%s: changes to tablespace directories will not be undone\n"),
+ _("%s: changes to tablespace directories will not be undone\n"),
progname);
}
printf(_(" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n"
" (in kB/s, or use suffix \"k\" or \"M\")\n"));
printf(_(" -R, --write-recovery-conf\n"
- " write recovery.conf for replication\n"));
+ " write recovery.conf for replication\n"));
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
printf(_(" --no-slot prevent creation of temporary replication slot\n"));
printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
snprintf(param->xlog, sizeof(param->xlog), "%s/%s",
basedir,
PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
- "pg_xlog" : "pg_wal");
+ "pg_xlog" : "pg_wal");
/* Temporary replication slots are only supported in 10 and newer */
if (PQserverVersion(conn) < MINIMUM_VERSION_FOR_TEMP_SLOTS)
{
/*
* Create pg_wal/archive_status or pg_xlog/archive_status (and thus
- * pg_wal or pg_xlog) depending on the target server so we can write to
- * basedir/pg_wal or basedir/pg_xlog as the directory entry in the tar
- * file may arrive later.
+ * pg_wal or pg_xlog) depending on the target server so we can write
+ * to basedir/pg_wal or basedir/pg_xlog as the directory entry in the
+ * tar file may arrive later.
*/
snprintf(statusdir, sizeof(statusdir), "%s/%s/archive_status",
basedir,
{
/*
* When streaming WAL, pg_wal (or pg_xlog for pre-9.6
- * clusters) will have been created by the wal receiver
- * process. Also, when the WAL directory location
- * was specified, pg_wal (or pg_xlog) has already been
- * created as a symbolic link before starting the actual
- * backup. So just ignore creation failures on related
- * directories.
+ * clusters) will have been created by the wal
+ * receiver process. Also, when the WAL directory
+ * location was specified, pg_wal (or pg_xlog) has
+ * already been created as a symbolic link before
+ * starting the actual backup. So just ignore creation
+ * failures on related directories.
*/
if (!((pg_str_endswith(filename, "/pg_wal") ||
- pg_str_endswith(filename, "/pg_xlog")||
- pg_str_endswith(filename, "/archive_status")) &&
+ pg_str_endswith(filename, "/pg_xlog") ||
+ pg_str_endswith(filename, "/archive_status")) &&
errno == EEXIST))
{
fprintf(stderr,
if (verbose)
fprintf(stderr,
- _("%s: initiating base backup, waiting for checkpoint to complete\n"),
+ _("%s: initiating base backup, waiting for checkpoint to complete\n"),
progname);
if (showprogress && !verbose)
PQfinish(conn);
/*
- * Make data persistent on disk once backup is completed. For tar
- * format once syncing the parent directory is fine, each tar file
- * created per tablespace has been already synced. In plain format,
- * all the data of the base directory is synced, taking into account
- * all the tablespaces. Errors are not considered fatal.
+ * Make data persistent on disk once backup is completed. For tar format
+ * once syncing the parent directory is fine, each tar file created per
+ * tablespace has been already synced. In plain format, all the data of
+ * the base directory is synced, taking into account all the tablespaces.
+ * Errors are not considered fatal.
*/
if (do_sync)
{
includewal = NO_WAL;
}
else if (strcmp(optarg, "f") == 0 ||
- strcmp(optarg, "fetch") == 0)
+ strcmp(optarg, "fetch") == 0)
{
includewal = FETCH_WAL;
}
if (format == 't' && includewal == STREAM_WAL && strcmp(basedir, "-") == 0)
{
fprintf(stderr,
- _("%s: cannot stream write-ahead logs in tar mode to stdout\n"),
+ _("%s: cannot stream write-ahead logs in tar mode to stdout\n"),
progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
verify_dir_is_empty_or_create(xlog_dir, &made_new_xlogdir, &found_existing_xlogdir);
/*
- * Form name of the place where the symlink must go. pg_xlog has
- * been renamed to pg_wal in post-10 clusters.
+ * Form name of the place where the symlink must go. pg_xlog has been
+ * renamed to pg_wal in post-10 clusters.
*/
linkloc = psprintf("%s/%s", basedir,
- PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
- "pg_xlog" : "pg_wal");
+ PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
+ "pg_xlog" : "pg_wal");
#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, linkloc) != 0)
}
/* Routines to evaluate segment file format */
-#define IsCompressXLogFileName(fname) \
- (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz") && \
+#define IsCompressXLogFileName(fname) \
+ (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz") && \
strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN && \
strcmp((fname) + XLOG_FNAME_LEN, ".gz") == 0)
-#define IsPartialCompressXLogFileName(fname) \
- (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz.partial") && \
+#define IsPartialCompressXLogFileName(fname) \
+ (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz.partial") && \
strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN && \
strcmp((fname) + XLOG_FNAME_LEN, ".gz.partial") == 0)
/*
* Check that the segment has the right size, if it's supposed to be
* completed. For non-compressed segments just check the on-disk size
- * and see if it matches a completed segment.
- * For compressed segments, look at the last 4 bytes of the compressed
- * file, which is where the uncompressed size is located for gz files
- * with a size lower than 4GB, and then compare it to the size of a
- * completed segment. The 4 last bytes correspond to the ISIZE member
- * according to http://www.zlib.org/rfc-gzip.html.
+ * and see if it matches a completed segment. For compressed segments,
+ * look at the last 4 bytes of the compressed file, which is where the
+ * uncompressed size is located for gz files with a size lower than
+ * 4GB, and then compare it to the size of a completed segment. The 4
+ * last bytes correspond to the ISIZE member according to
+ * http://www.zlib.org/rfc-gzip.html.
*/
if (!ispartial && !iscompress)
{
}
else if (!ispartial && iscompress)
{
- int fd;
- char buf[4];
- int bytes_out;
- char fullpath[MAXPGPATH * 2];
+ int fd;
+ char buf[4];
+ int bytes_out;
+ char fullpath[MAXPGPATH * 2];
snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
progname, fullpath, strerror(errno));
disconnect_and_exit(1);
}
- if (lseek(fd, (off_t)(-4), SEEK_END) < 0)
+ if (lseek(fd, (off_t) (-4), SEEK_END) < 0)
{
fprintf(stderr, _("%s: could not seek compressed file \"%s\": %s\n"),
progname, fullpath, strerror(errno));
close(fd);
bytes_out = (buf[3] << 24) | (buf[2] << 16) |
- (buf[1] << 8) | buf[0];
+ (buf[1] << 8) | buf[0];
if (bytes_out != XLOG_SEG_SIZE)
{
return false;
/*
- * Decide whether we want to report the flush position. If we report
- * the flush position, the primary will know what WAL we'll
- * possibly re-request, and it can then remove older WAL safely.
- * We must always do that when we are using slots.
+ * Decide whether we want to report the flush position. If we report the
+ * flush position, the primary will know what WAL we'll possibly
+ * re-request, and it can then remove older WAL safely. We must always do
+ * that when we are using slots.
*
* Reporting the flush position makes one eligible as a synchronous
* replica. People shouldn't include generic names in
- * synchronous_standby_names, but we've protected them against it so
- * far, so let's continue to do so unless specifically requested.
+ * synchronous_standby_names, but we've protected them against it so far,
+ * so let's continue to do so unless specifically requested.
*/
if (stream->replication_slot != NULL)
{
char *basedir;
int compression;
bool sync;
-} DirectoryMethodData;
+} DirectoryMethodData;
static DirectoryMethodData *dir_data = NULL;
/*
#ifdef HAVE_LIBZ
gzFile gzfp;
#endif
-} DirectoryMethodFile;
+} DirectoryMethodFile;
static const char *
dir_getlasterror(void)
char header[512];
char *pathname;
size_t pad_to_size;
-} TarMethodFile;
+} TarMethodFile;
typedef struct TarMethodData
{
z_streamp zp;
void *zlibOut;
#endif
-} TarMethodData;
+} TarMethodData;
static TarMethodData *tar_data = NULL;
#define tar_clear_error() tar_data->lasterror[0] = '\0'
}
static bool
-tar_write_padding_data(TarMethodFile * f, size_t bytes)
+tar_write_padding_data(TarMethodFile *f, size_t bytes)
{
char *zerobuf = pg_malloc0(XLOG_BLCKSZ);
size_t bytesleft = bytes;
pg_free(tar_data->tarfilename);
#ifdef HAVE_LIBZ
if (tar_data->compression)
- pg_free(tar_data->zlibOut);
+ pg_free(tar_data->zlibOut);
#endif
pg_free(tar_data);
}
CLOSE_NORMAL,
CLOSE_UNLINK,
CLOSE_NO_RENAME
-} WalCloseMethod;
+} WalCloseMethod;
/*
* A WalWriteMethod structure represents the different methods used
* automatically renamed in close(). If pad_to_size is specified, the file
* will be padded with NUL up to that size, if supported by the Walmethod.
*/
- Walfile(*open_for_write) (const char *pathname, const char *temp_suffix, size_t pad_to_size);
+ Walfile (*open_for_write) (const char *pathname, const char *temp_suffix, size_t pad_to_size);
/*
* Close an open Walfile, using one or more methods for handling automatic
* not all those required for pg_receivewal)
*/
WalWriteMethod *CreateWalDirectoryMethod(const char *basedir,
- int compression, bool sync);
+ int compression, bool sync);
WalWriteMethod *CreateWalTarMethod(const char *tarbase, int compression, bool sync);
/* Cleanup routines for previously-created methods */
-void FreeWalDirectoryMethod(void);
-void FreeWalTarMethod(void);
+void FreeWalDirectoryMethod(void);
+void FreeWalTarMethod(void);
{
/*
* If backup_label exists, an online backup is running. Warn the user
- * that smart shutdown will wait for it to finish. However, if
- * the server is in archive recovery, we're recovering from an online
+ * that smart shutdown will wait for it to finish. However, if the
+ * server is in archive recovery, we're recovering from an online
* backup instead of performing one.
*/
if (shutdown_mode == SMART_MODE &&
/*
* If backup_label exists, an online backup is running. Warn the user
- * that smart shutdown will wait for it to finish. However, if
- * the server is in archive recovery, we're recovering from an online
+ * that smart shutdown will wait for it to finish. However, if the
+ * server is in archive recovery, we're recovering from an online
* backup instead of performing one.
*/
if (shutdown_mode == SMART_MODE &&
if (do_wait)
{
- DBState state = DB_STARTUP;
+ DBState state = DB_STARTUP;
print_msg(_("waiting for server to promote..."));
while (wait_seconds > 0)
break;
print_msg(".");
- pg_usleep(1000000); /* 1 sec */
+ pg_usleep(1000000); /* 1 sec */
wait_seconds--;
}
if (state == DB_IN_PRODUCTION)
static DBState
get_control_dbstate(void)
{
- DBState ret;
- bool crc_ok;
+ DBState ret;
+ bool crc_ok;
ControlFileData *control_file_data = get_controlfile(pg_data, progname, &crc_ok);
if (!crc_ok)
int dump_inserts;
int column_inserts;
int if_exists;
- int no_publications; /* Skip publication entries */
+ int no_publications; /* Skip publication entries */
int no_security_labels; /* Skip security label entries */
int no_subscriptions; /* Skip subscription entries */
int strict_names;
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
- const int compression, bool dosync, ArchiveMode mode,
- SetupWorkerPtrType setupWorkerPtr);
+ const int compression, bool dosync, ArchiveMode mode,
+ SetupWorkerPtrType setupWorkerPtr);
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
ArchiveHandle *AH);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass);
* Make sure we won't need (de)compression we haven't got
*/
#ifndef HAVE_LIBZ
- if (AH->compression != 0 && AH->PrintTocDataPtr !=NULL)
+ if (AH->compression != 0 && AH->PrintTocDataPtr != NULL)
{
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
/*
* If we can output the data, then restore it.
*/
- if (AH->PrintTocDataPtr !=NULL)
+ if (AH->PrintTocDataPtr != NULL)
{
_printTocEntry(AH, te, true, false);
newToc->formatData = NULL;
- if (AH->ArchiveEntryPtr !=NULL)
+ if (AH->ArchiveEntryPtr != NULL)
(*AH->ArchiveEntryPtr) (AH, newToc);
}
else if (AH->gzOut)
bytes_written = GZWRITE(ptr, size, nmemb, AH->OF);
else if (AH->CustomOutPtr)
- bytes_written = AH->CustomOutPtr (AH, ptr, size * nmemb);
+ bytes_written = AH->CustomOutPtr(AH, ptr, size * nmemb);
else
{
WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{
StartDataPtrType startPtr;
- EndDataPtrType endPtr;
+ EndDataPtrType endPtr;
AH->currToc = te;
}
ahprintf(AH, "\n");
- if (AH->PrintExtraTocPtr !=NULL)
+ if (AH->PrintExtraTocPtr != NULL)
(*AH->PrintExtraTocPtr) (AH, te);
ahprintf(AH, "--\n\n");
}
size_t lookaheadLen; /* Length of data in lookahead */
pgoff_t lookaheadPos; /* Current read position in lookahead buffer */
- ArchiveEntryPtrType ArchiveEntryPtr; /* Called for each metadata object */
- StartDataPtrType StartDataPtr; /* Called when table data is about to be
- * dumped */
- WriteDataPtrType WriteDataPtr; /* Called to send some table data to the
- * archive */
- EndDataPtrType EndDataPtr; /* Called when table data dump is finished */
- WriteBytePtrType WriteBytePtr; /* Write a byte to output */
+ ArchiveEntryPtrType ArchiveEntryPtr; /* Called for each metadata
+ * object */
+ StartDataPtrType StartDataPtr; /* Called when table data is about to
+ * be dumped */
+ WriteDataPtrType WriteDataPtr; /* Called to send some table data to
+ * the archive */
+ EndDataPtrType EndDataPtr; /* Called when table data dump is finished */
+ WriteBytePtrType WriteBytePtr; /* Write a byte to output */
ReadBytePtrType ReadBytePtr; /* Read a byte from an archive */
WriteBufPtrType WriteBufPtr; /* Write a buffer of output to the archive */
- ReadBufPtrType ReadBufPtr; /* Read a buffer of input from the archive */
- ClosePtrType ClosePtr; /* Close the archive */
- ReopenPtrType ReopenPtr; /* Reopen the archive */
- WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data
- * associated with the current archive
- * format */
- ReadExtraTocPtrType ReadExtraTocPtr; /* Read extra info associated with
- * archive format */
- PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
+ ReadBufPtrType ReadBufPtr; /* Read a buffer of input from the archive */
+ ClosePtrType ClosePtr; /* Close the archive */
+ ReopenPtrType ReopenPtr; /* Reopen the archive */
+ WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data
+ * associated with the current
+ * archive format */
+ ReadExtraTocPtrType ReadExtraTocPtr; /* Read extra info associated
+ * with archive format */
+ PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
PrintTocDataPtrType PrintTocDataPtr;
StartBlobsPtrType StartBlobsPtr;
WorkerJobDumpPtrType WorkerJobDumpPtr;
WorkerJobRestorePtrType WorkerJobRestorePtr;
- ClonePtrType ClonePtr; /* Clone format-specific fields */
- DeClonePtrType DeClonePtr; /* Clean up cloned fields */
+ ClonePtrType ClonePtr; /* Clone format-specific fields */
+ DeClonePtrType DeClonePtr; /* Clean up cloned fields */
- CustomOutPtrType CustomOutPtr; /* Alternative script output routine */
+ CustomOutPtrType CustomOutPtr; /* Alternative script output routine */
/* Stuff for direct DB connection */
char *archdbname; /* DB name *read* from archive */
/* global decls */
bool g_verbose; /* User wants verbose narration of our
* activities. */
-static bool dosync = true; /* Issue fsync() to make dump durable
- * on disk. */
+static bool dosync = true; /* Issue fsync() to make dump durable on disk. */
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
* For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use
* FirstNormalObjectId - 1.
*/
-static Oid g_last_builtin_oid; /* value of the last builtin oid */
+static Oid g_last_builtin_oid; /* value of the last builtin oid */
/* The specified names/patterns should to match at least one entity */
static int strict_names = 0;
const char *proc);
static char *convertOperatorReference(Archive *fout, const char *opr);
static char *convertTSFunction(Archive *fout, Oid funcOid);
-static Oid findLastBuiltinOid_V71(Archive *fout, const char *);
+static Oid findLastBuiltinOid_V71(Archive *fout, const char *);
static void selectSourceSchema(Archive *fout, const char *schemaName);
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static void getBlobs(Archive *fout);
*/
if (fout->remoteVersion < 80100)
g_last_builtin_oid = findLastBuiltinOid_V71(fout,
- PQdb(GetConnection(fout)));
+ PQdb(GetConnection(fout)));
else
g_last_builtin_oid = FirstNormalObjectId - 1;
"SELECT c.oid"
"\nFROM pg_catalog.pg_class c"
"\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace"
- "\nWHERE c.relkind in ('%c', '%c', '%c', '%c', '%c', '%c')\n",
+ "\nWHERE c.relkind in ('%c', '%c', '%c', '%c', '%c', '%c')\n",
RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
RELKIND_PARTITIONED_TABLE);
"AND d2.objid = r1.oid "
"AND d2.refobjid <> d1.objid "
"JOIN pg_class c2 ON c2.oid = d2.refobjid "
- "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW) ","
+ "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW) ","
CppAsString2(RELKIND_VIEW) ") "
"WHERE d1.classid = 'pg_class'::regclass "
"UNION "
"AND d3.objid = r3.oid "
"AND d3.refobjid <> w.refobjid "
"JOIN pg_class c3 ON c3.oid = d3.refobjid "
- "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW) ","
+ "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW) ","
CppAsString2(RELKIND_VIEW) ") "
") "
"SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
"SELECT oid, tableoid, pol.polname, pol.polcmd, pol.polpermissive, "
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
"pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
"FROM pg_catalog.pg_policy pol "
"WHERE polrelid = '%u'",
"SELECT oid, tableoid, pol.polname, pol.polcmd, 't' as polpermissive, "
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
" pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
"pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
"FROM pg_catalog.pg_policy pol "
"WHERE polrelid = '%u'",
continue;
/*
- * Ignore publication membership of tables whose definitions are
- * not to be dumped.
+ * Ignore publication membership of tables whose definitions are not
+ * to be dumped.
*/
if (!(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION))
continue;
fmtId(tbinfo->dobj.name));
/*
- * There is no point in creating drop query as drop query as the drop
- * is done by table drop.
+ * There is no point in creating drop query as drop query as the drop is
+ * done by table drop.
*/
ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
tag,
if (!is_superuser(fout))
{
- int n;
+ int n;
res = ExecuteSqlQuery(fout,
"SELECT count(*) FROM pg_subscription "
- "WHERE subdbid = (SELECT oid FROM pg_catalog.pg_database"
- " WHERE datname = current_database())",
+ "WHERE subdbid = (SELECT oid FROM pg_catalog.pg_database"
+ " WHERE datname = current_database())",
PGRES_TUPLES_OK);
n = atoi(PQgetvalue(res, 0, 0));
if (n > 0)
" s.subconninfo, s.subslotname, s.subsynccommit, "
" s.subpublications "
"FROM pg_catalog.pg_subscription s "
- "WHERE s.subdbid = (SELECT oid FROM pg_catalog.pg_database"
- " WHERE datname = current_database())",
+ "WHERE s.subdbid = (SELECT oid FROM pg_catalog.pg_database"
+ " WHERE datname = current_database())",
username_subquery);
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
* the public schema is dropped.
*/
if (dopt->outputClean)
- appendPQExpBuffer(query," AND pip.objoid <> 'public'::regnamespace");
+ appendPQExpBuffer(query, " AND pip.objoid <> 'public'::regnamespace");
- appendPQExpBuffer(query,") ");
+ appendPQExpBuffer(query, ") ");
destroyPQExpBuffer(acl_subquery);
destroyPQExpBuffer(racl_subquery);
"WHERE classid = 'pg_proc'::regclass AND "
"objid = p.oid AND deptype = 'i')");
appendPQExpBuffer(query,
- "\n AND ("
- "\n pronamespace != "
- "(SELECT oid FROM pg_namespace "
- "WHERE nspname = 'pg_catalog')"
- "\n OR EXISTS (SELECT 1 FROM pg_cast"
- "\n WHERE pg_cast.oid > '%u'::oid"
- "\n AND p.oid = pg_cast.castfunc)",
- g_last_builtin_oid);
+ "\n AND ("
+ "\n pronamespace != "
+ "(SELECT oid FROM pg_namespace "
+ "WHERE nspname = 'pg_catalog')"
+ "\n OR EXISTS (SELECT 1 FROM pg_cast"
+ "\n WHERE pg_cast.oid > '%u'::oid"
+ "\n AND p.oid = pg_cast.castfunc)",
+ g_last_builtin_oid);
if (fout->remoteVersion >= 90500)
appendPQExpBuffer(query,
- "\n OR EXISTS (SELECT 1 FROM pg_transform"
- "\n WHERE pg_transform.oid > '%u'::oid"
- "\n AND (p.oid = pg_transform.trffromsql"
- "\n OR p.oid = pg_transform.trftosql))",
- g_last_builtin_oid);
+ "\n OR EXISTS (SELECT 1 FROM pg_transform"
+ "\n WHERE pg_transform.oid > '%u'::oid"
+ "\n AND (p.oid = pg_transform.trffromsql"
+ "\n OR p.oid = pg_transform.trftosql))",
+ g_last_builtin_oid);
if (dopt->binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
buildACLQueries(acl_subquery, racl_subquery, initacl_subquery,
initracl_subquery, "c.relacl", "c.relowner",
- "CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
+ "CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
" THEN 's' ELSE 'r' END::\"char\"",
dopt->binary_upgrade);
"(c.relkind = '%c' AND "
"d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 AND "
- "d.refclassid = c.tableoid AND d.deptype IN ('a', 'i')) "
+ "d.refclassid = c.tableoid AND d.deptype IN ('a', 'i')) "
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
"LEFT JOIN pg_init_privs pip ON "
"(c.oid = pip.objoid "
"AND pip.classoid = 'pg_class'::regclass "
"AND pip.objsubid = 0) "
- "WHERE c.relkind in ('%c', '%c', '%c', '%c', '%c', '%c', '%c') "
+ "WHERE c.relkind in ('%c', '%c', '%c', '%c', '%c', '%c', '%c') "
"ORDER BY c.oid",
acl_subquery->data,
racl_subquery->data,
tblinfo[i].postponed_def = false; /* might get set during sort */
tblinfo[i].is_identity_sequence = (i_is_identity_sequence >= 0 &&
- strcmp(PQgetvalue(res, i, i_is_identity_sequence), "t") == 0);
+ strcmp(PQgetvalue(res, i, i_is_identity_sequence), "t") == 0);
/* Partition key string or NULL */
tblinfo[i].partkeydef = pg_strdup(PQgetvalue(res, i, i_partkeydef));
void
getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
{
- int i,
- j;
- PQExpBuffer query;
- PGresult *res;
- StatsExtInfo *statsextinfo;
- int ntups;
- int i_tableoid;
- int i_oid;
- int i_stxname;
- int i_stxdef;
+ int i,
+ j;
+ PQExpBuffer query;
+ PGresult *res;
+ StatsExtInfo *statsextinfo;
+ int ntups;
+ int i_tableoid;
+ int i_oid;
+ int i_stxname;
+ int i_stxdef;
/* Extended statistics were new in v10 */
if (fout->remoteVersion < 100000)
appendPQExpBuffer(query,
"SELECT "
- "tableoid, "
- "oid, "
- "stxname, "
+ "tableoid, "
+ "oid, "
+ "stxname, "
"pg_catalog.pg_get_statisticsobjdef(oid) AS stxdef "
"FROM pg_statistic_ext "
"WHERE stxrelid = '%u' "
appendPQExpBuffer(q, " OF %s", tbinfo->reloftype);
/*
- * If the table is a partition, dump it as such; except in the case
- * of a binary upgrade, we dump the table normally and attach it to
- * the parent afterward.
+ * If the table is a partition, dump it as such; except in the case of
+ * a binary upgrade, we dump the table normally and attach it to the
+ * parent afterward.
*/
if (tbinfo->ispartition && !dopt->binary_upgrade)
{
/*
* Attribute type
*
- * In binary-upgrade mode, we always include the type.
- * If we aren't in binary-upgrade mode, then we skip the
- * type when creating a typed table ('OF type_name') or a
+ * In binary-upgrade mode, we always include the type. If
+ * we aren't in binary-upgrade mode, then we skip the type
+ * when creating a typed table ('OF type_name') or a
* partition ('PARTITION OF'), since the type comes from
* the parent/partitioned table.
*/
if (actual_atts)
appendPQExpBufferStr(q, "\n)");
else if (!((tbinfo->reloftype || tbinfo->ispartition) &&
- !dopt->binary_upgrade))
+ !dopt->binary_upgrade))
{
/*
* We must have a parenthesized attribute list, even though
for (k = 0; k < numParents; k++)
{
TableInfo *parentRel = parents[k];
- PQExpBuffer parentname = createPQExpBuffer();
+ PQExpBuffer parentname = createPQExpBuffer();
/* Schema-qualify the parent table, if necessary */
if (parentRel->dobj.namespace != tbinfo->dobj.namespace)
appendPQExpBuffer(parentname, "%s.",
- fmtId(parentRel->dobj.namespace->dobj.name));
+ fmtId(parentRel->dobj.namespace->dobj.name));
appendPQExpBuffer(parentname, "%s",
fmtId(parentRel->dobj.name));
/* In the partitioning case, we alter the parent */
if (tbinfo->ispartition)
appendPQExpBuffer(q,
- "ALTER TABLE ONLY %s ATTACH PARTITION ",
+ "ALTER TABLE ONLY %s ATTACH PARTITION ",
parentname->data);
else
appendPQExpBuffer(q, "ALTER TABLE ONLY %s INHERIT ",
- fmtId(tbinfo->dobj.name));
+ fmtId(tbinfo->dobj.name));
/* Partition needs specifying the bounds */
if (tbinfo->ispartition)
appendPQExpBuffer(q, "%s;\n", statsextinfo->statsextdef);
appendPQExpBuffer(delq, "DROP STATISTICS %s.",
- fmtId(tbinfo->dobj.namespace->dobj.name));
+ fmtId(tbinfo->dobj.namespace->dobj.name));
appendPQExpBuffer(delq, "%s;\n",
- fmtId(statsextinfo->dobj.name));
+ fmtId(statsextinfo->dobj.name));
if (statsextinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, statsextinfo->dobj.catId,
- statsextinfo->dobj.dumpId,
- statsextinfo->dobj.name,
- tbinfo->dobj.namespace->dobj.name,
- NULL,
- tbinfo->rolname, false,
- "STATISTICS", SECTION_POST_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
+ ArchiveEntry(fout, statsextinfo->dobj.catId,
+ statsextinfo->dobj.dumpId,
+ statsextinfo->dobj.name,
+ tbinfo->dobj.namespace->dobj.name,
+ NULL,
+ tbinfo->rolname, false,
+ "STATISTICS", SECTION_POST_DATA,
+ q->data, delq->data, NULL,
+ NULL, 0,
+ NULL, NULL);
/* Dump Statistics Comments */
if (statsextinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
findLastBuiltinOid_V71(Archive *fout, const char *dbname)
{
PGresult *res;
- Oid last_oid;
+ Oid last_oid;
PQExpBuffer query = createPQExpBuffer();
resetPQExpBuffer(query);
appendPQExpBuffer(query,
"SELECT 'bigint'::name AS sequence_type, "
- "0 AS start_value, increment_by, max_value, min_value, "
+ "0 AS start_value, increment_by, max_value, min_value, "
"cache_value, is_cycled FROM %s",
fmtId(tbinfo->dobj.name));
}
fmtId(owning_tab->dobj.name));
appendPQExpBuffer(query,
"ALTER COLUMN %s ADD GENERATED ",
- fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
+ fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_ALWAYS)
appendPQExpBuffer(query, "ALWAYS");
else if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_BY_DEFAULT)
bool interesting; /* true if need to collect more data */
bool dummy_view; /* view's real definition must be postponed */
bool postponed_def; /* matview must be postponed into post-data */
- bool ispartition; /* is table a partition? */
+ bool ispartition; /* is table a partition? */
/*
* These fields are computed only if we decide the table is interesting
struct _constraintInfo *checkexprs; /* CHECK constraints */
char *partkeydef; /* partition key definition */
char *partbound; /* partition bound definition */
- bool needs_override; /* has GENERATED ALWAYS AS IDENTITY */
+ bool needs_override; /* has GENERATED ALWAYS AS IDENTITY */
/*
* Stuff computed only for dumpable tables.
extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables);
extern void getPublications(Archive *fout);
extern void getPublicationTables(Archive *fout, TableInfo tblinfo[],
- int numTables);
+ int numTables);
extern void getSubscriptions(Archive *fout);
#endif /* PG_DUMP_H */
}
/*
- * If password values are not required in the dump, switch to
- * using pg_roles which is equally useful, just more likely
- * to have unrestricted access than pg_authid.
+ * If password values are not required in the dump, switch to using
+ * pg_roles which is equally useful, just more likely to have unrestricted
+ * access than pg_authid.
*/
if (no_role_passwords)
sprintf(role_catalog, "%s", PG_ROLES);
if (server_version >= 90600)
printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "WHERE rolname !~ '^pg_' "
- "ORDER BY 1", role_catalog);
+ "SELECT rolname "
+ "FROM %s "
+ "WHERE rolname !~ '^pg_' "
+ "ORDER BY 1", role_catalog);
else if (server_version >= 80100)
printfPQExpBuffer(buf,
- "SELECT rolname "
- "FROM %s "
- "ORDER BY 1", role_catalog);
+ "SELECT rolname "
+ "FROM %s "
+ "ORDER BY 1", role_catalog);
else
printfPQExpBuffer(buf,
- "SELECT usename as rolname "
- "FROM pg_shadow "
- "UNION "
- "SELECT groname as rolname "
- "FROM pg_group "
- "ORDER BY 1");
+ "SELECT usename as rolname "
+ "FROM pg_shadow "
+ "UNION "
+ "SELECT groname as rolname "
+ "FROM pg_group "
+ "ORDER BY 1");
res = executeQuery(conn, buf->data);
"rolcreaterole, rolcreatedb, "
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
+ "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
"rolname = current_user AS is_current_user "
"FROM %s "
"WHERE rolname !~ '^pg_' "
"rolcreaterole, rolcreatedb, "
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, rolreplication, rolbypassrls, "
- "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
+ "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
"rolname = current_user AS is_current_user "
"FROM %s "
"ORDER BY 2", role_catalog, role_catalog);
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, rolreplication, "
"false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
+ "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
"rolname = current_user AS is_current_user "
"FROM %s "
"ORDER BY 2", role_catalog, role_catalog);
"rolcanlogin, rolconnlimit, rolpassword, "
"rolvaliduntil, false as rolreplication, "
"false as rolbypassrls, "
- "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
+ "pg_catalog.shobj_description(oid, '%s') as rolcomment, "
"rolname = current_user AS is_current_user "
"FROM %s "
"ORDER BY 2", role_catalog, role_catalog);
int i;
printfPQExpBuffer(buf, "SELECT ur.rolname AS roleid, "
- "um.rolname AS member, "
- "a.admin_option, "
- "ug.rolname AS grantor "
- "FROM pg_auth_members a "
- "LEFT JOIN %s ur on ur.oid = a.roleid "
- "LEFT JOIN %s um on um.oid = a.member "
- "LEFT JOIN %s ug on ug.oid = a.grantor "
+ "um.rolname AS member, "
+ "a.admin_option, "
+ "ug.rolname AS grantor "
+ "FROM pg_auth_members a "
+ "LEFT JOIN %s ur on ur.oid = a.roleid "
+ "LEFT JOIN %s um on um.oid = a.member "
+ "LEFT JOIN %s ug on ug.oid = a.grantor "
"WHERE NOT (ur.rolname ~ '^pg_' AND um.rolname ~ '^pg_')"
- "ORDER BY 1,2,3", role_catalog, role_catalog, role_catalog);
+ "ORDER BY 1,2,3", role_catalog, role_catalog, role_catalog);
res = executeQuery(conn, buf->data);
if (PQntuples(res) > 0)
*/
if (server_version >= 90600)
printfPQExpBuffer(buf,
- "SELECT datname, "
- "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
- "pg_encoding_to_char(d.encoding), "
- "datcollate, datctype, datfrozenxid, datminmxid, "
- "datistemplate, "
- "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
- " SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba))) AS acl "
- " EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba))) as datacls)"
- "AS datacl, "
- "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
- " SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba)) AS acl "
- " EXCEPT SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba)))) as rdatacls)"
- "AS rdatacl, "
- "datconnlimit, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
- "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
+ "SELECT datname, "
+ "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
+ "pg_encoding_to_char(d.encoding), "
+ "datcollate, datctype, datfrozenxid, datminmxid, "
+ "datistemplate, "
+ "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
+ " SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba))) AS acl "
+ " EXCEPT SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba))) as datacls)"
+ "AS datacl, "
+ "(SELECT pg_catalog.array_agg(acl ORDER BY acl::text COLLATE \"C\") FROM ( "
+ " SELECT pg_catalog.unnest(pg_catalog.acldefault('d',datdba)) AS acl "
+ " EXCEPT SELECT pg_catalog.unnest(coalesce(datacl,pg_catalog.acldefault('d',datdba)))) as rdatacls)"
+ "AS rdatacl, "
+ "datconnlimit, "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
+ "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
+ "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
else if (server_version >= 90300)
printfPQExpBuffer(buf,
- "SELECT datname, "
- "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
- "pg_encoding_to_char(d.encoding), "
- "datcollate, datctype, datfrozenxid, datminmxid, "
- "datistemplate, datacl, '' as rdatacl, "
- "datconnlimit, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
- "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
+ "SELECT datname, "
+ "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
+ "pg_encoding_to_char(d.encoding), "
+ "datcollate, datctype, datfrozenxid, datminmxid, "
+ "datistemplate, datacl, '' as rdatacl, "
+ "datconnlimit, "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
+ "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
+ "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
else if (server_version >= 80400)
printfPQExpBuffer(buf,
- "SELECT datname, "
- "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
- "pg_encoding_to_char(d.encoding), "
+ "SELECT datname, "
+ "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
+ "pg_encoding_to_char(d.encoding), "
"datcollate, datctype, datfrozenxid, 0 AS datminmxid, "
- "datistemplate, datacl, '' as rdatacl, "
- "datconnlimit, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
- "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
+ "datistemplate, datacl, '' as rdatacl, "
+ "datconnlimit, "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
+ "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
+ "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
else if (server_version >= 80100)
printfPQExpBuffer(buf,
- "SELECT datname, "
- "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
- "pg_encoding_to_char(d.encoding), "
- "null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
- "datistemplate, datacl, '' as rdatacl, "
- "datconnlimit, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
- "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
- "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
+ "SELECT datname, "
+ "coalesce(rolname, (select rolname from %s where oid=(select datdba from pg_database where datname='template0'))), "
+ "pg_encoding_to_char(d.encoding), "
+ "null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
+ "datistemplate, datacl, '' as rdatacl, "
+ "datconnlimit, "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
+ "FROM pg_database d LEFT JOIN %s u ON (datdba = u.oid) "
+ "WHERE datallowconn ORDER BY 1", role_catalog, role_catalog);
else
printfPQExpBuffer(buf,
- "SELECT datname, "
- "coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
- "pg_encoding_to_char(d.encoding), "
- "null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
- "datistemplate, datacl, '' as rdatacl, "
- "-1 as datconnlimit, "
- "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
+ "SELECT datname, "
+ "coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), "
+ "pg_encoding_to_char(d.encoding), "
+ "null::text AS datcollate, null::text AS datctype, datfrozenxid, 0 AS datminmxid, "
+ "datistemplate, datacl, '' as rdatacl, "
+ "-1 as datconnlimit, "
+ "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace "
"FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) "
- "WHERE datallowconn ORDER BY 1");
+ "WHERE datallowconn ORDER BY 1");
res = executeQuery(conn, buf->data);
if (server_version >= 90000)
printfPQExpBuffer(buf, "SELECT setconfig[%d] FROM pg_db_role_setting WHERE "
"setdatabase = 0 AND setrole = "
- "(SELECT oid FROM %s WHERE rolname = ", count, role_catalog);
+ "(SELECT oid FROM %s WHERE rolname = ", count, role_catalog);
else if (server_version >= 80100)
printfPQExpBuffer(buf, "SELECT rolconfig[%d] FROM %s WHERE rolname = ", count, role_catalog);
else
printfPQExpBuffer(buf, "SELECT rolname, datname, unnest(setconfig) "
"FROM pg_db_role_setting, %s u, pg_database "
- "WHERE setrole = u.oid AND setdatabase = pg_database.oid", role_catalog);
+ "WHERE setrole = u.oid AND setdatabase = pg_database.oid", role_catalog);
res = executeQuery(conn, buf->data);
if (PQntuples(res) > 0)
newXlogSegNo = ControlFile.checkPointCopy.redo / ControlFile.xlog_seg_size;
/*
- * Scan the pg_wal directory to find existing WAL segment files. We
- * assume any present have been used; in most scenarios this should be
+ * Scan the pg_wal directory to find existing WAL segment files. We assume
+ * any present have been used; in most scenarios this should be
* conservative, because of xlog.c's attempts to pre-create files.
*/
xldir = opendir(XLOGDIR);
else
{
fprintf(stderr,
- _("%s: duration must be a positive integer (duration is \"%d\")\n"),
+ _("%s: duration must be a positive integer (duration is \"%d\")\n"),
progname, test_duration);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
/*
* check_single_dir()
*
- * Check for the presence of a single directory in PGDATA, and fail if
+ * Check for the presence of a single directory in PGDATA, and fail if
* is it missing or not accessible.
*/
static void
char subDirName[MAXPGPATH];
snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
- /* Win32 can't stat() a directory with a trailing slash. */
+ /* Win32 can't stat() a directory with a trailing slash. */
*subdir ? "/" : "",
subdir);
if (i >= db->rel_arr.nrels)
snprintf(reldesc + strlen(reldesc),
sizeof(reldesc) - strlen(reldesc),
- _(" which is the TOAST table for OID %u"), rel->toastheap);
+ _(" which is the TOAST table for OID %u"), rel->toastheap);
}
if (is_new_db)
check_required_directory(&new_cluster.bindir, NULL, "PGBINNEW", "-B",
_("new cluster binaries reside"));
check_required_directory(&old_cluster.pgdata, &old_cluster.pgconfig,
- "PGDATAOLD", "-d", _("old cluster data resides"));
+ "PGDATAOLD", "-d", _("old cluster data resides"));
check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig,
- "PGDATANEW", "-D", _("new cluster data resides"));
+ "PGDATANEW", "-D", _("new cluster data resides"));
#ifdef WIN32
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\n"
"Before running pg_upgrade you must:\n"
- " create a new database cluster (using the new version of initdb)\n"
+ " create a new database cluster (using the new version of initdb)\n"
" shutdown the postmaster servicing the old cluster\n"
" shutdown the postmaster servicing the new cluster\n"));
printf(_("\n"
- "When you run pg_upgrade, you must provide the following information:\n"
+ "When you run pg_upgrade, you must provide the following information:\n"
" the data directory for the old cluster (-d DATADIR)\n"
" the data directory for the new cluster (-D DATADIR)\n"
" the \"bin\" directory for the old version (-b BINDIR)\n"
XLogFileName(fname, timeline_id, sendSegNo);
/*
- * In follow mode there is a short period of time after the
- * server has written the end of the previous file before the
- * new file is available. So we loop for 5 seconds looking
- * for the file to appear before giving up.
+ * In follow mode there is a short period of time after the server
+ * has written the end of the previous file before the new file is
+ * available. So we loop for 5 seconds looking for the file to
+ * appear before giving up.
*/
for (tries = 0; tries < 10; tries++)
{
" use --rmgr=list to list valid resource manager names\n"));
printf(_(" -s, --start=RECPTR start reading at WAL location RECPTR\n"));
printf(_(" -t, --timeline=TLI timeline from which to read log records\n"
- " (default: 1 or the value used in STARTSEG)\n"));
+ " (default: 1 or the value used in STARTSEG)\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -x, --xid=XID only show records with TransactionId XID\n"));
printf(_(" -z, --stats[=record] show statistics instead of records\n"
- " (optionally, show per-record statistics)\n"));
+ " (optionally, show per-record statistics)\n"));
printf(_(" -?, --help show this help, then exit\n"));
}
else if (!XLByteInSeg(private.startptr, segno))
{
fprintf(stderr,
- _("%s: start WAL location %X/%X is not inside file \"%s\"\n"),
+ _("%s: start WAL location %X/%X is not inside file \"%s\"\n"),
progname,
(uint32) (private.startptr >> 32),
(uint32) private.startptr,
private.endptr != (segno + 1) * XLogSegSize)
{
fprintf(stderr,
- _("%s: end WAL location %X/%X is not inside file \"%s\"\n"),
+ _("%s: end WAL location %X/%X is not inside file \"%s\"\n"),
progname,
(uint32) (private.endptr >> 32),
(uint32) private.endptr,
typedef struct ConditionalStackData
{
IfStackElem *head;
-} ConditionalStackData;
+} ConditionalStackData;
typedef struct ConditionalStackData *ConditionalStack;
" WHEN " CppAsString2(RELKIND_VIEW) " THEN '%s'"
" WHEN " CppAsString2(RELKIND_MATVIEW) " THEN '%s'"
" WHEN " CppAsString2(RELKIND_SEQUENCE) " THEN '%s'"
- " WHEN " CppAsString2(RELKIND_FOREIGN_TABLE) " THEN '%s'"
- " WHEN " CppAsString2(RELKIND_PARTITIONED_TABLE) " THEN '%s'"
+ " WHEN " CppAsString2(RELKIND_FOREIGN_TABLE) " THEN '%s'"
+ " WHEN " CppAsString2(RELKIND_PARTITIONED_TABLE) " THEN '%s'"
" END as \"%s\",\n"
" ",
gettext_noop("Schema"),
/* Collation, Nullable, Default */
if (show_column_details)
{
- char *identity;
- char *default_str = "";
+ char *identity;
+ char *default_str = "";
printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
/* If verbose, also request the partition constraint definition */
if (verbose)
printfPQExpBuffer(&buf,
- "SELECT inhparent::pg_catalog.regclass,"
- " pg_get_expr(c.relpartbound, inhrelid),"
- " pg_get_partition_constraintdef(inhrelid)"
- " FROM pg_catalog.pg_class c"
- " JOIN pg_catalog.pg_inherits"
- " ON c.oid = inhrelid"
- " WHERE c.oid = '%s' AND c.relispartition;", oid);
+ "SELECT inhparent::pg_catalog.regclass,"
+ " pg_get_expr(c.relpartbound, inhrelid),"
+ " pg_get_partition_constraintdef(inhrelid)"
+ " FROM pg_catalog.pg_class c"
+ " JOIN pg_catalog.pg_inherits"
+ " ON c.oid = inhrelid"
+ " WHERE c.oid = '%s' AND c.relispartition;", oid);
else
printfPQExpBuffer(&buf,
- "SELECT inhparent::pg_catalog.regclass,"
- " pg_get_expr(c.relpartbound, inhrelid)"
- " FROM pg_catalog.pg_class c"
- " JOIN pg_catalog.pg_inherits"
- " ON c.oid = inhrelid"
- " WHERE c.oid = '%s' AND c.relispartition;", oid);
+ "SELECT inhparent::pg_catalog.regclass,"
+ " pg_get_expr(c.relpartbound, inhrelid)"
+ " FROM pg_catalog.pg_class c"
+ " JOIN pg_catalog.pg_inherits"
+ " ON c.oid = inhrelid"
+ " WHERE c.oid = '%s' AND c.relispartition;", oid);
result = PSQLexec(buf.data);
if (!result)
goto error_return;
partconstraintdef = PQgetvalue(result, 0, 2);
printfPQExpBuffer(&tmpbuf, _("Partition of: %s %s"), parent_name,
- partdef);
+ partdef);
printTableAddFooter(&cont, tmpbuf.data);
if (partconstraintdef)
char *partkeydef;
printfPQExpBuffer(&buf,
- "SELECT pg_catalog.pg_get_partkeydef('%s'::pg_catalog.oid);",
+ "SELECT pg_catalog.pg_get_partkeydef('%s'::pg_catalog.oid);",
oid);
result = PSQLexec(buf.data);
if (!result || PQntuples(result) != 1)
printfPQExpBuffer(&buf,
"SELECT pol.polname, pol.polpermissive,\n"
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
"CASE pol.polcmd\n"
"WHEN 'r' THEN 'SELECT'\n"
"WHEN 'a' THEN 'INSERT'\n"
oid);
else
printfPQExpBuffer(&buf,
- "SELECT pol.polname, 't' as polpermissive,\n"
+ "SELECT pol.polname, 't' as polpermissive,\n"
"CASE WHEN pol.polroles = '{0}' THEN NULL ELSE array_to_string(array(select rolname from pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
- "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
- "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
+ "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
+ "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid),\n"
"CASE pol.polcmd\n"
"WHEN 'r' THEN 'SELECT'\n"
"WHEN 'a' THEN 'INSERT'\n"
" (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(attname),', ')\n"
" FROM pg_catalog.unnest(stxkeys) s(attnum)\n"
" JOIN pg_catalog.pg_attribute a ON (stxrelid = a.attrelid AND\n"
- " a.attnum = s.attnum AND NOT attisdropped)) AS columns,\n"
+ " a.attnum = s.attnum AND NOT attisdropped)) AS columns,\n"
" (stxkind @> '{d}') AS ndist_enabled,\n"
" (stxkind @> '{f}') AS deps_enabled\n"
"FROM pg_catalog.pg_statistic_ext stat "
/* print inherited tables (exclude, if parent is a partitioned table) */
printfPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass"
- " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
- " WHERE c.oid=i.inhparent AND i.inhrelid = '%s'"
- " AND c.relkind != " CppAsString2(RELKIND_PARTITIONED_TABLE)
- " ORDER BY inhseqno;", oid);
+ "SELECT c.oid::pg_catalog.regclass"
+ " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
+ " WHERE c.oid=i.inhparent AND i.inhrelid = '%s'"
+ " AND c.relkind != " CppAsString2(RELKIND_PARTITIONED_TABLE)
+ " ORDER BY inhseqno;", oid);
result = PSQLexec(buf.data);
if (!result)
/* print child tables (with additional info if partitions) */
if (pset.sversion >= 100000)
printfPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass, pg_get_expr(c.relpartbound, c.oid)"
- " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
- " WHERE c.oid=i.inhrelid AND"
- " i.inhparent = '%s' AND"
- " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
- " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid, oid);
+ "SELECT c.oid::pg_catalog.regclass, pg_get_expr(c.relpartbound, c.oid)"
+ " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
+ " WHERE c.oid=i.inhrelid AND"
+ " i.inhparent = '%s' AND"
+ " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
+ " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid, oid);
else if (pset.sversion >= 80300)
printfPQExpBuffer(&buf,
- "SELECT c.oid::pg_catalog.regclass"
- " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
- " WHERE c.oid=i.inhrelid AND"
- " i.inhparent = '%s' AND"
- " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
- " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid, oid);
+ "SELECT c.oid::pg_catalog.regclass"
+ " FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i"
+ " WHERE c.oid=i.inhrelid AND"
+ " i.inhparent = '%s' AND"
+ " EXISTS (SELECT 1 FROM pg_class c WHERE c.oid = '%s')"
+ " ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", oid, oid);
else
printfPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i WHERE c.oid=i.inhrelid AND i.inhparent = '%s' ORDER BY c.relname;", oid);
{
/* display the list of child tables */
const char *ct = (tableinfo.relkind != RELKIND_PARTITIONED_TABLE) ?
- _("Child tables") : _("Partitions");
+ _("Child tables") : _("Partitions");
int ctw = pg_wcswidth(ct, strlen(ct), pset.encoding);
for (i = 0; i < tuples; i++)
" WHEN " CppAsString2(RELKIND_INDEX) " THEN '%s'"
" WHEN " CppAsString2(RELKIND_SEQUENCE) " THEN '%s'"
" WHEN 's' THEN '%s'"
- " WHEN " CppAsString2(RELKIND_FOREIGN_TABLE) " THEN '%s'"
- " WHEN " CppAsString2(RELKIND_PARTITIONED_TABLE) " THEN '%s'"
+ " WHEN " CppAsString2(RELKIND_FOREIGN_TABLE) " THEN '%s'"
+ " WHEN " CppAsString2(RELKIND_PARTITIONED_TABLE) " THEN '%s'"
" END as \"%s\",\n"
" pg_catalog.pg_get_userbyid(c.relowner) as \"%s\"",
gettext_noop("Schema"),
printfPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
- " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n",
+ " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Type"));
" WHERE c.oid = t.typcollation AND bt.oid = t.typbasetype AND t.typcollation <> bt.typcollation) as \"%s\",\n",
gettext_noop("Collation"));
appendPQExpBuffer(&buf,
- " CASE WHEN t.typnotnull THEN 'not null' END as \"%s\",\n"
+ " CASE WHEN t.typnotnull THEN 'not null' END as \"%s\",\n"
" t.typdefault as \"%s\",\n"
" pg_catalog.array_to_string(ARRAY(\n"
" SELECT pg_catalog.pg_get_constraintdef(r.oid, true) FROM pg_catalog.pg_constraint r WHERE t.oid = r.contypid\n"
printfPQExpBuffer(&buf,
"SELECT '%s' AS \"%s\",\n"
" p.prsstart::pg_catalog.regproc AS \"%s\",\n"
- " pg_catalog.obj_description(p.prsstart, 'pg_proc') as \"%s\"\n"
+ " pg_catalog.obj_description(p.prsstart, 'pg_proc') as \"%s\"\n"
" FROM pg_catalog.pg_ts_parser p\n"
" WHERE p.oid = '%s'\n"
"UNION ALL\n"
"SELECT '%s',\n"
" p.prstoken::pg_catalog.regproc,\n"
- " pg_catalog.obj_description(p.prstoken, 'pg_proc')\n"
+ " pg_catalog.obj_description(p.prstoken, 'pg_proc')\n"
" FROM pg_catalog.pg_ts_parser p\n"
" WHERE p.oid = '%s'\n"
"UNION ALL\n"
"UNION ALL\n"
"SELECT '%s',\n"
" p.prsheadline::pg_catalog.regproc,\n"
- " pg_catalog.obj_description(p.prsheadline, 'pg_proc')\n"
+ " pg_catalog.obj_description(p.prsheadline, 'pg_proc')\n"
" FROM pg_catalog.pg_ts_parser p\n"
" WHERE p.oid = '%s'\n"
"UNION ALL\n"
"SELECT '%s',\n"
" p.prslextype::pg_catalog.regproc,\n"
- " pg_catalog.obj_description(p.prslextype, 'pg_proc')\n"
+ " pg_catalog.obj_description(p.prslextype, 'pg_proc')\n"
" FROM pg_catalog.pg_ts_parser p\n"
" WHERE p.oid = '%s';",
gettext_noop("Start parse"),
printfPQExpBuffer(&buf,
"SELECT t.alias as \"%s\",\n"
" t.description as \"%s\"\n"
- "FROM pg_catalog.ts_token_type( '%s'::pg_catalog.oid ) as t\n"
+ "FROM pg_catalog.ts_token_type( '%s'::pg_catalog.oid ) as t\n"
"ORDER BY 1;",
gettext_noop("Token name"),
gettext_noop("Description"),
" c.cfgname as \"%s\",\n"
" pg_catalog.obj_description(c.oid, 'pg_ts_config') as \"%s\"\n"
"FROM pg_catalog.pg_ts_config c\n"
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace\n",
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace\n",
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("Description")
" p.prsname,\n"
" np.nspname as pnspname\n"
"FROM pg_catalog.pg_ts_config c\n"
- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace,\n"
+ " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace,\n"
" pg_catalog.pg_ts_parser p\n"
- " LEFT JOIN pg_catalog.pg_namespace np ON np.oid = p.prsnamespace\n"
+ " LEFT JOIN pg_catalog.pg_namespace np ON np.oid = p.prsnamespace\n"
"WHERE p.oid = c.cfgparser\n"
);
" pg_catalog.ts_token_type(c.cfgparser) AS t\n"
" WHERE t.tokid = m.maptokentype ) AS \"%s\",\n"
" pg_catalog.btrim(\n"
- " ARRAY( SELECT mm.mapdict::pg_catalog.regdictionary\n"
+ " ARRAY( SELECT mm.mapdict::pg_catalog.regdictionary\n"
" FROM pg_catalog.pg_ts_config_map AS mm\n"
" WHERE mm.mapcfg = m.mapcfg AND mm.maptokentype = m.maptokentype\n"
" ORDER BY mapcfg, maptokentype, mapseqno\n"
" ) :: pg_catalog.text,\n"
" '{}') AS \"%s\"\n"
- "FROM pg_catalog.pg_ts_config AS c, pg_catalog.pg_ts_config_map AS m\n"
+ "FROM pg_catalog.pg_ts_config AS c, pg_catalog.pg_ts_config_map AS m\n"
"WHERE c.oid = '%s' AND m.mapcfg = c.oid\n"
"GROUP BY m.mapcfg, m.maptokentype, c.cfgparser\n"
"ORDER BY 1;",
if (pset.sversion < 100000)
{
char sverbuf[32];
+
psql_error("The server (version %s) does not support publications.\n",
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf)));
describePublications(const char *pattern)
{
PQExpBufferData buf;
- int i;
- PGresult *res;
+ int i;
+ PGresult *res;
if (pset.sversion < 100000)
{
char sverbuf[32];
+
psql_error("The server (version %s) does not support publications.\n",
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf)));
"FROM pg_catalog.pg_class c,\n"
" pg_catalog.pg_namespace n\n"
"WHERE c.relnamespace = n.oid\n"
- " AND c.relkind = " CppAsString2(RELKIND_RELATION) "\n"
+ " AND c.relkind = " CppAsString2(RELKIND_RELATION) "\n"
" AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n"
"ORDER BY 1,2");
PGresult *res;
printQueryOpt myopt = pset.popt;
static const bool translate_columns[] = {false, false, false, false,
- false, false};
+ false, false};
if (pset.sversion < 100000)
{
char sverbuf[32];
+
psql_error("The server (version %s) does not support subscriptions.\n",
formatPGVersionNumber(pset.sversion, false,
sverbuf, sizeof(sverbuf)));
"FROM pg_catalog.pg_subscription\n"
"WHERE subdbid = (SELECT oid\n"
" FROM pg_catalog.pg_database\n"
- " WHERE datname = current_database())");
+ " WHERE datname = current_database())");
processSQLNamePattern(pset.db, &buf, pattern, true, false,
NULL, "subname", NULL,
extern bool listEventTriggers(const char *pattern, bool verbose);
/* \dRp */
-bool listPublications(const char *pattern);
+bool listPublications(const char *pattern);
/* \dRp+ */
-bool describePublications(const char *pattern);
+bool describePublications(const char *pattern);
/* \dRs */
-bool describeSubscriptions(const char *pattern, bool verbose);
+bool describeSubscriptions(const char *pattern, bool verbose);
#endif /* DESCRIBE_H */
{"MATERIALIZED VIEW", NULL, &Query_for_list_of_matviews},
{"OPERATOR", NULL, NULL}, /* Querying for this is probably not such a
* good idea. */
- {"OWNED", NULL, NULL, THING_NO_CREATE | THING_NO_ALTER}, /* for DROP OWNED BY ... */
+ {"OWNED", NULL, NULL, THING_NO_CREATE | THING_NO_ALTER}, /* for DROP OWNED BY ... */
{"PARSER", Query_for_list_of_ts_parsers, NULL, THING_NO_SHOW},
{"POLICY", NULL, NULL},
{"PUBLICATION", Query_for_list_of_publications},
{"SYSTEM", NULL, NULL, THING_NO_CREATE | THING_NO_DROP},
{"TABLE", NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
- {"TEMP", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMP TABLE ... */
+ {"TEMP", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMP TABLE
+ * ... */
{"TEMPLATE", Query_for_list_of_ts_templates, NULL, THING_NO_SHOW},
- {"TEMPORARY", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMPORARY TABLE ... */
+ {"TEMPORARY", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE TEMPORARY
+ * TABLE ... */
{"TEXT SEARCH", NULL, NULL},
{"TRANSFORM", NULL, NULL},
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s' AND NOT tgisinternal"},
{"TYPE", NULL, &Query_for_list_of_datatypes},
- {"UNIQUE", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNIQUE INDEX ... */
- {"UNLOGGED", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNLOGGED TABLE
- * ... */
+ {"UNIQUE", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNIQUE
+ * INDEX ... */
+ {"UNLOGGED", NULL, NULL, THING_NO_DROP | THING_NO_ALTER}, /* for CREATE UNLOGGED
+ * TABLE ... */
{"USER", Query_for_list_of_roles},
{"USER MAPPING FOR", NULL, NULL},
{"VIEW", NULL, &Query_for_list_of_views},
COMPLETE_WITH_CONST("SCHEMA");
/* ALTER DEFAULT PRIVILEGES FOR ROLE|USER ... */
else if (Matches6("ALTER", "DEFAULT", "PRIVILEGES", "FOR", "ROLE|USER",
- MatchAny))
+ MatchAny))
COMPLETE_WITH_LIST3("GRANT", "REVOKE", "IN SCHEMA");
/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... */
else if (Matches6("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
- MatchAny))
+ MatchAny))
COMPLETE_WITH_LIST3("GRANT", "REVOKE", "FOR ROLE");
/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR */
else if (Matches7("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
- MatchAny, "FOR"))
+ MatchAny, "FOR"))
COMPLETE_WITH_CONST("ROLE");
/* ALTER DEFAULT PRIVILEGES FOR ROLE|USER ... IN SCHEMA ... */
/* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR ROLE|USER ... */
else if (Matches9("ALTER", "DEFAULT", "PRIVILEGES", "FOR", "ROLE|USER",
- MatchAny, "IN", "SCHEMA", MatchAny) ||
- Matches9("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
- MatchAny, "FOR", "ROLE|USER", MatchAny))
+ MatchAny, "IN", "SCHEMA", MatchAny) ||
+ Matches9("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA",
+ MatchAny, "FOR", "ROLE|USER", MatchAny))
COMPLETE_WITH_LIST2("GRANT", "REVOKE");
/* ALTER DOMAIN <name> */
else if (Matches3("ALTER", "DOMAIN", MatchAny))
static const char *const list_ALTER2[] =
{"ADD", "ALTER", "CLUSTER ON", "DISABLE", "DROP", "ENABLE", "INHERIT",
"NO INHERIT", "RENAME", "RESET", "OWNER TO", "SET",
- "VALIDATE CONSTRAINT", "REPLICA IDENTITY", "ATTACH PARTITION",
+ "VALIDATE CONSTRAINT", "REPLICA IDENTITY", "ATTACH PARTITION",
"DETACH PARTITION", NULL};
COMPLETE_WITH_LIST(list_ALTER2);
COMPLETE_WITH_LIST4("FULL", "NOTHING", "DEFAULT", "USING");
else if (Matches4("ALTER", "TABLE", MatchAny, "REPLICA"))
COMPLETE_WITH_CONST("IDENTITY");
+
/*
* If we have ALTER TABLE <foo> ATTACH PARTITION, provide a list of
* tables.
COMPLETE_WITH_CONST("FOR VALUES");
else if (TailMatches2("FOR", "VALUES"))
COMPLETE_WITH_LIST2("FROM (", "IN (");
+
/*
* If we have ALTER TABLE <foo> DETACH PARTITION, provide a list of
* partitions of <foo>.
/* ALTER TYPE xxx RENAME (ATTRIBUTE|VALUE) yyy */
else if (Matches6("ALTER", "TYPE", MatchAny, "RENAME", "ATTRIBUTE|VALUE", MatchAny))
COMPLETE_WITH_CONST("TO");
+
/*
* If we have ALTER TYPE <sth> ALTER/DROP/RENAME ATTRIBUTE, provide list
* of attributes
/* CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE */
else if (Matches6("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS"))
COMPLETE_WITH_LIST2("PERMISSIVE", "RESTRICTIVE");
- /* CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR|TO|USING|WITH CHECK */
+
+ /*
+ * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE
+ * FOR|TO|USING|WITH CHECK
+ */
else if (Matches7("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny))
COMPLETE_WITH_LIST4("FOR", "TO", "USING", "WITH CHECK");
/* CREATE POLICY <name> ON <table> FOR ALL|SELECT|INSERT|UPDATE|DELETE */
/* Complete "CREATE POLICY <name> ON <table> USING (" */
else if (Matches6("CREATE", "POLICY", MatchAny, "ON", MatchAny, "USING"))
COMPLETE_WITH_CONST("(");
- /* CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR ALL|SELECT|INSERT|UPDATE|DELETE */
+
+ /*
+ * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
+ * ALL|SELECT|INSERT|UPDATE|DELETE
+ */
else if (Matches8("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR"))
COMPLETE_WITH_LIST5("ALL", "SELECT", "INSERT", "UPDATE", "DELETE");
- /* Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR INSERT TO|WITH CHECK" */
+
+ /*
+ * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
+ * INSERT TO|WITH CHECK"
+ */
else if (Matches9("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "INSERT"))
COMPLETE_WITH_LIST2("TO", "WITH CHECK (");
- /* Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR SELECT|DELETE TO|USING" */
+
+ /*
+ * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
+ * SELECT|DELETE TO|USING"
+ */
else if (Matches9("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "SELECT|DELETE"))
COMPLETE_WITH_LIST2("TO", "USING (");
- /* CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR ALL|UPDATE TO|USING|WITH CHECK */
+
+ /*
+ * CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE FOR
+ * ALL|UPDATE TO|USING|WITH CHECK
+ */
else if (Matches9("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "FOR", "ALL|UPDATE"))
COMPLETE_WITH_LIST3("TO", "USING (", "WITH CHECK (");
- /* Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE TO <role>" */
+
+ /*
+ * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE TO
+ * <role>"
+ */
else if (Matches8("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "TO"))
COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
- /* Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE USING (" */
+
+ /*
+ * Complete "CREATE POLICY <name> ON <table> AS PERMISSIVE|RESTRICTIVE
+ * USING ("
+ */
else if (Matches8("CREATE", "POLICY", MatchAny, "ON", MatchAny, "AS", MatchAny, "USING"))
COMPLETE_WITH_CONST("(");
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_views, NULL);
else if (HeadMatches2("CREATE", "TRIGGER") && TailMatches2("ON", MatchAny))
COMPLETE_WITH_LIST7("NOT DEFERRABLE", "DEFERRABLE", "INITIALLY",
- "REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
+ "REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
else if (HeadMatches2("CREATE", "TRIGGER") &&
(TailMatches1("DEFERRABLE") || TailMatches2("INITIALLY", "IMMEDIATE|DEFERRED")))
COMPLETE_WITH_LIST4("REFERENCING", "FOR", "WHEN (", "EXECUTE PROCEDURE");
else if (TailMatches1("GRANT|REVOKE"))
{
/*
- * With ALTER DEFAULT PRIVILEGES, restrict completion
- * to grantable privileges (can't grant roles)
+ * With ALTER DEFAULT PRIVILEGES, restrict completion to grantable
+ * privileges (can't grant roles)
*/
- if (HeadMatches3("ALTER","DEFAULT","PRIVILEGES"))
+ if (HeadMatches3("ALTER", "DEFAULT", "PRIVILEGES"))
COMPLETE_WITH_LIST10("SELECT", "INSERT", "UPDATE",
- "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
- "EXECUTE", "USAGE", "ALL");
+ "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER",
+ "EXECUTE", "USAGE", "ALL");
else
COMPLETE_WITH_QUERY(Query_for_list_of_roles
- " UNION SELECT 'SELECT'"
- " UNION SELECT 'INSERT'"
- " UNION SELECT 'UPDATE'"
- " UNION SELECT 'DELETE'"
- " UNION SELECT 'TRUNCATE'"
- " UNION SELECT 'REFERENCES'"
- " UNION SELECT 'TRIGGER'"
- " UNION SELECT 'CREATE'"
- " UNION SELECT 'CONNECT'"
- " UNION SELECT 'TEMPORARY'"
- " UNION SELECT 'EXECUTE'"
- " UNION SELECT 'USAGE'"
- " UNION SELECT 'ALL'");
+ " UNION SELECT 'SELECT'"
+ " UNION SELECT 'INSERT'"
+ " UNION SELECT 'UPDATE'"
+ " UNION SELECT 'DELETE'"
+ " UNION SELECT 'TRUNCATE'"
+ " UNION SELECT 'REFERENCES'"
+ " UNION SELECT 'TRIGGER'"
+ " UNION SELECT 'CREATE'"
+ " UNION SELECT 'CONNECT'"
+ " UNION SELECT 'TEMPORARY'"
+ " UNION SELECT 'EXECUTE'"
+ " UNION SELECT 'USAGE'"
+ " UNION SELECT 'ALL'");
}
+
/*
* Complete GRANT/REVOKE <privilege> with "ON", GRANT/REVOKE <role> with
* TO/FROM
else if (TailMatches3("GRANT|REVOKE", MatchAny, "ON"))
{
/*
- * With ALTER DEFAULT PRIVILEGES, restrict completion
- * to the kinds of objects supported.
+ * With ALTER DEFAULT PRIVILEGES, restrict completion to the kinds of
+ * objects supported.
*/
- if (HeadMatches3("ALTER","DEFAULT","PRIVILEGES"))
+ if (HeadMatches3("ALTER", "DEFAULT", "PRIVILEGES"))
COMPLETE_WITH_LIST5("TABLES", "SEQUENCES", "FUNCTIONS", "TYPES", "SCHEMAS");
else
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsvmf,
- " UNION SELECT 'ALL FUNCTIONS IN SCHEMA'"
- " UNION SELECT 'ALL SEQUENCES IN SCHEMA'"
- " UNION SELECT 'ALL TABLES IN SCHEMA'"
- " UNION SELECT 'DATABASE'"
- " UNION SELECT 'DOMAIN'"
- " UNION SELECT 'FOREIGN DATA WRAPPER'"
- " UNION SELECT 'FOREIGN SERVER'"
- " UNION SELECT 'FUNCTION'"
- " UNION SELECT 'LANGUAGE'"
- " UNION SELECT 'LARGE OBJECT'"
- " UNION SELECT 'SCHEMA'"
- " UNION SELECT 'SEQUENCE'"
- " UNION SELECT 'TABLE'"
- " UNION SELECT 'TABLESPACE'"
- " UNION SELECT 'TYPE'");
+ " UNION SELECT 'ALL FUNCTIONS IN SCHEMA'"
+ " UNION SELECT 'ALL SEQUENCES IN SCHEMA'"
+ " UNION SELECT 'ALL TABLES IN SCHEMA'"
+ " UNION SELECT 'DATABASE'"
+ " UNION SELECT 'DOMAIN'"
+ " UNION SELECT 'FOREIGN DATA WRAPPER'"
+ " UNION SELECT 'FOREIGN SERVER'"
+ " UNION SELECT 'FUNCTION'"
+ " UNION SELECT 'LANGUAGE'"
+ " UNION SELECT 'LARGE OBJECT'"
+ " UNION SELECT 'SCHEMA'"
+ " UNION SELECT 'SEQUENCE'"
+ " UNION SELECT 'TABLE'"
+ " UNION SELECT 'TABLESPACE'"
+ " UNION SELECT 'TYPE'");
}
else if (TailMatches4("GRANT|REVOKE", MatchAny, "ON", "ALL"))
COMPLETE_WITH_LIST3("FUNCTIONS IN SCHEMA", "SEQUENCES IN SCHEMA",
(HeadMatches1("REVOKE") && TailMatches1("FROM")))
COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
/* Complete "ALTER DEFAULT PRIVILEGES ... GRANT/REVOKE ... TO/FROM */
- else if (HeadMatches3("ALTER","DEFAULT", "PRIVILEGES") && TailMatches1("TO|FROM"))
+ else if (HeadMatches3("ALTER", "DEFAULT", "PRIVILEGES") && TailMatches1("TO|FROM"))
COMPLETE_WITH_QUERY(Query_for_list_of_grant_roles);
/* Complete "GRANT/REVOKE ... ON * *" with TO/FROM */
else if (HeadMatches1("GRANT") && TailMatches3("ON", MatchAny, MatchAny))
COMPLETE_WITH_LIST4("ISOLATION LEVEL", "READ", "DEFERRABLE", "NOT DEFERRABLE");
else if (Matches3("SET|BEGIN|START", "TRANSACTION|WORK", "NOT") ||
Matches2("BEGIN", "NOT") ||
- Matches6("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "NOT"))
+ Matches6("SET", "SESSION", "CHARACTERISTICS", "AS", "TRANSACTION", "NOT"))
COMPLETE_WITH_CONST("DEFERRABLE");
else if (Matches3("SET|BEGIN|START", "TRANSACTION|WORK", "ISOLATION") ||
Matches2("BEGIN", "ISOLATION") ||
matches = completion_matches(text, drop_command_generator);
else if (TailMatches1("ALTER"))
matches = completion_matches(text, alter_command_generator);
- /* CREATE is recognized by tail match elsewhere, so doesn't need to be
- * repeated here */
+
+ /*
+ * CREATE is recognized by tail match elsewhere, so doesn't need to be
+ * repeated here
+ */
}
else if (TailMatchesCS3("\\h|\\help", MatchAny, MatchAny))
{
/*
* pg_xlog has been renamed to pg_wal in version 10.
*/
-#define MINIMUM_VERSION_FOR_PG_WAL 100000
+#define MINIMUM_VERSION_FOR_PG_WAL 100000
#ifdef PG_FLUSH_DATA_WORKS
static int pre_sync_fname(const char *fname, bool isdir,
- const char *progname);
+ const char *progname);
#endif
static void walkdir(const char *path,
- int (*action) (const char *fname, bool isdir, const char *progname),
- bool process_symlinks, const char *progname);
+ int (*action) (const char *fname, bool isdir, const char *progname),
+ bool process_symlinks, const char *progname);
/*
* Issue fsync recursively on PGDATA and all its contents.
/* handle renaming of pg_xlog to pg_wal in post-10 clusters */
snprintf(pg_wal, MAXPGPATH, "%s/%s", pg_data,
- serverVersion < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal");
+ serverVersion < MINIMUM_VERSION_FOR_PG_WAL ? "pg_xlog" : "pg_wal");
snprintf(pg_tblspc, MAXPGPATH, "%s/pg_tblspc", pg_data);
/*
int
durable_rename(const char *oldfile, const char *newfile, const char *progname)
{
- int fd;
+ int fd;
/*
* First fsync the old and target path (if it exists), to ensure that they
}
/*
- * Quick check if the input is pure ASCII. An ASCII string requires
- * no further processing.
+ * Quick check if the input is pure ASCII. An ASCII string requires no
+ * further processing.
*/
if (pg_is_ascii_string(input))
{
*----------
*/
maxlen = strlen("SCRAM-SHA-256") + 1
- + 10 + 1 /* iteration count */
- + pg_b64_enc_len(saltlen) + 1 /* Base64-encoded salt */
+ + 10 + 1 /* iteration count */
+ + pg_b64_enc_len(saltlen) + 1 /* Base64-encoded salt */
+ pg_b64_enc_len(SCRAM_KEY_LEN) + 1 /* Base64-encoded StoredKey */
+ pg_b64_enc_len(SCRAM_KEY_LEN) + 1; /* Base64-encoded ServerKey */
* Portions Copyright (c) 2016, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * src/common/sha2_openssl.c
+ * src/common/sha2_openssl.c
*
*-------------------------------------------------------------------------
*/
* is only valid until next call to this function!
*/
static const pg_wchar *
-get_code_decomposition(pg_unicode_decomposition * entry, int *dec_size)
+get_code_decomposition(pg_unicode_decomposition *entry, int *dec_size)
{
static pg_wchar x;
*/
typedef struct BrinStatsData
{
- BlockNumber pagesPerRange;
- BlockNumber revmapNumPages;
+ BlockNumber pagesPerRange;
+ BlockNumber revmapNumPages;
} BrinStatsData;
BlockNumber bt_blkno; /* heap blkno that the tuple is for */
MemoryContext bt_context; /* memcxt holding the bt_columns values */
/* output arrays for brin_deform_tuple: */
- Datum *bt_values; /* values array */
- bool *bt_allnulls; /* allnulls array */
- bool *bt_hasnulls; /* hasnulls array */
+ Datum *bt_values; /* values array */
+ bool *bt_allnulls; /* allnulls array */
+ bool *bt_hasnulls; /* hasnulls array */
/* not an output array, but must be last */
BrinValues bt_columns[FLEXIBLE_ARRAY_MEMBER];
} BrinMemTuple;
*/
typedef struct xl_brin_desummarize
{
- BlockNumber pagesPerRange;
+ BlockNumber pagesPerRange;
/* page number location to set to invalid */
BlockNumber heapBlk;
/* offset of item to delete in regular index page */
typedef struct xl_clog_truncate
{
- int pageno;
+ int pageno;
TransactionId oldestXact;
- Oid oldestXactDb;
+ Oid oldestXactDb;
} xl_clog_truncate;
extern void TransactionIdSetTreeStatus(TransactionId xid, int nsubxids,
#define LH_BUCKET_BEING_POPULATED (1 << 4)
#define LH_BUCKET_BEING_SPLIT (1 << 5)
#define LH_BUCKET_NEEDS_SPLIT_CLEANUP (1 << 6)
-#define LH_PAGE_HAS_DEAD_TUPLES (1 << 7)
+#define LH_PAGE_HAS_DEAD_TUPLES (1 << 7)
#define LH_PAGE_TYPE \
(LH_OVERFLOW_PAGE | LH_BUCKET_PAGE | LH_BITMAP_PAGE | LH_META_PAGE)
*/
#define HASHO_PAGE_ID 0xFF80
-typedef struct HashScanPosItem /* what we remember about each match */
+typedef struct HashScanPosItem /* what we remember about each match */
{
ItemPointerData heapTid; /* TID of referenced heap item */
OffsetNumber indexOffset; /* index item's location within page */
*/
bool hashso_buc_split;
/* info about killed items if any (killedItems is NULL if never used) */
- HashScanPosItem *killedItems; /* tids and offset numbers of killed items */
- int numKilled; /* number of currently stored items */
+ HashScanPosItem *killedItems; /* tids and offset numbers of killed
+ * items */
+ int numKilled; /* number of currently stored items */
} HashScanOpaqueData;
typedef HashScanOpaqueData *HashScanOpaque;
HashMetaPage *cachedmetap);
extern Buffer _hash_getinitbuf(Relation rel, BlockNumber blkno);
extern void _hash_initbuf(Buffer buf, uint32 max_bucket, uint32 num_bucket,
- uint32 flag, bool initpage);
+ uint32 flag, bool initpage);
extern Buffer _hash_getnewbuf(Relation rel, BlockNumber blkno,
ForkNumber forkNum);
extern Buffer _hash_getbuf_with_strategy(Relation rel, BlockNumber blkno,
#define XLOG_HASH_UPDATE_META_PAGE 0xB0 /* update meta page after
* vacuum */
-#define XLOG_HASH_VACUUM_ONE_PAGE 0xC0 /* remove dead tuples from index page */
+#define XLOG_HASH_VACUUM_ONE_PAGE 0xC0 /* remove dead tuples from
+ * index page */
/*
* xl_hash_split_allocate_page flag values, 8 bits are available.
typedef struct xl_hash_insert
{
OffsetNumber offnum;
-} xl_hash_insert;
+} xl_hash_insert;
#define SizeOfHashInsert (offsetof(xl_hash_insert, offnum) + sizeof(OffsetNumber))
{
uint16 bmsize;
bool bmpage_found;
-} xl_hash_add_ovfl_page;
+} xl_hash_add_ovfl_page;
#define SizeOfHashAddOvflPage \
(offsetof(xl_hash_add_ovfl_page, bmpage_found) + sizeof(bool))
uint16 old_bucket_flag;
uint16 new_bucket_flag;
uint8 flags;
-} xl_hash_split_allocate_page;
+} xl_hash_split_allocate_page;
#define SizeOfHashSplitAllocPage \
(offsetof(xl_hash_split_allocate_page, flags) + sizeof(uint8))
{
uint16 old_bucket_flag;
uint16 new_bucket_flag;
-} xl_hash_split_complete;
+} xl_hash_split_complete;
#define SizeOfHashSplitComplete \
(offsetof(xl_hash_split_complete, new_bucket_flag) + sizeof(uint16))
bool is_prim_bucket_same_wrt; /* TRUE if the page to which
* tuples are moved is same as
* primary bucket page */
-} xl_hash_move_page_contents;
+} xl_hash_move_page_contents;
#define SizeOfHashMovePageContents \
(offsetof(xl_hash_move_page_contents, is_prim_bucket_same_wrt) + sizeof(bool))
* tuples are moved is the
* page previous to the freed
* overflow page */
-} xl_hash_squeeze_page;
+} xl_hash_squeeze_page;
#define SizeOfHashSqueezePage \
(offsetof(xl_hash_squeeze_page, is_prev_bucket_same_wrt) + sizeof(bool))
* LH_PAGE_HAS_DEAD_TUPLES flag */
bool is_primary_bucket_page; /* TRUE if the operation is for
* primary bucket page */
-} xl_hash_delete;
+} xl_hash_delete;
#define SizeOfHashDelete (offsetof(xl_hash_delete, is_primary_bucket_page) + sizeof(bool))
typedef struct xl_hash_update_meta_page
{
double ntuples;
-} xl_hash_update_meta_page;
+} xl_hash_update_meta_page;
#define SizeOfHashUpdateMetaPage \
(offsetof(xl_hash_update_meta_page, ntuples) + sizeof(double))
double num_tuples;
RegProcedure procid;
uint16 ffactor;
-} xl_hash_init_meta_page;
+} xl_hash_init_meta_page;
#define SizeOfHashInitMetaPage \
(offsetof(xl_hash_init_meta_page, ffactor) + sizeof(uint16))
typedef struct xl_hash_init_bitmap_page
{
uint16 bmsize;
-} xl_hash_init_bitmap_page;
+} xl_hash_init_bitmap_page;
#define SizeOfHashInitBitmapPage \
(offsetof(xl_hash_init_bitmap_page, bmsize) + sizeof(uint16))
*/
typedef struct xl_hash_vacuum_one_page
{
- RelFileNode hnode;
- int ntuples;
+ RelFileNode hnode;
+ int ntuples;
/* TARGET OFFSET NUMBERS FOLLOW AT THE END */
-} xl_hash_vacuum_one_page;
+} xl_hash_vacuum_one_page;
-#define SizeOfHashVacuumOnePage \
+#define SizeOfHashVacuumOnePage \
(offsetof(xl_hash_vacuum_one_page, ntuples) + sizeof(int))
extern void hash_redo(XLogReaderState *record);
Oid ps_indexid;
Size ps_offset; /* Offset in bytes of am specific structure */
char ps_snapshot_data[FLEXIBLE_ARRAY_MEMBER];
-} ParallelIndexScanDescData;
+} ParallelIndexScanDescData;
/* Struct for heap-or-index scans of system tables */
typedef struct SysScanDescData
extern void FinishPreparedTransaction(const char *gid, bool isCommit);
extern void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn,
- XLogRecPtr end_lsn);
+ XLogRecPtr end_lsn);
extern void PrepareRedoRemove(TransactionId xid, bool giveWarning);
extern void restoreTwoPhaseData(void);
#endif /* TWOPHASE_H */
* globally accessible, so can be set from anywhere in the code which requires
* recording flags.
*/
-extern int MyXactFlags;
+extern int MyXactFlags;
/*
* XACT_FLAGS_ACCESSEDTEMPREL - set when a temporary relation is accessed. We
struct XLogRecData;
extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata,
- XLogRecPtr fpw_lsn,
- uint8 flags);
+ XLogRecPtr fpw_lsn,
+ uint8 flags);
extern void XLogFlush(XLogRecPtr RecPtr);
extern bool XLogBackgroundFlush(void);
extern bool XLogNeedsFlush(XLogRecPtr RecPtr);
XLogRecPtr currRecPtr;
/* timeline to read it from, 0 if a lookup is required */
TimeLineID currTLI;
+
/*
* Safe point to read to in currTLI if current TLI is historical
* (tliSwitchPoint) or InvalidXLogRecPtr if on current timeline.
*
- * Actually set to the start of the segment containing the timeline
- * switch that ends currTLI's validity, not the LSN of the switch
- * its self, since we can't assume the old segment will be present.
+ * Actually set to the start of the segment containing the timeline switch
+ * that ends currTLI's validity, not the LSN of the switch its self, since
+ * we can't assume the old segment will be present.
*/
XLogRecPtr currTLIValidUntil;
+
/*
* If currTLI is not the most recent known timeline, the next timeline to
* read from when currTLIValidUntil is reached.
TimeLineID *pageTLI);
extern void XLogReadDetermineTimeline(XLogReaderState *state,
- XLogRecPtr wantPage, uint32 wantLength);
+ XLogRecPtr wantPage, uint32 wantLength);
#endif
typedef struct
{
int indx[MAXDIM];
-} IntArray;
+} IntArray;
/* ----------------
* Variable-length datatypes all share the 'struct varlena' header.
extern bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId);
extern List *getOwnedSequences(Oid relid, AttrNumber attnum);
-extern Oid getOwnedSequence(Oid relid, AttrNumber attnum);
+extern Oid getOwnedSequence(Oid relid, AttrNumber attnum);
extern Oid get_constraint_index(Oid constraintId);
DATA(insert OID = 3374 ( "pg_read_all_settings" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_READ_ALL_SETTINGS 3374
DATA(insert OID = 3375 ( "pg_read_all_stats" f t f f f f f -1 _null_ _null_));
-#define DEFAULT_ROLE_READ_ALL_STATS 3375
+#define DEFAULT_ROLE_READ_ALL_STATS 3375
DATA(insert OID = 3377 ( "pg_stat_scan_tables" f t f f f f f -1 _null_ _null_));
#define DEFAULT_ROLE_STAT_SCAN_TABLES 3377
DATA(insert OID = 4200 ( "pg_signal_backend" f t f f f f f -1 _null_ _null_));
NameData collcollate; /* LC_COLLATE setting */
NameData collctype; /* LC_CTYPE setting */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
- text collversion; /* provider-dependent version of collation data */
+ text collversion; /* provider-dependent version of collation
+ * data */
#endif
} FormData_pg_collation;
DESCR("concatenate");
DATA(insert OID = 3285 ( "-" PGNSP PGUID b f f 3802 25 3802 0 0 3302 - - ));
DESCR("delete object field");
-DATA(insert OID = 3398 ( "-" PGNSP PGUID b f f 3802 1009 3802 0 0 3343 - -));
+DATA(insert OID = 3398 ( "-" PGNSP PGUID b f f 3802 1009 3802 0 0 3343 - -));
DESCR("delete object fields");
DATA(insert OID = 3286 ( "-" PGNSP PGUID b f f 3802 23 3802 0 0 3303 - - ));
DESCR("delete array element");
#define Anum_pg_policy_polpermissive 4
#define Anum_pg_policy_polroles 5
#define Anum_pg_policy_polqual 6
-#define Anum_pg_policy_polwithcheck 7
+#define Anum_pg_policy_polwithcheck 7
#endif /* PG_POLICY_H */
DESCR("set sequence value and is_called status");
DATA(insert OID = 3078 ( pg_sequence_parameters PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 2249 "26" "{26,20,20,20,20,16,20,26}" "{i,o,o,o,o,o,o,o}" "{sequence_oid,start_value,minimum_value,maximum_value,increment,cycle_option,cache_size,data_type}" _null_ _null_ pg_sequence_parameters _null_ _null_ _null_));
DESCR("sequence parameters, for use by information schema");
-DATA(insert OID = 4032 ( pg_sequence_last_value PGNSP PGUID 12 1 0 0 0 f f f f t f v u 1 0 20 "2205" _null_ _null_ _null_ _null_ _null_ pg_sequence_last_value _null_ _null_ _null_ ));
+DATA(insert OID = 4032 ( pg_sequence_last_value PGNSP PGUID 12 1 0 0 0 f f f f t f v u 1 0 20 "2205" _null_ _null_ _null_ _null_ _null_ pg_sequence_last_value _null_ _null_ _null_ ));
DESCR("sequence last value");
DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 1 0 0 0 f f f f t f i s 3 0 1562 "2275 26 23" _null_ _null_ _null_ _null_ _null_ varbit_in _null_ _null_ _null_ ));
DESCR("extended statistics object description");
DATA(insert OID = 3352 ( pg_get_partkeydef PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 25 "26" _null_ _null_ _null_ _null_ _null_ pg_get_partkeydef _null_ _null_ _null_ ));
DESCR("partition key description");
-DATA(insert OID = 3408 ( pg_get_partition_constraintdef PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 25 "26" _null_ _null_ _null_ _null_ _null_ pg_get_partition_constraintdef _null_ _null_ _null_ ));
+DATA(insert OID = 3408 ( pg_get_partition_constraintdef PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 25 "26" _null_ _null_ _null_ _null_ _null_ pg_get_partition_constraintdef _null_ _null_ _null_ ));
DESCR("partition constraint description");
DATA(insert OID = 1662 ( pg_get_triggerdef PGNSP PGUID 12 1 0 0 0 f f f f t f s s 1 0 25 "26" _null_ _null_ _null_ _null_ _null_ pg_get_triggerdef _null_ _null_ _null_ ));
DESCR("trigger description");
DATA(insert OID = 3843 ( pg_column_is_updatable PGNSP PGUID 12 10 0 0 0 f f f f t f s s 3 0 16 "2205 21 16" _null_ _null_ _null_ _null_ _null_ pg_column_is_updatable _null_ _null_ _null_ ));
DESCR("is a column updatable");
-DATA(insert OID = 6120 ( pg_get_replica_identity_index PGNSP PGUID 12 10 0 0 0 f f f f t f s s 1 0 2205 "2205" _null_ _null_ _null_ _null_ _null_ pg_get_replica_identity_index _null_ _null_ _null_ ));
+DATA(insert OID = 6120 ( pg_get_replica_identity_index PGNSP PGUID 12 10 0 0 0 f f f f t f s s 1 0 2205 "2205" _null_ _null_ _null_ _null_ _null_ pg_get_replica_identity_index _null_ _null_ _null_ ));
DESCR("oid of replica identity index if any");
/* Deferrable unique constraint trigger */
DESCR("switch to new wal file");
DATA(insert OID = 3098 ( pg_create_restore_point PGNSP PGUID 12 1 0 0 0 f f f f t f v s 1 0 3220 "25" _null_ _null_ _null_ _null_ _null_ pg_create_restore_point _null_ _null_ _null_ ));
DESCR("create a named restore point");
-DATA(insert OID = 2849 ( pg_current_wal_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_lsn _null_ _null_ _null_ ));
+DATA(insert OID = 2849 ( pg_current_wal_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_lsn _null_ _null_ _null_ ));
DESCR("current wal write location");
DATA(insert OID = 2852 ( pg_current_wal_insert_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_current_wal_insert_lsn _null_ _null_ _null_ ));
DESCR("current wal insert location");
DATA(insert OID = 3820 ( pg_last_wal_receive_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_receive_lsn _null_ _null_ _null_ ));
DESCR("current wal flush location");
-DATA(insert OID = 3821 ( pg_last_wal_replay_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_replay_lsn _null_ _null_ _null_ ));
+DATA(insert OID = 3821 ( pg_last_wal_replay_lsn PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 3220 "" _null_ _null_ _null_ _null_ _null_ pg_last_wal_replay_lsn _null_ _null_ _null_ ));
DESCR("last wal replay location");
DATA(insert OID = 3830 ( pg_last_xact_replay_timestamp PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 1184 "" _null_ _null_ _null_ _null_ _null_ pg_last_xact_replay_timestamp _null_ _null_ _null_ ));
DESCR("timestamp of last replay xact");
DESCR("reload configuration files");
DATA(insert OID = 2622 ( pg_rotate_logfile PGNSP PGUID 12 1 0 0 0 f f f f t f v s 0 0 16 "" _null_ _null_ _null_ _null_ _null_ pg_rotate_logfile _null_ _null_ _null_ ));
DESCR("rotate log file");
-DATA(insert OID = 3800 ( pg_current_logfile PGNSP PGUID 12 1 0 0 0 f f f f f f v s 0 0 25 "" _null_ _null_ _null_ _null_ _null_ pg_current_logfile _null_ _null_ _null_ ));
+DATA(insert OID = 3800 ( pg_current_logfile PGNSP PGUID 12 1 0 0 0 f f f f f f v s 0 0 25 "" _null_ _null_ _null_ _null_ _null_ pg_current_logfile _null_ _null_ _null_ ));
DESCR("current logging collector file location");
-DATA(insert OID = 3801 ( pg_current_logfile PGNSP PGUID 12 1 0 0 0 f f f f f f v s 1 0 25 "25" _null_ _null_ _null_ _null_ _null_ pg_current_logfile_1arg _null_ _null_ _null_ ));
+DATA(insert OID = 3801 ( pg_current_logfile PGNSP PGUID 12 1 0 0 0 f f f f f f v s 1 0 25 "25" _null_ _null_ _null_ _null_ _null_ pg_current_logfile_1arg _null_ _null_ _null_ ));
DESCR("current logging collector file location");
DATA(insert OID = 2623 ( pg_stat_file PGNSP PGUID 12 1 0 0 0 f f f f t f v s 1 0 2249 "25" "{25,20,1184,1184,1184,1184,16}" "{i,o,o,o,o,o,o}" "{filename,size,access,modification,change,creation,isdir}" _null_ _null_ pg_stat_file_1arg _null_ _null_ _null_ ));
DATA(insert OID = 3301 ( jsonb_concat PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 3802 "3802 3802" _null_ _null_ _null_ _null_ _null_ jsonb_concat _null_ _null_ _null_ ));
DATA(insert OID = 3302 ( jsonb_delete PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 3802 "3802 25" _null_ _null_ _null_ _null_ _null_ jsonb_delete _null_ _null_ _null_ ));
DATA(insert OID = 3303 ( jsonb_delete PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 3802 "3802 23" _null_ _null_ _null_ _null_ _null_ jsonb_delete_idx _null_ _null_ _null_ ));
-DATA(insert OID = 3343 ( jsonb_delete PGNSP PGUID 12 1 0 25 0 f f f f t f i s 2 0 3802 "3802 1009" "{3802,1009}" "{i,v}" "{from_json,path_elems}" _null_ _null_ jsonb_delete_array _null_ _null_ _null_ ));
+DATA(insert OID = 3343 ( jsonb_delete PGNSP PGUID 12 1 0 25 0 f f f f t f i s 2 0 3802 "3802 1009" "{3802,1009}" "{i,v}" "{from_json,path_elems}" _null_ _null_ jsonb_delete_array _null_ _null_ _null_ ));
DATA(insert OID = 3304 ( jsonb_delete_path PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 3802 "3802 1009" _null_ _null_ _null_ _null_ _null_ jsonb_delete_path _null_ _null_ _null_ ));
DATA(insert OID = 3305 ( jsonb_set PGNSP PGUID 12 1 0 0 0 f f f f t f i s 4 0 3802 "3802 1009 3802 16" _null_ _null_ _null_ _null_ _null_ jsonb_set _null_ _null_ _null_ ));
DESCR("Set part of a jsonb");
DESCR("import collations from operating system");
/* system management/monitoring related functions */
-DATA(insert OID = 3353 ( pg_ls_logdir PGNSP PGUID 12 10 20 0 0 f f f f t t v s 0 0 2249 "" "{25,20,1184}" "{o,o,o}" "{name,size,modification}" _null_ _null_ pg_ls_logdir _null_ _null_ _null_ ));
+DATA(insert OID = 3353 ( pg_ls_logdir PGNSP PGUID 12 10 20 0 0 f f f f t t v s 0 0 2249 "" "{25,20,1184}" "{o,o,o}" "{name,size,modification}" _null_ _null_ pg_ls_logdir _null_ _null_ _null_ ));
DESCR("list files in the log directory");
-DATA(insert OID = 3354 ( pg_ls_waldir PGNSP PGUID 12 10 20 0 0 f f f f t t v s 0 0 2249 "" "{25,20,1184}" "{o,o,o}" "{name,size,modification}" _null_ _null_ pg_ls_waldir _null_ _null_ _null_ ));
+DATA(insert OID = 3354 ( pg_ls_waldir PGNSP PGUID 12 10 20 0 0 f f f f t t v s 0 0 2249 "" "{25,20,1184}" "{o,o,o}" "{name,size,modification}" _null_ _null_ pg_ls_waldir _null_ _null_ _null_ ));
DESCR("list of files in the WAL directory");
/*
CATALOG(pg_publication,6104)
{
- NameData pubname; /* name of the publication */
+ NameData pubname; /* name of the publication */
- Oid pubowner; /* publication owner */
+ Oid pubowner; /* publication owner */
/*
- * indicates that this is special publication which should encompass
- * all tables in the database (except for the unlogged and temp ones)
+ * indicates that this is special publication which should encompass all
+ * tables in the database (except for the unlogged and temp ones)
*/
bool puballtables;
typedef struct PublicationActions
{
- bool pubinsert;
- bool pubupdate;
- bool pubdelete;
+ bool pubinsert;
+ bool pubupdate;
+ bool pubdelete;
} PublicationActions;
typedef struct Publication
{
- Oid oid;
- char *name;
- bool alltables;
+ Oid oid;
+ char *name;
+ bool alltables;
PublicationActions pubactions;
} Publication;
extern List *GetAllTablesPublicationRelations(void);
extern ObjectAddress publication_add_relation(Oid pubid, Relation targetrel,
- bool if_not_exists);
+ bool if_not_exists);
-extern Oid get_publication_oid(const char *pubname, bool missing_ok);
+extern Oid get_publication_oid(const char *pubname, bool missing_ok);
extern char *get_publication_name(Oid pubid);
extern Datum pg_get_publication_tables(PG_FUNCTION_ARGS);
CATALOG(pg_publication_rel,6106)
{
- Oid prpubid; /* Oid of the publication */
- Oid prrelid; /* Oid of the relation */
+ Oid prpubid; /* Oid of the publication */
+ Oid prrelid; /* Oid of the relation */
} FormData_pg_publication_rel;
/* ----------------
#define Anum_pg_sequence_seqcache 7
#define Anum_pg_sequence_seqcycle 8
-#endif /* PG_SEQUENCE_H */
+#endif /* PG_SEQUENCE_H */
int2vector stxkeys; /* array of column keys */
#ifdef CATALOG_VARLEN
- char stxkind[1] BKI_FORCE_NOT_NULL; /* statistic types
- * requested to build */
+ char stxkind[1] BKI_FORCE_NOT_NULL; /* statistic types requested
+ * to build */
pg_ndistinct stxndistinct; /* ndistinct coefficients (serialized) */
pg_dependencies stxdependencies; /* dependencies (serialized) */
#endif
* ----------------
*/
#define SubscriptionRelationId 6100
-#define SubscriptionRelation_Rowtype_Id 6101
+#define SubscriptionRelation_Rowtype_Id 6101
/*
* Technically, the subscriptions live inside the database, so a shared catalog
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled
- * (the worker should be running) */
+ bool subenabled; /* True if the subscription is enabled (the
+ * worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconninfo BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
/* Synchronous commit setting for worker */
- text subsynccommit BKI_FORCE_NOT_NULL;
+ text subsynccommit BKI_FORCE_NOT_NULL;
/* List of publications subscribed to */
text subpublications[1] BKI_FORCE_NOT_NULL;
typedef struct Subscription
{
- Oid oid; /* Oid of the subscription */
- Oid dbid; /* Oid of the database which subscription is in */
- char *name; /* Name of the subscription */
- Oid owner; /* Oid of the subscription owner */
- bool enabled; /* Indicates if the subscription is enabled */
- char *conninfo; /* Connection string to the publisher */
- char *slotname; /* Name of the replication slot */
- char *synccommit; /* Synchronous commit setting for worker */
- List *publications; /* List of publication names to subscribe to */
+ Oid oid; /* Oid of the subscription */
+ Oid dbid; /* Oid of the database which subscription is
+ * in */
+ char *name; /* Name of the subscription */
+ Oid owner; /* Oid of the subscription owner */
+ bool enabled; /* Indicates if the subscription is enabled */
+ char *conninfo; /* Connection string to the publisher */
+ char *slotname; /* Name of the replication slot */
+ char *synccommit; /* Synchronous commit setting for worker */
+ List *publications; /* List of publication names to subscribe to */
} Subscription;
extern Subscription *GetSubscription(Oid subid, bool missing_ok);
extern void FreeSubscription(Subscription *sub);
-extern Oid get_subscription_oid(const char *subname, bool missing_ok);
+extern Oid get_subscription_oid(const char *subname, bool missing_ok);
extern char *get_subscription_name(Oid subid);
-extern int CountDBSubscriptions(Oid dbid);
+extern int CountDBSubscriptions(Oid dbid);
#endif /* PG_SUBSCRIPTION_H */
Oid srsubid; /* Oid of subscription */
Oid srrelid; /* Oid of relation */
char srsubstate; /* state of the relation in subscription */
- pg_lsn srsublsn; /* remote lsn of the state change
- * used for synchronization coordination */
+ pg_lsn srsublsn; /* remote lsn of the state change used for
+ * synchronization coordination */
} FormData_pg_subscription_rel;
typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
* ----------------
*/
#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
-#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn NULL) */
-#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of apply (sublsn set) */
+#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn
+ * NULL) */
+#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front
+ * of apply (sublsn set) */
#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
/* These are never stored in the catalog, we only use them for IPC. */
} SubscriptionRelState;
extern Oid SetSubscriptionRelState(Oid subid, Oid relid, char state,
- XLogRecPtr sublsn);
+ XLogRecPtr sublsn);
extern char GetSubscriptionRelState(Oid subid, Oid relid,
- XLogRecPtr *sublsn, bool missing_ok);
+ XLogRecPtr *sublsn, bool missing_ok);
extern void RemoveSubscriptionRel(Oid subid, Oid relid);
extern List *GetSubscriptionRelations(Oid subid);
extern ObjectAddress ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString,
- ParamListInfo params, QueryEnvironment *queryEnv, char *completionTag);
+ ParamListInfo params, QueryEnvironment *queryEnv, char *completionTag);
extern int GetIntoRelEFlags(IntoClause *intoClause);
extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
- ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest);
+ ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest);
extern ExplainState *NewExplainState(void);
#include "nodes/parsenodes.h"
extern ObjectAddress CreateSubscription(CreateSubscriptionStmt *stmt,
- bool isTopLevel);
+ bool isTopLevel);
extern ObjectAddress AlterSubscription(AlterSubscriptionStmt *stmt);
extern void DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel);
#define FILE_UTILS_H
extern int fsync_fname(const char *fname, bool isdir,
- const char *progname);
+ const char *progname);
extern void fsync_pgdata(const char *pg_data, const char *progname,
- int serverVersion);
+ int serverVersion);
extern void fsync_dir_recurse(const char *dir, const char *progname);
extern int durable_rename(const char *oldfile, const char *newfile,
- const char *progname);
-extern int fsync_parent_path(const char *fname, const char *progname);
+ const char *progname);
+extern int fsync_parent_path(const char *fname, const char *progname);
#endif /* FILE_UTILS_H */
extern void scram_HMAC_final(uint8 *result, scram_HMAC_ctx *ctx);
extern void scram_SaltedPassword(const char *password, const char *salt,
- int saltlen, int iterations, uint8 *result);
+ int saltlen, int iterations, uint8 *result);
extern void scram_H(const uint8 *str, int len, uint8 *result);
extern void scram_ClientKey(const uint8 *salted_password, uint8 *result);
extern void scram_ServerKey(const uint8 *salted_password, uint8 *result);
extern void ExecutorRun(QueryDesc *queryDesc,
ScanDirection direction, uint64 count, bool execute_once);
extern void standard_ExecutorRun(QueryDesc *queryDesc,
- ScanDirection direction, uint64 count, bool execute_once);
+ ScanDirection direction, uint64 count, bool execute_once);
extern void ExecutorFinish(QueryDesc *queryDesc);
extern void standard_ExecutorFinish(QueryDesc *queryDesc);
extern void ExecutorEnd(QueryDesc *queryDesc);
extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
- const char *relname);
+ const char *relname);
#endif /* EXECUTOR_H */
#include "nodes/execnodes.h"
-extern GatherMergeState *ExecInitGatherMerge(GatherMerge * node,
+extern GatherMergeState *ExecInitGatherMerge(GatherMerge *node,
EState *estate,
int eflags);
-extern TupleTableSlot *ExecGatherMerge(GatherMergeState * node);
-extern void ExecEndGatherMerge(GatherMergeState * node);
-extern void ExecReScanGatherMerge(GatherMergeState * node);
-extern void ExecShutdownGatherMerge(GatherMergeState * node);
+extern TupleTableSlot *ExecGatherMerge(GatherMergeState *node);
+extern void ExecEndGatherMerge(GatherMergeState *node);
+extern void ExecReScanGatherMerge(GatherMergeState *node);
+extern void ExecShutdownGatherMerge(GatherMergeState *node);
#endif /* NODEGATHERMERGE_H */
#define SPI_ERROR_NOATTRIBUTE (-9)
#define SPI_ERROR_NOOUTFUNC (-10)
#define SPI_ERROR_TYPUNKNOWN (-11)
-#define SPI_ERROR_REL_DUPLICATE (-12)
-#define SPI_ERROR_REL_NOT_FOUND (-13)
+#define SPI_ERROR_REL_DUPLICATE (-12)
+#define SPI_ERROR_REL_NOT_FOUND (-13)
#define SPI_OK_CONNECT 1
#define SPI_OK_FINISH 2
extern void SPI_scroll_cursor_move(Portal, FetchDirection direction, long count);
extern void SPI_cursor_close(Portal portal);
-extern int SPI_register_relation(EphemeralNamedRelation enr);
-extern int SPI_unregister_relation(const char *name);
-extern int SPI_register_trigger_data(TriggerData *tdata);
+extern int SPI_register_relation(EphemeralNamedRelation enr);
+extern int SPI_unregister_relation(const char *name);
+extern int SPI_register_trigger_data(TriggerData *tdata);
extern void AtEOXact_SPI(bool isCommit);
extern void AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid);
char *uri);
void (*SetRowFilter) (struct TableFuncScanState *state, char *path);
void (*SetColumnFilter) (struct TableFuncScanState *state,
- char *path, int colnum);
+ char *path, int colnum);
bool (*FetchRow) (struct TableFuncScanState *state);
Datum (*GetValue) (struct TableFuncScanState *state, int colnum,
- Oid typid, int32 typmod, bool *isnull);
+ Oid typid, int32 typmod, bool *isnull);
void (*DestroyOpaque) (struct TableFuncScanState *state);
} TableFuncRoutine;
* - SH_DEFINE - if defined function definitions are generated
* - SH_SCOPE - in which scope (e.g. extern, static inline) do function
* declarations reside
- * - SH_USE_NONDEFAULT_ALLOCATOR - if defined no element allocator functions
- * are defined, so you can supply your own
+ * - SH_USE_NONDEFAULT_ALLOCATOR - if defined no element allocator functions
+ * are defined, so you can supply your own
* The following parameters are only relevant when SH_DEFINE is defined:
* - SH_KEY - name of the element in SH_ELEMENT_TYPE containing the hash key
* - SH_EQUAL(table, a, b) - compare two table keys
/* user defined data, useful for callbacks */
void *private_data;
-} SH_TYPE;
+} SH_TYPE;
typedef enum SH_STATUS
{
uint32 cur; /* current element */
uint32 end;
bool done; /* iterator exhausted? */
-} SH_ITERATOR;
+} SH_ITERATOR;
/* externally visible function prototypes */
SH_SCOPE SH_TYPE *SH_CREATE(MemoryContext ctx, uint32 nelements,
- void *private_data);
-SH_SCOPE void SH_DESTROY(SH_TYPE *tb);
-SH_SCOPE void SH_GROW(SH_TYPE *tb, uint32 newsize);
-SH_SCOPE SH_ELEMENT_TYPE *SH_INSERT(SH_TYPE *tb, SH_KEY_TYPE key, bool *found);
-SH_SCOPE SH_ELEMENT_TYPE *SH_LOOKUP(SH_TYPE *tb, SH_KEY_TYPE key);
-SH_SCOPE bool SH_DELETE(SH_TYPE *tb, SH_KEY_TYPE key);
-SH_SCOPE void SH_START_ITERATE(SH_TYPE *tb, SH_ITERATOR *iter);
-SH_SCOPE void SH_START_ITERATE_AT(SH_TYPE *tb, SH_ITERATOR *iter, uint32 at);
-SH_SCOPE SH_ELEMENT_TYPE *SH_ITERATE(SH_TYPE *tb, SH_ITERATOR *iter);
-SH_SCOPE void SH_STAT(SH_TYPE *tb);
+ void *private_data);
+SH_SCOPE void SH_DESTROY(SH_TYPE * tb);
+SH_SCOPE void SH_GROW(SH_TYPE * tb, uint32 newsize);
+SH_SCOPE SH_ELEMENT_TYPE *SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found);
+SH_SCOPE SH_ELEMENT_TYPE *SH_LOOKUP(SH_TYPE * tb, SH_KEY_TYPE key);
+SH_SCOPE bool SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key);
+SH_SCOPE void SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter);
+SH_SCOPE void SH_START_ITERATE_AT(SH_TYPE * tb, SH_ITERATOR * iter, uint32 at);
+SH_SCOPE SH_ELEMENT_TYPE *SH_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter);
+SH_SCOPE void SH_STAT(SH_TYPE * tb);
#endif /* SH_DECLARE */
* the hashtable.
*/
static inline void
-SH_COMPUTE_PARAMETERS(SH_TYPE *tb, uint32 newsize)
+SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint32 newsize)
{
uint64 size;
/* return the optimal bucket for the hash */
static inline uint32
-SH_INITIAL_BUCKET(SH_TYPE *tb, uint32 hash)
+SH_INITIAL_BUCKET(SH_TYPE * tb, uint32 hash)
{
return hash & tb->sizemask;
}
/* return next bucket after the current, handling wraparound */
static inline uint32
-SH_NEXT(SH_TYPE *tb, uint32 curelem, uint32 startelem)
+SH_NEXT(SH_TYPE * tb, uint32 curelem, uint32 startelem)
{
curelem = (curelem + 1) & tb->sizemask;
/* return bucket before the current, handling wraparound */
static inline uint32
-SH_PREV(SH_TYPE *tb, uint32 curelem, uint32 startelem)
+SH_PREV(SH_TYPE * tb, uint32 curelem, uint32 startelem)
{
curelem = (curelem - 1) & tb->sizemask;
/* return distance between bucket and its optimal position */
static inline uint32
-SH_DISTANCE_FROM_OPTIMAL(SH_TYPE *tb, uint32 optimal, uint32 bucket)
+SH_DISTANCE_FROM_OPTIMAL(SH_TYPE * tb, uint32 optimal, uint32 bucket)
{
if (optimal <= bucket)
return bucket - optimal;
}
static inline uint32
-SH_ENTRY_HASH(SH_TYPE *tb, SH_ELEMENT_TYPE * entry)
+SH_ENTRY_HASH(SH_TYPE * tb, SH_ELEMENT_TYPE * entry)
{
#ifdef SH_STORE_HASH
return SH_GET_HASH(tb, entry);
}
/* default memory allocator function */
-static inline void *SH_ALLOCATE(SH_TYPE *type, Size size);
-static inline void SH_FREE(SH_TYPE *type, void *pointer);
+static inline void *SH_ALLOCATE(SH_TYPE * type, Size size);
+static inline void SH_FREE(SH_TYPE * type, void *pointer);
#ifndef SH_USE_NONDEFAULT_ALLOCATOR
/* default memory allocator function */
static inline void *
-SH_ALLOCATE(SH_TYPE *type, Size size)
+SH_ALLOCATE(SH_TYPE * type, Size size)
{
return MemoryContextAllocExtended(type->ctx, size,
MCXT_ALLOC_HUGE | MCXT_ALLOC_ZERO);
/* default memory free function */
static inline void
-SH_FREE(SH_TYPE *type, void *pointer)
+SH_FREE(SH_TYPE * type, void *pointer)
{
pfree(pointer);
}
/* destroy a previously created hash table */
SH_SCOPE void
-SH_DESTROY(SH_TYPE *tb)
+SH_DESTROY(SH_TYPE * tb)
{
SH_FREE(tb, tb->data);
pfree(tb);
* performance-wise, when known at some point.
*/
SH_SCOPE void
-SH_GROW(SH_TYPE *tb, uint32 newsize)
+SH_GROW(SH_TYPE * tb, uint32 newsize)
{
uint64 oldsize = tb->size;
SH_ELEMENT_TYPE *olddata = tb->data;
* case.
*/
SH_SCOPE SH_ELEMENT_TYPE *
-SH_INSERT(SH_TYPE *tb, SH_KEY_TYPE key, bool *found)
+SH_INSERT(SH_TYPE * tb, SH_KEY_TYPE key, bool *found)
{
uint32 hash = SH_HASH_KEY(tb, key);
uint32 startelem;
* Lookup up entry in hash table. Returns NULL if key not present.
*/
SH_SCOPE SH_ELEMENT_TYPE *
-SH_LOOKUP(SH_TYPE *tb, SH_KEY_TYPE key)
+SH_LOOKUP(SH_TYPE * tb, SH_KEY_TYPE key)
{
uint32 hash = SH_HASH_KEY(tb, key);
const uint32 startelem = SH_INITIAL_BUCKET(tb, hash);
* present.
*/
SH_SCOPE bool
-SH_DELETE(SH_TYPE *tb, SH_KEY_TYPE key)
+SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key)
{
uint32 hash = SH_HASH_KEY(tb, key);
uint32 startelem = SH_INITIAL_BUCKET(tb, hash);
* Initialize iterator.
*/
SH_SCOPE void
-SH_START_ITERATE(SH_TYPE *tb, SH_ITERATOR *iter)
+SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
{
int i;
uint64 startelem = PG_UINT64_MAX;
* same position.
*/
SH_SCOPE void
-SH_START_ITERATE_AT(SH_TYPE *tb, SH_ITERATOR *iter, uint32 at)
+SH_START_ITERATE_AT(SH_TYPE * tb, SH_ITERATOR * iter, uint32 at)
{
/*
* Iterate backwards, that allows the current element to be deleted, even
* visited at least once, nor a guarantee that a node is visited at most once.
*/
SH_SCOPE SH_ELEMENT_TYPE *
-SH_ITERATE(SH_TYPE *tb, SH_ITERATOR *iter)
+SH_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
{
while (!iter->done)
{
* debugging/profiling purposes only.
*/
SH_SCOPE void
-SH_STAT(SH_TYPE *tb)
+SH_STAT(SH_TYPE * tb)
{
uint32 max_chain_length = 0;
uint32 total_chain_length = 0;
bool compat_realm;
bool upn_username;
List *radiusservers;
- char *radiusservers_s;
+ char *radiusservers_s;
List *radiussecrets;
- char *radiussecrets_s;
+ char *radiussecrets_s;
List *radiusidentifiers;
- char *radiusidentifiers_s;
+ char *radiusidentifiers_s;
List *radiusports;
- char *radiusports_s;
+ char *radiusports_s;
} HbaLine;
typedef struct IdentLine
*
* 1. Using a radix tree, from source to destination code.
* 2. Using a sorted array of source -> destination code pairs. This
- * method is used for "combining" characters. There are so few of
- * them that building a radix tree would be wasteful.
+ * method is used for "combining" characters. There are so few of
+ * them that building a radix tree would be wasteful.
* 3. Using a conversion function.
*/
const uint32 *chars32;
/* Radix tree for 1-byte inputs */
- uint32 b1root; /* offset of table in the chars[16|32] array */
- uint8 b1_lower; /* min allowed value for a single byte input */
- uint8 b1_upper; /* max allowed value for a single byte input */
+ uint32 b1root; /* offset of table in the chars[16|32] array */
+ uint8 b1_lower; /* min allowed value for a single byte input */
+ uint8 b1_upper; /* max allowed value for a single byte input */
/* Radix tree for 2-byte inputs */
- uint32 b2root; /* offset of 1st byte's table */
- uint8 b2_1_lower; /* min/max allowed value for 1st input byte */
+ uint32 b2root; /* offset of 1st byte's table */
+ uint8 b2_1_lower; /* min/max allowed value for 1st input byte */
uint8 b2_1_upper;
- uint8 b2_2_lower; /* min/max allowed value for 2nd input byte */
+ uint8 b2_2_lower; /* min/max allowed value for 2nd input byte */
uint8 b2_2_upper;
/* Radix tree for 3-byte inputs */
- uint32 b3root; /* offset of 1st byte's table */
- uint8 b3_1_lower; /* min/max allowed value for 1st input byte */
+ uint32 b3root; /* offset of 1st byte's table */
+ uint8 b3_1_lower; /* min/max allowed value for 1st input byte */
uint8 b3_1_upper;
- uint8 b3_2_lower; /* min/max allowed value for 2nd input byte */
+ uint8 b3_2_lower; /* min/max allowed value for 2nd input byte */
uint8 b3_2_upper;
- uint8 b3_3_lower; /* min/max allowed value for 3rd input byte */
+ uint8 b3_3_lower; /* min/max allowed value for 3rd input byte */
uint8 b3_3_upper;
/* Radix tree for 4-byte inputs */
- uint32 b4root; /* offset of 1st byte's table */
- uint8 b4_1_lower; /* min/max allowed value for 1st input byte */
+ uint32 b4root; /* offset of 1st byte's table */
+ uint8 b4_1_lower; /* min/max allowed value for 1st input byte */
uint8 b4_1_upper;
- uint8 b4_2_lower; /* min/max allowed value for 2nd input byte */
+ uint8 b4_2_lower; /* min/max allowed value for 2nd input byte */
uint8 b4_2_upper;
- uint8 b4_3_lower; /* min/max allowed value for 3rd input byte */
+ uint8 b4_3_lower; /* min/max allowed value for 3rd input byte */
uint8 b4_3_upper;
- uint8 b4_4_lower; /* min/max allowed value for 4th input byte */
+ uint8 b4_4_lower; /* min/max allowed value for 4th input byte */
uint8 b4_4_upper;
} pg_mb_radix_tree;
ParamListInfo es_param_list_info; /* values of external params */
ParamExecData *es_param_exec_vals; /* values of internal params */
- QueryEnvironment *es_queryEnv; /* query environment */
+ QueryEnvironment *es_queryEnv; /* query environment */
/* Other working state: */
MemoryContext es_query_cxt; /* per-query context in which EState lives */
bool *es_epqScanDone; /* true if EPQ tuple has been fetched */
/* The per-query shared memory area to use for parallel execution. */
- struct dsa_area *es_query_dsa;
+ struct dsa_area *es_query_dsa;
} EState;
TupleTableSlot *mt_conflproj; /* CONFLICT ... SET ... projection
* target */
struct PartitionDispatchData **mt_partition_dispatch_info;
- /* Tuple-routing support info */
- int mt_num_dispatch; /* Number of entries in the above
- * array */
- int mt_num_partitions; /* Number of members in the
- * following arrays */
- ResultRelInfo *mt_partitions; /* Per partition result relation */
+ /* Tuple-routing support info */
+ int mt_num_dispatch; /* Number of entries in the above array */
+ int mt_num_partitions; /* Number of members in the following
+ * arrays */
+ ResultRelInfo *mt_partitions; /* Per partition result relation */
TupleConversionMap **mt_partition_tupconv_maps;
- /* Per partition tuple conversion map */
+ /* Per partition tuple conversion map */
TupleTableSlot *mt_partition_tuple_slot;
} ModifyTableState;
extern DefElem *makeDefElem(char *name, Node *arg, int location);
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
- DefElemAction defaction, int location);
+ DefElemAction defaction, int location);
extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int location);
bool is_local; /* column has local (non-inherited) def'n */
bool is_not_null; /* NOT NULL constraint specified? */
bool is_from_type; /* column definition came from table type */
- bool is_from_parent; /* column def came from partition parent */
+ bool is_from_parent; /* column def came from partition parent */
char storage; /* attstorage setting, or 0 for default */
Node *raw_default; /* default value (untransformed parse tree) */
Node *cooked_default; /* default value (transformed expr tree) */
bool is_grant; /* true = GRANT, false = REVOKE */
GrantTargetType targtype; /* type of the grant target */
GrantObjectType objtype; /* kind of object being operated on */
- List *objects; /* list of RangeVar nodes, ObjectWithArgs nodes,
- * or plain names (as Value strings) */
+ List *objects; /* list of RangeVar nodes, ObjectWithArgs
+ * nodes, or plain names (as Value strings) */
List *privileges; /* list of AccessPriv nodes */
/* privileges == NIL denotes ALL PRIVILEGES */
List *grantees; /* list of RoleSpec nodes */
NodeTag type;
List *objname; /* qualified name of function/operator */
List *objargs; /* list of Typename nodes */
- bool args_unspecified; /* argument list was omitted, so name must
- * be unique (note that objargs == NIL means
- * zero args) */
+ bool args_unspecified; /* argument list was omitted, so name
+ * must be unique (note that objargs
+ * == NIL means zero args) */
} ObjectWithArgs;
/*
char *pubname; /* Name of of the publication */
List *options; /* List of DefElem nodes */
List *tables; /* Optional list of tables to add */
- bool for_all_tables; /* Special publication for all tables in db */
+ bool for_all_tables; /* Special publication for all tables in db */
} CreatePublicationStmt;
typedef struct AlterPublicationStmt
/* parameters used for ALTER PUBLICATION ... ADD/DROP TABLE */
List *tables; /* List of tables to add/drop */
- bool for_all_tables; /* Special publication for all tables in db */
- DefElemAction tableAction; /* What action to perform with the tables */
+ bool for_all_tables; /* Special publication for all tables in db */
+ DefElemAction tableAction; /* What action to perform with the tables */
} AlterPublicationStmt;
typedef struct CreateSubscriptionStmt
typedef struct AlterSubscriptionStmt
{
NodeTag type;
- AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
+ AlterSubscriptionType kind; /* ALTER_SUBSCRIPTION_OPTIONS, etc */
char *subname; /* Name of of the subscription */
char *conninfo; /* Connection string to publisher */
List *publication; /* One or more publication to subscribe to */
List *resultRelations; /* integer list of RT indexes, or NIL */
/*
- * rtable indexes of non-leaf target relations for UPDATE/DELETE on
- * all the partitioned table mentioned in the query.
+ * rtable indexes of non-leaf target relations for UPDATE/DELETE on all
+ * the partitioned table mentioned in the query.
*/
List *nonleafResultRelations;
List *partitioned_rels;
List *resultRelations; /* integer list of RT indexes */
int resultRelIndex; /* index of first resultRel in plan's list */
- int rootResultRelIndex; /* index of the partitioned table root */
+ int rootResultRelIndex; /* index of the partitioned table root */
List *plans; /* plan(s) producing source data */
List *withCheckOptionLists; /* per-target-table WCO lists */
List *returningLists; /* per-target-table RETURNING tlists */
List *resultRelations; /* "flat" list of integer RT indexes */
- List *nonleafResultRelations; /* "flat" list of integer RT indexes */
- List *rootResultRelations; /* "flat" list of integer RT indexes */
+ List *nonleafResultRelations; /* "flat" list of integer RT indexes */
+ List *rootResultRelations; /* "flat" list of integer RT indexes */
List *relationOids; /* OIDs of relations the plan depends on */
extern void cost_ctescan(Path *path, PlannerInfo *root,
RelOptInfo *baserel, ParamPathInfo *param_info);
extern void cost_namedtuplestorescan(Path *path, PlannerInfo *root,
- RelOptInfo *baserel, ParamPathInfo *param_info);
+ RelOptInfo *baserel, ParamPathInfo *param_info);
extern void cost_recursive_union(Path *runion, Path *nrterm, Path *rterm);
extern void cost_sort(Path *path, PlannerInfo *root,
List *pathkeys, Cost input_cost, double tuples, int width,
extern void set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel);
extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target);
extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
- Path *bitmapqual, int loop_count, Cost *cost, double *tuple);
+ Path *bitmapqual, int loop_count, Cost *cost, double *tuple);
/*
* prototypes for clausesel.c
JoinType jointype,
SpecialJoinInfo *sjinfo);
extern void cost_gather_merge(GatherMergePath *path, PlannerInfo *root,
- RelOptInfo *rel, ParamPathInfo *param_info,
- Cost input_startup_cost, Cost input_total_cost,
- double *rows);
+ RelOptInfo *rel, ParamPathInfo *param_info,
+ Cost input_startup_cost, Cost input_total_cost,
+ double *rows);
#endif /* COST_H */
RelOptInfo *rel, Path *subpath, PathTarget *target,
Relids required_outer, double *rows);
extern GatherMergePath *create_gather_merge_path(PlannerInfo *root,
- RelOptInfo *rel,
- Path *subpath,
- PathTarget *target,
- List *pathkeys,
- Relids required_outer,
- double *rows);
+ RelOptInfo *rel,
+ Path *subpath,
+ PathTarget *target,
+ List *pathkeys,
+ Relids required_outer,
+ double *rows);
extern SubqueryScanPath *create_subqueryscan_path(PlannerInfo *root,
RelOptInfo *rel, Path *subpath,
List *pathkeys, Relids required_outer);
extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel,
Relids required_outer);
extern Path *create_namedtuplestorescan_path(PlannerInfo *root, RelOptInfo *rel,
- Relids required_outer);
+ Relids required_outer);
extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel,
Relids required_outer);
extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
extern int compute_parallel_worker(RelOptInfo *rel, double heap_pages,
double index_pages);
extern void create_partial_bitmap_paths(PlannerInfo *root, RelOptInfo *rel,
- Path *bitmapqual);
+ Path *bitmapqual);
#ifdef OPTIMIZER_DEBUG
extern void debug_print_rel(PlannerInfo *root, RelOptInfo *rel);
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError);
extern Oid LookupFuncWithArgs(ObjectWithArgs *func,
- bool noError);
+ bool noError);
extern Oid LookupAggWithArgs(ObjectWithArgs *agg,
- bool noError);
+ bool noError);
extern void check_srf_call_placement(ParseState *pstate, int location);
bool p_resolve_unknowns; /* resolve unknown-type SELECT outputs
* as type text */
- QueryEnvironment *p_queryEnv; /* curr env, incl refs to enclosing env */
+ QueryEnvironment *p_queryEnv; /* curr env, incl refs to enclosing
+ * env */
/* Flags telling about things found in the query: */
bool p_hasAggs;
extern Oid LookupOperName(ParseState *pstate, List *opername,
Oid oprleft, Oid oprright,
bool noError, int location);
-extern Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError);
+extern Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError);
/* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */
typedef void (*LogicalOutputPluginWriterUpdateProgress) (
struct LogicalDecodingContext *lr,
- XLogRecPtr Ptr,
+ XLogRecPtr Ptr,
TransactionId xid
);
XLogPageReadCB read_page,
LogicalOutputPluginWriterPrepareWrite prepare_write,
LogicalOutputPluginWriterWrite do_write,
- LogicalOutputPluginWriterUpdateProgress update_progress);
+ LogicalOutputPluginWriterUpdateProgress update_progress);
extern LogicalDecodingContext *CreateDecodingContext(
XLogRecPtr start_lsn,
List *output_plugin_options,
XLogPageReadCB read_page,
LogicalOutputPluginWriterPrepareWrite prepare_write,
LogicalOutputPluginWriterWrite do_write,
- LogicalOutputPluginWriterUpdateProgress update_progress);
+ LogicalOutputPluginWriterUpdateProgress update_progress);
extern void DecodingContextFindStartpoint(LogicalDecodingContext *ctx);
extern bool DecodingContextReady(LogicalDecodingContext *ctx);
extern void FreeDecodingContext(LogicalDecodingContext *ctx);
#ifndef LOGICALLAUNCHER_H
#define LOGICALLAUNCHER_H
-extern int max_logical_replication_workers;
-extern int max_sync_workers_per_subscription;
+extern int max_logical_replication_workers;
+extern int max_sync_workers_per_subscription;
extern void ApplyLauncherRegister(void);
extern void ApplyLauncherMain(Datum main_arg);
typedef struct LogicalRepTupleData
{
/* column values in text format, or NULL for a null value: */
- char *values[MaxTupleAttributeNumber];
+ char *values[MaxTupleAttributeNumber];
/* markers for changed/unchanged column values: */
- bool changed[MaxTupleAttributeNumber];
+ bool changed[MaxTupleAttributeNumber];
} LogicalRepTupleData;
-typedef uint32 LogicalRepRelId;
+typedef uint32 LogicalRepRelId;
/* Relation information */
typedef struct LogicalRepRelation
{
/* Info coming from the remote side. */
- LogicalRepRelId remoteid; /* unique id of the relation */
- char *nspname; /* schema name */
- char *relname; /* relation name */
- int natts; /* number of columns */
- char **attnames; /* column names */
- Oid *atttyps; /* column types */
- char replident; /* replica identity */
- Bitmapset *attkeys; /* Bitmap of key columns */
+ LogicalRepRelId remoteid; /* unique id of the relation */
+ char *nspname; /* schema name */
+ char *relname; /* relation name */
+ int natts; /* number of columns */
+ char **attnames; /* column names */
+ Oid *atttyps; /* column types */
+ char replident; /* replica identity */
+ Bitmapset *attkeys; /* Bitmap of key columns */
} LogicalRepRelation;
/* Type mapping info */
typedef struct LogicalRepTyp
{
- Oid remoteid; /* unique id of the type */
- char *nspname; /* schema name */
- char *typname; /* name of the type */
- Oid typoid; /* local type Oid */
+ Oid remoteid; /* unique id of the type */
+ char *nspname; /* schema name */
+ char *typname; /* name of the type */
+ Oid typoid; /* local type Oid */
} LogicalRepTyp;
/* Transaction info */
typedef struct LogicalRepBeginData
{
- XLogRecPtr final_lsn;
- TimestampTz committime;
- TransactionId xid;
+ XLogRecPtr final_lsn;
+ TimestampTz committime;
+ TransactionId xid;
} LogicalRepBeginData;
typedef struct LogicalRepCommitData
{
- XLogRecPtr commit_lsn;
- XLogRecPtr end_lsn;
- TimestampTz committime;
+ XLogRecPtr commit_lsn;
+ XLogRecPtr end_lsn;
+ TimestampTz committime;
} LogicalRepCommitData;
-extern void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn);
+extern void logicalrep_write_begin(StringInfo out, ReorderBufferTXN *txn);
extern void logicalrep_read_begin(StringInfo in,
LogicalRepBeginData *begin_data);
extern void logicalrep_write_commit(StringInfo out, ReorderBufferTXN *txn,
XLogRecPtr origin_lsn);
extern char *logicalrep_read_origin(StringInfo in, XLogRecPtr *origin_lsn);
extern void logicalrep_write_insert(StringInfo out, Relation rel,
- HeapTuple newtuple);
+ HeapTuple newtuple);
extern LogicalRepRelId logicalrep_read_insert(StringInfo in, LogicalRepTupleData *newtup);
extern void logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
- HeapTuple newtuple);
+ HeapTuple newtuple);
extern LogicalRepRelId logicalrep_read_update(StringInfo in,
bool *has_oldtuple, LogicalRepTupleData *oldtup,
LogicalRepTupleData *newtup);
extern void logicalrep_write_delete(StringInfo out, Relation rel,
- HeapTuple oldtuple);
+ HeapTuple oldtuple);
extern LogicalRepRelId logicalrep_read_delete(StringInfo in,
- LogicalRepTupleData *oldtup);
+ LogicalRepTupleData *oldtup);
extern void logicalrep_write_rel(StringInfo out, Relation rel);
extern LogicalRepRelation *logicalrep_read_rel(StringInfo in);
extern void logicalrep_write_typ(StringInfo out, Oid typoid);
extern void logicalrep_read_typ(StringInfo out, LogicalRepTyp *ltyp);
-#endif /* LOGICALREP_PROTO_H */
+#endif /* LOGICALREP_PROTO_H */
typedef struct LogicalRepRelMapEntry
{
- LogicalRepRelation remoterel; /* key is remoterel.remoteid */
+ LogicalRepRelation remoterel; /* key is remoterel.remoteid */
/* Mapping to local relation, filled as needed. */
- Oid localreloid; /* local relation id */
- Relation localrel; /* relcache entry */
- AttrNumber *attrmap; /* map of local attributes to
- * remote ones */
- bool updatable; /* Can apply updates/deletes? */
+ Oid localreloid; /* local relation id */
+ Relation localrel; /* relcache entry */
+ AttrNumber *attrmap; /* map of local attributes to remote ones */
+ bool updatable; /* Can apply updates/deletes? */
/* Sync state. */
- char state;
- XLogRecPtr statelsn;
+ char state;
+ XLogRecPtr statelsn;
} LogicalRepRelMapEntry;
extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
- LOCKMODE lockmode);
+ LOCKMODE lockmode);
extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
- LOCKMODE lockmode);
+ LOCKMODE lockmode);
extern void logicalrep_typmap_update(LogicalRepTyp *remotetyp);
-extern Oid logicalrep_typmap_getid(Oid remoteid);
+extern Oid logicalrep_typmap_getid(Oid remoteid);
#endif /* LOGICALRELATION_H */
typedef struct PGOutputData
{
- MemoryContext context; /* private memory context for transient
- * allocations */
+ MemoryContext context; /* private memory context for transient
+ * allocations */
/* client info */
- uint32 protocol_version;
+ uint32 protocol_version;
- List *publication_names;
- List *publications;
+ List *publication_names;
+ List *publications;
} PGOutputData;
-#endif /* PGOUTPUT_H */
+#endif /* PGOUTPUT_H */
* that started after this.
*
* Once we reached this we start to collect changes. We cannot apply them
- * yet, because they might be based on transactions that were still running
- * when FULL_SNAPSHOT was reached.
+ * yet, because they might be based on transactions that were still
+ * running when FULL_SNAPSHOT was reached.
*/
SNAPBUILD_FULL_SNAPSHOT = 1,
int config_size; /* total size of this struct, in bytes */
int num_sync; /* number of sync standbys that we need to
* wait for */
- uint8 syncrep_method; /* method to choose sync standbys */
+ uint8 syncrep_method; /* method to choose sync standbys */
int nmembers; /* number of members in the following list */
/* member_names contains nmembers consecutive nul-terminated C strings */
char member_names[FLEXIBLE_ARRAY_MEMBER];
* Latch used by startup process to wake up walreceiver after telling it
* where to start streaming (after setting receiveStart and
* receiveStartTLI), and also to tell it to send apply feedback to the
- * primary whenever specially marked commit records are applied.
- * This is normally mapped to procLatch when walreceiver is running.
+ * primary whenever specially marked commit records are applied. This is
+ * normally mapped to procLatch when walreceiver is running.
*/
Latch *latch;
} WalRcvData;
typedef struct
{
- bool logical; /* True if this is logical
- replication stream, false if
- physical stream. */
- char *slotname; /* Name of the replication slot
- or NULL. */
- XLogRecPtr startpoint; /* LSN of starting point. */
+ bool logical; /* True if this is logical replication stream,
+ * false if physical stream. */
+ char *slotname; /* Name of the replication slot or NULL. */
+ XLogRecPtr startpoint; /* LSN of starting point. */
union
{
struct
{
- TimeLineID startpointTLI; /* Starting timeline */
- } physical;
+ TimeLineID startpointTLI; /* Starting timeline */
+ } physical;
struct
{
- uint32 proto_version; /* Logical protocol version */
- List *publication_names; /* String list of publications */
- } logical;
- } proto;
+ uint32 proto_version; /* Logical protocol version */
+ List *publication_names; /* String list of publications */
+ } logical;
+ } proto;
} WalRcvStreamOptions;
struct WalReceiverConn;
typedef enum
{
WALRCV_ERROR, /* There was error when executing the query. */
- WALRCV_OK_COMMAND, /* Query executed utility or replication command. */
+ WALRCV_OK_COMMAND, /* Query executed utility or replication
+ * command. */
WALRCV_OK_TUPLES, /* Query returned tuples. */
WALRCV_OK_COPY_IN, /* Query started COPY FROM. */
WALRCV_OK_COPY_OUT, /* Query started COPY TO. */
- WALRCV_OK_COPY_BOTH /* Query started COPY BOTH replication protocol. */
+ WALRCV_OK_COPY_BOTH /* Query started COPY BOTH replication
+ * protocol. */
} WalRcvExecStatus;
/*
*/
typedef struct WalRcvExecResult
{
- WalRcvExecStatus status;
- char *err;
- Tuplestorestate *tuplestore;
- TupleDesc tupledesc;
+ WalRcvExecStatus status;
+ char *err;
+ Tuplestorestate *tuplestore;
+ TupleDesc tupledesc;
} WalRcvExecResult;
/* libpqwalreceiver hooks */
typedef WalReceiverConn *(*walrcv_connect_fn) (const char *conninfo, bool logical,
- const char *appname,
- char **err);
+ const char *appname,
+ char **err);
typedef void (*walrcv_check_conninfo_fn) (const char *conninfo);
typedef char *(*walrcv_get_conninfo_fn) (WalReceiverConn *conn);
typedef char *(*walrcv_identify_system_fn) (WalReceiverConn *conn,
- TimeLineID *primary_tli,
- int *server_version);
+ TimeLineID *primary_tli,
+ int *server_version);
typedef void (*walrcv_readtimelinehistoryfile_fn) (WalReceiverConn *conn,
- TimeLineID tli,
- char **filename,
- char **content, int *size);
+ TimeLineID tli,
+ char **filename,
+ char **content, int *size);
typedef bool (*walrcv_startstreaming_fn) (WalReceiverConn *conn,
- const WalRcvStreamOptions *options);
+ const WalRcvStreamOptions *options);
typedef void (*walrcv_endstreaming_fn) (WalReceiverConn *conn,
- TimeLineID *next_tli);
+ TimeLineID *next_tli);
typedef int (*walrcv_receive_fn) (WalReceiverConn *conn, char **buffer,
- pgsocket *wait_fd);
+ pgsocket *wait_fd);
typedef void (*walrcv_send_fn) (WalReceiverConn *conn, const char *buffer,
- int nbytes);
+ int nbytes);
typedef char *(*walrcv_create_slot_fn) (WalReceiverConn *conn,
const char *slotname, bool temporary,
- CRSSnapshotAction snapshot_action,
- XLogRecPtr *lsn);
+ CRSSnapshotAction snapshot_action,
+ XLogRecPtr *lsn);
typedef WalRcvExecResult *(*walrcv_exec_fn) (WalReceiverConn *conn,
- const char *query,
- const int nRetTypes,
- const Oid *retTypes);
+ const char *query,
+ const int nRetTypes,
+ const Oid *retTypes);
typedef void (*walrcv_disconnect_fn) (WalReceiverConn *conn);
typedef struct WalReceiverFunctionsType
{
- walrcv_connect_fn walrcv_connect;
- walrcv_check_conninfo_fn walrcv_check_conninfo;
- walrcv_get_conninfo_fn walrcv_get_conninfo;
- walrcv_identify_system_fn walrcv_identify_system;
- walrcv_readtimelinehistoryfile_fn walrcv_readtimelinehistoryfile;
- walrcv_startstreaming_fn walrcv_startstreaming;
- walrcv_endstreaming_fn walrcv_endstreaming;
- walrcv_receive_fn walrcv_receive;
- walrcv_send_fn walrcv_send;
- walrcv_create_slot_fn walrcv_create_slot;
- walrcv_exec_fn walrcv_exec;
- walrcv_disconnect_fn walrcv_disconnect;
+ walrcv_connect_fn walrcv_connect;
+ walrcv_check_conninfo_fn walrcv_check_conninfo;
+ walrcv_get_conninfo_fn walrcv_get_conninfo;
+ walrcv_identify_system_fn walrcv_identify_system;
+ walrcv_readtimelinehistoryfile_fn walrcv_readtimelinehistoryfile;
+ walrcv_startstreaming_fn walrcv_startstreaming;
+ walrcv_endstreaming_fn walrcv_endstreaming;
+ walrcv_receive_fn walrcv_receive;
+ walrcv_send_fn walrcv_send;
+ walrcv_create_slot_fn walrcv_create_slot;
+ walrcv_exec_fn walrcv_exec;
+ walrcv_disconnect_fn walrcv_disconnect;
} WalReceiverFunctionsType;
extern PGDLLIMPORT WalReceiverFunctionsType *WalReceiverFunctions;
typedef struct LogicalRepWorker
{
/* Time at which this worker was launched. */
- TimestampTz launch_time;
+ TimestampTz launch_time;
/* Indicates if this slot is used or free. */
- bool in_use;
+ bool in_use;
/* Increased everytime the slot is taken by new worker. */
- uint16 generation;
+ uint16 generation;
/* Pointer to proc array. NULL if not running. */
- PGPROC *proc;
+ PGPROC *proc;
/* Database id to connect to. */
- Oid dbid;
+ Oid dbid;
/* User to use for connection (will be same as owner of subscription). */
- Oid userid;
+ Oid userid;
/* Subscription id for the worker. */
- Oid subid;
+ Oid subid;
/* Used for initial table synchronization. */
- Oid relid;
- char relstate;
+ Oid relid;
+ char relstate;
XLogRecPtr relstate_lsn;
slock_t relmutex;
/* Stats. */
XLogRecPtr last_lsn;
- TimestampTz last_send_time;
- TimestampTz last_recv_time;
+ TimestampTz last_send_time;
+ TimestampTz last_recv_time;
XLogRecPtr reply_lsn;
- TimestampTz reply_time;
+ TimestampTz reply_time;
} LogicalRepWorker;
/* Main memory context for apply worker. Permanent during worker lifetime. */
-extern MemoryContext ApplyContext;
+extern MemoryContext ApplyContext;
/* libpqreceiver connection */
-extern struct WalReceiverConn *wrconn;
+extern struct WalReceiverConn *wrconn;
/* Worker and subscription objects. */
-extern Subscription *MySubscription;
-extern LogicalRepWorker *MyLogicalRepWorker;
+extern Subscription *MySubscription;
+extern LogicalRepWorker *MyLogicalRepWorker;
-extern bool in_remote_transaction;
+extern bool in_remote_transaction;
extern volatile sig_atomic_t got_SIGHUP;
extern volatile sig_atomic_t got_SIGTERM;
extern void logicalrep_worker_attach(int slot);
extern LogicalRepWorker *logicalrep_worker_find(Oid subid, Oid relid,
- bool only_running);
+ bool only_running);
extern void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname,
- Oid userid, Oid relid);
+ Oid userid, Oid relid);
extern void logicalrep_worker_stop(Oid subid, Oid relid);
extern void logicalrep_worker_wakeup(Oid subid, Oid relid);
extern void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker);
-extern int logicalrep_sync_worker_count(Oid subid);
+extern int logicalrep_sync_worker_count(Oid subid);
extern void logicalrep_worker_sighup(SIGNAL_ARGS);
extern void logicalrep_worker_sigterm(SIGNAL_ARGS);
extern char *LogicalRepSyncTableStart(XLogRecPtr *origin_startpos);
-void process_syncing_tables(XLogRecPtr current_lsn);
+void process_syncing_tables(XLogRecPtr current_lsn);
void invalidate_syncing_table_states(Datum arg, int cacheid,
- uint32 hashvalue);
+ uint32 hashvalue);
static inline bool
am_tablesync_worker(void)
extern MVNDistinct *statext_ndistinct_deserialize(bytea *data);
extern MVDependencies *statext_dependencies_build(int numrows, HeapTuple *rows,
- Bitmapset *attrs, VacAttrStats **stats);
+ Bitmapset *attrs, VacAttrStats **stats);
extern bytea *statext_dependencies_serialize(MVDependencies *dependencies);
extern MVDependencies *statext_dependencies_deserialize(bytea *data);
extern void multi_sort_add_dimension(MultiSortSupport mss, int sortdim,
Oid oper);
extern int multi_sort_compare(const void *a, const void *b, void *arg);
-extern int multi_sort_compare_dim(int dim, const SortItem * a,
- const SortItem * b, MultiSortSupport mss);
-extern int multi_sort_compare_dims(int start, int end, const SortItem * a,
- const SortItem * b, MultiSortSupport mss);
+extern int multi_sort_compare_dim(int dim, const SortItem *a,
+ const SortItem *b, MultiSortSupport mss);
+extern int multi_sort_compare_dims(int start, int end, const SortItem *a,
+ const SortItem *b, MultiSortSupport mss);
#endif /* EXTENDED_STATS_INTERNAL_H */
typedef struct
{
slock_t mutex;
- proclist_head wakeup;
+ proclist_head wakeup;
} ConditionVariable;
/* Initialize a condition variable. */
/* Wake up a single waiter (via signal) or all waiters (via broadcast). */
extern bool ConditionVariableSignal(ConditionVariable *);
-extern int ConditionVariableBroadcast(ConditionVariable *);
+extern int ConditionVariableBroadcast(ConditionVariable *);
#endif /* CONDITION_VARIABLE_H */
Oid databaseId; /* OID of database this backend is using */
Oid roleId; /* OID of role using this backend */
- bool isBackgroundWorker; /* true if background worker. */
+ bool isBackgroundWorker; /* true if background worker. */
/*
* While in hot standby mode, shows that a conflict signal has been sent
* to avoid forcing to include proc.h when including procarray.h. So if you modify
* PROC_XXX flags, you need to modify these flags.
*/
-#define PROCARRAY_VACUUM_FLAG 0x02 /* currently running lazy vacuum */
-#define PROCARRAY_ANALYZE_FLAG 0x04 /* currently running analyze */
-#define PROCARRAY_LOGICAL_DECODING_FLAG 0x10 /* currently doing logical
- * decoding outside xact */
-
-#define PROCARRAY_SLOTS_XMIN 0x20 /* replication slot xmin,
- * catalog_xmin */
+#define PROCARRAY_VACUUM_FLAG 0x02 /* currently running
+ * lazy vacuum */
+#define PROCARRAY_ANALYZE_FLAG 0x04 /* currently running
+ * analyze */
+#define PROCARRAY_LOGICAL_DECODING_FLAG 0x10 /* currently doing
+ * logical decoding
+ * outside xact */
+
+#define PROCARRAY_SLOTS_XMIN 0x20 /* replication slot
+ * xmin, catalog_xmin */
/*
* Only flags in PROCARRAY_PROC_FLAGS_MASK are considered when matching
* PGXACT->vacuumFlags. Other flags are used for different purposes and
/* Hook for plugins to get control in ProcessUtility() */
typedef void (*ProcessUtility_hook_type) (PlannedStmt *pstmt,
const char *queryString, ProcessUtilityContext context,
- ParamListInfo params,
- QueryEnvironment *queryEnv,
+ ParamListInfo params,
+ QueryEnvironment *queryEnv,
DestReceiver *dest, char *completionTag);
extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
typedef void (*JsonIterateStringValuesAction) (void *state, char *elem_value, int elem_len);
/* an action that will be applied to each value in transform_json(b)_string_values functions */
-typedef text * (*JsonTransformStringValuesAction) (void *state, char *elem_value, int elem_len);
+typedef text *(*JsonTransformStringValuesAction) (void *state, char *elem_value, int elem_len);
extern void iterate_jsonb_string_values(Jsonb *jb, void *state,
- JsonIterateStringValuesAction action);
+ JsonIterateStringValuesAction action);
extern void iterate_json_string_values(text *json, void *action_state,
- JsonIterateStringValuesAction action);
+ JsonIterateStringValuesAction action);
extern Jsonb *transform_jsonb_string_values(Jsonb *jsonb, void *action_state,
- JsonTransformStringValuesAction transform_action);
+ JsonTransformStringValuesAction transform_action);
extern text *transform_json_string_values(text *json, void *action_state,
- JsonTransformStringValuesAction transform_action);
+ JsonTransformStringValuesAction transform_action);
#endif /* JSONAPI_H */
extern char *get_attname(Oid relid, AttrNumber attnum);
extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
extern AttrNumber get_attnum(Oid relid, const char *attname);
-extern char get_attidentity(Oid relid, AttrNumber attnum);
+extern char get_attidentity(Oid relid, AttrNumber attnum);
extern Oid get_atttype(Oid relid, AttrNumber attnum);
extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
*/
struct pg_locale_struct
{
- char provider;
+ char provider;
union
{
#ifdef HAVE_LOCALE_T
- locale_t lt;
+ locale_t lt;
#endif
#ifdef USE_ICU
- struct {
+ struct
+ {
const char *locale;
- UCollator *ucol;
- } icu;
+ UCollator *ucol;
+ } icu;
#endif
int dummy; /* in case we have neither LOCALE_T nor ICU */
- } info;
+ } info;
};
typedef struct pg_locale_struct *pg_locale_t;
extern bool CachedPlanIsValid(CachedPlanSource *plansource);
extern List *CachedPlanGetTargetList(CachedPlanSource *plansource,
- QueryEnvironment *queryEnv);
+ QueryEnvironment *queryEnv);
extern CachedPlan *GetCachedPlan(CachedPlanSource *plansource,
ParamListInfo boundParams,
*/
typedef struct EphemeralNamedRelationMetadataData
{
- char *name; /* name used to identify the relation */
+ char *name; /* name used to identify the relation */
/* only one of the next two fields should be used */
- Oid reliddesc; /* oid of relation to get tupdesc */
- TupleDesc tupdesc; /* description of result rows */
+ Oid reliddesc; /* oid of relation to get tupdesc */
+ TupleDesc tupdesc; /* description of result rows */
EphemeralNameRelationType enrtype; /* to identify type of relation */
- double enrtuples; /* estimated number of tuples */
+ double enrtuples; /* estimated number of tuples */
} EphemeralNamedRelationMetadataData;
typedef EphemeralNamedRelationMetadataData *EphemeralNamedRelationMetadata;
*/
typedef struct EphemeralNamedRelationData
{
- EphemeralNamedRelationMetadataData md;
+ EphemeralNamedRelationMetadataData md;
void *reldata; /* structure for execution-time access to data */
} EphemeralNamedRelationData;
/*-------------------------------------------------------------------------
*
* regproc.h
- * Functions for the built-in types regproc, regclass, regtype, etc.
+ * Functions for the built-in types regproc, regclass, regtype, etc.
*
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
bool *parttypbyval;
char *parttypalign;
Oid *parttypcoll;
-} PartitionKeyData;
+} PartitionKeyData;
typedef struct PartitionKeyData *PartitionKey;
Bitmapset *rd_pkattr; /* cols included in primary key */
Bitmapset *rd_idattr; /* included in replica identity index */
- PublicationActions *rd_pubactions; /* publication actions */
+ PublicationActions *rd_pubactions; /* publication actions */
/*
* rd_options is set whenever rd_rel is loaded into the relcache entry.
/*-------------------------------------------------------------------------
*
* varlena.h
- * Functions for the variable-length built-in types.
+ * Functions for the variable-length built-in types.
*
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
{
*success = false;
printfPQExpBuffer(errorMessage,
- libpq_gettext("invalid server signature\n"));
+ libpq_gettext("invalid server signature\n"));
}
*done = true;
state->state = FE_SCRAM_FINISHED;
#endif
#define near
#include <shlobj.h>
-#ifdef _MSC_VER /* mstcpip.h is missing on mingw */
+#ifdef _MSC_VER /* mstcpip.h is missing on mingw */
#include <mstcpip.h>
#endif
#else
if ((conn->pghostaddr == NULL || conn->pghostaddr[0] == '\0')
&& conn->pghost != NULL)
{
- char *s;
+ char *s;
for (s = conn->pghost; *s != '\0'; ++s)
if (*s == ',')
goto oom_error;
/*
- * We now have one pg_conn_host structure per possible host. Fill in
- * the host details for each one.
+ * We now have one pg_conn_host structure per possible host. Fill in the
+ * host details for each one.
*/
if (conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0')
{
}
else if (conn->pghost != NULL && conn->pghost[0] != '\0')
{
- int i = 0;
- char *s = conn->pghost;
+ int i = 0;
+ char *s = conn->pghost;
while (1)
{
- char *e = s;
+ char *e = s;
/*
* Search for the end of the current hostname; a comma or
*/
if (conn->pgport != NULL && conn->pgport[0] != '\0')
{
- int i = 0;
- char *s = conn->pgport;
- int nports = 1;
+ int i = 0;
+ char *s = conn->pgport;
+ int nports = 1;
for (i = 0; i < conn->nconnhost; ++i)
{
- char *e = s;
+ char *e = s;
/* Search for the end of the current port number. */
while (*e != '\0' && *e != ',')
}
/*
- * Move on to the next port number, unless there are no more.
- * (If only one part number is specified, we reuse it for every
- * host.)
+ * Move on to the next port number, unless there are no more. (If
+ * only one part number is specified, we reuse it for every host.)
*/
if (*e != '\0')
{
{
conn->status = CONNECTION_BAD;
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not match %d port numbers to %d hosts\n"),
+ libpq_gettext("could not match %d port numbers to %d hosts\n"),
nports, conn->nconnhost);
return false;
}
}
/*
- * Supply default password if none given. Note that the password might
- * be different for each host/port pair.
+ * Supply default password if none given. Note that the password might be
+ * different for each host/port pair.
*/
if (conn->pgpass == NULL || conn->pgpass[0] == '\0')
{
- int i;
+ int i;
if (conn->pgpassfile == NULL || conn->pgpassfile[0] == '\0')
{
for (i = 0; i < conn->nconnhost; i++)
{
/*
- * Try to get a password for this host from pgpassfile. We use host
- * name rather than host address in the same manner to PQhost().
+ * Try to get a password for this host from pgpassfile. We use
+ * host name rather than host address in the same manner to
+ * PQhost().
*/
- char *pwhost = conn->connhost[i].host;
+ char *pwhost = conn->connhost[i].host;
if (conn->connhost[i].type == CHT_HOST_ADDRESS &&
conn->pghost != NULL && conn->pghost[0] != '\0')
{
conn->status = CONNECTION_BAD;
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("invalid target_session_attrs value: \"%s\"\n"),
+ libpq_gettext("invalid target_session_attrs value: \"%s\"\n"),
conn->target_session_attrs);
return false;
}
{
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("Unix-domain socket path \"%s\" is too long (maximum %d bytes)\n"),
- portstr,
- (int) (UNIXSOCK_PATH_BUFLEN - 1));
+ portstr,
+ (int) (UNIXSOCK_PATH_BUFLEN - 1));
conn->options_valid = false;
goto connect_errReturn;
}
strcmp(conn->target_session_attrs, "read-write") == 0)
{
/*
- * We are yet to make a connection. Save all existing error
- * messages until we make a successful connection state.
- * This is important because PQsendQuery is going to reset
- * conn->errorMessage and we will lose error messages
- * related to previous hosts we have tried to connect and
- * failed.
+ * We are yet to make a connection. Save all existing
+ * error messages until we make a successful connection
+ * state. This is important because PQsendQuery is going
+ * to reset conn->errorMessage and we will lose error
+ * messages related to previous hosts we have tried to
+ * connect and failed.
*/
if (!saveErrorMessage(conn, &savedMessage))
goto error_return;
release_all_addrinfo(conn);
/*
- * Finish reading any remaining messages before
- * being considered as ready.
+ * Finish reading any remaining messages before being
+ * considered as ready.
*/
conn->status = CONNECTION_CONSUME;
goto keep_going;
char *user = NULL;
char *host = NULL;
bool retval = false;
- PQExpBufferData hostbuf;
- PQExpBufferData portbuf;
+ PQExpBufferData hostbuf;
+ PQExpBufferData portbuf;
initPQExpBuffer(&hostbuf);
initPQExpBuffer(&portbuf);
host = p;
/*
- * Look for port specifier (colon) or end of host specifier (slash)
- * or query (question mark) or host separator (comma).
+ * Look for port specifier (colon) or end of host specifier
+ * (slash) or query (question mark) or host separator (comma).
*/
while (*p && *p != ':' && *p != '/' && *p != '?' && *p != ',')
++p;
if (prevchar == ':')
{
- const char *port = ++p; /* advance past host terminator */
+ const char *port = ++p; /* advance past host terminator */
while (*p && *p != '/' && *p != '?' && *p != ',')
++p;
if (prevchar != ',')
break;
- ++p; /* advance past comma separator */
+ ++p; /* advance past comma separator */
appendPQExpBufferStr(&hostbuf, ",");
appendPQExpBufferStr(&portbuf, ",");
}
char *
PQpass(const PGconn *conn)
{
- char *password = NULL;
+ char *password = NULL;
if (!conn)
return NULL;
int
PQconnectionNeedsPassword(const PGconn *conn)
{
- char *password;
+ char *password;
if (!conn)
return false;
if (conn->ssl == NULL)
{
/*
- * Create a connection-specific SSL object, and load client certificate,
- * private key, and trusted CA certs.
+ * Create a connection-specific SSL object, and load client
+ * certificate, private key, and trusted CA certs.
*/
if (initialize_SSL(conn) != 0)
{
CRYPTO_set_id_callback(NULL);
/*
- * We don't free the lock array. If we get another connection in
- * this process, we will just re-use them with the existing mutexes.
+ * We don't free the lock array. If we get another connection in this
+ * process, we will just re-use them with the existing mutexes.
*
* This means we leak a little memory on repeated load/unload of the
* library.
static int
initialize_SSL(PGconn *conn)
{
- SSL_CTX *SSL_context;
+ SSL_CTX *SSL_context;
struct stat buf;
char homedir[MAXPGPATH];
char fnbuf[MAXPGPATH];
* Create a new SSL_CTX object.
*
* We used to share a single SSL_CTX between all connections, but it was
- * complicated if connections used different certificates. So now we create
- * a separate context for each connection, and accept the overhead.
+ * complicated if connections used different certificates. So now we
+ * create a separate context for each connection, and accept the overhead.
*/
SSL_context = SSL_CTX_new(SSLv23_method());
if (!SSL_context)
char *err = SSLerrmessage(ERR_get_error());
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create SSL context: %s\n"),
- err);
+ libpq_gettext("could not create SSL context: %s\n"),
+ err);
SSLerrfree(err);
return -1;
}
SSL_CTX_set_options(SSL_context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
/*
- * Disable OpenSSL's moving-write-buffer sanity check, because it
- * causes unnecessary failures in nonblocking send cases.
+ * Disable OpenSSL's moving-write-buffer sanity check, because it causes
+ * unnecessary failures in nonblocking send cases.
*/
SSL_CTX_set_mode(SSL_context, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
{
/*
* Cert file exists, so load it. Since OpenSSL doesn't provide the
- * equivalent of "SSL_use_certificate_chain_file", we have to load
- * it into the SSL context, rather than the SSL object.
+ * equivalent of "SSL_use_certificate_chain_file", we have to load it
+ * into the SSL context, rather than the SSL object.
*/
if (SSL_CTX_use_certificate_chain_file(SSL_context, fnbuf) != 1)
{
}
/*
- * The SSL context is now loaded with the correct root and client certificates.
- * Create a connection-specific SSL object. The private key is loaded directly
- * into the SSL object. (We could load the private key into the context, too, but
- * we have done it this way historically, and it doesn't really matter.)
+ * The SSL context is now loaded with the correct root and client
+ * certificates. Create a connection-specific SSL object. The private key
+ * is loaded directly into the SSL object. (We could load the private key
+ * into the context, too, but we have done it this way historically, and
+ * it doesn't really matter.)
*/
if (!(conn->ssl = SSL_new(SSL_context)) ||
!SSL_set_app_data(conn->ssl, conn) ||
conn->ssl_in_use = true;
/*
- * SSL contexts are reference counted by OpenSSL. We can free it as soon as we
- * have created the SSL object, and it will stick around for as long as it's
- * actually needed.
+ * SSL contexts are reference counted by OpenSSL. We can free it as soon
+ * as we have created the SSL object, and it will stick around for as long
+ * as it's actually needed.
*/
SSL_CTX_free(SSL_context);
SSL_context = NULL;
}
/*
- * If a root cert was loaded, also set our certificate verification callback.
+ * If a root cert was loaded, also set our certificate verification
+ * callback.
*/
if (have_rootcert)
SSL_set_verify(conn->ssl, SSL_VERIFY_PEER, verify_cb);
my_bio_methods = BIO_meth_new(my_bio_index, "libpq socket");
if (!my_bio_methods)
return NULL;
+
/*
- * As of this writing, these functions never fail. But check anyway, like
- * OpenSSL's own examples do.
+ * As of this writing, these functions never fail. But check anyway,
+ * like OpenSSL's own examples do.
*/
if (!BIO_meth_set_write(my_bio_methods, my_sock_write) ||
!BIO_meth_set_read(my_bio_methods, my_sock_read) ||
!BIO_meth_set_puts(my_bio_methods, BIO_meth_get_puts(biom)) ||
!BIO_meth_set_ctrl(my_bio_methods, BIO_meth_get_ctrl(biom)) ||
!BIO_meth_set_create(my_bio_methods, BIO_meth_get_create(biom)) ||
- !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) ||
+ !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) ||
!BIO_meth_set_callback_ctrl(my_bio_methods, BIO_meth_get_callback_ctrl(biom)))
{
BIO_meth_free(my_bio_methods);
CONNECTION_NEEDED, /* Internal state: connect() needed */
CONNECTION_CHECK_WRITABLE, /* Check if we could make a writable
* connection. */
- CONNECTION_CONSUME /* Wait for any pending message and
- * consume them. */
+ CONNECTION_CONSUME /* Wait for any pending message and consume
+ * them. */
} ConnStatusType;
typedef enum
HV *hvTD;
ErrorContextCallback pl_error_context;
TriggerData *tdata;
- int rc PG_USED_FOR_ASSERTS_ONLY;
+ int rc PG_USED_FOR_ASSERTS_ONLY;
/* Connect to SPI manager */
if (SPI_connect() != SPI_OK_CONNECT)
typedef struct PLpgSQL_nsitem
{
PLpgSQL_nsitem_type itemtype;
+
/*
* For labels, itemno is a value of enum PLpgSQL_label_type. For other
* itemtypes, itemno is the associated PLpgSQL_datum's dno.
int lineno;
PLpgSQL_expr *sqlstmt;
bool mod_stmt; /* is the stmt INSERT/UPDATE/DELETE? Note:
- mod_stmt is set when we plan the query */
+ * mod_stmt is set when we plan the query */
bool into; /* INTO supplied? */
bool strict; /* INTO STRICT flag */
PLpgSQL_rec *rec; /* INTO target, if record */
PG_TRY();
{
- int rc PG_USED_FOR_ASSERTS_ONLY;
+ int rc PG_USED_FOR_ASSERTS_ONLY;
rc = SPI_register_trigger_data(tdata);
Assert(rc >= 0);
/*
* We iterate the SQL array in the physical order it's stored in the
- * datum. For example, for a 3-dimensional array the order of iteration would
- * be the following: [0,0,0] elements through [0,0,k], then [0,1,0] through
- * [0,1,k] till [0,m,k], then [1,0,0] through [1,0,k] till [1,m,k], and so on.
+ * datum. For example, for a 3-dimensional array the order of iteration
+ * would be the following: [0,0,0] elements through [0,0,k], then [0,1,0]
+ * through [0,1,k] till [0,m,k], then [1,0,0] through [1,0,k] till
+ * [1,m,k], and so on.
*
* In Python, there are no multi-dimensional lists as such, but they are
* represented as a list of lists. So a 3-d array of [n,m,k] elements is a
* literal.
*
* To make that less confusing to users who are upgrading from older
- * versions, try to give a hint in the typical instances of that. If we are
- * parsing an array of composite types, and we see a string literal that
- * is not a valid record literal, give a hint. We only want to give the
- * hint in the narrow case of a malformed string literal, not any error
- * from record_in(), so check for that case here specifically.
+ * versions, try to give a hint in the typical instances of that. If we
+ * are parsing an array of composite types, and we see a string literal
+ * that is not a valid record literal, give a hint. We only want to give
+ * the hint in the narrow case of a malformed string literal, not any
+ * error from record_in(), so check for that case here specifically.
*
* This check better match the one in record_in(), so that we don't forbid
* literals that are actually valid!
const char *result;
int result_Objc;
Tcl_Obj **result_Objv;
- int rc PG_USED_FOR_ASSERTS_ONLY;
+ int rc PG_USED_FOR_ASSERTS_ONLY;
call_state->trigdata = trigdata;
if (GetLastError() == ERROR_DELETE_PENDING)
{
/*
- * File has been deleted, but is not gone from the filesystem
- * yet. This can happen when some process with FILE_SHARE_DELETE
- * has it open and it will be fully removed once that handle
- * is closed. Meanwhile, we can't open it, so indicate that
- * the file just doesn't exist.
+ * File has been deleted, but is not gone from the filesystem yet.
+ * This can happen when some process with FILE_SHARE_DELETE has it
+ * open and it will be fully removed once that handle is closed.
+ * Meanwhile, we can't open it, so indicate that the file just
+ * doesn't exist.
*/
errno = ENOENT;
return -1;
Datum
widget_out(PG_FUNCTION_ARGS)
{
- WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
- char *str = psprintf("(%g,%g,%g)",
- widget->center.x, widget->center.y, widget->radius);
+ WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(0);
+ char *str = psprintf("(%g,%g,%g)",
+ widget->center.x, widget->center.y, widget->radius);
+
PG_RETURN_CSTRING(str);
}
int64 hi;
#endif
} hl;
-} test128;
+} test128;
/*