int64 statementId; /* Simple counter */
int64 substatementId; /* Simple counter */
- LogStmtLevel logStmtLevel; /* From GetCommandLogLevel when possible, */
- /* generated when not. */
+ LogStmtLevel logStmtLevel; /* From GetCommandLogLevel when possible,
+ * generated when not. */
NodeTag commandTag; /* same here */
const char *command; /* same here */
- const char *objectType; /* From event trigger when possible */
- /* generated when not. */
+ const char *objectType; /* From event trigger when possible, generated
+ * when not. */
char *objectName; /* Fully qualified object identification */
const char *commandText; /* sourceText / queryString */
ParamListInfo paramList; /* QueryDesc/ProcessUtility parameters */
bool granted; /* Audit role has object permissions? */
- bool logged; /* Track if we have logged this event, used */
- /* post-ProcessUtility to make sure we log */
+ bool logged; /* Track if we have logged this event, used
+ * post-ProcessUtility to make sure we log */
bool statementLogged; /* Track if we have logged the statement */
} AuditEvent;
/* Classify the statement using log stmt level and the command tag */
switch (stackItem->auditEvent.logStmtLevel)
{
- /* All mods go in WRITE class, execpt EXECUTE */
+ /* All mods go in WRITE class, except EXECUTE */
case LOGSTMT_MOD:
className = CLASS_WRITE;
class = LOG_WRITE;
break;
}
- /*
+ /*----------
* Only log the statement if:
*
- * 1. If object was selected for audit logging (granted) 2. The statement
- * belongs to a class that is being logged
+ * 1. If object was selected for audit logging (granted), or
+ * 2. The statement belongs to a class that is being logged
*
* If neither of these is true, return.
+ *----------
*/
if (!stackItem->auditEvent.granted && !(auditLogBitmap & class))
return;
switch (rte->relkind)
{
case RELKIND_RELATION:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_TABLE;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_TABLE;
break;
case RELKIND_INDEX:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_INDEX;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_INDEX;
break;
case RELKIND_SEQUENCE:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_SEQUENCE;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_SEQUENCE;
break;
case RELKIND_TOASTVALUE:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_TOASTVALUE;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_TOASTVALUE;
break;
case RELKIND_VIEW:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_VIEW;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_VIEW;
break;
case RELKIND_COMPOSITE_TYPE:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_COMPOSITE_TYPE;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_COMPOSITE_TYPE;
break;
case RELKIND_FOREIGN_TABLE:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_FOREIGN_TABLE;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_FOREIGN_TABLE;
break;
case RELKIND_MATVIEW:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_MATVIEW;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_MATVIEW;
break;
default:
- auditEventStack->auditEvent.objectType =
- OBJECT_TYPE_UNKNOWN;
-
+ auditEventStack->auditEvent.objectType = OBJECT_TYPE_UNKNOWN;
break;
}
/* Perform object auditing only if the audit role is valid */
if (auditOid != InvalidOid)
{
- AclMode auditPerms =
- (ACL_SELECT | ACL_UPDATE | ACL_INSERT | ACL_DELETE) &
- rte->requiredPerms;
+ AclMode auditPerms = (ACL_SELECT | ACL_UPDATE | ACL_INSERT | ACL_DELETE) & rte->requiredPerms;
/*
* If any of the required permissions for the relation are granted
stackItem->auditEvent.commandTag = T_DoStmt;
stackItem->auditEvent.command = COMMAND_EXECUTE;
stackItem->auditEvent.objectType = OBJECT_TYPE_FUNCTION;
-
stackItem->auditEvent.commandText = stackItem->next->auditEvent.commandText;
log_audit_event(stackItem);
/* Supply object name and type for audit event */
auditEventStack->auditEvent.objectType =
- SPI_getvalue(spiTuple, spiTupDesc, 1);
-
+ SPI_getvalue(spiTuple, spiTupDesc, 1);
auditEventStack->auditEvent.objectName =
SPI_getvalue(spiTuple, spiTupDesc, 2);
spiTuple = SPI_tuptable->vals[row];
auditEventStack->auditEvent.objectType =
- SPI_getvalue(spiTuple, spiTupDesc, 1);
-
+ SPI_getvalue(spiTuple, spiTupDesc, 1);
auditEventStack->auditEvent.objectName =
SPI_getvalue(spiTuple, spiTupDesc, 2);
foreach(lt, flagRawList)
{
+ char *token = (char *) lfirst(lt);
bool subtract = false;
int class;
- /* Retrieve a token */
- char *token = (char *) lfirst(lt);
-
/* If token is preceded by -, then the token is subtractive */
- if (strstr(token, "-") == token)
+ if (token[0] == '-')
{
- token = token + 1;
+ token++;
subtract = true;
}
tsm_bernoulli_nextblock(PG_FUNCTION_ARGS)
{
TableSampleDesc *tsdesc = (TableSampleDesc *) PG_GETARG_POINTER(0);
- BernoulliSamplerData *sampler =
- (BernoulliSamplerData *) tsdesc->tsmdata;
+ BernoulliSamplerData *sampler = (BernoulliSamplerData *) tsdesc->tsmdata;
/*
* Bernoulli sampling scans all blocks on the table and supports syncscan
* tuples have same probability of being returned the visible and invisible
* tuples will be returned in same ratio as they have in the actual table.
* This means that there is no skew towards either visible or invisible tuples
- * and the number returned visible tuples to from the executor node is the
- * fraction of visible tuples which was specified in input.
+ * and the number of visible tuples returned from the executor node should
+ * match the fraction of visible tuples which was specified by user.
*
- * This is faster than doing the coinflip in the examinetuple because we don't
+ * This is faster than doing the coinflip in examinetuple because we don't
* have to do visibility checks on uninteresting tuples.
*
* If we reach end of the block return InvalidOffsetNumber which tells
{
TableSampleDesc *tsdesc = (TableSampleDesc *) PG_GETARG_POINTER(0);
OffsetNumber maxoffset = PG_GETARG_UINT16(2);
- BernoulliSamplerData *sampler =
- (BernoulliSamplerData *) tsdesc->tsmdata;
+ BernoulliSamplerData *sampler = (BernoulliSamplerData *) tsdesc->tsmdata;
OffsetNumber tupoffset = sampler->lt;
float4 probability = sampler->probability;
tsm_bernoulli_reset(PG_FUNCTION_ARGS)
{
TableSampleDesc *tsdesc = (TableSampleDesc *) PG_GETARG_POINTER(0);
- BernoulliSamplerData *sampler =
- (BernoulliSamplerData *) tsdesc->tsmdata;
+ BernoulliSamplerData *sampler = (BernoulliSamplerData *) tsdesc->tsmdata;
sampler->blockno = InvalidBlockNumber;
sampler->lt = InvalidOffsetNumber;
fcinfo.argnull[0] = false;
/*
- * Second arg for init function is always REPEATABLE When
- * tablesample->repeatable is NULL then REPEATABLE clause was not
- * specified. When specified, the expression cannot evaluate to NULL.
+ * Second arg for init function is always REPEATABLE.
+ *
+ * If tablesample->repeatable is NULL then REPEATABLE clause was not
+ * specified, and we insert a random value as default.
+ *
+ * When specified, the expression cannot evaluate to NULL.
*/
if (tablesample->repeatable)
{
* overall targetlist's econtext. GroupingFunc arguments are never
* evaluated at all.
*/
- if (IsA(node, Aggref) ||IsA(node, GroupingFunc))
+ if (IsA(node, Aggref))
return false;
if (IsA(node, WindowFunc))
return false;
+ if (IsA(node, GroupingFunc))
+ return false;
return expression_tree_walker(node, get_last_attnums,
(void *) projInfo);
}
/*
* get state info from node
*
- * econtext is the per-output-tuple expression context tmpcontext is the
- * per-input-tuple expression context
+ * econtext is the per-output-tuple expression context
+ *
+ * tmpcontext is the per-input-tuple expression context
*/
econtext = aggstate->ss.ps.ps_ExprContext;
tmpcontext = aggstate->tmpcontext;
else
nextSetSize = 0;
- /*-
+ /*----------
* If a subgroup for the current grouping set is present, project it.
*
* We have a new group if:
* AND
* - the previous and pending rows differ on the grouping columns
* of the next grouping set
+ *----------
*/
if (aggstate->input_done ||
(node->aggstrategy == AGG_SORTED &&
* Buckets are simple pointers to hashjoin tuples, while tupsize
* includes the pointer, hash code, and MinimalTupleData. So buckets
* should never really exceed 25% of work_mem (even for
- * NTUP_PER_BUCKET=1); except maybe * for work_mem values that are not
- * 2^N bytes, where we might get more * because of doubling. So let's
+ * NTUP_PER_BUCKET=1); except maybe for work_mem values that are not
+ * 2^N bytes, where we might get more because of doubling. So let's
* look for 50% here.
*/
Assert(bucket_bytes <= hash_table_bytes / 2);
if (batchno == curbatch)
{
/* keep tuple in memory - copy it into the new chunk */
- HashJoinTuple copyTuple =
- (HashJoinTuple) dense_alloc(hashtable, hashTupleSize);
+ HashJoinTuple copyTuple;
+ copyTuple = (HashJoinTuple) dense_alloc(hashtable, hashTupleSize);
memcpy(copyTuple, hashTuple, hashTupleSize);
/* and add it back to the appropriate bucket */
* whether HAVING succeeds. Furthermore, there cannot be any
* variables in either HAVING or the targetlist, so we
* actually do not need the FROM table at all! We can just
- * throw away the plan-so-far and generate a Result node.
- * This is a sufficiently unusual corner case that it's not
- * worth contorting the structure of this routine to avoid
- * having to generate the plan in the first place.
+ * throw away the plan-so-far and generate a Result node. This
+ * is a sufficiently unusual corner case that it's not worth
+ * contorting the structure of this routine to avoid having to
+ * generate the plan in the first place.
*/
result_plan = (Plan *) make_result(root,
tlist,
if (!lc1)
return list_make1(groupingSets);
- /*
+ /*----------
* We don't strictly need to remove duplicate sets here, but if we don't,
* they tend to become scattered through the result, which is a bit
- * confusing (and irritating if we ever decide to optimize them out). So
- * we remove them here and add them back after.
+ * confusing (and irritating if we ever decide to optimize them out).
+ * So we remove them here and add them back after.
*
* For each non-duplicate set, we fill in the following:
*
- * orig_sets[i] = list of the original set lists set_masks[i] = bitmapset
- * for testing inclusion adjacency[i] = array [n, v1, v2, ... vn] of
- * adjacency indices
+ * orig_sets[i] = list of the original set lists
+ * set_masks[i] = bitmapset for testing inclusion
+ * adjacency[i] = array [n, v1, v2, ... vn] of adjacency indices
*
* chains[i] will be the result group this set is assigned to.
*
- * We index all of these from 1 rather than 0 because it is convenient to
- * leave 0 free for the NIL node in the graph algorithm.
+ * We index all of these from 1 rather than 0 because it is convenient
+ * to leave 0 free for the NIL node in the graph algorithm.
+ *----------
*/
orig_sets = palloc0((num_sets_raw + 1) * sizeof(List *));
set_masks = palloc0((num_sets_raw + 1) * sizeof(Bitmapset *));
*qual_eval = (Expr *) linitial(quals);
/*
- * Similairly, if more than one WITH CHECK qual is returned, then they
- * need to be combined together.
+ * Similarly, if more than one WITH CHECK qual is returned, then they need
+ * to be combined together.
*
* with_check_quals is allowed to be NIL here since this might not be the
* resultRelation (see above).
*
* Given the datatype OID, return its JsonbTypeCategory, as well as the type's
* output function OID. If the returned category is JSONBTYPE_JSONCAST,
- * we return the OID of the relevant cast function instead.
+ * we return the OID of the relevant cast function instead.
*/
static void
jsonb_categorize_type(Oid typoid,
int wrapColumn; /* max line length, or -1 for no limit */
int indentLevel; /* current indent level for prettyprint */
bool varprefix; /* TRUE to print prefixes on Vars */
- ParseExprKind special_exprkind; /* set only for exprkinds needing */
- /* special handling */
+ ParseExprKind special_exprkind; /* set only for exprkinds needing
+ * special handling */
} deparse_context;
/*