/* Disallow '/a/b/data/..' */
if (path_contains_parent_reference(filename))
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("reference to parent directory (\"..\") not allowed"))));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("reference to parent directory (\"..\") not allowed"))));
+
/*
- * Allow absolute paths if within DataDir or Log_directory, even
- * though Log_directory might be outside DataDir.
+ * Allow absolute paths if within DataDir or Log_directory, even
+ * though Log_directory might be outside DataDir.
*/
if (!path_is_prefix_of_path(DataDir, filename) &&
(!logAllowed || !is_absolute_path(Log_directory) ||
!path_is_prefix_of_path(Log_directory, filename)))
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("absolute path not allowed"))));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("absolute path not allowed"))));
}
else if (!path_is_relative_and_below_cwd(filename))
ereport(ERROR,
PG_MODULE_MAGIC;
-void _PG_init(void);
+void _PG_init(void);
/* GUC Variables */
static int auth_delay_milliseconds;
/* Original Hook */
-static ClientAuthentication_hook_type original_client_auth_hook = NULL;
+static ClientAuthentication_hook_type original_client_auth_hook = NULL;
/*
* Check authentication
{
/* Define custom GUC variables */
DefineCustomIntVariable("auth_delay.milliseconds",
- "Milliseconds to delay before reporting authentication failure",
+ "Milliseconds to delay before reporting authentication failure",
NULL,
&auth_delay_milliseconds,
0,
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
gdb_date_dist(const void *a, const void *b)
{
/* we assume the difference can't overflow */
- Datum diff = DirectFunctionCall2(date_mi,
+ Datum diff = DirectFunctionCall2(date_mi,
DateADTGetDatum(*((const DateADT *) a)),
- DateADTGetDatum(*((const DateADT *) b)));
+ DateADTGetDatum(*((const DateADT *) b)));
return (float8) Abs(DatumGetInt32(diff));
}
PG_FUNCTION_INFO_V1(date_dist);
-Datum date_dist(PG_FUNCTION_ARGS);
+Datum date_dist(PG_FUNCTION_ARGS);
Datum
date_dist(PG_FUNCTION_ARGS)
{
/* we assume the difference can't overflow */
- Datum diff = DirectFunctionCall2(date_mi,
- PG_GETARG_DATUM(0),
- PG_GETARG_DATUM(1));
+ Datum diff = DirectFunctionCall2(date_mi,
+ PG_GETARG_DATUM(0),
+ PG_GETARG_DATUM(1));
PG_RETURN_INT32(Abs(DatumGetInt32(diff)));
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
PG_FUNCTION_INFO_V1(float4_dist);
-Datum float4_dist(PG_FUNCTION_ARGS);
+Datum float4_dist(PG_FUNCTION_ARGS);
Datum
float4_dist(PG_FUNCTION_ARGS)
{
- float4 a = PG_GETARG_FLOAT4(0);
+ float4 a = PG_GETARG_FLOAT4(0);
float4 b = PG_GETARG_FLOAT4(1);
float4 r;
r = a - b;
CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
- PG_RETURN_FLOAT4( Abs(r) );
+ PG_RETURN_FLOAT4(Abs(r));
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
static float8
gbt_float8_dist(const void *a, const void *b)
{
- float8 arg1 = *(const float8 *)a;
- float8 arg2 = *(const float8 *)b;
+ float8 arg1 = *(const float8 *) a;
+ float8 arg2 = *(const float8 *) b;
float8 r;
r = arg1 - arg2;
PG_FUNCTION_INFO_V1(float8_dist);
-Datum float8_dist(PG_FUNCTION_ARGS);
+Datum float8_dist(PG_FUNCTION_ARGS);
Datum
float8_dist(PG_FUNCTION_ARGS)
{
r = a - b;
CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
- PG_RETURN_FLOAT8( Abs(r) );
+ PG_RETURN_FLOAT8(Abs(r));
}
/**************************************************
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
PG_FUNCTION_INFO_V1(int2_dist);
-Datum int2_dist(PG_FUNCTION_ARGS);
+Datum int2_dist(PG_FUNCTION_ARGS);
Datum
int2_dist(PG_FUNCTION_ARGS)
{
- int2 a = PG_GETARG_INT16(0);
- int2 b = PG_GETARG_INT16(1);
+ int2 a = PG_GETARG_INT16(0);
+ int2 b = PG_GETARG_INT16(1);
int2 r;
int2 ra;
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
PG_FUNCTION_INFO_V1(int4_dist);
-Datum int4_dist(PG_FUNCTION_ARGS);
+Datum int4_dist(PG_FUNCTION_ARGS);
Datum
int4_dist(PG_FUNCTION_ARGS)
{
- int4 a = PG_GETARG_INT32(0);
- int4 b = PG_GETARG_INT32(1);
- int4 r;
- int4 ra;
+ int4 a = PG_GETARG_INT32(0);
+ int4 b = PG_GETARG_INT32(1);
+ int4 r;
+ int4 ra;
r = a - b;
ra = Abs(r);
if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("integer out of range")));
+ errmsg("integer out of range")));
PG_RETURN_INT32(ra);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
PG_FUNCTION_INFO_V1(int8_dist);
-Datum int8_dist(PG_FUNCTION_ARGS);
+Datum int8_dist(PG_FUNCTION_ARGS);
Datum
int8_dist(PG_FUNCTION_ARGS)
{
- int64 a = PG_GETARG_INT64(0);
- int64 b = PG_GETARG_INT64(1);
- int64 r;
- int64 ra;
+ int64 a = PG_GETARG_INT64(0);
+ int64 b = PG_GETARG_INT64(1);
+ int64 r;
+ int64 ra;
r = a - b;
ra = Abs(r);
if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
+ errmsg("bigint out of range")));
PG_RETURN_INT64(ra);
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
static float8
gbt_intv_dist(const void *a, const void *b)
{
- return (float8)Abs(intr2num((Interval*)a) - intr2num((Interval*)b));
+ return (float8) Abs(intr2num((Interval *) a) - intr2num((Interval *) b));
}
/*
}
PG_FUNCTION_INFO_V1(interval_dist);
-Datum interval_dist(PG_FUNCTION_ARGS);
+Datum interval_dist(PG_FUNCTION_ARGS);
Datum
interval_dist(PG_FUNCTION_ARGS)
{
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo)
);
}
PG_FUNCTION_INFO_V1(oid_dist);
-Datum oid_dist(PG_FUNCTION_ARGS);
+Datum oid_dist(PG_FUNCTION_ARGS);
Datum
oid_dist(PG_FUNCTION_ARGS)
{
- Oid a = PG_GETARG_OID(0);
- Oid b = PG_GETARG_OID(1);
- Oid res;
+ Oid a = PG_GETARG_OID(0);
+ Oid b = PG_GETARG_OID(1);
+ Oid res;
if (a < b)
res = b - a;
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
{
const TimeADT *aa = (const TimeADT *) a;
const TimeADT *bb = (const TimeADT *) b;
- Interval *i;
+ Interval *i;
i = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
TimeADTGetDatumFast(*aa),
PG_FUNCTION_INFO_V1(time_dist);
-Datum time_dist(PG_FUNCTION_ARGS);
+Datum time_dist(PG_FUNCTION_ARGS);
Datum
time_dist(PG_FUNCTION_ARGS)
{
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
{
const Timestamp *aa = (const Timestamp *) a;
const Timestamp *bb = (const Timestamp *) b;
- Interval *i;
+ Interval *i;
if (TIMESTAMP_NOT_FINITE(*aa) || TIMESTAMP_NOT_FINITE(*bb))
return get_float8_infinity();
PG_FUNCTION_INFO_V1(ts_dist);
-Datum ts_dist(PG_FUNCTION_ARGS);
+Datum ts_dist(PG_FUNCTION_ARGS);
Datum
ts_dist(PG_FUNCTION_ARGS)
{
Timestamp a = PG_GETARG_TIMESTAMP(0);
Timestamp b = PG_GETARG_TIMESTAMP(1);
- Interval *r;
+ Interval *r;
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
{
- Interval *p = palloc(sizeof(Interval));
+ Interval *p = palloc(sizeof(Interval));
p->day = INT_MAX;
p->month = INT_MAX;
PG_RETURN_INTERVAL_P(p);
}
else
-
- r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
- PG_GETARG_DATUM(0),
- PG_GETARG_DATUM(1)));
- PG_RETURN_INTERVAL_P( abs_interval(r) );
+ r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
+ PG_GETARG_DATUM(0),
+ PG_GETARG_DATUM(1)));
+ PG_RETURN_INTERVAL_P(abs_interval(r));
}
PG_FUNCTION_INFO_V1(tstz_dist);
-Datum tstz_dist(PG_FUNCTION_ARGS);
+Datum tstz_dist(PG_FUNCTION_ARGS);
Datum
tstz_dist(PG_FUNCTION_ARGS)
{
- TimestampTz a = PG_GETARG_TIMESTAMPTZ(0);
- TimestampTz b = PG_GETARG_TIMESTAMPTZ(1);
- Interval *r;
+ TimestampTz a = PG_GETARG_TIMESTAMPTZ(0);
+ TimestampTz b = PG_GETARG_TIMESTAMPTZ(1);
+ Interval *r;
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
{
- Interval *p = palloc(sizeof(Interval));
+ Interval *p = palloc(sizeof(Interval));
p->day = INT_MAX;
p->month = INT_MAX;
r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
PG_GETARG_DATUM(0),
PG_GETARG_DATUM(1)));
- PG_RETURN_INTERVAL_P( abs_interval(r) );
+ PG_RETURN_INTERVAL_P(abs_interval(r));
}
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}
qqq = tstz_to_ts_gmt(query);
PG_RETURN_FLOAT8(
- gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo)
+ gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo)
);
}
retval = (*tinfo->f_le) (query, key->upper);
break;
case BtreeGistNotEqualStrategyNumber:
- retval = (! ((*tinfo->f_eq) (query, key->lower) &&
- (*tinfo->f_eq) (query, key->upper))) ? true : false;
+ retval = (!((*tinfo->f_eq) (query, key->lower) &&
+ (*tinfo->f_eq) (query, key->upper))) ? true : false;
break;
default:
retval = false;
if (tinfo->f_dist == NULL)
elog(ERROR, "KNN search is not supported for btree_gist type %d",
(int) tinfo->t);
- if ( tinfo->f_le(query, key->lower) )
+ if (tinfo->f_le(query, key->lower))
retval = tinfo->f_dist(query, key->lower);
- else if ( tinfo->f_ge(query, key->upper) )
+ else if (tinfo->f_ge(query, key->upper))
retval = tinfo->f_dist(query, key->upper);
else
retval = 0.0;
bool (*f_le) (const void *, const void *); /* less or equal */
bool (*f_lt) (const void *, const void *); /* less than */
int (*f_cmp) (const void *, const void *); /* key compare function */
- float8 (*f_dist) (const void *, const void *); /* key distance function */
+ float8 (*f_dist) (const void *, const void *); /* key distance function */
} gbtree_ninfo;
#define GET_FLOAT_DISTANCE(t, arg1, arg2) Abs( ((float8) *((const t *) (arg1))) - ((float8) *((const t *) (arg2))) )
-#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
+#define SAMESIGN(a,b) (((a) < 0) == ((b) < 0))
/*
* check to see if a float4/8 val has underflowed or overflowed
const gbtree_ninfo *tinfo);
extern float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query,
- bool is_leaf, const gbtree_ninfo *tinfo);
+ bool is_leaf, const gbtree_ninfo *tinfo);
extern GIST_SPLITVEC *gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
const gbtree_ninfo *tinfo);
|| gbt_var_node_pf_match(key, query, tinfo);
break;
case BtreeGistNotEqualStrategyNumber:
- retval = ! ((*tinfo->f_eq) (query, key->lower) && (*tinfo->f_eq) (query, key->upper));
+ retval = !((*tinfo->f_eq) (query, key->lower) && (*tinfo->f_eq) (query, key->upper));
break;
default:
retval = FALSE;
PG_MODULE_MAGIC;
/* Entrypoint of the module */
-void _PG_init(void);
+void _PG_init(void);
static void
dummy_object_relabel(const ObjectAddress *object, const char *seclabel)
*/
static struct FileFdwOption valid_options[] = {
/* File options */
- { "filename", ForeignTableRelationId },
+ {"filename", ForeignTableRelationId},
/* Format options */
/* oids option is not supported */
- { "format", ForeignTableRelationId },
- { "header", ForeignTableRelationId },
- { "delimiter", ForeignTableRelationId },
- { "quote", ForeignTableRelationId },
- { "escape", ForeignTableRelationId },
- { "null", ForeignTableRelationId },
- { "encoding", ForeignTableRelationId },
+ {"format", ForeignTableRelationId},
+ {"header", ForeignTableRelationId},
+ {"delimiter", ForeignTableRelationId},
+ {"quote", ForeignTableRelationId},
+ {"escape", ForeignTableRelationId},
+ {"null", ForeignTableRelationId},
+ {"encoding", ForeignTableRelationId},
/*
* force_quote is not supported by file_fdw because it's for COPY TO.
*/
/* Sentinel */
- { NULL, InvalidOid }
+ {NULL, InvalidOid}
};
/*
*/
typedef struct FileFdwExecutionState
{
- char *filename; /* file to read */
- List *options; /* merged COPY options, excluding filename */
- CopyState cstate; /* state of reading file */
+ char *filename; /* file to read */
+ List *options; /* merged COPY options, excluding filename */
+ CopyState cstate; /* state of reading file */
} FileFdwExecutionState;
/*
* FDW callback routines
*/
static FdwPlan *filePlanForeignScan(Oid foreigntableid,
- PlannerInfo *root,
- RelOptInfo *baserel);
+ PlannerInfo *root,
+ RelOptInfo *baserel);
static void fileExplainForeignScan(ForeignScanState *node, ExplainState *es);
static void fileBeginForeignScan(ForeignScanState *node, int eflags);
static TupleTableSlot *fileIterateForeignScan(ForeignScanState *node);
static void fileGetOptions(Oid foreigntableid,
char **filename, List **other_options);
static void estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
- const char *filename,
- Cost *startup_cost, Cost *total_cost);
+ const char *filename,
+ Cost *startup_cost, Cost *total_cost);
/*
/*
* Only superusers are allowed to set options of a file_fdw foreign table.
- * This is because the filename is one of those options, and we don't
- * want non-superusers to be able to determine which file gets read.
+ * This is because the filename is one of those options, and we don't want
+ * non-superusers to be able to determine which file gets read.
*
* Putting this sort of permissions check in a validator is a bit of a
* crock, but there doesn't seem to be any other place that can enforce
* the check more cleanly.
*
- * Note that the valid_options[] array disallows setting filename at
- * any options level other than foreign table --- otherwise there'd
- * still be a security hole.
+ * Note that the valid_options[] array disallows setting filename at any
+ * options level other than foreign table --- otherwise there'd still be a
+ * security hole.
*/
if (catalog == ForeignTableRelationId && !superuser())
ereport(ERROR,
*/
foreach(cell, options_list)
{
- DefElem *def = (DefElem *) lfirst(cell);
+ DefElem *def = (DefElem *) lfirst(cell);
if (!is_valid_option(def->defname, catalog))
{
prev = NULL;
foreach(lc, options)
{
- DefElem *def = (DefElem *) lfirst(lc);
+ DefElem *def = (DefElem *) lfirst(lc);
if (strcmp(def->defname, "filename") == 0)
{
PlannerInfo *root,
RelOptInfo *baserel)
{
- FdwPlan *fdwplan;
+ FdwPlan *fdwplan;
char *filename;
List *options;
fdwplan = makeNode(FdwPlan);
estimate_costs(root, baserel, filename,
&fdwplan->startup_cost, &fdwplan->total_cost);
- fdwplan->fdw_private = NIL; /* not used */
+ fdwplan->fdw_private = NIL; /* not used */
return fdwplan;
}
/* Suppress file size if we're not showing cost details */
if (es->costs)
{
- struct stat stat_buf;
+ struct stat stat_buf;
if (stat(filename, &stat_buf) == 0)
ExplainPropertyLong("Foreign File Size", (long) stat_buf.st_size,
&filename, &options);
/*
- * Create CopyState from FDW options. We always acquire all columns,
- * so as to match the expected ScanTupleSlot signature.
+ * Create CopyState from FDW options. We always acquire all columns, so
+ * as to match the expected ScanTupleSlot signature.
*/
cstate = BeginCopyFrom(node->ss.ss_currentRelation,
filename,
{
FileFdwExecutionState *festate = (FileFdwExecutionState *) node->fdw_state;
TupleTableSlot *slot = node->ss.ss_ScanTupleSlot;
- bool found;
+ bool found;
ErrorContextCallback errcontext;
/* Set up callback to identify error line number. */
/*
* The protocol for loading a virtual tuple into a slot is first
* ExecClearTuple, then fill the values/isnull arrays, then
- * ExecStoreVirtualTuple. If we don't find another row in the file,
- * we just skip the last step, leaving the slot empty as required.
+ * ExecStoreVirtualTuple. If we don't find another row in the file, we
+ * just skip the last step, leaving the slot empty as required.
*
* We can pass ExprContext = NULL because we read all columns from the
* file, so no need to evaluate default expressions.
const char *filename,
Cost *startup_cost, Cost *total_cost)
{
- struct stat stat_buf;
- BlockNumber pages;
- int tuple_width;
- double ntuples;
- double nrows;
- Cost run_cost = 0;
- Cost cpu_per_tuple;
+ struct stat stat_buf;
+ BlockNumber pages;
+ int tuple_width;
+ double ntuples;
+ double nrows;
+ Cost run_cost = 0;
+ Cost cpu_per_tuple;
/*
- * Get size of the file. It might not be there at plan time, though,
- * in which case we have to use a default estimate.
+ * Get size of the file. It might not be there at plan time, though, in
+ * which case we have to use a default estimate.
*/
if (stat(filename, &stat_buf) < 0)
stat_buf.st_size = 10 * BLCKSZ;
/*
* Convert size to pages for use in I/O cost estimate below.
*/
- pages = (stat_buf.st_size + (BLCKSZ-1)) / BLCKSZ;
+ pages = (stat_buf.st_size + (BLCKSZ - 1)) / BLCKSZ;
if (pages < 1)
pages = 1;
ntuples = clamp_row_est((double) stat_buf.st_size / (double) tuple_width);
/*
- * Now estimate the number of rows returned by the scan after applying
- * the baserestrictinfo quals. This is pretty bogus too, since the
- * planner will have no stats about the relation, but it's better than
- * nothing.
+ * Now estimate the number of rows returned by the scan after applying the
+ * baserestrictinfo quals. This is pretty bogus too, since the planner
+ * will have no stats about the relation, but it's better than nothing.
*/
nrows = ntuples *
clauselist_selectivity(root,
baserel->rows = nrows;
/*
- * Now estimate costs. We estimate costs almost the same way as
+ * Now estimate costs. We estimate costs almost the same way as
* cost_seqscan(), thus assuming that I/O costs are equivalent to a
* regular table file of the same size. However, we take per-tuple CPU
* costs as 10x of a seqscan, to account for the cost of parsing records.
*/
#ifdef LEVENSHTEIN_LESS_EQUAL
static int levenshtein_less_equal_internal(text *s, text *t,
- int ins_c, int del_c, int sub_c, int max_d);
+ int ins_c, int del_c, int sub_c, int max_d);
#else
static int levenshtein_internal(text *s, text *t,
int ins_c, int del_c, int sub_c);
* array.
*
* If max_d >= 0, we only need to provide an accurate answer when that answer
- * is less than or equal to the bound. From any cell in the matrix, there is
+ * is less than or equal to the bound. From any cell in the matrix, there is
* theoretical "minimum residual distance" from that cell to the last column
* of the final row. This minimum residual distance is zero when the
* untransformed portions of the strings are of equal length (because we might
/*
* For levenshtein_less_equal_internal, we have real variables called
- * start_column and stop_column; otherwise it's just short-hand for 0
- * and m.
+ * start_column and stop_column; otherwise it's just short-hand for 0 and
+ * m.
*/
#ifdef LEVENSHTEIN_LESS_EQUAL
- int start_column, stop_column;
+ int start_column,
+ stop_column;
+
#undef START_COLUMN
#undef STOP_COLUMN
#define START_COLUMN start_column
stop_column = m + 1;
/*
- * If max_d >= 0, determine whether the bound is impossibly tight. If so,
+ * If max_d >= 0, determine whether the bound is impossibly tight. If so,
* return max_d + 1 immediately. Otherwise, determine whether it's tight
* enough to limit the computation we must perform. If so, figure out
* initial stop column.
*/
if (max_d >= 0)
{
- int min_theo_d; /* Theoretical minimum distance. */
- int max_theo_d; /* Theoretical maximum distance. */
- int net_inserts = n - m;
+ int min_theo_d; /* Theoretical minimum distance. */
+ int max_theo_d; /* Theoretical maximum distance. */
+ int net_inserts = n - m;
min_theo_d = net_inserts < 0 ?
-net_inserts * del_c : net_inserts * ins_c;
else if (ins_c + del_c > 0)
{
/*
- * Figure out how much of the first row of the notional matrix
- * we need to fill in. If the string is growing, the theoretical
+ * Figure out how much of the first row of the notional matrix we
+ * need to fill in. If the string is growing, the theoretical
* minimum distance already incorporates the cost of deleting the
- * number of characters necessary to make the two strings equal
- * in length. Each additional deletion forces another insertion,
- * so the best-case total cost increases by ins_c + del_c.
- * If the string is shrinking, the minimum theoretical cost
- * assumes no excess deletions; that is, we're starting no futher
- * right than column n - m. If we do start further right, the
- * best-case total cost increases by ins_c + del_c for each move
- * right.
+ * number of characters necessary to make the two strings equal in
+ * length. Each additional deletion forces another insertion, so
+ * the best-case total cost increases by ins_c + del_c. If the
+ * string is shrinking, the minimum theoretical cost assumes no
+ * excess deletions; that is, we're starting no futher right than
+ * column n - m. If we do start further right, the best-case
+ * total cost increases by ins_c + del_c for each move right.
*/
- int slack_d = max_d - min_theo_d;
- int best_column = net_inserts < 0 ? -net_inserts : 0;
+ int slack_d = max_d - min_theo_d;
+ int best_column = net_inserts < 0 ? -net_inserts : 0;
+
stop_column = best_column + (slack_d / (ins_c + del_c)) + 1;
if (stop_column > m)
stop_column = m + 1;
/*
* In order to avoid calling pg_mblen() repeatedly on each character in s,
- * we cache all the lengths before starting the main loop -- but if all the
- * characters in both strings are single byte, then we skip this and use
- * a fast-path in the main loop. If only one string contains multi-byte
- * characters, we still build the array, so that the fast-path needn't
- * deal with the case where the array hasn't been initialized.
+ * we cache all the lengths before starting the main loop -- but if all
+ * the characters in both strings are single byte, then we skip this and
+ * use a fast-path in the main loop. If only one string contains
+ * multi-byte characters, we still build the array, so that the fast-path
+ * needn't deal with the case where the array hasn't been initialized.
*/
if (m != s_bytes || n != t_bytes)
{
- int i;
+ int i;
const char *cp = s_data;
s_char_len = (int *) palloc((m + 1) * sizeof(int));
curr = prev + m;
/*
- * To transform the first i characters of s into the first 0 characters
- * of t, we must perform i deletions.
+ * To transform the first i characters of s into the first 0 characters of
+ * t, we must perform i deletions.
*/
for (i = START_COLUMN; i < STOP_COLUMN; i++)
prev[i] = i * del_c;
int y_char_len = n != t_bytes + 1 ? pg_mblen(y) : 1;
#ifdef LEVENSHTEIN_LESS_EQUAL
+
/*
* In the best case, values percolate down the diagonal unchanged, so
* we must increment stop_column unless it's already on the right end
}
/*
- * The main loop fills in curr, but curr[0] needs a special case:
- * to transform the first 0 characters of s into the first j
- * characters of t, we must perform j insertions. However, if
- * start_column > 0, this special case does not apply.
+ * The main loop fills in curr, but curr[0] needs a special case: to
+ * transform the first 0 characters of s into the first j characters
+ * of t, we must perform j insertions. However, if start_column > 0,
+ * this special case does not apply.
*/
if (start_column == 0)
{
*/
ins = prev[i] + ins_c;
del = curr[i - 1] + del_c;
- if (x[x_char_len-1] == y[y_char_len-1]
+ if (x[x_char_len - 1] == y[y_char_len - 1]
&& x_char_len == y_char_len &&
(x_char_len == 1 || rest_of_char_same(x, y, x_char_len)))
sub = prev[i - 1];
y += y_char_len;
#ifdef LEVENSHTEIN_LESS_EQUAL
+
/*
* This chunk of code represents a significant performance hit if used
* in the case where there is no max_d bound. This is probably not
* string, so we want to find the value for zp where where (n - 1)
* - j = (m - 1) - zp.
*/
- int zp = j - (n - m);
+ int zp = j - (n - m);
/* Check whether the stop column can slide left. */
while (stop_column > 0)
{
- int ii = stop_column - 1;
- int net_inserts = ii - zp;
+ int ii = stop_column - 1;
+ int net_inserts = ii - zp;
+
if (prev[ii] + (net_inserts > 0 ? net_inserts * ins_c :
- -net_inserts * del_c) <= max_d)
+ -net_inserts * del_c) <= max_d)
break;
stop_column--;
}
/* Check whether the start column can slide right. */
while (start_column < stop_column)
{
- int net_inserts = start_column - zp;
+ int net_inserts = start_column - zp;
+
if (prev[start_column] +
(net_inserts > 0 ? net_inserts * ins_c :
- -net_inserts * del_c) <= max_d)
+ -net_inserts * del_c) <= max_d)
break;
+
/*
- * We'll never again update these values, so we must make
- * sure there's nothing here that could confuse any future
+ * We'll never again update these values, so we must make sure
+ * there's nothing here that could confuse any future
* iteration of the outer loop.
*/
prev[start_column] = max_d + 1;
/*
* When using a GIN index for hstore, we choose to index both keys and values.
* The storage format is "text" values, with K, V, or N prepended to the string
- * to indicate key, value, or null values. (As of 9.1 it might be better to
+ * to indicate key, value, or null values. (As of 9.1 it might be better to
* store null values as nulls, but we'll keep it this way for on-disk
* compatibility.)
*/
{
/*
* Index doesn't have information about correspondence of keys and
- * values, so we need recheck. However, if not all the keys are
+ * values, so we need recheck. However, if not all the keys are
* present, we can fail at once.
*/
*recheck = true;
if (snullval != HS_VALISNULL(es2, j)
|| (!snullval
&& (svallen != HS_VALLEN(es2, j)
- || memcmp(HS_VAL(es, ps, i), HS_VAL(es2, ps2, j), svallen) != 0)))
+ || memcmp(HS_VAL(es, ps, i), HS_VAL(es2, ps2, j), svallen) != 0)))
{
HS_COPYITEM(ed, bufd, pd,
HS_KEY(es, ps, i), HS_KEYLEN(es, i),
if (nullval != HS_VALISNULL(ve, idx)
|| (!nullval
&& (vallen != HS_VALLEN(ve, idx)
- || memcmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen))))
+ || memcmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen))))
res = false;
}
else
}
else
{
- long lval;
+ long lval;
nnn[innn] = '\0';
errno = 0;
return FALSE;
/*
- * Set up data for checkcondition_gin. This must agree with the
- * query extraction code in ginint4_queryextract.
+ * Set up data for checkcondition_gin. This must agree with the query
+ * extraction code in ginint4_queryextract.
*/
gcv.first = items;
gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
/*
* If the query doesn't have any required primitive values (for
- * instance, it's something like '! 42'), we have to do a full
- * index scan.
+ * instance, it's something like '! 42'), we have to do a full index
+ * scan.
*/
if (query_has_required_values(query))
*searchMode = GIN_SEARCH_MODE_DEFAULT;
case RTOldContainsStrategyNumber:
if (*nentries > 0)
*searchMode = GIN_SEARCH_MODE_DEFAULT;
- else /* everything contains the empty set */
+ else /* everything contains the empty set */
*searchMode = GIN_SEARCH_MODE_ALL;
break;
default:
bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1);
int32 nkeys = PG_GETARG_INT32(3);
+
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = FALSE;
*size = (float) ARRNELEMS(a);
}
-/* Sort the given data (len >= 2). Return true if any duplicates found */
+/* Sort the given data (len >= 2). Return true if any duplicates found */
bool
isort(int4 *a, int len)
{
bool r = FALSE;
/*
- * We use a simple insertion sort. While this is O(N^2) in the worst
+ * We use a simple insertion sort. While this is O(N^2) in the worst
* case, it's quite fast if the input is already sorted or nearly so.
* Also, for not-too-large inputs it's faster than more complex methods
* anyhow.
{"10-976000", "10-999999"},
{NULL, NULL},
};
-
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
-#else /* WIN32 */
+#else /* WIN32 */
extern int getopt(int argc, char *const argv[], const char *optstring);
-#endif /* ! WIN32 */
+#endif /* ! WIN32 */
extern char *optarg;
extern int optind;
PGSS_TRACK_NONE, /* track no statements */
PGSS_TRACK_TOP, /* only top level statements */
PGSS_TRACK_ALL /* all statements, including nested ones */
-} PGSSTrackLevel;
+} PGSSTrackLevel;
static const struct config_enum_entry track_options[] =
{
static const char *progname;
-static int ops_per_test = 2000;
-static char full_buf[XLOG_SEG_SIZE], *buf, *filename = FSYNC_FILENAME;
-static struct timeval start_t, stop_t;
-
-
-static void handle_args(int argc, char *argv[]);
-static void prepare_buf(void);
-static void test_open(void);
-static void test_non_sync(void);
-static void test_sync(int writes_per_op);
-static void test_open_syncs(void);
-static void test_open_sync(const char *msg, int writes_size);
-static void test_file_descriptor_sync(void);
+static int ops_per_test = 2000;
+static char full_buf[XLOG_SEG_SIZE],
+ *buf,
+ *filename = FSYNC_FILENAME;
+static struct timeval start_t,
+ stop_t;
+
+
+static void handle_args(int argc, char *argv[]);
+static void prepare_buf(void);
+static void test_open(void);
+static void test_non_sync(void);
+static void test_sync(int writes_per_op);
+static void test_open_syncs(void);
+static void test_open_sync(const char *msg, int writes_size);
+static void test_file_descriptor_sync(void);
+
#ifdef HAVE_FSYNC_WRITETHROUGH
static int pg_fsync_writethrough(int fd);
#endif
-static void print_elapse(struct timeval start_t, struct timeval stop_t);
-static void die(const char *str);
+static void print_elapse(struct timeval start_t, struct timeval stop_t);
+static void die(const char *str);
int
}
while ((option = getopt_long(argc, argv, "f:o:",
- long_options, &optindex)) != -1)
+ long_options, &optindex)) != -1)
{
switch (option)
{
static void
test_sync(int writes_per_op)
{
- int tmpfile, ops, writes;
+ int tmpfile,
+ ops,
+ writes;
bool fs_warning = false;
if (writes_per_op == 1)
static void
test_open_sync(const char *msg, int writes_size)
{
- int tmpfile, ops, writes;
+ int tmpfile,
+ ops,
+ writes;
printf(LABEL_FORMAT, msg);
fflush(stdout);
close(tmpfile);
print_elapse(start_t, stop_t);
}
-
#else
printf(NA_FORMAT, "n/a\n");
#endif
static void
test_file_descriptor_sync(void)
{
- int tmpfile, ops;
+ int tmpfile,
+ ops;
/*
- * Test whether fsync can sync data written on a different
- * descriptor for the same file. This checks the efficiency
- * of multi-process fsyncs against the same file.
- * Possibly this should be done with writethrough on platforms
- * which support it.
+ * Test whether fsync can sync data written on a different descriptor for
+ * the same file. This checks the efficiency of multi-process fsyncs
+ * against the same file. Possibly this should be done with writethrough
+ * on platforms which support it.
*/
printf("\nTest if fsync on non-write file descriptor is honored:\n");
printf("(If the times are similar, fsync() can sync data written\n");
printf("on a different descriptor.)\n");
/*
- * first write, fsync and close, which is the
- * normal behavior without multiple descriptors
+ * first write, fsync and close, which is the normal behavior without
+ * multiple descriptors
*/
printf(LABEL_FORMAT, "write, fsync, close");
fflush(stdout);
if (fsync(tmpfile) != 0)
die("fsync failed");
close(tmpfile);
+
/*
- * open and close the file again to be consistent
- * with the following test
+ * open and close the file again to be consistent with the following
+ * test
*/
if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
die("could not open output file");
print_elapse(start_t, stop_t);
/*
- * Now open, write, close, open again and fsync
- * This simulates processes fsyncing each other's
- * writes.
+ * Now open, write, close, open again and fsync This simulates processes
+ * fsyncing each other's writes.
*/
printf(LABEL_FORMAT, "write, close, fsync");
fflush(stdout);
static void
test_non_sync(void)
{
- int tmpfile, ops;
+ int tmpfile,
+ ops;
/*
* Test a simple write without fsync
return -1;
#endif
}
-
#endif
/*
#endif
#define ISPRINTABLETRGM(t) ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) )
-#define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
-#define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%') /* Wildcard meta-character */
+#define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
+#define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%') /* Wildcard
+ * meta-character */
typedef struct
{
float4 cnt_sml(TRGM *trg1, TRGM *trg2);
bool trgm_contained_by(TRGM *trg1, TRGM *trg2);
-#endif /* __TRGM_H__ */
+#endif /* __TRGM_H__ */
ptr = GETARR(trg);
for (i = 0; i < trglen; i++)
{
- int32 item = trgm2int(ptr);
+ int32 item = trgm2int(ptr);
entries[i] = Int32GetDatum(item);
ptr++;
text *val = (text *) PG_GETARG_TEXT_P(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
- /* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
- /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
- int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
+
+ /* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
+ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
+ int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
Datum *entries = NULL;
TRGM *trg;
int32 trglen;
#endif
/* FALL THRU */
case LikeStrategyNumber:
+
/*
* For wildcard search we extract all the trigrams that every
* potentially-matching string must include.
break;
default:
elog(ERROR, "unrecognized strategy number: %d", strategy);
- trg = NULL; /* keep compiler quiet */
+ trg = NULL; /* keep compiler quiet */
break;
}
ptr = GETARR(trg);
for (i = 0; i < trglen; i++)
{
- int32 item = trgm2int(ptr);
+ int32 item = trgm2int(ptr);
entries[i] = Int32GetDatum(item);
ptr++;
{
bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1);
+
/* text *query = PG_GETARG_TEXT_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+
+ /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res;
int32 i,
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
text *query = PG_GETARG_TEXT_P(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
+
/* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4);
TRGM *key = (TRGM *) DatumGetPointer(entry->key);
TRGM *qtrg;
bool res;
char *cache = (char *) fcinfo->flinfo->fn_extra,
- *cacheContents = cache + MAXALIGN(sizeof(StrategyNumber));
+ *cacheContents = cache + MAXALIGN(sizeof(StrategyNumber));
/*
* Store both the strategy number and extracted trigrams in cache, because
- * trigram extraction is relatively CPU-expensive. We must include
+ * trigram extraction is relatively CPU-expensive. We must include
* strategy number because trigram extraction depends on strategy.
*/
if (cache == NULL || strategy != *((StrategyNumber *) cache) ||
break;
default:
elog(ERROR, "unrecognized strategy number: %d", strategy);
- qtrg = NULL; /* keep compiler quiet */
+ qtrg = NULL; /* keep compiler quiet */
break;
}
*recheck = false;
if (GIST_LEAF(entry))
- { /* all leafs contains orig trgm */
- float4 tmpsml = cnt_sml(key, qtrg);
+ { /* all leafs contains orig trgm */
+ float4 tmpsml = cnt_sml(key, qtrg);
/* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
res = (*(int *) &tmpsml == *(int *) &trgm_limit || tmpsml > trgm_limit) ? true : false;
}
else if (ISALLTRUE(key))
- { /* non-leaf contains signature */
+ { /* non-leaf contains signature */
res = true;
}
else
- { /* non-leaf contains signature */
- int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
- int4 len = ARRNELEM(qtrg);
+ { /* non-leaf contains signature */
+ int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
+ int4 len = ARRNELEM(qtrg);
if (len == 0)
res = false;
* nodes.
*/
if (GIST_LEAF(entry))
- { /* all leafs contains orig trgm */
+ { /* all leafs contains orig trgm */
res = trgm_contained_by(qtrg, key);
}
else if (ISALLTRUE(key))
- { /* non-leaf contains signature */
+ { /* non-leaf contains signature */
res = true;
}
else
- { /* non-leaf contains signature */
- int32 k,
- tmp = 0,
- len = ARRNELEM(qtrg);
- trgm *ptr = GETARR(qtrg);
- BITVECP sign = GETSIGN(key);
+ { /* non-leaf contains signature */
+ int32 k,
+ tmp = 0,
+ len = ARRNELEM(qtrg);
+ trgm *ptr = GETARR(qtrg);
+ BITVECP sign = GETSIGN(key);
res = true;
for (k = 0; k < len; k++)
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
text *query = PG_GETARG_TEXT_P(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
+
/* Oid subtype = PG_GETARG_OID(3); */
TRGM *key = (TRGM *) DatumGetPointer(entry->key);
TRGM *qtrg;
{
case DistanceStrategyNumber:
if (GIST_LEAF(entry))
- { /* all leafs contains orig trgm */
+ { /* all leafs contains orig trgm */
res = 1.0 - cnt_sml(key, qtrg);
}
else if (ISALLTRUE(key))
- { /* all leafs contains orig trgm */
+ { /* all leafs contains orig trgm */
res = 0.0;
}
else
- { /* non-leaf contains signature */
- int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
- int4 len = ARRNELEM(qtrg);
+ { /* non-leaf contains signature */
+ int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
+ int4 len = ARRNELEM(qtrg);
res = (len == 0) ? -1.0 : 1.0 - ((float8) count) / ((float8) len);
}
const char *beginword = str;
const char *endword;
char *s = buf;
- bool in_wildcard_meta = false;
- bool in_escape = false;
- int clen;
+ bool in_wildcard_meta = false;
+ bool in_escape = false;
+ int clen;
/*
* Find the first word character remembering whether last character was
{
TRGM *trg;
char *buf,
- *buf2;
+ *buf2;
trgm *tptr;
int len,
charlen,
bytelen;
const char *eword;
- trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) * 3);
+ trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
trg->flag = ARRKEY;
SET_VARSIZE(trg, TRGMHDRSIZE);
float4 res = DatumGetFloat4(DirectFunctionCall2(similarity,
PG_GETARG_DATUM(0),
PG_GETARG_DATUM(1)));
+
PG_RETURN_FLOAT4(1.0 - res);
}
old_cluster.major_version = get_major_server_version(&old_cluster);
new_cluster.major_version = get_major_server_version(&new_cluster);
- /* We allow upgrades from/to the same major version for alpha/beta upgrades */
+ /*
+ * We allow upgrades from/to the same major version for alpha/beta
+ * upgrades
+ */
if (GET_MAJOR_VERSION(old_cluster.major_version) < 803)
pg_log(PG_FATAL, "This utility can only upgrade from PostgreSQL version 8.3 and later.\n");
}
if (script)
- fclose(script);
+ fclose(script);
if (found)
{
"\nOld and new pg_controldata date/time storage types do not match.\n");
/*
- * This is a common 8.3 -> 8.4 upgrade problem, so we are more
- * verbose
+ * This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose
*/
pg_log(PG_FATAL,
"You will need to rebuild the new server with configure\n"
static void check_data_dir(const char *pg_data);
static void check_bin_dir(ClusterInfo *cluster);
-static void validate_exec(const char *dir, const char *cmdName);
+static void validate_exec(const char *dir, const char *cmdName);
/*
else
return 0;
}
+
#endif
void
install_support_functions_in_new_db(const char *db_name)
{
- PGconn *conn = connectToServer(&new_cluster, db_name);
-
+ PGconn *conn = connectToServer(&new_cluster, db_name);
+
/* suppress NOTICE of dropped objects */
PQclear(executeQueryOrDie(conn,
"SET client_min_messages = warning;"));
PQclear(executeQueryOrDie(conn,
- "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
+ "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
PQclear(executeQueryOrDie(conn,
"RESET client_min_messages;"));
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_array_pg_type_oid(OID) "
+ "binary_upgrade.set_next_array_pg_type_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_toast_pg_type_oid(OID) "
+ "binary_upgrade.set_next_toast_pg_type_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_heap_pg_class_oid(OID) "
+ "binary_upgrade.set_next_heap_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_index_pg_class_oid(OID) "
+ "binary_upgrade.set_next_index_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
PQclear(executeQueryOrDie(conn,
"CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_toast_pg_class_oid(OID) "
+ "binary_upgrade.set_next_toast_pg_class_oid(OID) "
"RETURNS VOID "
"AS '$libdir/pg_upgrade_support' "
"LANGUAGE C STRICT;"));
static void create_rel_filename_map(const char *old_data, const char *new_data,
- const DbInfo *old_db, const DbInfo *new_db,
- const RelInfo *old_rel, const RelInfo *new_rel,
- FileNameMap *map);
+ const DbInfo *old_db, const DbInfo *new_db,
+ const RelInfo *old_rel, const RelInfo *new_rel,
+ FileNameMap *map);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
if (old_db->rel_arr.nrels != new_db->rel_arr.nrels)
pg_log(PG_FATAL, "old and new databases \"%s\" have a different number of relations\n",
- old_db->db_name);
+ old_db->db_name);
maps = (FileNameMap *) pg_malloc(sizeof(FileNameMap) *
old_db->rel_arr.nrels);
if (old_rel->reloid != new_rel->reloid)
pg_log(PG_FATAL, "Mismatch of relation id: database \"%s\", old relid %d, new relid %d\n",
- old_db->db_name, old_rel->reloid, new_rel->reloid);
+ old_db->db_name, old_rel->reloid, new_rel->reloid);
/*
- * In pre-8.4, TOAST table names change during CLUSTER; in >= 8.4
- * TOAST relation names always use heap table oids, hence we
- * cannot check relation names when upgrading from pre-8.4.
+ * In pre-8.4, TOAST table names change during CLUSTER; in >= 8.4
+ * TOAST relation names always use heap table oids, hence we cannot
+ * check relation names when upgrading from pre-8.4.
*/
if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 ||
strcmp(old_rel->nspname, "pg_toast") != 0) &&
strcmp(old_rel->relname, new_rel->relname) != 0))
pg_log(PG_FATAL, "Mismatch of relation names: database \"%s\", "
- "old rel %s.%s, new rel %s.%s\n",
- old_db->db_name, old_rel->nspname, old_rel->relname,
- new_rel->nspname, new_rel->relname);
+ "old rel %s.%s, new rel %s.%s\n",
+ old_db->db_name, old_rel->nspname, old_rel->relname,
+ new_rel->nspname, new_rel->relname);
create_rel_filename_map(old_pgdata, new_pgdata, old_db, new_db,
- old_rel, new_rel, maps + num_maps);
+ old_rel, new_rel, maps + num_maps);
num_maps++;
}
*/
static void
create_rel_filename_map(const char *old_data, const char *new_data,
- const DbInfo *old_db, const DbInfo *new_db,
- const RelInfo *old_rel, const RelInfo *new_rel,
- FileNameMap *map)
+ const DbInfo *old_db, const DbInfo *new_db,
+ const RelInfo *old_rel, const RelInfo *new_rel,
+ FileNameMap *map)
{
if (strlen(old_rel->tablespace) == 0)
{
}
/*
- * old_relfilenode might differ from pg_class.oid (and hence
- * new_relfilenode) because of CLUSTER, REINDEX, or VACUUM FULL.
+ * old_relfilenode might differ from pg_class.oid (and hence
+ * new_relfilenode) because of CLUSTER, REINDEX, or VACUUM FULL.
*/
map->old_relfilenode = old_rel->relfilenode;
int ntups;
int tupnum;
DbInfo *dbinfos;
- int i_datname, i_oid, i_spclocation;
+ int i_datname,
+ i_oid,
+ i_spclocation;
res = executeQueryOrDie(conn,
"SELECT d.oid, d.datname, t.spclocation "
int num_rels = 0;
char *nspname = NULL;
char *relname = NULL;
- int i_spclocation, i_nspname, i_relname, i_oid, i_relfilenode;
+ int i_spclocation,
+ i_nspname,
+ i_relname,
+ i_oid,
+ i_relfilenode;
char query[QUERY_ALLOC];
/*
* pg_largeobject contains user data that does not appear in pg_dumpall
* --schema-only output, so we have to copy that system table heap and
- * index. We could grab the pg_largeobject oids from template1, but
- * it is easy to treat it as a normal table.
- * Order by oid so we can join old/new structures efficiently.
+ * index. We could grab the pg_largeobject oids from template1, but it is
+ * easy to treat it as a normal table. Order by oid so we can join old/new
+ * structures efficiently.
*/
snprintf(query, sizeof(query),
" ((n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
" c.oid >= %u) "
" OR (n.nspname = 'pg_catalog' AND "
- " relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
+ " relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
/* we preserve pg_class.oid so we sort by it to match old/new */
"ORDER BY 1;",
/* see the comment at the top of old_8_3_create_sequence_script() */
FirstNormalObjectId,
/* does pg_largeobject_metadata need to be migrated? */
(GET_MAJOR_VERSION(old_cluster.major_version) <= 804) ?
- "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'");
+ "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'");
res = executeQueryOrDie(conn, query);
* FYI, while pg_class.oid and pg_class.relfilenode are intially the same
* in a cluster, but they can diverge due to CLUSTER, REINDEX, or VACUUM
* FULL. The new cluster will have matching pg_class.oid and
- * pg_class.relfilenode values and be based on the old oid value. This can
+ * pg_class.relfilenode values and be based on the old oid value. This can
* cause the old and new pg_class.relfilenode values to differ. In summary,
* old and new pg_class.oid and new pg_class.relfilenode will have the
* same value, and old pg_class.relfilenode might differ.
*/
-
+
#include "pg_upgrade.h"
#ifdef HAVE_LANGINFO_H
/* This is the database used by pg_dumpall to restore global tables */
#define GLOBAL_DUMP_DB "postgres"
-ClusterInfo old_cluster, new_cluster;
+ClusterInfo old_cluster,
+ new_cluster;
OSInfo os_info;
int
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --analyze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+ new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
check_ok();
/*
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --freeze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+ new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
check_ok();
get_pg_database_relfilenode(&new_cluster);
prep_status("Creating databases in the new cluster");
/*
- * Install support functions in the global-restore database
- * to preserve pg_authid.oid.
+ * Install support functions in the global-restore database to preserve
+ * pg_authid.oid.
*/
install_support_functions_in_new_db(GLOBAL_DUMP_DB);
/*
* We have to create the databases first so we can install support
- * functions in all the other databases. Ideally we could create
- * the support functions in template1 but pg_dumpall creates database
- * using the template0 template.
+ * functions in all the other databases. Ideally we could create the
+ * support functions in template1 but pg_dumpall creates database using
+ * the template0 template.
*/
exec_prog(true,
SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
{
char old_dir[MAXPGPATH];
char new_dir[MAXPGPATH];
+
/*
* old/new relfilenodes might differ for pg_largeobject(_metadata) indexes
* due to VACUUM FULL or REINDEX. Other relfilenodes are preserved.
Oid old_relfilenode;
Oid new_relfilenode;
/* the rest are used only for logging and error reporting */
- char nspname[NAMEDATALEN]; /* namespaces */
+ char nspname[NAMEDATALEN]; /* namespaces */
char relname[NAMEDATALEN];
} FileNameMap;
char *bindir; /* pathname for cluster's executable directory */
unsigned short port; /* port number where postmaster is waiting */
uint32 major_version; /* PG_VERSION of cluster */
- char major_version_str[64]; /* string PG_VERSION of cluster */
+ char major_version_str[64]; /* string PG_VERSION of cluster */
Oid pg_database_oid; /* OID of pg_database relation */
char *libpath; /* pathname for cluster's pkglibdir */
char *tablespace_suffix; /* directory specification */
/*
* Global variables
*/
-extern LogOpts log_opts;
+extern LogOpts log_opts;
extern UserOpts user_opts;
-extern ClusterInfo old_cluster, new_cluster;
+extern ClusterInfo old_cluster,
+ new_cluster;
extern OSInfo os_info;
extern char scandir_file_pattern[];
char **sequence_script_file_name);
void check_new_cluster(void);
void report_clusters_compatible(void);
-void issue_warnings(char *sequence_script_file_name);
-void output_completion_banner(char *deletion_script_file_name);
+void issue_warnings(char *sequence_script_file_name);
+void output_completion_banner(char *deletion_script_file_name);
void check_cluster_versions(void);
void check_cluster_compatibility(bool live_check);
void create_script_for_old_cluster_deletion(char **deletion_script_file_name);
int dir_matching_filenames(const struct dirent * scan_ent);
int pg_scandir(const char *dirname, struct dirent *** namelist,
- int (*selector) (const struct dirent *));
+ int (*selector) (const struct dirent *));
const char *copyAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
const char *dst, bool force);
const char *linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
- const char *dst);
+ const char *dst);
void check_hard_link(void);
FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
-void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_db_and_rel_infos(ClusterInfo *cluster);
void free_db_and_rel_infos(DbInfoArr *db_arr);
-void print_maps(FileNameMap *maps, int n,
- const char *db_name);
+void print_maps(FileNameMap *maps, int n,
+ const char *db_name);
/* option.c */
/* server.c */
-PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
-PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...);
+PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
+PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...);
void start_postmaster(ClusterInfo *cluster, bool quiet);
void stop_postmaster(bool fast, bool quiet);
-uint32 get_major_server_version(ClusterInfo *cluster);
+uint32 get_major_server_version(ClusterInfo *cluster);
void check_for_libpq_envvars(void);
/* version.c */
void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
- bool check_mode);
+ bool check_mode);
/* version_old_8_3.c */
void old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster);
void old_8_3_check_for_tsquery_usage(ClusterInfo *cluster);
-void old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode);
-void old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode);
+void old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode);
+void old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode);
void old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
- bool check_mode);
+ bool check_mode);
char *old_8_3_create_sequence_script(ClusterInfo *cluster);
*/
const char *
transfer_all_new_dbs(DbInfoArr *old_db_arr,
- DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
+ DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
{
int dbnum;
const char *msg = NULL;
if (old_db_arr->ndbs != new_db_arr->ndbs)
pg_log(PG_FATAL, "old and new clusters have a different number of databases\n");
-
+
for (dbnum = 0; dbnum < old_db_arr->ndbs; dbnum++)
{
DbInfo *old_db = &old_db_arr->dbs[dbnum];
if (strcmp(old_db->db_name, new_db->db_name) != 0)
pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
- old_db->db_name, new_db->db_name);
-
+ old_db->db_name, new_db->db_name);
+
n_maps = 0;
mappings = gen_db_file_maps(old_db, new_db, &n_maps, old_pgdata,
new_pgdata);
for (fileno = 0; fileno < numFiles; fileno++)
{
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
- strlen(scandir_file_pattern)) == 0)
+ strlen(scandir_file_pattern)) == 0)
{
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
namelist[fileno]->d_name);
unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file,
- maps[mapnum].nspname, maps[mapnum].relname);
+ maps[mapnum].nspname, maps[mapnum].relname);
}
}
}
for (fileno = 0; fileno < numFiles; fileno++)
{
if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
- strlen(scandir_file_pattern)) == 0)
+ strlen(scandir_file_pattern)) == 0)
{
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
namelist[fileno]->d_name);
unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file,
- maps[mapnum].nspname, maps[mapnum].relname);
+ maps[mapnum].nspname, maps[mapnum].relname);
}
}
}
*/
static void
transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
- const char *new_file, const char *nspname, const char *relname)
+ const char *new_file, const char *nspname, const char *relname)
{
const char *msg;
if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
pg_log(PG_FATAL,
- "error while creating link from %s.%s (%s to %s): %s\n",
+ "error while creating link from %s.%s (%s to %s): %s\n",
nspname, relname, old_file, new_file, msg);
}
return;
* because it is being used by another process." so we have to send all
* other output to 'nul'.
*
- * Using autovacuum=off disables cleanup vacuum and analyze, but
- * freeze vacuums can still happen, so we set
- * autovacuum_freeze_max_age to its maximum. We assume all datfrozenxid
- * and relfrozen values are less than a gap of 2000000000 from the current
- * xid counter, so autovacuum will not touch them.
- */
+ * Using autovacuum=off disables cleanup vacuum and analyze, but freeze
+ * vacuums can still happen, so we set autovacuum_freeze_max_age to its
+ * maximum. We assume all datfrozenxid and relfrozen values are less than
+ * a gap of 2000000000 from the current xid counter, so autovacuum will
+ * not touch them.
+ */
snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
"-o \"-p %d -c autovacuum=off "
"\"%s\" 2>&1" SYSTEMQUOTE,
bindir,
#ifndef WIN32
- log_opts.filename, datadir, fast ? "-m fast" : "", log_opts.filename);
+ log_opts.filename, datadir, fast ? "-m fast" : "", log_opts.filename);
#else
DEVNULL, datadir, fast ? "-m fast" : "", DEVNULL);
#endif
{
/* This cluster has a version-specific subdirectory */
cluster->tablespace_suffix = pg_malloc(4 +
- strlen(cluster->major_version_str) +
- 10 /* OIDCHARS */ + 1);
+ strlen(cluster->major_version_str) +
+ 10 /* OIDCHARS */ + 1);
/* The leading slash is needed to start a new directory. */
sprintf(cluster->tablespace_suffix, "/PG_%s_%d", cluster->major_version_str,
#include <signal.h>
-LogOpts log_opts;
+LogOpts log_opts;
/*
* report_status()
/* Rebuild all tsvector collumns with one ALTER TABLE command */
if (strcmp(PQgetvalue(res, rowno, i_nspname), nspname) != 0 ||
- strcmp(PQgetvalue(res, rowno, i_relname), relname) != 0)
+ strcmp(PQgetvalue(res, rowno, i_relname), relname) != 0)
{
if (strlen(nspname) != 0 || strlen(relname) != 0)
fprintf(script, ";\n\n");
&textDatums, NULL, &ndatums);
for (i = 0; i < ndatums; i++)
{
- text *txtname = DatumGetTextPP(textDatums[i]);
- char *extName = text_to_cstring(txtname);
- Oid extOid = get_extension_oid(extName, false);
+ text *txtname = DatumGetTextPP(textDatums[i]);
+ char *extName = text_to_cstring(txtname);
+ Oid extOid = get_extension_oid(extName, false);
requiredExtensions = lappend_oid(requiredExtensions, extOid);
}
InsertExtensionTuple(text_to_cstring(extName),
GetUserId(),
- get_namespace_oid(text_to_cstring(schemaName), false),
+ get_namespace_oid(text_to_cstring(schemaName), false),
relocatable,
text_to_cstring(extVersion),
extConfig,
typedef struct win32_pthread *pthread_t;
typedef int pthread_attr_t;
-static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
+static int pthread_create(pthread_t *thread, pthread_attr_t * attr, void *(*start_routine) (void *), void *arg);
static int pthread_join(pthread_t th, void **thread_return);
#elif defined(ENABLE_THREAD_SAFETY)
/* Use platform-dependent pthread capability */
typedef struct fork_pthread *pthread_t;
typedef int pthread_attr_t;
-static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
+static int pthread_create(pthread_t *thread, pthread_attr_t * attr, void *(*start_routine) (void *), void *arg);
static int pthread_join(pthread_t th, void **thread_return);
#endif
INSTR_TIME_SET_CURRENT(now);
INSTR_TIME_ACCUM_DIFF(thread->exec_elapsed[cnum],
- now, st->stmt_begin);
+ now, st->stmt_begin);
thread->exec_count[cnum]++;
}
if (commands[st->state]->type == SQL_COMMAND)
{
/*
- * Read and discard the query result; note this is not included
- * in the statement latency numbers.
+ * Read and discard the query result; note this is not included in
+ * the statement latency numbers.
*/
res = PQgetResult(st->con);
switch (PQresultStatus(res))
for (i = 0; i < num_files; i++)
{
- Command **commands;
+ Command **commands;
if (num_files > 1)
- printf("statement latencies in milliseconds, file %d:\n", i+1);
+ printf("statement latencies in milliseconds, file %d:\n", i + 1);
else
printf("statement latencies in milliseconds:\n");
for (commands = sql_files[i]; *commands != NULL; commands++)
{
- Command *command = *commands;
+ Command *command = *commands;
int cnum = command->command_num;
double total_time;
instr_time total_exec_elapsed;
total_exec_count = 0;
for (t = 0; t < nthreads; t++)
{
- TState *thread = &threads[t];
+ TState *thread = &threads[t];
INSTR_TIME_ADD(total_exec_elapsed,
thread->exec_elapsed[cnum]);
* is_latencies only works with multiple threads in thread-based
* implementations, not fork-based ones, because it supposes that the
* parent can see changes made to the per-thread execution stats by child
- * threads. It seems useful enough to accept despite this limitation,
- * but perhaps we should FIXME someday (by passing the stats data back
- * up through the parent-to-child pipes).
+ * threads. It seems useful enough to accept despite this limitation, but
+ * perhaps we should FIXME someday (by passing the stats data back up
+ * through the parent-to-child pipes).
*/
#ifndef ENABLE_THREAD_SAFETY
if (is_latencies && nthreads > 1)
threads = (TState *) xmalloc(sizeof(TState) * nthreads);
for (i = 0; i < nthreads; i++)
{
- TState *thread = &threads[i];
+ TState *thread = &threads[i];
thread->tid = i;
thread->state = &state[nclients / nthreads * i];
if (is_latencies)
{
/* Reserve memory for the thread to store per-command latencies */
- int t;
+ int t;
thread->exec_elapsed = (instr_time *)
xmalloc(sizeof(instr_time) * num_commands);
/* start threads */
for (i = 0; i < nthreads; i++)
{
- TState *thread = &threads[i];
+ TState *thread = &threads[i];
INSTR_TIME_SET_CURRENT(thread->start_time);
static int
pthread_create(pthread_t *thread,
- pthread_attr_t *attr,
+ pthread_attr_t * attr,
void *(*start_routine) (void *),
void *arg)
{
void *(*routine) (void *);
void *arg;
void *result;
-} win32_pthread;
+} win32_pthread;
static unsigned __stdcall
win32_pthread_run(void *arg)
static int
pthread_create(pthread_t *thread,
- pthread_attr_t *attr,
+ pthread_attr_t * attr,
void *(*start_routine) (void *),
void *arg)
{
{
seg = (SEG *) DatumGetPointer(entryvec->vector[i].key);
/* center calculation is done this way to avoid possible overflow */
- sort_items[i - 1].center = seg->lower*0.5f + seg->upper*0.5f;
+ sort_items[i - 1].center = seg->lower * 0.5f + seg->upper * 0.5f;
sort_items[i - 1].index = i;
sort_items[i - 1].data = seg;
}
result = bms_copy(columns);
result = bms_del_member(result, index);
- for (attno=1; attno <= natts; attno++)
+ for (attno = 1; attno <= natts; attno++)
{
tuple = SearchSysCache2(ATTNUM,
ObjectIdGetDatum(relOid),
while ((index = bms_first_member(tmpset)) > 0)
{
attno = index + FirstLowInvalidHeapAttributeNumber;
+
/*
* whole-row-reference shall be fixed-up later
*/
bool result = true;
/*
- * Hardwired Policies:
- * SE-PostgreSQL enforces
- * - clients cannot modify system catalogs using DMLs
- * - clients cannot reference/modify toast relations using DMLs
+ * Hardwired Policies: SE-PostgreSQL enforces - clients cannot modify
+ * system catalogs using DMLs - clients cannot reference/modify toast
+ * relations using DMLs
*/
if (sepgsql_getenforce() > 0)
{
- Oid relnamespace = get_rel_namespace(relOid);
+ Oid relnamespace = get_rel_namespace(relOid);
if (IsSystemNamespace(relnamespace) &&
(required & (SEPG_DB_TABLE__UPDATE |
{
AttrNumber attnum;
uint32 column_perms = 0;
- ObjectAddress object;
+ ObjectAddress object;
if (bms_is_member(index, selected))
column_perms |= SEPG_DB_COLUMN__SELECT;
{
ListCell *lr;
- foreach (lr, rangeTabls)
+ foreach(lr, rangeTabls)
{
- RangeTblEntry *rte = lfirst(lr);
- uint32 required = 0;
- List *tableIds;
- ListCell *li;
+ RangeTblEntry *rte = lfirst(lr);
+ uint32 required = 0;
+ List *tableIds;
+ ListCell *li;
/*
* Only regular relations shall be checked
/*
* If this RangeTblEntry is also supposed to reference inherited
- * tables, we need to check security label of the child tables.
- * So, we expand rte->relid into list of OIDs of inheritance
- * hierarchy, then checker routine will be invoked for each
- * relations.
+ * tables, we need to check security label of the child tables. So, we
+ * expand rte->relid into list of OIDs of inheritance hierarchy, then
+ * checker routine will be invoked for each relations.
*/
if (!rte->inh)
tableIds = list_make1_oid(rte->relid);
else
tableIds = find_all_inheritors(rte->relid, NoLock, NULL);
- foreach (li, tableIds)
+ foreach(li, tableIds)
{
Oid tableOid = lfirst_oid(li);
Bitmapset *selectedCols;
Bitmapset *modifiedCols;
/*
- * child table has different attribute numbers, so we need
- * to fix up them.
+ * child table has different attribute numbers, so we need to fix
+ * up them.
*/
selectedCols = fixup_inherited_columns(rte->relid, tableOid,
rte->selectedCols);
/*
* Declarations
*/
-void _PG_init(void);
+void _PG_init(void);
/*
* Saved hook entries (if stacked)
*/
-static object_access_hook_type next_object_access_hook = NULL;
-static ClientAuthentication_hook_type next_client_auth_hook = NULL;
-static ExecutorCheckPerms_hook_type next_exec_check_perms_hook = NULL;
-static needs_fmgr_hook_type next_needs_fmgr_hook = NULL;
-static fmgr_hook_type next_fmgr_hook = NULL;
-static ProcessUtility_hook_type next_ProcessUtility_hook = NULL;
+static object_access_hook_type next_object_access_hook = NULL;
+static ClientAuthentication_hook_type next_client_auth_hook = NULL;
+static ExecutorCheckPerms_hook_type next_exec_check_perms_hook = NULL;
+static needs_fmgr_hook_type next_needs_fmgr_hook = NULL;
+static fmgr_hook_type next_fmgr_hook = NULL;
+static ProcessUtility_hook_type next_ProcessUtility_hook = NULL;
/*
* GUC: sepgsql.permissive = (on|off)
static void
sepgsql_client_auth(Port *port, int status)
{
- char *context;
+ char *context;
if (next_client_auth_hook)
- (*next_client_auth_hook)(port, status);
+ (*next_client_auth_hook) (port, status);
/*
- * In the case when authentication failed, the supplied socket
- * shall be closed soon, so we don't need to do anything here.
+ * In the case when authentication failed, the supplied socket shall be
+ * closed soon, so we don't need to do anything here.
*/
if (status != STATUS_OK)
return;
sepgsql_set_client_label(context);
/*
- * Switch the current performing mode from INTERNAL to either
- * DEFAULT or PERMISSIVE.
+ * Switch the current performing mode from INTERNAL to either DEFAULT or
+ * PERMISSIVE.
*/
if (sepgsql_permissive)
sepgsql_set_mode(SEPGSQL_MODE_PERMISSIVE);
*/
static void
sepgsql_object_access(ObjectAccessType access,
- Oid classId,
- Oid objectId,
- int subId)
+ Oid classId,
+ Oid objectId,
+ int subId)
{
if (next_object_access_hook)
- (*next_object_access_hook)(access, classId, objectId, subId);
+ (*next_object_access_hook) (access, classId, objectId, subId);
switch (access)
{
break;
default:
- elog(ERROR, "unexpected object access type: %d", (int)access);
+ elog(ERROR, "unexpected object access type: %d", (int) access);
break;
}
}
sepgsql_exec_check_perms(List *rangeTabls, bool abort)
{
/*
- * If security provider is stacking and one of them replied 'false'
- * at least, we don't need to check any more.
+ * If security provider is stacking and one of them replied 'false' at
+ * least, we don't need to check any more.
*/
if (next_exec_check_perms_hook &&
- !(*next_exec_check_perms_hook)(rangeTabls, abort))
+ !(*next_exec_check_perms_hook) (rangeTabls, abort))
return false;
if (!sepgsql_dml_privileges(rangeTabls, abort))
static bool
sepgsql_needs_fmgr_hook(Oid functionId)
{
- char *old_label;
- char *new_label;
- char *function_label;
+ char *old_label;
+ char *new_label;
+ char *function_label;
if (next_needs_fmgr_hook &&
- (*next_needs_fmgr_hook)(functionId))
+ (*next_needs_fmgr_hook) (functionId))
return true;
/*
- * SELinux needs the function to be called via security_definer
- * wrapper, if this invocation will take a domain-transition.
- * We call these functions as trusted-procedure, if the security
- * policy has a rule that switches security label of the client
- * on execution.
+ * SELinux needs the function to be called via security_definer wrapper,
+ * if this invocation will take a domain-transition. We call these
+ * functions as trusted-procedure, if the security policy has a rule that
+ * switches security label of the client on execution.
*/
old_label = sepgsql_get_client_label();
new_label = sepgsql_proc_get_domtrans(functionId);
/*
* Even if not a trusted-procedure, this function should not be inlined
- * unless the client has db_procedure:{execute} permission.
- * Please note that it shall be actually failed later because of same
- * reason with ACL_EXECUTE.
+ * unless the client has db_procedure:{execute} permission. Please note
+ * that it shall be actually failed later because of same reason with
+ * ACL_EXECUTE.
*/
function_label = sepgsql_get_label(ProcedureRelationId, functionId, 0);
if (sepgsql_check_perms(sepgsql_get_client_label(),
sepgsql_fmgr_hook(FmgrHookEventType event,
FmgrInfo *flinfo, Datum *private)
{
- struct {
- char *old_label;
- char *new_label;
- Datum next_private;
- } *stack;
+ struct
+ {
+ char *old_label;
+ char *new_label;
+ Datum next_private;
+ } *stack;
switch (event)
{
case FHET_START:
- stack = (void *)DatumGetPointer(*private);
+ stack = (void *) DatumGetPointer(*private);
if (!stack)
{
- MemoryContext oldcxt;
- const char *cur_label = sepgsql_get_client_label();
+ MemoryContext oldcxt;
+ const char *cur_label = sepgsql_get_client_label();
oldcxt = MemoryContextSwitchTo(flinfo->fn_mcxt);
stack = palloc(sizeof(*stack));
{
/*
* process:transition permission between old and new
- * label, when user tries to switch security label of
- * the client on execution of trusted procedure.
+ * label, when user tries to switch security label of the
+ * client on execution of trusted procedure.
*/
sepgsql_check_perms(cur_label, stack->new_label,
SEPG_CLASS_PROCESS,
stack->old_label = sepgsql_set_client_label(stack->new_label);
if (next_fmgr_hook)
- (*next_fmgr_hook)(event, flinfo, &stack->next_private);
+ (*next_fmgr_hook) (event, flinfo, &stack->next_private);
break;
case FHET_END:
case FHET_ABORT:
- stack = (void *)DatumGetPointer(*private);
+ stack = (void *) DatumGetPointer(*private);
if (next_fmgr_hook)
- (*next_fmgr_hook)(event, flinfo, &stack->next_private);
+ (*next_fmgr_hook) (event, flinfo, &stack->next_private);
sepgsql_set_client_label(stack->old_label);
stack->old_label = NULL;
break;
default:
- elog(ERROR, "unexpected event type: %d", (int)event);
+ elog(ERROR, "unexpected event type: %d", (int) event);
break;
}
}
char *completionTag)
{
if (next_ProcessUtility_hook)
- (*next_ProcessUtility_hook)(parsetree, queryString, params,
- isTopLevel, dest, completionTag);
+ (*next_ProcessUtility_hook) (parsetree, queryString, params,
+ isTopLevel, dest, completionTag);
/*
* Check command tag to avoid nefarious operations
switch (nodeTag(parsetree))
{
case T_LoadStmt:
+
/*
* We reject LOAD command across the board on enforcing mode,
* because a binary module can arbitrarily override hooks.
}
break;
default:
+
/*
- * Right now we don't check any other utility commands,
- * because it needs more detailed information to make
- * access control decision here, but we don't want to
- * have two parse and analyze routines individually.
+ * Right now we don't check any other utility commands, because it
+ * needs more detailed information to make access control decision
+ * here, but we don't want to have two parse and analyze routines
+ * individually.
*/
break;
}
void
_PG_init(void)
{
- char *context;
+ char *context;
/*
* We allow to load the SE-PostgreSQL module on single-user-mode or
if (IsUnderPostmaster)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("sepgsql must be loaded via shared_preload_libraries")));
+ errmsg("sepgsql must be loaded via shared_preload_libraries")));
/*
- * Check availability of SELinux on the platform.
- * If disabled, we cannot activate any SE-PostgreSQL features,
- * and we have to skip rest of initialization.
+ * Check availability of SELinux on the platform. If disabled, we cannot
+ * activate any SE-PostgreSQL features, and we have to skip rest of
+ * initialization.
*/
if (is_selinux_enabled() < 1)
{
/*
* sepgsql.permissive = (on|off)
*
- * This variable controls performing mode of SE-PostgreSQL
- * on user's session.
+ * This variable controls performing mode of SE-PostgreSQL on user's
+ * session.
*/
DefineCustomBoolVariable("sepgsql.permissive",
"Turn on/off permissive mode in SE-PostgreSQL",
/*
* sepgsql.debug_audit = (on|off)
*
- * This variable allows users to turn on/off audit logs on access
- * control decisions, independent from auditallow/auditdeny setting
- * in the security policy.
- * We intend to use this option for debugging purpose.
+ * This variable allows users to turn on/off audit logs on access control
+ * decisions, independent from auditallow/auditdeny setting in the
+ * security policy. We intend to use this option for debugging purpose.
*/
DefineCustomBoolVariable("sepgsql.debug_audit",
"Turn on/off debug audit messages",
/*
* Set up dummy client label.
*
- * XXX - note that PostgreSQL launches background worker process
- * like autovacuum without authentication steps. So, we initialize
- * sepgsql_mode with SEPGSQL_MODE_INTERNAL, and client_label with
- * the security context of server process.
- * Later, it also launches background of user session. In this case,
- * the process is always hooked on post-authentication, and we can
- * initialize the sepgsql_mode and client_label correctly.
+ * XXX - note that PostgreSQL launches background worker process like
+ * autovacuum without authentication steps. So, we initialize sepgsql_mode
+ * with SEPGSQL_MODE_INTERNAL, and client_label with the security context
+ * of server process. Later, it also launches background of user session.
+ * In this case, the process is always hooked on post-authentication, and
+ * we can initialize the sepgsql_mode and client_label correctly.
*/
if (getcon_raw(&context) < 0)
ereport(ERROR,
*
* security label of the client process
*/
-static char *client_label = NULL;
+static char *client_label = NULL;
char *
sepgsql_get_client_label(void)
char *
sepgsql_set_client_label(char *new_label)
{
- char *old_label = client_label;
+ char *old_label = client_label;
client_label = new_label;
char *
sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
{
- ObjectAddress object;
- char *label;
+ ObjectAddress object;
+ char *label;
- object.classId = classId;
- object.objectId = objectId;
- object.objectSubId = subId;
+ object.classId = classId;
+ object.objectId = objectId;
+ object.objectSubId = subId;
label = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG);
- if (!label || security_check_context_raw((security_context_t)label))
+ if (!label || security_check_context_raw((security_context_t) label))
{
- security_context_t unlabeled;
+ security_context_t unlabeled;
if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("SELinux: failed to get initial security label: %m")));
+ errmsg("SELinux: failed to get initial security label: %m")));
PG_TRY();
{
label = pstrdup(unlabeled);
sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
{
/*
- * validate format of the supplied security label,
- * if it is security context of selinux.
+ * validate format of the supplied security label, if it is security
+ * context of selinux.
*/
if (seclabel &&
security_check_context_raw((security_context_t) seclabel) < 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_NAME),
- errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
+ errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
+
/*
* Do actual permission checks for each object classes
*/
switch (object->classId)
{
case NamespaceRelationId:
- sepgsql_schema_relabel(object->objectId, seclabel);
+ sepgsql_schema_relabel(object->objectId, seclabel);
break;
case RelationRelationId:
if (object->objectSubId == 0)
Datum
sepgsql_getcon(PG_FUNCTION_ARGS)
{
- char *client_label;
+ char *client_label;
if (!sepgsql_is_enabled())
PG_RETURN_NULL();
Datum
sepgsql_mcstrans_in(PG_FUNCTION_ARGS)
{
- text *label = PG_GETARG_TEXT_P(0);
- char *raw_label;
- char *result;
+ text *label = PG_GETARG_TEXT_P(0);
+ char *raw_label;
+ char *result;
if (!sepgsql_is_enabled())
ereport(ERROR,
Datum
sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
{
- text *label = PG_GETARG_TEXT_P(0);
- char *qual_label;
- char *result;
+ text *label = PG_GETARG_TEXT_P(0);
+ char *qual_label;
+ char *result;
if (!sepgsql_is_enabled())
ereport(ERROR,
quote_object_name(const char *src1, const char *src2,
const char *src3, const char *src4)
{
- StringInfoData result;
- const char *temp;
+ StringInfoData result;
+ const char *temp;
initStringInfo(&result);
temp = quote_identifier(src1);
appendStringInfo(&result, "%s", temp);
if (src1 != temp)
- pfree((void *)temp);
+ pfree((void *) temp);
}
if (src2)
{
temp = quote_identifier(src2);
appendStringInfo(&result, ".%s", temp);
if (src2 != temp)
- pfree((void *)temp);
+ pfree((void *) temp);
}
if (src3)
{
temp = quote_identifier(src3);
appendStringInfo(&result, ".%s", temp);
if (src3 != temp)
- pfree((void *)temp);
+ pfree((void *) temp);
}
if (src4)
{
temp = quote_identifier(src4);
appendStringInfo(&result, ".%s", temp);
if (src4 != temp)
- pfree((void *)temp);
+ pfree((void *) temp);
}
return result.data;
}
* catalog OID.
*/
static void
-exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
+exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId)
{
- Relation rel;
- SysScanDesc sscan;
- HeapTuple tuple;
- char *database_name = get_database_name(MyDatabaseId);
- char *namespace_name;
- Oid namespace_id;
- char *relation_name;
+ Relation rel;
+ SysScanDesc sscan;
+ HeapTuple tuple;
+ char *database_name = get_database_name(MyDatabaseId);
+ char *namespace_name;
+ Oid namespace_id;
+ char *relation_name;
/*
- * Open the target catalog. We don't want to allow writable
- * accesses by other session during initial labeling.
+ * Open the target catalog. We don't want to allow writable accesses by
+ * other session during initial labeling.
*/
rel = heap_open(catalogId, AccessShareLock);
SnapshotNow, 0, NULL);
while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
{
- Form_pg_namespace nspForm;
- Form_pg_class relForm;
- Form_pg_attribute attForm;
- Form_pg_proc proForm;
- char *objname;
- int objtype = 1234;
- ObjectAddress object;
- security_context_t context;
+ Form_pg_namespace nspForm;
+ Form_pg_class relForm;
+ Form_pg_attribute attForm;
+ Form_pg_proc proForm;
+ char *objname;
+ int objtype = 1234;
+ ObjectAddress object;
+ security_context_t context;
/*
- * The way to determine object name depends on object classes.
- * So, any branches set up `objtype', `objname' and `object' here.
+ * The way to determine object name depends on object classes. So, any
+ * branches set up `objtype', `objname' and `object' here.
*/
switch (catalogId)
{
default:
elog(ERROR, "unexpected catalog id: %u", catalogId);
- objname = NULL; /* for compiler quiet */
+ objname = NULL; /* for compiler quiet */
break;
}
Datum
sepgsql_restorecon(PG_FUNCTION_ARGS)
{
- struct selabel_handle *sehnd;
- struct selinux_opt seopts;
+ struct selabel_handle *sehnd;
+ struct selinux_opt seopts;
/*
* SELinux has to be enabled on the running platform.
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("sepgsql is not currently enabled")));
+
/*
- * Check DAC permission. Only superuser can set up initial
- * security labels, like root-user in filesystems
+ * Check DAC permission. Only superuser can set up initial security
+ * labels, like root-user in filesystems
*/
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("SELinux: must be superuser to restore initial contexts")));
+ errmsg("SELinux: must be superuser to restore initial contexts")));
/*
- * Open selabel_lookup(3) stuff. It provides a set of mapping
- * between an initial security label and object class/name due
- * to the system setting.
+ * Open selabel_lookup(3) stuff. It provides a set of mapping between an
+ * initial security label and object class/name due to the system setting.
*/
if (PG_ARGISNULL(0))
{
if (!sehnd)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("SELinux: failed to initialize labeling handle: %m")));
+ errmsg("SELinux: failed to initialize labeling handle: %m")));
PG_TRY();
{
/*
- * Right now, we have no support labeling on the shared
- * database objects, such as database, role, or tablespace.
+ * Right now, we have no support labeling on the shared database
+ * objects, such as database, role, or tablespace.
*/
exec_object_restorecon(sehnd, NamespaceRelationId);
exec_object_restorecon(sehnd, RelationRelationId);
selabel_close(sehnd);
PG_RE_THROW();
}
- PG_END_TRY();
+ PG_END_TRY();
selabel_close(sehnd);
void
sepgsql_proc_post_create(Oid functionId)
{
- Relation rel;
- ScanKeyData skey;
- SysScanDesc sscan;
- HeapTuple tuple;
- Oid namespaceId;
- ObjectAddress object;
- char *scontext;
- char *tcontext;
- char *ncontext;
+ Relation rel;
+ ScanKeyData skey;
+ SysScanDesc sscan;
+ HeapTuple tuple;
+ Oid namespaceId;
+ ObjectAddress object;
+ char *scontext;
+ char *tcontext;
+ char *ncontext;
/*
* Fetch namespace of the new procedure. Because pg_proc entry is not
heap_close(rel, AccessShareLock);
/*
- * Compute a default security label when we create a new procedure
- * object under the specified namespace.
+ * Compute a default security label when we create a new procedure object
+ * under the specified namespace.
*/
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(NamespaceRelationId, namespaceId, 0);
char *
sepgsql_proc_get_domtrans(Oid functionId)
{
- char *scontext = sepgsql_get_client_label();
- char *tcontext;
- char *ncontext;
+ char *scontext = sepgsql_get_client_label();
+ char *tcontext;
+ char *ncontext;
tcontext = sepgsql_get_label(ProcedureRelationId, functionId, 0);
void
sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
{
- char *scontext = sepgsql_get_client_label();
- char *tcontext;
- char *ncontext;
- ObjectAddress object;
+ char *scontext = sepgsql_get_client_label();
+ char *tcontext;
+ char *ncontext;
+ ObjectAddress object;
/*
- * Only attributes within regular relation have individual
- * security labels.
+ * Only attributes within regular relation have individual security
+ * labels.
*/
if (get_rel_relkind(relOid) != RELKIND_RELATION)
return;
/*
- * Compute a default security label when we create a new procedure
- * object under the specified namespace.
+ * Compute a default security label when we create a new procedure object
+ * under the specified namespace.
*/
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(RelationRelationId, relOid, 0);
ncontext = sepgsql_compute_create(scontext, tcontext,
SEPG_CLASS_DB_COLUMN);
+
/*
* Assign the default security label on a new procedure
*/
char *scontext = sepgsql_get_client_label();
char *tcontext;
char *audit_name;
- ObjectAddress object;
+ ObjectAddress object;
if (get_rel_relkind(relOid) != RELKIND_RELATION)
ereport(ERROR,
void
sepgsql_relation_post_create(Oid relOid)
{
- Relation rel;
- ScanKeyData skey;
- SysScanDesc sscan;
- HeapTuple tuple;
- Form_pg_class classForm;
- ObjectAddress object;
- uint16 tclass;
- char *scontext; /* subject */
- char *tcontext; /* schema */
- char *rcontext; /* relation */
- char *ccontext; /* column */
+ Relation rel;
+ ScanKeyData skey;
+ SysScanDesc sscan;
+ HeapTuple tuple;
+ Form_pg_class classForm;
+ ObjectAddress object;
+ uint16 tclass;
+ char *scontext; /* subject */
+ char *tcontext; /* schema */
+ char *rcontext; /* relation */
+ char *ccontext; /* column */
/*
- * Fetch catalog record of the new relation. Because pg_class entry is
- * not visible right now, we need to scan the catalog using SnapshotSelf.
+ * Fetch catalog record of the new relation. Because pg_class entry is not
+ * visible right now, we need to scan the catalog using SnapshotSelf.
*/
rel = heap_open(RelationRelationId, AccessShareLock);
else if (classForm->relkind == RELKIND_VIEW)
tclass = SEPG_CLASS_DB_VIEW;
else
- goto out; /* No need to assign individual labels */
+ goto out; /* No need to assign individual labels */
/*
- * Compute a default security label when we create a new relation
- * object under the specified namespace.
+ * Compute a default security label when we create a new relation object
+ * under the specified namespace.
*/
scontext = sepgsql_get_client_label();
tcontext = sepgsql_get_label(NamespaceRelationId,
SetSecurityLabel(&object, SEPGSQL_LABEL_TAG, rcontext);
/*
- * We also assigns a default security label on columns of the new
- * regular tables.
+ * We also assigns a default security label on columns of the new regular
+ * tables.
*/
if (classForm->relkind == RELKIND_RELATION)
{
void
sepgsql_schema_post_create(Oid namespaceId)
{
- char *scontext = sepgsql_get_client_label();
- char *tcontext;
- char *ncontext;
- ObjectAddress object;
+ char *scontext = sepgsql_get_client_label();
+ char *tcontext;
+ char *ncontext;
+ ObjectAddress object;
/*
- * FIXME: Right now, we assume pg_database object has a fixed
- * security label, because pg_seclabel does not support to store
- * label of shared database objects.
+ * FIXME: Right now, we assume pg_database object has a fixed security
+ * label, because pg_seclabel does not support to store label of shared
+ * database objects.
*/
tcontext = "system_u:object_r:sepgsql_db_t:s0";
/*
- * Compute a default security label when we create a new schema
- * object under the working database.
+ * Compute a default security label when we create a new schema object
+ * under the working database.
*/
ncontext = sepgsql_compute_create(scontext, tcontext,
SEPG_CLASS_DB_SCHEMA);
*/
static struct
{
- const char *class_name;
- uint16 class_code;
+ const char *class_name;
+ uint16 class_code;
struct
{
- const char *av_name;
- uint32 av_code;
- } av[32];
-} selinux_catalog[] = {
+ const char *av_name;
+ uint32 av_code;
+ } av[32];
+} selinux_catalog[] =
+
+{
{
- "process", SEPG_CLASS_PROCESS,
+ "process", SEPG_CLASS_PROCESS,
{
- { "transition", SEPG_PROCESS__TRANSITION },
- { NULL, 0UL }
+ {
+ "transition", SEPG_PROCESS__TRANSITION
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "file", SEPG_CLASS_FILE,
+ "file", SEPG_CLASS_FILE,
{
- { "read", SEPG_FILE__READ },
- { "write", SEPG_FILE__WRITE },
- { "create", SEPG_FILE__CREATE },
- { "getattr", SEPG_FILE__GETATTR },
- { "unlink", SEPG_FILE__UNLINK },
- { "rename", SEPG_FILE__RENAME },
- { "append", SEPG_FILE__APPEND },
- { NULL, 0UL }
+ {
+ "read", SEPG_FILE__READ
+ },
+ {
+ "write", SEPG_FILE__WRITE
+ },
+ {
+ "create", SEPG_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_FILE__RENAME
+ },
+ {
+ "append", SEPG_FILE__APPEND
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "dir", SEPG_CLASS_DIR,
+ "dir", SEPG_CLASS_DIR,
{
- { "read", SEPG_DIR__READ },
- { "write", SEPG_DIR__WRITE },
- { "create", SEPG_DIR__CREATE },
- { "getattr", SEPG_DIR__GETATTR },
- { "unlink", SEPG_DIR__UNLINK },
- { "rename", SEPG_DIR__RENAME },
- { "search", SEPG_DIR__SEARCH },
- { "add_name", SEPG_DIR__ADD_NAME },
- { "remove_name", SEPG_DIR__REMOVE_NAME },
- { "rmdir", SEPG_DIR__RMDIR },
- { "reparent", SEPG_DIR__REPARENT },
- { NULL, 0UL }
+ {
+ "read", SEPG_DIR__READ
+ },
+ {
+ "write", SEPG_DIR__WRITE
+ },
+ {
+ "create", SEPG_DIR__CREATE
+ },
+ {
+ "getattr", SEPG_DIR__GETATTR
+ },
+ {
+ "unlink", SEPG_DIR__UNLINK
+ },
+ {
+ "rename", SEPG_DIR__RENAME
+ },
+ {
+ "search", SEPG_DIR__SEARCH
+ },
+ {
+ "add_name", SEPG_DIR__ADD_NAME
+ },
+ {
+ "remove_name", SEPG_DIR__REMOVE_NAME
+ },
+ {
+ "rmdir", SEPG_DIR__RMDIR
+ },
+ {
+ "reparent", SEPG_DIR__REPARENT
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "lnk_file", SEPG_CLASS_LNK_FILE,
+ "lnk_file", SEPG_CLASS_LNK_FILE,
{
- { "read", SEPG_LNK_FILE__READ },
- { "write", SEPG_LNK_FILE__WRITE },
- { "create", SEPG_LNK_FILE__CREATE },
- { "getattr", SEPG_LNK_FILE__GETATTR },
- { "unlink", SEPG_LNK_FILE__UNLINK },
- { "rename", SEPG_LNK_FILE__RENAME },
- { NULL, 0UL }
+ {
+ "read", SEPG_LNK_FILE__READ
+ },
+ {
+ "write", SEPG_LNK_FILE__WRITE
+ },
+ {
+ "create", SEPG_LNK_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_LNK_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_LNK_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_LNK_FILE__RENAME
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "chr_file", SEPG_CLASS_CHR_FILE,
+ "chr_file", SEPG_CLASS_CHR_FILE,
{
- { "read", SEPG_CHR_FILE__READ },
- { "write", SEPG_CHR_FILE__WRITE },
- { "create", SEPG_CHR_FILE__CREATE },
- { "getattr", SEPG_CHR_FILE__GETATTR },
- { "unlink", SEPG_CHR_FILE__UNLINK },
- { "rename", SEPG_CHR_FILE__RENAME },
- { NULL, 0UL }
+ {
+ "read", SEPG_CHR_FILE__READ
+ },
+ {
+ "write", SEPG_CHR_FILE__WRITE
+ },
+ {
+ "create", SEPG_CHR_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_CHR_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_CHR_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_CHR_FILE__RENAME
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "blk_file", SEPG_CLASS_BLK_FILE,
+ "blk_file", SEPG_CLASS_BLK_FILE,
{
- { "read", SEPG_BLK_FILE__READ },
- { "write", SEPG_BLK_FILE__WRITE },
- { "create", SEPG_BLK_FILE__CREATE },
- { "getattr", SEPG_BLK_FILE__GETATTR },
- { "unlink", SEPG_BLK_FILE__UNLINK },
- { "rename", SEPG_BLK_FILE__RENAME },
- { NULL, 0UL }
+ {
+ "read", SEPG_BLK_FILE__READ
+ },
+ {
+ "write", SEPG_BLK_FILE__WRITE
+ },
+ {
+ "create", SEPG_BLK_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_BLK_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_BLK_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_BLK_FILE__RENAME
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "sock_file", SEPG_CLASS_SOCK_FILE,
+ "sock_file", SEPG_CLASS_SOCK_FILE,
{
- { "read", SEPG_SOCK_FILE__READ },
- { "write", SEPG_SOCK_FILE__WRITE },
- { "create", SEPG_SOCK_FILE__CREATE },
- { "getattr", SEPG_SOCK_FILE__GETATTR },
- { "unlink", SEPG_SOCK_FILE__UNLINK },
- { "rename", SEPG_SOCK_FILE__RENAME },
- { NULL, 0UL }
+ {
+ "read", SEPG_SOCK_FILE__READ
+ },
+ {
+ "write", SEPG_SOCK_FILE__WRITE
+ },
+ {
+ "create", SEPG_SOCK_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_SOCK_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_SOCK_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_SOCK_FILE__RENAME
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "fifo_file", SEPG_CLASS_FIFO_FILE,
+ "fifo_file", SEPG_CLASS_FIFO_FILE,
{
- { "read", SEPG_FIFO_FILE__READ },
- { "write", SEPG_FIFO_FILE__WRITE },
- { "create", SEPG_FIFO_FILE__CREATE },
- { "getattr", SEPG_FIFO_FILE__GETATTR },
- { "unlink", SEPG_FIFO_FILE__UNLINK },
- { "rename", SEPG_FIFO_FILE__RENAME },
- { NULL, 0UL }
+ {
+ "read", SEPG_FIFO_FILE__READ
+ },
+ {
+ "write", SEPG_FIFO_FILE__WRITE
+ },
+ {
+ "create", SEPG_FIFO_FILE__CREATE
+ },
+ {
+ "getattr", SEPG_FIFO_FILE__GETATTR
+ },
+ {
+ "unlink", SEPG_FIFO_FILE__UNLINK
+ },
+ {
+ "rename", SEPG_FIFO_FILE__RENAME
+ },
+ {
+ NULL, 0UL
+ }
}
},
{
- "db_database", SEPG_CLASS_DB_DATABASE,
+ "db_database", SEPG_CLASS_DB_DATABASE,
{
- { "create", SEPG_DB_DATABASE__CREATE },
- { "drop", SEPG_DB_DATABASE__DROP },
- { "getattr", SEPG_DB_DATABASE__GETATTR },
- { "setattr", SEPG_DB_DATABASE__SETATTR },
- { "relabelfrom", SEPG_DB_DATABASE__RELABELFROM },
- { "relabelto", SEPG_DB_DATABASE__RELABELTO },
- { "access", SEPG_DB_DATABASE__ACCESS },
- { "load_module", SEPG_DB_DATABASE__LOAD_MODULE },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_DATABASE__CREATE
+ },
+ {
+ "drop", SEPG_DB_DATABASE__DROP
+ },
+ {
+ "getattr", SEPG_DB_DATABASE__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_DATABASE__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_DATABASE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_DATABASE__RELABELTO
+ },
+ {
+ "access", SEPG_DB_DATABASE__ACCESS
+ },
+ {
+ "load_module", SEPG_DB_DATABASE__LOAD_MODULE
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_schema", SEPG_CLASS_DB_SCHEMA,
+ "db_schema", SEPG_CLASS_DB_SCHEMA,
{
- { "create", SEPG_DB_SCHEMA__CREATE },
- { "drop", SEPG_DB_SCHEMA__DROP },
- { "getattr", SEPG_DB_SCHEMA__GETATTR },
- { "setattr", SEPG_DB_SCHEMA__SETATTR },
- { "relabelfrom", SEPG_DB_SCHEMA__RELABELFROM },
- { "relabelto", SEPG_DB_SCHEMA__RELABELTO },
- { "search", SEPG_DB_SCHEMA__SEARCH },
- { "add_name", SEPG_DB_SCHEMA__ADD_NAME },
- { "remove_name", SEPG_DB_SCHEMA__REMOVE_NAME },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_SCHEMA__CREATE
+ },
+ {
+ "drop", SEPG_DB_SCHEMA__DROP
+ },
+ {
+ "getattr", SEPG_DB_SCHEMA__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_SCHEMA__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_SCHEMA__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_SCHEMA__RELABELTO
+ },
+ {
+ "search", SEPG_DB_SCHEMA__SEARCH
+ },
+ {
+ "add_name", SEPG_DB_SCHEMA__ADD_NAME
+ },
+ {
+ "remove_name", SEPG_DB_SCHEMA__REMOVE_NAME
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_table", SEPG_CLASS_DB_TABLE,
+ "db_table", SEPG_CLASS_DB_TABLE,
{
- { "create", SEPG_DB_TABLE__CREATE },
- { "drop", SEPG_DB_TABLE__DROP },
- { "getattr", SEPG_DB_TABLE__GETATTR },
- { "setattr", SEPG_DB_TABLE__SETATTR },
- { "relabelfrom", SEPG_DB_TABLE__RELABELFROM },
- { "relabelto", SEPG_DB_TABLE__RELABELTO },
- { "select", SEPG_DB_TABLE__SELECT },
- { "update", SEPG_DB_TABLE__UPDATE },
- { "insert", SEPG_DB_TABLE__INSERT },
- { "delete", SEPG_DB_TABLE__DELETE },
- { "lock", SEPG_DB_TABLE__LOCK },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_TABLE__CREATE
+ },
+ {
+ "drop", SEPG_DB_TABLE__DROP
+ },
+ {
+ "getattr", SEPG_DB_TABLE__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_TABLE__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_TABLE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_TABLE__RELABELTO
+ },
+ {
+ "select", SEPG_DB_TABLE__SELECT
+ },
+ {
+ "update", SEPG_DB_TABLE__UPDATE
+ },
+ {
+ "insert", SEPG_DB_TABLE__INSERT
+ },
+ {
+ "delete", SEPG_DB_TABLE__DELETE
+ },
+ {
+ "lock", SEPG_DB_TABLE__LOCK
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_sequence", SEPG_CLASS_DB_SEQUENCE,
+ "db_sequence", SEPG_CLASS_DB_SEQUENCE,
{
- { "create", SEPG_DB_SEQUENCE__CREATE },
- { "drop", SEPG_DB_SEQUENCE__DROP },
- { "getattr", SEPG_DB_SEQUENCE__GETATTR },
- { "setattr", SEPG_DB_SEQUENCE__SETATTR },
- { "relabelfrom", SEPG_DB_SEQUENCE__RELABELFROM },
- { "relabelto", SEPG_DB_SEQUENCE__RELABELTO },
- { "get_value", SEPG_DB_SEQUENCE__GET_VALUE },
- { "next_value", SEPG_DB_SEQUENCE__NEXT_VALUE },
- { "set_value", SEPG_DB_SEQUENCE__SET_VALUE },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_SEQUENCE__CREATE
+ },
+ {
+ "drop", SEPG_DB_SEQUENCE__DROP
+ },
+ {
+ "getattr", SEPG_DB_SEQUENCE__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_SEQUENCE__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_SEQUENCE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_SEQUENCE__RELABELTO
+ },
+ {
+ "get_value", SEPG_DB_SEQUENCE__GET_VALUE
+ },
+ {
+ "next_value", SEPG_DB_SEQUENCE__NEXT_VALUE
+ },
+ {
+ "set_value", SEPG_DB_SEQUENCE__SET_VALUE
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_procedure", SEPG_CLASS_DB_PROCEDURE,
+ "db_procedure", SEPG_CLASS_DB_PROCEDURE,
{
- { "create", SEPG_DB_PROCEDURE__CREATE },
- { "drop", SEPG_DB_PROCEDURE__DROP },
- { "getattr", SEPG_DB_PROCEDURE__GETATTR },
- { "setattr", SEPG_DB_PROCEDURE__SETATTR },
- { "relabelfrom", SEPG_DB_PROCEDURE__RELABELFROM },
- { "relabelto", SEPG_DB_PROCEDURE__RELABELTO },
- { "execute", SEPG_DB_PROCEDURE__EXECUTE },
- { "entrypoint", SEPG_DB_PROCEDURE__ENTRYPOINT },
- { "install", SEPG_DB_PROCEDURE__INSTALL },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_PROCEDURE__CREATE
+ },
+ {
+ "drop", SEPG_DB_PROCEDURE__DROP
+ },
+ {
+ "getattr", SEPG_DB_PROCEDURE__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_PROCEDURE__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_PROCEDURE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_PROCEDURE__RELABELTO
+ },
+ {
+ "execute", SEPG_DB_PROCEDURE__EXECUTE
+ },
+ {
+ "entrypoint", SEPG_DB_PROCEDURE__ENTRYPOINT
+ },
+ {
+ "install", SEPG_DB_PROCEDURE__INSTALL
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_column", SEPG_CLASS_DB_COLUMN,
+ "db_column", SEPG_CLASS_DB_COLUMN,
{
- { "create", SEPG_DB_COLUMN__CREATE },
- { "drop", SEPG_DB_COLUMN__DROP },
- { "getattr", SEPG_DB_COLUMN__GETATTR },
- { "setattr", SEPG_DB_COLUMN__SETATTR },
- { "relabelfrom", SEPG_DB_COLUMN__RELABELFROM },
- { "relabelto", SEPG_DB_COLUMN__RELABELTO },
- { "select", SEPG_DB_COLUMN__SELECT },
- { "update", SEPG_DB_COLUMN__UPDATE },
- { "insert", SEPG_DB_COLUMN__INSERT },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_COLUMN__CREATE
+ },
+ {
+ "drop", SEPG_DB_COLUMN__DROP
+ },
+ {
+ "getattr", SEPG_DB_COLUMN__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_COLUMN__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_COLUMN__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_COLUMN__RELABELTO
+ },
+ {
+ "select", SEPG_DB_COLUMN__SELECT
+ },
+ {
+ "update", SEPG_DB_COLUMN__UPDATE
+ },
+ {
+ "insert", SEPG_DB_COLUMN__INSERT
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_tuple", SEPG_CLASS_DB_TUPLE,
+ "db_tuple", SEPG_CLASS_DB_TUPLE,
{
- { "relabelfrom", SEPG_DB_TUPLE__RELABELFROM },
- { "relabelto", SEPG_DB_TUPLE__RELABELTO },
- { "select", SEPG_DB_TUPLE__SELECT },
- { "update", SEPG_DB_TUPLE__UPDATE },
- { "insert", SEPG_DB_TUPLE__INSERT },
- { "delete", SEPG_DB_TUPLE__DELETE },
- { NULL, 0UL },
+ {
+ "relabelfrom", SEPG_DB_TUPLE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_TUPLE__RELABELTO
+ },
+ {
+ "select", SEPG_DB_TUPLE__SELECT
+ },
+ {
+ "update", SEPG_DB_TUPLE__UPDATE
+ },
+ {
+ "insert", SEPG_DB_TUPLE__INSERT
+ },
+ {
+ "delete", SEPG_DB_TUPLE__DELETE
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_blob", SEPG_CLASS_DB_BLOB,
+ "db_blob", SEPG_CLASS_DB_BLOB,
{
- { "create", SEPG_DB_BLOB__CREATE },
- { "drop", SEPG_DB_BLOB__DROP },
- { "getattr", SEPG_DB_BLOB__GETATTR },
- { "setattr", SEPG_DB_BLOB__SETATTR },
- { "relabelfrom", SEPG_DB_BLOB__RELABELFROM },
- { "relabelto", SEPG_DB_BLOB__RELABELTO },
- { "read", SEPG_DB_BLOB__READ },
- { "write", SEPG_DB_BLOB__WRITE },
- { "import", SEPG_DB_BLOB__IMPORT },
- { "export", SEPG_DB_BLOB__EXPORT },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_BLOB__CREATE
+ },
+ {
+ "drop", SEPG_DB_BLOB__DROP
+ },
+ {
+ "getattr", SEPG_DB_BLOB__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_BLOB__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_BLOB__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_BLOB__RELABELTO
+ },
+ {
+ "read", SEPG_DB_BLOB__READ
+ },
+ {
+ "write", SEPG_DB_BLOB__WRITE
+ },
+ {
+ "import", SEPG_DB_BLOB__IMPORT
+ },
+ {
+ "export", SEPG_DB_BLOB__EXPORT
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_language", SEPG_CLASS_DB_LANGUAGE,
+ "db_language", SEPG_CLASS_DB_LANGUAGE,
{
- { "create", SEPG_DB_LANGUAGE__CREATE },
- { "drop", SEPG_DB_LANGUAGE__DROP },
- { "getattr", SEPG_DB_LANGUAGE__GETATTR },
- { "setattr", SEPG_DB_LANGUAGE__SETATTR },
- { "relabelfrom", SEPG_DB_LANGUAGE__RELABELFROM },
- { "relabelto", SEPG_DB_LANGUAGE__RELABELTO },
- { "implement", SEPG_DB_LANGUAGE__IMPLEMENT },
- { "execute", SEPG_DB_LANGUAGE__EXECUTE },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_LANGUAGE__CREATE
+ },
+ {
+ "drop", SEPG_DB_LANGUAGE__DROP
+ },
+ {
+ "getattr", SEPG_DB_LANGUAGE__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_LANGUAGE__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_LANGUAGE__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_LANGUAGE__RELABELTO
+ },
+ {
+ "implement", SEPG_DB_LANGUAGE__IMPLEMENT
+ },
+ {
+ "execute", SEPG_DB_LANGUAGE__EXECUTE
+ },
+ {
+ NULL, 0UL
+ },
}
},
{
- "db_view", SEPG_CLASS_DB_VIEW,
+ "db_view", SEPG_CLASS_DB_VIEW,
{
- { "create", SEPG_DB_VIEW__CREATE },
- { "drop", SEPG_DB_VIEW__DROP },
- { "getattr", SEPG_DB_VIEW__GETATTR },
- { "setattr", SEPG_DB_VIEW__SETATTR },
- { "relabelfrom", SEPG_DB_VIEW__RELABELFROM },
- { "relabelto", SEPG_DB_VIEW__RELABELTO },
- { "expand", SEPG_DB_VIEW__EXPAND },
- { NULL, 0UL },
+ {
+ "create", SEPG_DB_VIEW__CREATE
+ },
+ {
+ "drop", SEPG_DB_VIEW__DROP
+ },
+ {
+ "getattr", SEPG_DB_VIEW__GETATTR
+ },
+ {
+ "setattr", SEPG_DB_VIEW__SETATTR
+ },
+ {
+ "relabelfrom", SEPG_DB_VIEW__RELABELFROM
+ },
+ {
+ "relabelto", SEPG_DB_VIEW__RELABELTO
+ },
+ {
+ "expand", SEPG_DB_VIEW__EXPAND
+ },
+ {
+ NULL, 0UL
+ },
}
},
};
int
sepgsql_set_mode(int new_mode)
{
- int old_mode = sepgsql_mode;
+ int old_mode = sepgsql_mode;
sepgsql_mode = new_mode;
uint32 audited,
const char *audit_name)
{
- StringInfoData buf;
- const char *class_name;
- const char *av_name;
- int i;
+ StringInfoData buf;
+ const char *class_name;
+ const char *av_name;
+ int i;
/* lookup name of the object class */
Assert(tclass < SEPG_CLASS_MAX);
initStringInfo(&buf);
appendStringInfo(&buf, "%s {",
(denied ? "denied" : "allowed"));
- for (i=0; selinux_catalog[tclass].av[i].av_name; i++)
+ for (i = 0; selinux_catalog[tclass].av[i].av_name; i++)
{
if (audited & (1UL << i))
{
sepgsql_compute_avd(const char *scontext,
const char *tcontext,
uint16 tclass,
- struct av_decision *avd)
+ struct av_decision * avd)
{
- const char *tclass_name;
- security_class_t tclass_ex;
- struct av_decision avd_ex;
- int i, deny_unknown = security_deny_unknown();
+ const char *tclass_name;
+ security_class_t tclass_ex;
+ struct av_decision avd_ex;
+ int i,
+ deny_unknown = security_deny_unknown();
- /* Get external code of the object class*/
+ /* Get external code of the object class */
Assert(tclass < SEPG_CLASS_MAX);
Assert(tclass == selinux_catalog[tclass].class_code);
{
/*
* If the current security policy does not support permissions
- * corresponding to database objects, we fill up them with dummy
- * data.
+ * corresponding to database objects, we fill up them with dummy data.
* If security_deny_unknown() returns positive value, undefined
* permissions should be denied. Otherwise, allowed
*/
avd->allowed = (security_deny_unknown() > 0 ? 0 : ~0);
avd->auditallow = 0U;
- avd->auditdeny = ~0U;
+ avd->auditdeny = ~0U;
avd->flags = 0;
return;
* Ask SELinux what is allowed set of permissions on a pair of the
* security contexts and the given object class.
*/
- if (security_compute_av_flags_raw((security_context_t)scontext,
- (security_context_t)tcontext,
+ if (security_compute_av_flags_raw((security_context_t) scontext,
+ (security_context_t) tcontext,
tclass_ex, 0, &avd_ex) < 0)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
/*
* SELinux returns its access control decision as a set of permissions
- * represented in external code which depends on run-time environment.
- * So, we need to translate it to the internal representation before
- * returning results for the caller.
+ * represented in external code which depends on run-time environment. So,
+ * we need to translate it to the internal representation before returning
+ * results for the caller.
*/
memset(avd, 0, sizeof(struct av_decision));
- for (i=0; selinux_catalog[tclass].av[i].av_name; i++)
+ for (i = 0; selinux_catalog[tclass].av[i].av_name; i++)
{
- access_vector_t av_code_ex;
- const char *av_name = selinux_catalog[tclass].av[i].av_name;
- uint32 av_code = selinux_catalog[tclass].av[i].av_code;
+ access_vector_t av_code_ex;
+ const char *av_name = selinux_catalog[tclass].av[i].av_name;
+ uint32 av_code = selinux_catalog[tclass].av[i].av_code;
av_code_ex = string_to_av_perm(tclass_ex, av_name);
if (av_code_ex == 0)
const char *tcontext,
uint16 tclass)
{
- security_context_t ncontext;
- security_class_t tclass_ex;
- const char *tclass_name;
- char *result;
+ security_context_t ncontext;
+ security_class_t tclass_ex;
+ const char *tclass_name;
+ char *result;
- /* Get external code of the object class*/
+ /* Get external code of the object class */
Assert(tclass < SEPG_CLASS_MAX);
tclass_name = selinux_catalog[tclass].class_name;
tclass_ex = string_to_security_class(tclass_name);
/*
- * Ask SELinux what is the default context for the given object class
- * on a pair of security contexts
+ * Ask SELinux what is the default context for the given object class on a
+ * pair of security contexts
*/
- if (security_compute_create_raw((security_context_t)scontext,
- (security_context_t)tcontext,
+ if (security_compute_create_raw((security_context_t) scontext,
+ (security_context_t) tcontext,
tclass_ex, &ncontext) < 0)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
scontext, tcontext, tclass_name)));
/*
- * libselinux returns malloc()'ed string, so we need to copy it
- * on the palloc()'ed region.
+ * libselinux returns malloc()'ed string, so we need to copy it on the
+ * palloc()'ed region.
*/
PG_TRY();
{
const char *audit_name,
bool abort)
{
- struct av_decision avd;
+ struct av_decision avd;
uint32 denied;
uint32 audited;
bool result = true;
audited = (denied ? denied : required);
else
audited = (denied ? (denied & avd.auditdeny)
- : (required & avd.auditallow));
+ : (required & avd.auditallow));
if (denied &&
sepgsql_getenforce() > 0 &&
result = false;
/*
- * It records a security audit for the request, if needed.
- * But, when SE-PgSQL performs 'internal' mode, it needs to keep silent.
+ * It records a security audit for the request, if needed. But, when
+ * SE-PgSQL performs 'internal' mode, it needs to keep silent.
*/
if (audited && sepgsql_mode != SEPGSQL_MODE_INTERNAL)
{
/*
* selinux.c
*/
-extern bool sepgsql_is_enabled(void);
+extern bool sepgsql_is_enabled(void);
extern int sepgsql_get_mode(void);
extern int sepgsql_set_mode(int new_mode);
extern bool sepgsql_getenforce(void);
extern void sepgsql_audit_log(bool denied,
- const char *scontext,
- const char *tcontext,
- uint16 tclass,
- uint32 audited,
- const char *audit_name);
+ const char *scontext,
+ const char *tcontext,
+ uint16 tclass,
+ uint32 audited,
+ const char *audit_name);
extern void sepgsql_compute_avd(const char *scontext,
- const char *tcontext,
- uint16 tclass,
- struct av_decision *avd);
+ const char *tcontext,
+ uint16 tclass,
+ struct av_decision * avd);
extern char *sepgsql_compute_create(const char *scontext,
- const char *tcontext,
- uint16 tclass);
+ const char *tcontext,
+ uint16 tclass);
extern bool sepgsql_check_perms(const char *scontext,
- const char *tcontext,
- uint16 tclass,
- uint32 required,
- const char *audit_name,
- bool abort);
+ const char *tcontext,
+ uint16 tclass,
+ uint32 required,
+ const char *audit_name,
+ bool abort);
+
/*
* label.c
*/
extern char *sepgsql_set_client_label(char *new_label);
extern char *sepgsql_get_label(Oid relOid, Oid objOid, int32 subId);
-extern void sepgsql_object_relabel(const ObjectAddress *object,
- const char *seclabel);
+extern void sepgsql_object_relabel(const ObjectAddress *object,
+ const char *seclabel);
extern Datum sepgsql_getcon(PG_FUNCTION_ARGS);
extern Datum sepgsql_mcstrans_in(PG_FUNCTION_ARGS);
*/
extern void sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum);
extern void sepgsql_attribute_relabel(Oid relOid, AttrNumber attnum,
- const char *seclabel);
+ const char *seclabel);
extern void sepgsql_relation_post_create(Oid relOid);
extern void sepgsql_relation_relabel(Oid relOid, const char *seclabel);
extern void sepgsql_proc_relabel(Oid functionId, const char *seclabel);
extern char *sepgsql_proc_get_domtrans(Oid functionId);
-#endif /* SEPGSQL_H */
+#endif /* SEPGSQL_H */
/*
* This is where we check to see if the field we are supposed to update
- * even exists. The above function must return -1 if name not found?
+ * even exists. The above function must return -1 if name not found?
*/
if (attnum < 0)
ereport(ERROR,
static xmlChar *pgxml_texttoxmlchar(text *textstring);
static xmlXPathObjectPtr pgxml_xpath(text *document, xmlChar *xpath,
- xpath_workspace *workspace);
+ xpath_workspace *workspace);
static void cleanup_workspace(xpath_workspace *workspace);
xpath_nodeset(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
- text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
+ text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
xmlChar *septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3));
xmlChar *xpath;
xpath_list(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
- text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
+ text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *plainsep = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
xmlChar *xpath;
text *xpres;
xpath_string(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
- text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
+ text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *xpath;
int32 pathsize;
text *xpres;
xpath_number(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
- text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
+ text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *xpath;
float4 fRes;
xmlXPathObjectPtr res;
xpath_bool(PG_FUNCTION_ARGS)
{
text *document = PG_GETARG_TEXT_P(0);
- text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
+ text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
xmlChar *xpath;
int bRes;
xmlXPathObjectPtr res;
/* local defs */
static const char **parse_params(text *paramstr);
-
#endif /* USE_LIBXSLT */
{
max_params *= 2;
params = (const char **) repalloc(params,
- (max_params + 1) * sizeof(char *));
+ (max_params + 1) * sizeof(char *));
}
params[nparams++] = pos;
pos = strstr(pos, nvsep);
*
* check to see if any preceding bits are null...
*/
- int byte = attnum >> 3;
+ int byte = attnum >> 3;
int finalbit = attnum & 0x07;
/* check for nulls "before" final bit of last byte */
* Now check to see if any preceding bits are null...
*/
{
- int byte = attnum >> 3;
+ int byte = attnum >> 3;
int finalbit = attnum & 0x07;
/* check for nulls "before" final bit of last byte */
ArrayType *array = PG_GETARG_ARRAYTYPE_P_COPY(0);
int32 *nkeys = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
- /* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
+
+ /* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
bool **nullFlags = (bool **) PG_GETARG_POINTER(5);
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
case GinContainsStrategy:
if (nelems > 0)
*searchMode = GIN_SEARCH_MODE_DEFAULT;
- else /* everything contains the empty set */
+ else /* everything contains the empty set */
*searchMode = GIN_SEARCH_MODE_ALL;
break;
case GinContainedStrategy:
{
bool *check = (bool *) PG_GETARG_POINTER(0);
StrategyNumber strategy = PG_GETARG_UINT16(1);
+
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
+
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
+
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(6); */
bool *nullFlags = (bool *) PG_GETARG_POINTER(7);
bool res;
case GinEqualStrategy:
/* we will need recheck */
*recheck = true;
+
/*
* Must have all elements in check[] true; no discrimination
- * against nulls here. This is because array_contain_compare
- * and array_eq handle nulls differently ...
+ * against nulls here. This is because array_contain_compare and
+ * array_eq handle nulls differently ...
*/
res = true;
for (i = 0; i < nkeys; i++)
GinEntryAccumulator *ea;
/*
- * Allocate memory by rather big chunks to decrease overhead. We have
- * no need to reclaim RBNodes individually, so this costs nothing.
+ * Allocate memory by rather big chunks to decrease overhead. We have no
+ * need to reclaim RBNodes individually, so this costs nothing.
*/
if (accum->entryallocator == NULL || accum->eas_used >= DEF_NENTRY)
{
cmpEntryAccumulator,
ginCombineData,
ginAllocEntryAccumulator,
- NULL, /* no freefunc needed */
+ NULL, /* no freefunc needed */
(void *) accum);
}
bool isNew;
/*
- * For the moment, fill only the fields of eatmp that will be looked at
- * by cmpEntryAccumulator or ginCombineData.
+ * For the moment, fill only the fields of eatmp that will be looked at by
+ * cmpEntryAccumulator or ginCombineData.
*/
eatmp.attnum = attnum;
eatmp.key = key;
int
ginCompareItemPointers(ItemPointer a, ItemPointer b)
{
- BlockNumber ba = GinItemPointerGetBlockNumber(a);
- BlockNumber bb = GinItemPointerGetBlockNumber(b);
+ BlockNumber ba = GinItemPointerGetBlockNumber(a);
+ BlockNumber bb = GinItemPointerGetBlockNumber(b);
if (ba == bb)
{
- OffsetNumber oa = GinItemPointerGetOffsetNumber(a);
- OffsetNumber ob = GinItemPointerGetOffsetNumber(b);
+ OffsetNumber oa = GinItemPointerGetOffsetNumber(a);
+ OffsetNumber ob = GinItemPointerGetOffsetNumber(b);
if (oa == ob)
return 0;
Page page = BufferGetPage(buf);
int sizeofitem = GinSizeOfDataPageItem(page);
int cnt = 0;
+
/* these must be static so they can be returned to caller */
static XLogRecData rdata[3];
static ginxlogInsert data;
Size pageSize = PageGetPageSize(lpage);
Size freeSpace;
uint32 nCopied = 1;
+
/* these must be static so they can be returned to caller */
static ginxlogSplit data;
static XLogRecData rdata[4];
if (errorTooBig)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("index row size %lu exceeds maximum %lu for index \"%s\"",
- (unsigned long) newsize,
- (unsigned long) Min(INDEX_SIZE_MASK,
- GinMaxItemSize),
- RelationGetRelationName(ginstate->index))));
+ errmsg("index row size %lu exceeds maximum %lu for index \"%s\"",
+ (unsigned long) newsize,
+ (unsigned long) Min(INDEX_SIZE_MASK,
+ GinMaxItemSize),
+ RelationGetRelationName(ginstate->index))));
pfree(itup);
return NULL;
}
* Form a non-leaf entry tuple by copying the key data from the given tuple,
* which can be either a leaf or non-leaf entry tuple.
*
- * Any posting list in the source tuple is not copied. The specified child
+ * Any posting list in the source tuple is not copied. The specified child
* block number is inserted into t_tid.
*/
static IndexTuple
key = gintuple_get_key(btree->ginstate, itup, &category);
if (ginCompareAttEntries(btree->ginstate,
- btree->entryAttnum, btree->entryKey, btree->entryCategory,
+ btree->entryAttnum, btree->entryKey, btree->entryCategory,
attnum, key, category) > 0)
return TRUE;
Page page = BufferGetPage(buf);
OffsetNumber placed;
int cnt = 0;
+
/* these must be static so they can be returned to caller */
static XLogRecData rdata[3];
static ginxlogInsert data;
Page lpage = PageGetTempPageCopy(BufferGetPage(lbuf));
Page rpage = BufferGetPage(rbuf);
Size pageSize = PageGetPageSize(lpage);
+
/* these must be static so they can be returned to caller */
static XLogRecData rdata[2];
static ginxlogSplit data;
GinPageGetOpaque(page)->rightlink = rightlink;
/*
- * tail page may contain only whole row(s) or final part of row placed
- * on previous pages (a "row" here meaning all the index tuples generated
- * for one heap tuple)
+ * tail page may contain only whole row(s) or final part of row placed on
+ * previous pages (a "row" here meaning all the index tuples generated for
+ * one heap tuple)
*/
if (rightlink == InvalidBlockNumber)
{
* Create temporary index tuples for a single indexable item (one index column
* for the heap tuple specified by ht_ctid), and append them to the array
* in *collector. They will subsequently be written out using
- * ginHeapTupleFastInsert. Note that to guarantee consistent state, all
+ * ginHeapTupleFastInsert. Note that to guarantee consistent state, all
* temp tuples for a given heap tuple must be written in one call to
* ginHeapTupleFastInsert.
*/
}
/*
- * Build an index tuple for each key value, and add to array. In
- * pending tuples we just stick the heap TID into t_tid.
+ * Build an index tuple for each key value, and add to array. In pending
+ * tuples we just stick the heap TID into t_tid.
*/
for (i = 0; i < nentries; i++)
{
{
IndexTuple itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
OffsetNumber curattnum;
- Datum curkey;
+ Datum curkey;
GinNullCategory curcategory;
/* Check for change of heap TID or attnum */
*/
ginBeginBAScan(&accum);
while ((list = ginGetBAEntry(&accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attnum, &key, &category, &nlist)) != NULL)
{
ginEntryInsert(ginstate, attnum, key, category,
list, nlist, NULL);
ginBeginBAScan(&accum);
while ((list = ginGetBAEntry(&accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attnum, &key, &category, &nlist)) != NULL)
ginEntryInsert(ginstate, attnum, key, category,
list, nlist, NULL);
}
callConsistentFn(GinState *ginstate, GinScanKey key)
{
/*
- * If we're dealing with a dummy EVERYTHING key, we don't want to call
- * the consistentFn; just claim it matches.
+ * If we're dealing with a dummy EVERYTHING key, we don't want to call the
+ * consistentFn; just claim it matches.
*/
if (key->searchMode == GIN_SEARCH_MODE_EVERYTHING)
{
/*
* Collects TIDs into scanEntry->matchBitmap for all heap tuples that
- * match the search entry. This supports three different match modes:
+ * match the search entry. This supports three different match modes:
*
* 1. Partial-match support: scan from current point until the
- * comparePartialFn says we're done.
+ * comparePartialFn says we're done.
* 2. SEARCH_MODE_ALL: scan from current point (which should be first
- * key for the current attnum) until we hit null items or end of attnum
+ * key for the current attnum) until we hit null items or end of attnum
* 3. SEARCH_MODE_EVERYTHING: scan from current point (which should be first
- * key for the current attnum) until we hit end of attnum
+ * key for the current attnum) until we hit end of attnum
*
* Returns true if done, false if it's necessary to restart scan from scratch
*/
collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack,
GinScanEntry scanEntry)
{
- OffsetNumber attnum;
+ OffsetNumber attnum;
Form_pg_attribute attr;
/* Initialize empty bitmap result */
cmp = DatumGetInt32(FunctionCall4(&btree->ginstate->comparePartialFn[attnum - 1],
scanEntry->queryKey,
idatum,
- UInt16GetDatum(scanEntry->strategy),
- PointerGetDatum(scanEntry->extra_data)));
+ UInt16GetDatum(scanEntry->strategy),
+ PointerGetDatum(scanEntry->extra_data)));
if (cmp > 0)
return true;
/*
* In ALL mode, we are not interested in null items, so we can
* stop if we get to a null-item placeholder (which will be the
- * last entry for a given attnum). We do want to include NULL_KEY
+ * last entry for a given attnum). We do want to include NULL_KEY
* and EMPTY_ITEM entries, though.
*/
if (icategory == GIN_CAT_NULL_ITEM)
* We should unlock current page (but not unpin) during tree scan
* to prevent deadlock with vacuum processes.
*
- * We save current entry value (idatum) to be able to re-find
- * our tuple after re-locking
+ * We save current entry value (idatum) to be able to re-find our
+ * tuple after re-locking
*/
if (icategory == GIN_CAT_NORM_KEY)
idatum = datumCopy(idatum, attr->attbyval, attr->attlen);
Page page;
/*
- * We should unlock entry page before touching posting tree
- * to prevent deadlocks with vacuum processes. Because entry is
- * never deleted from page and posting tree is never reduced to
- * the posting list, we can unlock page after getting BlockNumber
- * of root of posting tree.
+ * We should unlock entry page before touching posting tree to
+ * prevent deadlocks with vacuum processes. Because entry is never
+ * deleted from page and posting tree is never reduced to the
+ * posting list, we can unlock page after getting BlockNumber of
+ * root of posting tree.
*/
LockBuffer(stackEntry->buffer, GIN_UNLOCK);
needUnlock = FALSE;
if (!ItemPointerIsValid(&entry->curItem) ||
ginCompareItemPointers(&entry->curItem,
- entry->list + entry->offset - 1) == 0)
+ entry->list + entry->offset - 1) == 0)
{
/*
* First pages are deleted or empty, or we found exact
}
/*
- * Reset counter to the beginning of entry->matchResult.
- * Note: entry->offset is still greater than
- * matchResult->ntuples if matchResult is lossy. So, on next
- * call we will get next result from TIDBitmap.
+ * Reset counter to the beginning of entry->matchResult. Note:
+ * entry->offset is still greater than matchResult->ntuples if
+ * matchResult is lossy. So, on next call we will get next
+ * result from TIDBitmap.
*/
entry->offset = 0;
}
/*
* Find the minimum of the active entry curItems.
*
- * Note: a lossy-page entry is encoded by a ItemPointer with max value
- * for offset (0xffff), so that it will sort after any exact entries
- * for the same page. So we'll prefer to return exact pointers not
- * lossy pointers, which is good.
+ * Note: a lossy-page entry is encoded by a ItemPointer with max value for
+ * offset (0xffff), so that it will sort after any exact entries for the
+ * same page. So we'll prefer to return exact pointers not lossy
+ * pointers, which is good.
*/
ItemPointerSetMax(&minItem);
/*
* Lossy-page entries pose a problem, since we don't know the correct
- * entryRes state to pass to the consistentFn, and we also don't know
- * what its combining logic will be (could be AND, OR, or even NOT).
- * If the logic is OR then the consistentFn might succeed for all
- * items in the lossy page even when none of the other entries match.
+ * entryRes state to pass to the consistentFn, and we also don't know what
+ * its combining logic will be (could be AND, OR, or even NOT). If the
+ * logic is OR then the consistentFn might succeed for all items in the
+ * lossy page even when none of the other entries match.
*
* If we have a single lossy-page entry then we check to see if the
- * consistentFn will succeed with only that entry TRUE. If so,
- * we return a lossy-page pointer to indicate that the whole heap
- * page must be checked. (On subsequent calls, we'll do nothing until
- * minItem is past the page altogether, thus ensuring that we never return
- * both regular and lossy pointers for the same page.)
+ * consistentFn will succeed with only that entry TRUE. If so, we return
+ * a lossy-page pointer to indicate that the whole heap page must be
+ * checked. (On subsequent calls, we'll do nothing until minItem is past
+ * the page altogether, thus ensuring that we never return both regular
+ * and lossy pointers for the same page.)
*
- * This idea could be generalized to more than one lossy-page entry,
- * but ideally lossy-page entries should be infrequent so it would
- * seldom be the case that we have more than one at once. So it
- * doesn't seem worth the extra complexity to optimize that case.
- * If we do find more than one, we just punt and return a lossy-page
- * pointer always.
+ * This idea could be generalized to more than one lossy-page entry, but
+ * ideally lossy-page entries should be infrequent so it would seldom be
+ * the case that we have more than one at once. So it doesn't seem worth
+ * the extra complexity to optimize that case. If we do find more than
+ * one, we just punt and return a lossy-page pointer always.
*
- * Note that only lossy-page entries pointing to the current item's
- * page should trigger this processing; we might have future lossy
- * pages in the entry array, but they aren't relevant yet.
+ * Note that only lossy-page entries pointing to the current item's page
+ * should trigger this processing; we might have future lossy pages in the
+ * entry array, but they aren't relevant yet.
*/
ItemPointerSetLossyPage(&curPageLossy,
GinItemPointerGetBlockNumber(&key->curItem));
}
/*
- * At this point we know that we don't need to return a lossy
- * whole-page pointer, but we might have matches for individual exact
- * item pointers, possibly in combination with a lossy pointer. Our
- * strategy if there's a lossy pointer is to try the consistentFn both
- * ways and return a hit if it accepts either one (forcing the hit to
- * be marked lossy so it will be rechecked). An exception is that
- * we don't need to try it both ways if the lossy pointer is in a
- * "hidden" entry, because the consistentFn's result can't depend on
- * that.
+ * At this point we know that we don't need to return a lossy whole-page
+ * pointer, but we might have matches for individual exact item pointers,
+ * possibly in combination with a lossy pointer. Our strategy if there's
+ * a lossy pointer is to try the consistentFn both ways and return a hit
+ * if it accepts either one (forcing the hit to be marked lossy so it will
+ * be rechecked). An exception is that we don't need to try it both ways
+ * if the lossy pointer is in a "hidden" entry, because the consistentFn's
+ * result can't depend on that.
*
* Prepare entryRes array to be passed to consistentFn.
*/
keyGetItem(&so->ginstate, so->tempCtx, key);
if (key->isFinished)
- return false; /* finished one of keys */
+ return false; /* finished one of keys */
if (ginCompareItemPointers(&key->curItem, item) < 0)
*item = key->curItem;
* that exact TID, or a lossy reference to the same page.
*
* This logic works only if a keyGetItem stream can never contain both
- * exact and lossy pointers for the same page. Else we could have a
+ * exact and lossy pointers for the same page. Else we could have a
* case like
*
* stream 1 stream 2
break;
/*
- * No hit. Update myAdvancePast to this TID, so that on the next
- * pass we'll move to the next possible entry.
+ * No hit. Update myAdvancePast to this TID, so that on the next pass
+ * we'll move to the next possible entry.
*/
myAdvancePast = *item;
}
/*
* Now pos->firstOffset points to the first tuple of current heap
- * row, pos->lastOffset points to the first tuple of next heap
- * row (or to the end of page)
+ * row, pos->lastOffset points to the first tuple of next heap row
+ * (or to the end of page)
*/
break;
}
entry->queryKey,
datum[off - 1],
UInt16GetDatum(entry->strategy),
- PointerGetDatum(entry->extra_data)));
+ PointerGetDatum(entry->extra_data)));
if (cmp == 0)
return true;
else if (cmp > 0)
memset(pos->hasMatchKey, FALSE, so->nkeys);
/*
- * Outer loop iterates over multiple pending-list pages when a single
- * heap row has entries spanning those pages.
+ * Outer loop iterates over multiple pending-list pages when a single heap
+ * row has entries spanning those pages.
*/
for (;;)
{
if (res == 0)
{
/*
- * Found exact match (there can be only one, except
- * in EMPTY_QUERY mode).
+ * Found exact match (there can be only one, except in
+ * EMPTY_QUERY mode).
*
- * If doing partial match, scan forward from
- * here to end of page to check for matches.
+ * If doing partial match, scan forward from here to
+ * end of page to check for matches.
*
* See comment above about tuple's ordering.
*/
if (StopLow >= StopHigh && entry->isPartialMatch)
{
/*
- * No exact match on this page. If doing partial
- * match, scan from the first tuple greater than
- * target value to end of page. Note that since we
- * don't remember whether the comparePartialFn told us
- * to stop early on a previous page, we will uselessly
- * apply comparePartialFn to the first tuple on each
- * subsequent page.
+ * No exact match on this page. If doing partial match,
+ * scan from the first tuple greater than target value to
+ * end of page. Note that since we don't remember whether
+ * the comparePartialFn told us to stop early on a
+ * previous page, we will uselessly apply comparePartialFn
+ * to the first tuple on each subsequent page.
*/
key->entryRes[j] =
matchPartialInPendingList(&so->ginstate,
* Adds array of item pointers to tuple's posting list, or
* creates posting tree and tuple pointing to tree in case
* of not enough space. Max size of tuple is defined in
- * GinFormTuple(). Returns a new, modified index tuple.
+ * GinFormTuple(). Returns a new, modified index tuple.
* items[] must be in sorted order with no duplicates.
*/
static IndexTuple
BlockNumber postingRoot;
/*
- * Build posting-tree-only result tuple. We do this first so as
- * to fail quickly if the key is too big.
+ * Build posting-tree-only result tuple. We do this first so as to
+ * fail quickly if the key is too big.
*/
res = GinFormTuple(ginstate, attnum, key, category, NULL, 0, true);
/*
- * Initialize posting tree with as many TIDs as will fit on the
- * first page.
+ * Initialize posting tree with as many TIDs as will fit on the first
+ * page.
*/
postingRoot = createPostingTree(ginstate->index,
items,
ginBeginBAScan(&buildstate->accum);
while ((list = ginGetBAEntry(&buildstate->accum,
- &attnum, &key, &category, &nlist)) != NULL)
+ &attnum, &key, &category, &nlist)) != NULL)
{
/* there could be many entries, so be willing to abort here */
CHECK_FOR_INTERRUPTS();
break;
default:
elog(ERROR, "unexpected searchMode: %d", searchMode);
- queryCategory = 0; /* keep compiler quiet */
+ queryCategory = 0; /* keep compiler quiet */
break;
}
isPartialMatch = false;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
/*
- * We assume that GIN-indexable operators are strict, so a null
- * query argument means an unsatisfiable query.
+ * We assume that GIN-indexable operators are strict, so a null query
+ * argument means an unsatisfiable query.
*/
if (skey->sk_flags & SK_ISNULL)
{
PointerGetDatum(&searchMode)));
/*
- * If bogus searchMode is returned, treat as GIN_SEARCH_MODE_ALL;
- * note in particular we don't allow extractQueryFn to select
+ * If bogus searchMode is returned, treat as GIN_SEARCH_MODE_ALL; note
+ * in particular we don't allow extractQueryFn to select
* GIN_SEARCH_MODE_EVERYTHING.
*/
if (searchMode < GIN_SEARCH_MODE_DEFAULT ||
* If the extractQueryFn didn't create a nullFlags array, create one,
* assuming that everything's non-null. Otherwise, run through the
* array and make sure each value is exactly 0 or 1; this ensures
- * binary compatibility with the GinNullCategory representation.
- * While at it, detect whether any null keys are present.
+ * binary compatibility with the GinNullCategory representation. While
+ * at it, detect whether any null keys are present.
*/
if (nullFlags == NULL)
nullFlags = (bool *) palloc0(nQueryValues * sizeof(bool));
else
{
- int32 j;
+ int32 j;
for (j = 0; j < nQueryValues; j++)
{
if (nullFlags[j])
{
- nullFlags[j] = true; /* not any other nonzero value */
+ nullFlags[j] = true; /* not any other nonzero value */
hasNullQuery = true;
}
}
/*
* If the index is version 0, it may be missing null and placeholder
* entries, which would render searches for nulls and full-index scans
- * unreliable. Throw an error if so.
+ * unreliable. Throw an error if so.
*/
if (hasNullQuery && !so->isVoidRes)
{
- GinStatsData ginStats;
+ GinStatsData ginStats;
ginGetStats(scan->indexRelation, &ginStats);
if (ginStats.ginVersion < 1)
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(1);
+
/* remaining arguments are ignored */
GinScanOpaque so = (GinScanOpaque) scan->opaque;
* However, we may have a collatable storage type for a noncollatable
* indexed data type (for instance, hstore uses text index entries).
* If there's no index collation then specify default collation in
- * case the comparison function needs one. This is harmless if the
+ * case the comparison function needs one. This is harmless if the
* comparison function doesn't care about collation, so we just do it
* unconditionally. (We could alternatively call get_typcollation,
* but that seems like expensive overkill --- there aren't going to be
aa->datum, bb->datum));
/*
- * Detect if we have any duplicates. If there are equal keys, qsort
- * must compare them at some point, else it wouldn't know whether one
- * should go before or after the other.
+ * Detect if we have any duplicates. If there are equal keys, qsort must
+ * compare them at some point, else it wouldn't know whether one should go
+ * before or after the other.
*/
if (res == 0)
data->haveDups = true;
/*
* If the extractValueFn didn't create a nullFlags array, create one,
- * assuming that everything's non-null. Otherwise, run through the
- * array and make sure each value is exactly 0 or 1; this ensures
- * binary compatibility with the GinNullCategory representation.
+ * assuming that everything's non-null. Otherwise, run through the array
+ * and make sure each value is exactly 0 or 1; this ensures binary
+ * compatibility with the GinNullCategory representation.
*/
if (nullFlags == NULL)
nullFlags = (bool *) palloc0(*nentries * sizeof(bool));
* If there's more than one key, sort and unique-ify.
*
* XXX Using qsort here is notationally painful, and the overhead is
- * pretty bad too. For small numbers of keys it'd likely be better to
- * use a simple insertion sort.
+ * pretty bad too. For small numbers of keys it'd likely be better to use
+ * a simple insertion sort.
*/
if (*nentries > 1)
{
j = 1;
for (i = 1; i < *nentries; i++)
{
- if (cmpEntries(&keydata[i-1], &keydata[i], &arg) != 0)
+ if (cmpEntries(&keydata[i - 1], &keydata[i], &arg) != 0)
{
entries[j] = keydata[i].datum;
nullFlags[j] = keydata[i].isnull;
void
ginGetStats(Relation index, GinStatsData *stats)
{
- Buffer metabuffer;
- Page metapage;
- GinMetaPageData *metadata;
+ Buffer metabuffer;
+ Page metapage;
+ GinMetaPageData *metadata;
metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
LockBuffer(metabuffer, GIN_SHARE);
void
ginUpdateStats(Relation index, const GinStatsData *stats)
{
- Buffer metabuffer;
- Page metapage;
- GinMetaPageData *metadata;
+ Buffer metabuffer;
+ Page metapage;
+ GinMetaPageData *metadata;
metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
LockBuffer(metabuffer, GIN_EXCLUSIVE);
if (RelationNeedsWAL(index))
{
- XLogRecPtr recptr;
- ginxlogUpdateMeta data;
- XLogRecData rdata;
+ XLogRecPtr recptr;
+ ginxlogUpdateMeta data;
+ XLogRecData rdata;
data.node = index->rd_node;
data.ntuples = 0;
{
idxStat.nEntryPages++;
- if ( GinPageIsLeaf(page) )
+ if (GinPageIsLeaf(page))
idxStat.nEntries += PageGetMaxOffsetNumber(page);
}
else
{
OffsetNumber i,
- *tod;
+ *tod;
IndexTuple itup = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogVacuumPage));
tod = (OffsetNumber *) palloc(sizeof(OffsetNumber) * PageGetMaxOffsetNumber(page));
if (!XLByteLE(lsn, PageGetLSN(page)))
{
OffsetNumber l,
- off = (PageIsEmpty(page)) ? FirstOffsetNumber :
- OffsetNumberNext(PageGetMaxOffsetNumber(page));
+ off = (PageIsEmpty(page)) ? FirstOffsetNumber :
+ OffsetNumberNext(PageGetMaxOffsetNumber(page));
int i,
- tupsize;
+ tupsize;
IndexTuple tuples = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogUpdateMeta));
for (i = 0; i < data->ntuples; i++)
/* A List of these is used represent a split-in-progress. */
typedef struct
{
- Buffer buf; /* the split page "half" */
- IndexTuple downlink; /* downlink for this half. */
+ Buffer buf; /* the split page "half" */
+ IndexTuple downlink; /* downlink for this half. */
} GISTPageSplitInfo;
/* non-export function prototypes */
bool is_split;
/*
- * Refuse to modify a page that's incompletely split. This should
- * not happen because we finish any incomplete splits while we walk
- * down the tree. However, it's remotely possible that another
- * concurrent inserter splits a parent page, and errors out before
- * completing the split. We will just throw an error in that case,
- * and leave any split we had in progress unfinished too. The next
- * insert that comes along will clean up the mess.
+ * Refuse to modify a page that's incompletely split. This should not
+ * happen because we finish any incomplete splits while we walk down the
+ * tree. However, it's remotely possible that another concurrent inserter
+ * splits a parent page, and errors out before completing the split. We
+ * will just throw an error in that case, and leave any split we had in
+ * progress unfinished too. The next insert that comes along will clean up
+ * the mess.
*/
if (GistFollowRight(page))
elog(ERROR, "concurrent GiST page split was incomplete");
SplitedPageLayout *dist = NULL,
*ptr;
BlockNumber oldrlink = InvalidBlockNumber;
- GistNSN oldnsn = { 0, 0 };
+ GistNSN oldnsn = {0, 0};
SplitedPageLayout rootpg;
BlockNumber blkno = BufferGetBlockNumber(buffer);
bool is_rootsplit;
/*
* Set up pages to work with. Allocate new buffers for all but the
- * leftmost page. The original page becomes the new leftmost page,
- * and is just replaced with the new contents.
+ * leftmost page. The original page becomes the new leftmost page, and
+ * is just replaced with the new contents.
*
* For a root-split, allocate new buffers for all child pages, the
* original page is overwritten with new root page containing
if (is_rootsplit)
{
IndexTuple *downlinks;
- int ndownlinks = 0;
- int i;
+ int ndownlinks = 0;
+ int i;
rootpg.buffer = buffer;
rootpg.page = PageGetTempPageCopySpecial(BufferGetPage(rootpg.buffer));
for (ptr = dist; ptr; ptr = ptr->next)
{
GISTPageSplitInfo *si = palloc(sizeof(GISTPageSplitInfo));
+
si->buf = ptr->buffer;
si->downlink = ptr->itup;
*splitinfo = lappend(*splitinfo, si);
*/
for (ptr = dist; ptr; ptr = ptr->next)
{
- char *data = (char *) (ptr->list);
+ char *data = (char *) (ptr->list);
+
for (i = 0; i < ptr->block.num; i++)
{
if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, false, false) == InvalidOffsetNumber)
MarkBufferDirty(leftchildbuf);
/*
- * The first page in the chain was a temporary working copy meant
- * to replace the old page. Copy it over the old page.
+ * The first page in the chain was a temporary working copy meant to
+ * replace the old page. Copy it over the old page.
*/
PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer));
dist->page = BufferGetPage(dist->buffer);
* Return the new child buffers to the caller.
*
* If this was a root split, we've already inserted the downlink
- * pointers, in the form of a new root page. Therefore we can
- * release all the new buffers, and keep just the root page locked.
+ * pointers, in the form of a new root page. Therefore we can release
+ * all the new buffers, and keep just the root page locked.
*/
if (is_rootsplit)
{
/*
* If we inserted the downlink for a child page, set NSN and clear
- * F_FOLLOW_RIGHT flag on the left child, so that concurrent scans know
- * to follow the rightlink if and only if they looked at the parent page
+ * F_FOLLOW_RIGHT flag on the left child, so that concurrent scans know to
+ * follow the rightlink if and only if they looked at the parent page
* before we inserted the downlink.
*
* Note that we do this *after* writing the WAL record. That means that
- * the possible full page image in the WAL record does not include
- * these changes, and they must be replayed even if the page is restored
- * from the full page image. There's a chicken-and-egg problem: if we
- * updated the child pages first, we wouldn't know the recptr of the WAL
- * record we're about to write.
+ * the possible full page image in the WAL record does not include these
+ * changes, and they must be replayed even if the page is restored from
+ * the full page image. There's a chicken-and-egg problem: if we updated
+ * the child pages first, we wouldn't know the recptr of the WAL record
+ * we're about to write.
*/
if (BufferIsValid(leftchildbuf))
{
- Page leftpg = BufferGetPage(leftchildbuf);
+ Page leftpg = BufferGetPage(leftchildbuf);
GistPageGetOpaque(leftpg)->nsn = recptr;
GistClearFollowRight(leftpg);
stack->buffer = ReadBuffer(state.r, stack->blkno);
/*
- * Be optimistic and grab shared lock first. Swap it for an
- * exclusive lock later if we need to update the page.
+ * Be optimistic and grab shared lock first. Swap it for an exclusive
+ * lock later if we need to update the page.
*/
if (!xlocked)
{
Assert(!RelationNeedsWAL(state.r) || !XLogRecPtrIsInvalid(stack->lsn));
/*
- * If this page was split but the downlink was never inserted to
- * the parent because the inserting backend crashed before doing
- * that, fix that now.
+ * If this page was split but the downlink was never inserted to the
+ * parent because the inserting backend crashed before doing that, fix
+ * that now.
*/
if (GistFollowRight(stack->page))
{
/*
* Concurrent split detected. There's no guarantee that the
* downlink for this page is consistent with the tuple we're
- * inserting anymore, so go back to parent and rechoose the
- * best child.
+ * inserting anymore, so go back to parent and rechoose the best
+ * child.
*/
UnlockReleaseBuffer(stack->buffer);
xlocked = false;
* Find the child node that has the minimum insertion penalty.
*/
BlockNumber childblkno;
- IndexTuple newtup;
+ IndexTuple newtup;
GISTInsertStack *item;
stack->childoffnum = gistchoose(state.r, stack->page, itup, giststate);
if (newtup)
{
/*
- * Swap shared lock for an exclusive one. Beware, the page
- * may change while we unlock/lock the page...
+ * Swap shared lock for an exclusive one. Beware, the page may
+ * change while we unlock/lock the page...
*/
if (!xlocked)
{
continue;
}
}
+
/*
* Update the tuple.
*
stack->childoffnum, InvalidBuffer))
{
/*
- * If this was a root split, the root page continues to
- * be the parent and the updated tuple went to one of the
+ * If this was a root split, the root page continues to be
+ * the parent and the updated tuple went to one of the
* child pages, so we just need to retry from the root
* page.
*/
{
/*
* Leaf page. Insert the new key. We've already updated all the
- * parents on the way down, but we might have to split the page
- * if it doesn't fit. gistinserthere() will take care of that.
+ * parents on the way down, but we might have to split the page if
+ * it doesn't fit. gistinserthere() will take care of that.
*/
/*
- * Swap shared lock for an exclusive one. Be careful, the page
- * may change while we unlock/lock the page...
+ * Swap shared lock for an exclusive one. Be careful, the page may
+ * change while we unlock/lock the page...
*/
if (!xlocked)
{
if (stack->blkno == GIST_ROOT_BLKNO)
{
/*
- * the only page that can become inner instead of leaf
- * is the root page, so for root we should recheck it
+ * the only page that can become inner instead of leaf is
+ * the root page, so for root we should recheck it
*/
if (!GistPageIsLeaf(stack->page))
{
gistformdownlink(Relation rel, Buffer buf, GISTSTATE *giststate,
GISTInsertStack *stack)
{
- Page page = BufferGetPage(buf);
+ Page page = BufferGetPage(buf);
OffsetNumber maxoff;
OffsetNumber offset;
- IndexTuple downlink = NULL;
+ IndexTuple downlink = NULL;
maxoff = PageGetMaxOffsetNumber(page);
for (offset = FirstOffsetNumber; offset <= maxoff; offset = OffsetNumberNext(offset))
{
IndexTuple ituple = (IndexTuple)
- PageGetItem(page, PageGetItemId(page, offset));
+ PageGetItem(page, PageGetItemId(page, offset));
+
if (downlink == NULL)
downlink = CopyIndexTuple(ituple);
else
{
- IndexTuple newdownlink;
+ IndexTuple newdownlink;
+
newdownlink = gistgetadjusted(rel, downlink, ituple,
giststate);
if (newdownlink)
}
/*
- * If the page is completely empty, we can't form a meaningful
- * downlink for it. But we have to insert a downlink for the page.
- * Any key will do, as long as its consistent with the downlink of
- * parent page, so that we can legally insert it to the parent.
- * A minimal one that matches as few scans as possible would be best,
- * to keep scans from doing useless work, but we don't know how to
- * construct that. So we just use the downlink of the original page
- * that was split - that's as far from optimal as it can get but will
- * do..
+ * If the page is completely empty, we can't form a meaningful downlink
+ * for it. But we have to insert a downlink for the page. Any key will do,
+ * as long as its consistent with the downlink of parent page, so that we
+ * can legally insert it to the parent. A minimal one that matches as few
+ * scans as possible would be best, to keep scans from doing useless work,
+ * but we don't know how to construct that. So we just use the downlink of
+ * the original page that was split - that's as far from optimal as it can
+ * get but will do..
*/
if (!downlink)
{
- ItemId iid;
+ ItemId iid;
LockBuffer(stack->parent->buffer, GIST_EXCLUSIVE);
gistFindCorrectParent(rel, stack);
buf = stack->buffer;
/*
- * Read the chain of split pages, following the rightlinks. Construct
- * a downlink tuple for each page.
+ * Read the chain of split pages, following the rightlinks. Construct a
+ * downlink tuple for each page.
*/
for (;;)
{
GISTPageSplitInfo *si = palloc(sizeof(GISTPageSplitInfo));
- IndexTuple downlink;
+ IndexTuple downlink;
page = BufferGetPage(buf);
IndexTuple *tuples, int ntup, OffsetNumber oldoffnum,
Buffer leftchild)
{
- List *splitinfo;
- bool is_split;
+ List *splitinfo;
+ bool is_split;
is_split = gistplacetopage(state, giststate, stack->buffer,
tuples, ntup, oldoffnum,
gistfinishsplit(GISTInsertState *state, GISTInsertStack *stack,
GISTSTATE *giststate, List *splitinfo)
{
- ListCell *lc;
- List *reversed;
+ ListCell *lc;
+ List *reversed;
GISTPageSplitInfo *right;
GISTPageSplitInfo *left;
- IndexTuple tuples[2];
+ IndexTuple tuples[2];
/* A split always contains at least two halves */
Assert(list_length(splitinfo) >= 2);
/*
- * We need to insert downlinks for each new page, and update the
- * downlink for the original (leftmost) page in the split. Begin at
- * the rightmost page, inserting one downlink at a time until there's
- * only two pages left. Finally insert the downlink for the last new
- * page and update the downlink for the original page as one operation.
+ * We need to insert downlinks for each new page, and update the downlink
+ * for the original (leftmost) page in the split. Begin at the rightmost
+ * page, inserting one downlink at a time until there's only two pages
+ * left. Finally insert the downlink for the last new page and update the
+ * downlink for the original page as one operation.
*/
/* for convenience, create a copy of the list in reverse order */
LockBuffer(stack->parent->buffer, GIST_EXCLUSIVE);
gistFindCorrectParent(state->r, stack);
- while(list_length(reversed) > 2)
+ while (list_length(reversed) > 2)
{
right = (GISTPageSplitInfo *) linitial(reversed);
left = (GISTPageSplitInfo *) lsecond(reversed);
/* opclasses are not required to provide a Distance method */
if (OidIsValid(index_getprocid(index, i + 1, GIST_DISTANCE_PROC)))
fmgr_info_copy(&(giststate->distanceFn[i]),
- index_getprocinfo(index, i + 1, GIST_DISTANCE_PROC),
+ index_getprocinfo(index, i + 1, GIST_DISTANCE_PROC),
CurrentMemoryContext);
else
giststate->distanceFn[i].fn_oid = InvalidOid;
*
* On success return for a heap tuple, *recheck_p is set to indicate
* whether recheck is needed. We recheck if any of the consistent() functions
- * request it. recheck is not interesting when examining a non-leaf entry,
+ * request it. recheck is not interesting when examining a non-leaf entry,
* since we must visit the lower index page if there's any doubt.
*
* If we are doing an ordered scan, so->distances[] is filled with distance
*recheck_p = false;
/*
- * If it's a leftover invalid tuple from pre-9.1, treat it as a match
- * with minimum possible distances. This means we'll always follow it
- * to the referenced page.
+ * If it's a leftover invalid tuple from pre-9.1, treat it as a match with
+ * minimum possible distances. This means we'll always follow it to the
+ * referenced page.
*/
if (GistTupleIsInvalid(tuple))
{
- int i;
+ int i;
- if (GistPageIsLeaf(page)) /* shouldn't happen */
+ if (GistPageIsLeaf(page)) /* shouldn't happen */
elog(ERROR, "invalid GIST tuple found on leaf page");
for (i = 0; i < scan->numberOfOrderBys; i++)
so->distances[i] = -get_float8_infinity();
* always be zero, but might as well pass it for possible future
* use.)
*
- * Note that Distance functions don't get a recheck argument.
- * We can't tolerate lossy distance calculations on leaf tuples;
+ * Note that Distance functions don't get a recheck argument. We
+ * can't tolerate lossy distance calculations on leaf tuples;
* there is no opportunity to re-sort the tuples afterwards.
*/
dist = FunctionCall4(&key->sk_func,
* ntids: if not NULL, gistgetbitmap's output tuple counter
*
* If tbm/ntids aren't NULL, we are doing an amgetbitmap scan, and heap
- * tuples should be reported directly into the bitmap. If they are NULL,
+ * tuples should be reported directly into the bitmap. If they are NULL,
* we're doing a plain or ordered indexscan. For a plain indexscan, heap
* tuple TIDs are returned into so->pageData[]. For an ordered indexscan,
* heap tuple TIDs are pushed into individual search queue items.
/*
* While scanning a leaf page, ItemPointers of matching heap
* tuples are stored in so->pageData. If there are any on
- * this page, we fall out of the inner "do" and loop around
- * to return them.
+ * this page, we fall out of the inner "do" and loop around to
+ * return them.
*/
gistScanPage(scan, item, so->curTreeItem->distances, NULL, NULL);
PG_RETURN_POINTER(entry);
}
-#define point_point_distance(p1,p2) \
+#define point_point_distance(p1,p2) \
DatumGetFloat8(DirectFunctionCall2(point_distance, \
PointPGetDatum(p1), PointPGetDatum(p2)))
else
{
/* closest point will be a vertex */
- Point p;
- double subresult;
+ Point p;
+ double subresult;
result = point_point_distance(point, &box->low);
/*
* If new item is heap tuple, it goes to front of chain; otherwise insert
- * it before the first index-page item, so that index pages are visited
- * in LIFO order, ensuring depth-first search of index pages. See
- * comments in gist_private.h.
+ * it before the first index-page item, so that index pages are visited in
+ * LIFO order, ensuring depth-first search of index pages. See comments
+ * in gist_private.h.
*/
if (GISTSearchItemIsHeap(*newitem))
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanKey key = (ScanKey) PG_GETARG_POINTER(1);
ScanKey orderbys = (ScanKey) PG_GETARG_POINTER(3);
+
/* nkeys and norderbys arguments are ignored */
GISTScanOpaque so = (GISTScanOpaque) scan->opaque;
int i;
scan->numberOfKeys * sizeof(ScanKeyData));
/*
- * Modify the scan key so that the Consistent method is called for
- * all comparisons. The original operator is passed to the Consistent
+ * Modify the scan key so that the Consistent method is called for all
+ * comparisons. The original operator is passed to the Consistent
* function in the form of its strategy number, which is available
* from the sk_strategy field, and its subtype from the sk_subtype
* field. Also, preserve sk_func.fn_collation which is the input
}
res = index_form_tuple(giststate->tupdesc, compatt, isnull);
+
/*
* The offset number on tuples on internal pages is unused. For historical
* reasons, it is set 0xffff.
*/
- ItemPointerSetOffsetNumber( &(res->t_tid), 0xffff);
+ ItemPointerSetOffsetNumber(&(res->t_tid), 0xffff);
return res;
}
gistRedoClearFollowRight(RelFileNode node, XLogRecPtr lsn,
BlockNumber leftblkno)
{
- Buffer buffer;
+ Buffer buffer;
buffer = XLogReadBuffer(node, leftblkno, false);
if (BufferIsValid(buffer))
{
- Page page = (Page) BufferGetPage(buffer);
+ Page page = (Page) BufferGetPage(buffer);
/*
* Note that we still update the page even if page LSN is equal to the
{
int i;
OffsetNumber *todelete = (OffsetNumber *) data;
+
data += sizeof(OffsetNumber) * xldata->ntodelete;
for (i = 0; i < xldata->ntodelete; i++)
if (data - begin < record->xl_len)
{
OffsetNumber off = (PageIsEmpty(page)) ? FirstOffsetNumber :
- OffsetNumberNext(PageGetMaxOffsetNumber(page));
+ OffsetNumberNext(PageGetMaxOffsetNumber(page));
+
while (data - begin < record->xl_len)
{
- IndexTuple itup = (IndexTuple) data;
+ IndexTuple itup = (IndexTuple) data;
Size sz = IndexTupleSize(itup);
OffsetNumber l;
+
data += sz;
l = PageAddItem(page, (Item) itup, sz, off, false, false);
SplitedPageLayout *ptr;
int npage = 0,
cur;
- XLogRecPtr recptr;
+ XLogRecPtr recptr;
for (ptr = dist; ptr; ptr = ptr->next)
npage++;
}
/*
- * Include a full page image of the child buf. (only necessary if
- * a checkpoint happened since the child page was split)
+ * Include a full page image of the child buf. (only necessary if a
+ * checkpoint happened since the child page was split)
*/
if (BufferIsValid(leftchildbuf))
{
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(1);
+
/* remaining arguments are ignored */
HashScanOpaque so = (HashScanOpaque) scan->opaque;
Relation rel = scan->indexRelation;
* This is essentially relation_open plus check that the relation
* is not an index nor a composite type. (The caller should also
* check that it's not a view or foreign table before assuming it has
- * storage.)
+ * storage.)
* ----------------
*/
Relation
/*
* We're about to do the actual insert -- check for conflict at the
- * relation or buffer level first, to avoid possibly having to roll
- * back work we've just done.
+ * relation or buffer level first, to avoid possibly having to roll back
+ * work we've just done.
*/
CheckForSerializableConflictIn(relation, NULL, buffer);
}
/*
- * We're about to do the actual delete -- check for conflict first,
- * to avoid possibly having to roll back work we've just done.
+ * We're about to do the actual delete -- check for conflict first, to
+ * avoid possibly having to roll back work we've just done.
*/
CheckForSerializableConflictIn(relation, &tp, buffer);
}
/*
- * We're about to do the actual update -- check for conflict first,
- * to avoid possibly having to roll back work we've just done.
+ * We're about to do the actual update -- check for conflict first, to
+ * avoid possibly having to roll back work we've just done.
*/
CheckForSerializableConflictIn(relation, &oldtup, buffer);
}
/*
- * We're about to create the new tuple -- check for conflict first,
- * to avoid possibly having to roll back work we've just done.
+ * We're about to create the new tuple -- check for conflict first, to
+ * avoid possibly having to roll back work we've just done.
*
* NOTE: For a tuple insert, we only need to check for table locks, since
* predicate locking at the index level will cover ranges for anything
}
/*
- * Ignore tuples inserted by an aborted transaction or
- * if the tuple was updated/deleted by the inserting transaction.
+ * Ignore tuples inserted by an aborted transaction or if the tuple was
+ * updated/deleted by the inserting transaction.
*
* Look for a committed hint bit, or if no xmin bit is set, check clog.
- * This needs to work on both master and standby, where it is used
- * to assess btree delete records.
+ * This needs to work on both master and standby, where it is used to
+ * assess btree delete records.
*/
if ((tuple->t_infomask & HEAP_XMIN_COMMITTED) ||
(!(tuple->t_infomask & HEAP_XMIN_COMMITTED) &&
{
if (xmax != xmin &&
TransactionIdFollows(xmax, *latestRemovedXid))
- *latestRemovedXid = xmax;
+ *latestRemovedXid = xmax;
}
/* *latestRemovedXid may still be invalid at end */
recptr = XLogInsert(RM_HEAP_ID, XLOG_HEAP_NEWPAGE, rdata);
/*
- * The page may be uninitialized. If so, we can't set the LSN
- * and TLI because that would corrupt the page.
+ * The page may be uninitialized. If so, we can't set the LSN and TLI
+ * because that would corrupt the page.
*/
if (!PageIsNew(page))
{
memcpy(page, (char *) xlrec + SizeOfHeapNewpage, BLCKSZ);
/*
- * The page may be uninitialized. If so, we can't set the LSN
- * and TLI because that would corrupt the page.
+ * The page may be uninitialized. If so, we can't set the LSN and TLI
+ * because that would corrupt the page.
*/
if (!PageIsNew(page))
{
Buffer
RelationGetBufferForTuple(Relation relation, Size len,
Buffer otherBuffer, int options,
- struct BulkInsertStateData *bistate)
+ struct BulkInsertStateData * bistate)
{
bool use_fsm = !(options & HEAP_INSERT_SKIP_FSM);
Buffer buffer = InvalidBuffer;
* them */
HTAB *rs_unresolved_tups; /* unmatched A tuples */
HTAB *rs_old_new_tid_map; /* unmatched B tuples */
-} RewriteStateData;
+} RewriteStateData;
/*
* The lookup keys for the hash tables are tuple TID and xmin (we must check
}
/*
- * If the rel is WAL-logged, must fsync before commit. We use heap_sync
+ * If the rel is WAL-logged, must fsync before commit. We use heap_sync
* to ensure that the toast table gets fsync'd too.
*
* It's obvious that we must do this when not WAL-logging. It's less
procnum, attnum, RelationGetRelationName(irel));
fmgr_info_cxt(procId, locinfo, irel->rd_indexcxt);
- fmgr_info_set_collation(irel->rd_indcollation[attnum-1], locinfo);
+ fmgr_info_set_collation(irel->rd_indcollation[attnum - 1], locinfo);
}
return locinfo;
* The only conflict predicate locking cares about for indexes is when
* an index tuple insert conflicts with an existing lock. Since the
* actual location of the insert is hard to predict because of the
- * random search used to prevent O(N^2) performance when there are many
- * duplicate entries, we can just use the "first valid" page.
+ * random search used to prevent O(N^2) performance when there are
+ * many duplicate entries, we can just use the "first valid" page.
*/
CheckForSerializableConflictIn(rel, NULL, buf);
/* do the insertion */
/*
* origpage is the original page to be split. leftpage is a temporary
* buffer that receives the left-sibling data, which will be copied back
- * into origpage on success. rightpage is the new page that receives
- * the right-sibling data. If we fail before reaching the critical
- * section, origpage hasn't been modified and leftpage is only workspace.
- * In principle we shouldn't need to worry about rightpage either,
- * because it hasn't been linked into the btree page structure; but to
- * avoid leaving possibly-confusing junk behind, we are careful to rewrite
- * rightpage as zeroes before throwing any error.
+ * into origpage on success. rightpage is the new page that receives the
+ * right-sibling data. If we fail before reaching the critical section,
+ * origpage hasn't been modified and leftpage is only workspace. In
+ * principle we shouldn't need to worry about rightpage either, because it
+ * hasn't been linked into the btree page structure; but to avoid leaving
+ * possibly-confusing junk behind, we are careful to rewrite rightpage as
+ * zeroes before throwing any error.
*/
origpage = BufferGetPage(buf);
leftpage = PageGetTempPage(origpage);
{
memset(rightpage, 0, BufferGetPageSize(rbuf));
elog(ERROR, "right sibling's left-link doesn't match: "
- "block %u links to %u instead of expected %u in index \"%s\"",
+ "block %u links to %u instead of expected %u in index \"%s\"",
oopaque->btpo_next, sopaque->btpo_prev, origpagenumber,
RelationGetRelationName(rel));
}
/*
* Check that the parent-page index items we're about to delete/overwrite
- * contain what we expect. This can fail if the index has become
- * corrupt for some reason. We want to throw any error before entering
- * the critical section --- otherwise it'd be a PANIC.
+ * contain what we expect. This can fail if the index has become corrupt
+ * for some reason. We want to throw any error before entering the
+ * critical section --- otherwise it'd be a PANIC.
*
* The test on the target item is just an Assert because _bt_getstackbuf
* should have guaranteed it has the expected contents. The test on the
metapage = (Page) palloc(BLCKSZ);
_bt_initmetapage(metapage, P_NONE, 0);
- /* Write the page. If archiving/streaming, XLOG it. */
+ /* Write the page. If archiving/streaming, XLOG it. */
smgrwrite(index->rd_smgr, INIT_FORKNUM, BTREE_METAPAGE,
(char *) metapage, true);
if (XLogIsNeeded())
{
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(1);
+
/* remaining arguments are ignored */
BTScanOpaque so = (BTScanOpaque) scan->opaque;
/* If index is empty and access = BT_READ, no root page is created. */
if (!BufferIsValid(*bufP))
{
- PredicateLockRelation(rel); /* Nothing finer to lock exists. */
+ PredicateLockRelation(rel); /* Nothing finer to lock exists. */
return (BTStack) NULL;
}
if (!BufferIsValid(buf))
{
/* empty index... */
- PredicateLockRelation(rel); /* Nothing finer to lock exists. */
+ PredicateLockRelation(rel); /* Nothing finer to lock exists. */
return InvalidBuffer;
}
if (!BufferIsValid(buf))
{
/* empty index... */
- PredicateLockRelation(rel); /* Nothing finer to lock exists. */
+ PredicateLockRelation(rel); /* Nothing finer to lock exists. */
so->currPos.buf = InvalidBuffer;
return false;
}
/*
* If the index is WAL-logged, we must fsync it down to disk before it's
- * safe to commit the transaction. (For a non-WAL-logged index we don't
+ * safe to commit the transaction. (For a non-WAL-logged index we don't
* care since the index will be uninteresting after a crash anyway.)
*
* It's obvious that we must do this when not WAL-logging the build. It's
/*
* We can use the cached (default) support procs since no cross-type
- * comparison can be needed. The cached support proc entries have
- * the right collation for the index, too.
+ * comparison can be needed. The cached support proc entries have the
+ * right collation for the index, too.
*/
procinfo = index_getprocinfo(rel, i + 1, BTORDER_PROC);
arg = index_getattr(itup, i + 1, itupdesc, &null);
/*
* We can use the cached (default) support procs since no cross-type
- * comparison can be needed. The cached support proc entries have
- * the right collation for the index, too.
+ * comparison can be needed. The cached support proc entries have the
+ * right collation for the index, too.
*/
procinfo = index_getprocinfo(rel, i + 1, BTORDER_PROC);
flags = SK_ISNULL | (indoption[i] << SK_BT_INDOPTION_SHIFT);
TransactionId locking_xid; /* top-level XID of backend working on xact */
bool valid; /* TRUE if fully prepared */
char gid[GIDSIZE]; /* The GID assigned to the prepared xact */
-} GlobalTransactionData;
+} GlobalTransactionData;
/*
* Two Phase Commit shared state. Access to this struct is protected
/* If we crash now, we have prepared: WAL replay will fix things */
/*
- * Wake up all walsenders to send WAL up to the PREPARE record
- * immediately if replication is enabled
+ * Wake up all walsenders to send WAL up to the PREPARE record immediately
+ * if replication is enabled
*/
if (max_wal_senders > 0)
WalSndWakeup();
/*
* Wait for synchronous replication, if required.
*
- * Note that at this stage we have marked clog, but still show as
- * running in the procarray and continue to hold locks.
+ * Note that at this stage we have marked clog, but still show as running
+ * in the procarray and continue to hold locks.
*/
SyncRepWaitForLSN(recptr);
}
/*
* Wait for synchronous replication, if required.
*
- * Note that at this stage we have marked clog, but still show as
- * running in the procarray and continue to hold locks.
+ * Note that at this stage we have marked clog, but still show as running
+ * in the procarray and continue to hold locks.
*/
SyncRepWaitForLSN(recptr);
}
char *oldest_datname;
/*
- * We can be called when not inside a transaction, for example
- * during StartupXLOG(). In such a case we cannot do database
- * access, so we must just report the oldest DB's OID.
+ * We can be called when not inside a transaction, for example during
+ * StartupXLOG(). In such a case we cannot do database access, so we
+ * must just report the oldest DB's OID.
*
* Note: it's also possible that get_database_name fails and returns
* NULL, for example because the database just got dropped. We'll
*/
if (isSubXact && !TransactionIdIsValid(s->parent->transactionId))
{
- TransactionState p = s->parent;
- TransactionState *parents;
- size_t parentOffset = 0;
+ TransactionState p = s->parent;
+ TransactionState *parents;
+ size_t parentOffset = 0;
- parents = palloc(sizeof(TransactionState) * s->nestingLevel);
+ parents = palloc(sizeof(TransactionState) * s->nestingLevel);
while (p != NULL && !TransactionIdIsValid(p->transactionId))
{
parents[parentOffset++] = p;
}
/*
- * This is technically a recursive call, but the recursion will
- * never be more than one layer deep.
+ * This is technically a recursive call, but the recursion will never
+ * be more than one layer deep.
*/
while (parentOffset != 0)
AssignTransactionId(parents[--parentOffset]);
/*
* Check if we want to commit asynchronously. We can allow the XLOG flush
* to happen asynchronously if synchronous_commit=off, or if the current
- * transaction has not performed any WAL-logged operation. The latter case
- * can arise if the current transaction wrote only to temporary and/or
- * unlogged tables. In case of a crash, the loss of such a transaction
- * will be irrelevant since temp tables will be lost anyway, and unlogged
- * tables will be truncated. (Given the foregoing, you might think that it
- * would be unnecessary to emit the XLOG record at all in this case, but we
- * don't currently try to do that. It would certainly cause problems at
- * least in Hot Standby mode, where the KnownAssignedXids machinery
- * requires tracking every XID assignment. It might be OK to skip it only
- * when wal_level < hot_standby, but for now we don't.)
+ * transaction has not performed any WAL-logged operation. The latter
+ * case can arise if the current transaction wrote only to temporary
+ * and/or unlogged tables. In case of a crash, the loss of such a
+ * transaction will be irrelevant since temp tables will be lost anyway,
+ * and unlogged tables will be truncated. (Given the foregoing, you might
+ * think that it would be unnecessary to emit the XLOG record at all in
+ * this case, but we don't currently try to do that. It would certainly
+ * cause problems at least in Hot Standby mode, where the
+ * KnownAssignedXids machinery requires tracking every XID assignment. It
+ * might be OK to skip it only when wal_level < hot_standby, but for now
+ * we don't.)
*
* However, if we're doing cleanup of any non-temp rels or committing any
* command that wanted to force sync commit, then we must flush XLOG
/*
* Wait for synchronous replication, if required.
*
- * Note that at this stage we have marked clog, but still show as
- * running in the procarray and continue to hold locks.
+ * Note that at this stage we have marked clog, but still show as running
+ * in the procarray and continue to hold locks.
*/
SyncRepWaitForLSN(XactLastRecEnd);
}
/*
- * The remaining actions cannot call any user-defined code, so it's
- * safe to start shutting down within-transaction services. But note
- * that most of this stuff could still throw an error, which would
- * switch us into the transaction-abort path.
+ * The remaining actions cannot call any user-defined code, so it's safe
+ * to start shutting down within-transaction services. But note that most
+ * of this stuff could still throw an error, which would switch us into
+ * the transaction-abort path.
*/
/* Shut down the deferred-trigger manager */
/*
* Mark serializable transaction as complete for predicate locking
- * purposes. This should be done as late as we can put it and still
- * allow errors to be raised for failure patterns found at commit.
+ * purposes. This should be done as late as we can put it and still allow
+ * errors to be raised for failure patterns found at commit.
*/
PreCommit_CheckForSerializationFailure();
}
/*
- * The remaining actions cannot call any user-defined code, so it's
- * safe to start shutting down within-transaction services. But note
- * that most of this stuff could still throw an error, which would
- * switch us into the transaction-abort path.
+ * The remaining actions cannot call any user-defined code, so it's safe
+ * to start shutting down within-transaction services. But note that most
+ * of this stuff could still throw an error, which would switch us into
+ * the transaction-abort path.
*/
/* Shut down the deferred-trigger manager */
/*
* Mark serializable transaction as complete for predicate locking
- * purposes. This should be done as late as we can put it and still
- * allow errors to be raised for failure patterns found at commit.
+ * purposes. This should be done as late as we can put it and still allow
+ * errors to be raised for failure patterns found at commit.
*/
PreCommit_CheckForSerializationFailure();
/* File path names (all relative to $PGDATA) */
#define RECOVERY_COMMAND_FILE "recovery.conf"
#define RECOVERY_COMMAND_DONE "recovery.done"
-#define PROMOTE_SIGNAL_FILE "promote"
+#define PROMOTE_SIGNAL_FILE "promote"
/* User-settable parameters */
* known, need to check the shared state".
*/
static bool LocalRecoveryInProgress = true;
+
/*
* Local copy of SharedHotStandbyActive variable. False actually means "not
* known, need to check the shared state".
/*
* exclusiveBackup is true if a backup started with pg_start_backup() is
* in progress, and 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.
+ * 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.
*/
bool exclusiveBackup;
int nonExclusiveBackups;
XLogwrtResult LogwrtResult;
uint32 ckptXidEpoch; /* nextXID & epoch of latest checkpoint */
TransactionId ckptXid;
- XLogRecPtr asyncXactLSN; /* LSN of newest async commit/abort */
+ XLogRecPtr asyncXactLSN; /* LSN of newest async commit/abort */
uint32 lastRemovedLog; /* latest removed/recycled XLOG segment */
uint32 lastRemovedSeg;
bool SharedHotStandbyActive;
/*
- * recoveryWakeupLatch is used to wake up the startup process to
- * continue WAL replay, if it is waiting for WAL to arrive or failover
- * trigger file to appear.
+ * recoveryWakeupLatch is used to wake up the startup process to continue
+ * WAL replay, if it is waiting for WAL to arrive or failover trigger file
+ * to appear.
*/
Latch recoveryWakeupLatch;
/* logs restore point */
typedef struct xl_restore_point
{
- TimestampTz rp_time;
+ TimestampTz rp_time;
char rp_name[MAXFNAMELEN];
} xl_restore_point;
static bool
rescanLatestTimeLine(void)
{
- TimeLineID newtarget;
+ TimeLineID newtarget;
+
newtarget = findNewestTimeLine(recoveryTargetTLI);
if (newtarget != recoveryTargetTLI)
{
/*
* Determine the list of expected TLIs for the new TLI
*/
- List *newExpectedTLIs;
+ List *newExpectedTLIs;
+
newExpectedTLIs = readTimeLineHistory(newtarget);
/*
- * If the current timeline is not part of the history of the
- * new timeline, we cannot proceed to it.
+ * If the current timeline is not part of the history of the new
+ * timeline, we cannot proceed to it.
*
* XXX This isn't foolproof: The new timeline might have forked from
* the current one, but before the current recovery location. In that
* case we will still switch to the new timeline and proceed replaying
* from it even though the history doesn't match what we already
* replayed. That's not good. We will likely notice at the next online
- * checkpoint, as the TLI won't match what we expected, but it's
- * not guaranteed. The admin needs to make sure that doesn't happen.
+ * checkpoint, as the TLI won't match what we expected, but it's not
+ * guaranteed. The admin needs to make sure that doesn't happen.
*/
if (!list_member_int(newExpectedTLIs,
(int) recoveryTargetTLI))
timestamptz_to_str(recoveryStopTime));
else if (recoveryTarget == RECOVERY_TARGET_NAME)
snprintf(buffer, sizeof(buffer),
- "%s%u\t%s\tat restore point \"%s\"\n",
+ "%s%u\t%s\tat restore point \"%s\"\n",
(srcfd < 0) ? "" : "\n",
parentTLI,
xlogfname,
{
/*
* If we haven't yet changed the boot_val default of -1, just let it
- * be. We'll fix it when XLOGShmemSize is called.
+ * be. We'll fix it when XLOGShmemSize is called.
*/
if (XLOGbuffers == -1)
return true;
/*
* If the value of wal_buffers is -1, use the preferred auto-tune value.
* This isn't an amazingly clean place to do this, but we must wait till
- * NBuffers has received its final value, and must do it before using
- * the value of XLOGbuffers to do anything important.
+ * NBuffers has received its final value, and must do it before using the
+ * value of XLOGbuffers to do anything important.
*/
if (XLOGbuffers == -1)
{
/*
* Set up information for the initial checkpoint record
*
- * The initial checkpoint record is written to the beginning of the
- * WAL segment with logid=0 logseg=1. The very first WAL segment, 0/0, is
- * not used, so that we can use 0/0 to mean "before any valid WAL segment".
+ * The initial checkpoint record is written to the beginning of the WAL
+ * segment with logid=0 logseg=1. The very first WAL segment, 0/0, is not
+ * used, so that we can use 0/0 to mean "before any valid WAL segment".
*/
checkPoint.redo.xlogid = 0;
checkPoint.redo.xrecoff = XLogSegSize + SizeOfXLogLongPHD;
TimeLineID rtli = 0;
bool rtliGiven = false;
ConfigVariable *item,
- *head = NULL,
- *tail = NULL;
+ *head = NULL,
+ *tail = NULL;
fd = AllocateFile(RECOVERY_COMMAND_FILE, "r");
if (fd == NULL)
/*
* Since we're asking ParseConfigFp() to error out at FATAL, there's no
* need to check the return value.
- */
+ */
ParseConfigFp(fd, RECOVERY_COMMAND_FILE, 0, FATAL, &head, &tail);
for (item = head; item; item = item->next)
* this overrides recovery_target_time
*/
if (recoveryTarget == RECOVERY_TARGET_XID ||
- recoveryTarget == RECOVERY_TARGET_NAME)
+ recoveryTarget == RECOVERY_TARGET_NAME)
continue;
recoveryTarget = RECOVERY_TARGET_TIME;
*/
recoveryTargetTime =
DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in,
- CStringGetDatum(item->value),
+ CStringGetDatum(item->value),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1)));
ereport(DEBUG2,
if (recoveryTarget == RECOVERY_TARGET_UNSET)
{
/*
- * Save timestamp of latest transaction commit/abort if this is
- * a transaction record
+ * Save timestamp of latest transaction commit/abort if this is a
+ * transaction record
*/
if (record->xl_rmid == RM_XACT_ID)
SetLatestXTime(recordXtime);
else if (recoveryTarget == RECOVERY_TARGET_NAME)
{
/*
- * There can be many restore points that share the same name, so we stop
- * at the first one
+ * There can be many restore points that share the same name, so we
+ * stop at the first one
*/
stopsHere = (strcmp(recordRPName, recoveryTargetName) == 0);
strncpy(recoveryStopName, recordRPName, MAXFNAMELEN);
ereport(LOG,
- (errmsg("recovery stopping at restore point \"%s\", time %s",
- recoveryStopName,
- timestamptz_to_str(recoveryStopTime))));
+ (errmsg("recovery stopping at restore point \"%s\", time %s",
+ recoveryStopName,
+ timestamptz_to_str(recoveryStopTime))));
}
/*
- * Note that if we use a RECOVERY_TARGET_TIME then we can stop
- * at a restore point since they are timestamped, though the latest
+ * Note that if we use a RECOVERY_TARGET_TIME then we can stop at a
+ * restore point since they are timestamped, though the latest
* transaction time is not updated.
*/
if (record->xl_rmid == RM_XACT_ID && recoveryStopAfter)
while (RecoveryIsPaused())
{
- pg_usleep(1000000L); /* 1000 ms */
+ pg_usleep(1000000L); /* 1000 ms */
HandleStartupProcInterrupts();
}
}
{
/* use volatile pointer to prevent code rearrangement */
volatile XLogCtlData *xlogctl = XLogCtl;
- bool recoveryPause;
+ bool recoveryPause;
SpinLockAcquire(&xlogctl->info_lck);
recoveryPause = xlogctl->recoveryPause;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser to control recovery"))));
+ (errmsg("must be superuser to control recovery"))));
if (!RecoveryInProgress())
ereport(ERROR,
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser to control recovery"))));
+ (errmsg("must be superuser to control recovery"))));
if (!RecoveryInProgress())
ereport(ERROR,
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser to control recovery"))));
+ (errmsg("must be superuser to control recovery"))));
if (!RecoveryInProgress())
ereport(ERROR,
Datum
pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)
{
- TimestampTz xtime;
+ TimestampTz xtime;
xtime = GetLatestXTime();
if (xtime == 0)
InRecovery = true; /* force recovery even if SHUTDOWNED */
/*
- * Make sure that REDO location exists. This may not be
- * the case if there was a crash during an online backup,
- * which left a backup_label around that references a WAL
- * segment that's already been archived.
+ * Make sure that REDO location exists. This may not be the case
+ * if there was a crash during an online backup, which left a
+ * backup_label around that references a WAL segment that's
+ * already been archived.
*/
if (XLByteLT(checkPoint.redo, checkPointLoc))
{
ereport(FATAL,
(errmsg("could not locate required checkpoint record"),
errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".", DataDir)));
- wasShutdown = false; /* keep compiler quiet */
+ wasShutdown = false; /* keep compiler quiet */
}
/* set flag to delete it later */
haveBackupLabel = true;
/*
* We're in recovery, so unlogged relations relations may be trashed
- * and must be reset. This should be done BEFORE allowing Hot
- * Standby connections, so that read-only backends don't try to
- * read whatever garbage is left over from before.
+ * and must be reset. This should be done BEFORE allowing Hot Standby
+ * connections, so that read-only backends don't try to read whatever
+ * garbage is left over from before.
*/
ResetUnloggedRelations(UNLOGGED_RELATION_CLEANUP);
if (recoveryStopsHere(record, &recoveryApply))
{
/*
- * Pause only if users can connect to send a resume message
+ * Pause only if users can connect to send a resume
+ * message
*/
if (recoveryPauseAtTarget && standbyState == STANDBY_SNAPSHOT_READY)
{
{
/*
* We check shared state each time only until Hot Standby is active. We
- * can't de-activate Hot Standby, so there's no need to keep checking after
- * the shared variable has once been seen true.
+ * can't de-activate Hot Standby, so there's no need to keep checking
+ * after the shared variable has once been seen true.
*/
if (LocalHotStandbyActive)
return true;
*/
longest_secs = (long) (CheckpointStats.ckpt_longest_sync / 1000000);
longest_usecs = CheckpointStats.ckpt_longest_sync -
- (uint64) longest_secs * 1000000;
+ (uint64) longest_secs *1000000;
average_sync_time = 0;
- if (CheckpointStats.ckpt_sync_rels > 0)
+ if (CheckpointStats.ckpt_sync_rels > 0)
average_sync_time = CheckpointStats.ckpt_agg_sync_time /
CheckpointStats.ckpt_sync_rels;
average_secs = (long) (average_sync_time / 1000000);
- average_usecs = average_sync_time - (uint64) average_secs * 1000000;
+ average_usecs = average_sync_time - (uint64) average_secs *1000000;
if (restartpoint)
elog(LOG, "restartpoint complete: wrote %d buffers (%.1f%%); "
XLogRecPtr
XLogRestorePoint(const char *rpName)
{
- XLogRecPtr RecPtr;
- XLogRecData rdata;
- xl_restore_point xlrec;
+ XLogRecPtr RecPtr;
+ XLogRecData rdata;
+ xl_restore_point xlrec;
xlrec.rp_time = GetCurrentTimestamp();
strncpy(xlrec.rp_name, rpName, MAXFNAMELEN);
ereport(LOG,
(errmsg("restore point \"%s\" created at %X/%X",
- rpName, RecPtr.xlogid, RecPtr.xrecoff)));
+ rpName, RecPtr.xlogid, RecPtr.xrecoff)));
return RecPtr;
}
/*
* Optimize writes by bypassing kernel cache with O_DIRECT when using
- * O_SYNC/O_FSYNC and O_DSYNC. But only if archiving and streaming are
+ * O_SYNC/O_FSYNC and O_DSYNC. But only if archiving and streaming are
* disabled, otherwise the archive command or walsender process will read
* the WAL soon after writing it, which is guaranteed to cause a physical
* read if we bypassed the kernel cache. We also skip the
text *backupid = PG_GETARG_TEXT_P(0);
bool fast = PG_GETARG_BOOL(1);
char *backupidstr;
- XLogRecPtr startpoint;
+ XLogRecPtr startpoint;
char startxlogstr[MAXFNAMELEN];
backupidstr = text_to_cstring(backupid);
* do_pg_start_backup is the workhorse of the user-visible pg_start_backup()
* function. It creates the necessary starting checkpoint and constructs the
* backup label file.
- *
+ *
* There are two kind of backups: exclusive and non-exclusive. An exclusive
* backup is started with pg_start_backup(), and there can be only one active
* at a time. The backup label file of an exclusive backup is written to
if (!superuser() && !is_authenticated_user_replication_role())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser or replication role to run a backup")));
+ errmsg("must be superuser or replication role to run a backup")));
if (RecoveryInProgress())
ereport(ERROR,
/* Ensure we release forcePageWrites if fail below */
PG_ENSURE_ERROR_CLEANUP(pg_start_backup_callback, (Datum) BoolGetDatum(exclusive));
{
- bool gotUniqueStartpoint = false;
+ bool gotUniqueStartpoint = false;
+
do
{
/*
* Force a CHECKPOINT. Aside from being necessary to prevent torn
- * page problems, this guarantees that two successive backup runs will
- * have different checkpoint positions and hence different history
- * file names, even if nothing happened in between.
+ * page problems, this guarantees that two successive backup runs
+ * will have different checkpoint positions and hence different
+ * history file names, even if nothing happened in between.
*
- * We use CHECKPOINT_IMMEDIATE only if requested by user (via passing
- * fast = true). Otherwise this can take awhile.
+ * We use CHECKPOINT_IMMEDIATE only if requested by user (via
+ * passing fast = true). Otherwise this can take awhile.
*/
RequestCheckpoint(CHECKPOINT_FORCE | CHECKPOINT_WAIT |
(fast ? CHECKPOINT_IMMEDIATE : 0));
/*
- * Now we need to fetch the checkpoint record location, and also its
- * REDO pointer. The oldest point in WAL that would be needed to
- * restore starting from the checkpoint is precisely the REDO pointer.
+ * Now we need to fetch the checkpoint record location, and also
+ * its REDO pointer. The oldest point in WAL that would be needed
+ * to restore starting from the checkpoint is precisely the REDO
+ * pointer.
*/
LWLockAcquire(ControlFileLock, LW_SHARED);
checkpointloc = ControlFile->checkPoint;
LWLockRelease(ControlFileLock);
/*
- * If two base backups are started at the same time (in WAL
- * sender processes), we need to make sure that they use
- * different checkpoints as starting locations, because we use
- * the starting WAL location as a unique identifier for the base
- * backup in the end-of-backup WAL record and when we write the
- * backup history file. Perhaps it would be better generate a
- * separate unique ID for each backup instead of forcing another
- * checkpoint, but taking a checkpoint right after another is
- * not that expensive either because only few buffers have been
- * dirtied yet.
+ * If two base backups are started at the same time (in WAL sender
+ * processes), we need to make sure that they use different
+ * checkpoints as starting locations, because we use the starting
+ * WAL location as a unique identifier for the base backup in the
+ * end-of-backup WAL record and when we write the backup history
+ * file. Perhaps it would be better generate a separate unique ID
+ * for each backup instead of forcing another checkpoint, but
+ * taking a checkpoint right after another is not that expensive
+ * either because only few buffers have been dirtied yet.
*/
LWLockAcquire(WALInsertLock, LW_SHARED);
if (XLByteLT(XLogCtl->Insert.lastBackupStart, startpoint))
gotUniqueStartpoint = true;
}
LWLockRelease(WALInsertLock);
- } while(!gotUniqueStartpoint);
+ } while (!gotUniqueStartpoint);
XLByteToSeg(startpoint, _logId, _logSeg);
XLogFileName(xlogfilename, ThisTimeLineID, _logId, _logSeg);
/*
- * Construct backup label file
+ * Construct backup label file
*/
initStringInfo(&labelfbuf);
{
/*
* Check for existing backup label --- implies a backup is already
- * running. (XXX given that we checked exclusiveBackup above, maybe
- * it would be OK to just unlink any such label file?)
+ * running. (XXX given that we checked exclusiveBackup above,
+ * maybe it would be OK to just unlink any such label file?)
*/
if (stat(BACKUP_LABEL_FILE, &stat_buf) != 0)
{
static void
pg_start_backup_callback(int code, Datum arg)
{
- bool exclusive = DatumGetBool(arg);
+ bool exclusive = DatumGetBool(arg);
/* Update backup counters and forcePageWrites on failure */
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
if (!superuser() && !is_authenticated_user_replication_role())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("must be superuser or replication role to run a backup"))));
+ (errmsg("must be superuser or replication role to run a backup"))));
if (RecoveryInProgress())
ereport(ERROR,
/*
* Read the existing label file into memory.
*/
- struct stat statbuf;
- int r;
+ struct stat statbuf;
+ int r;
if (stat(BACKUP_LABEL_FILE, &statbuf))
{
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));
- remaining = strchr(labelfile, '\n') + 1; /* %n is not portable enough */
+ remaining = strchr(labelfile, '\n') + 1; /* %n is not portable enough */
/*
* Write the backup-end xlog record
Datum
pg_create_restore_point(PG_FUNCTION_ARGS)
{
- text *restore_name = PG_GETARG_TEXT_P(0);
- char *restore_name_str;
+ text *restore_name = PG_GETARG_TEXT_P(0);
+ char *restore_name_str;
XLogRecPtr restorepoint;
char location[MAXFNAMELEN];
if (!XLogIsNeeded())
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("WAL level not sufficient for creating a restore point"),
+ errmsg("WAL level not sufficient for creating a restore point"),
errhint("wal_level must be set to \"archive\" or \"hot_standby\" at server start.")));
restore_name_str = text_to_cstring(restore_name);
* As a convenience, return the WAL location of the restore point record
*/
snprintf(location, sizeof(location), "%X/%X",
- restorepoint.xlogid, restorepoint.xrecoff);
+ restorepoint.xlogid, restorepoint.xrecoff);
PG_RETURN_TEXT_P(cstring_to_text(location));
}
}
/*
- * If it hasn't been long since last attempt, sleep
- * to avoid busy-waiting.
+ * If it hasn't been long since last attempt, sleep to
+ * avoid busy-waiting.
*/
now = (pg_time_t) time(NULL);
if ((now - last_fail_time) < 5)
CheckForStandbyTrigger(void)
{
struct stat stat_buf;
- static bool triggered = false;
+ static bool triggered = false;
if (triggered)
return true;
if (stat(PROMOTE_SIGNAL_FILE, &stat_buf) == 0)
{
/*
- * Since we are in a signal handler, it's not safe
- * to elog. We silently ignore any error from unlink.
+ * Since we are in a signal handler, it's not safe to elog. We
+ * silently ignore any error from unlink.
*/
unlink(PROMOTE_SIGNAL_FILE);
return true;
/*
* Note that we must do the permissions check against the target
- * role not the calling user. We require CREATE privileges,
- * since without CREATE you won't be able to do anything using the
+ * role not the calling user. We require CREATE privileges, since
+ * without CREATE you won't be able to do anything using the
* default privs anyway.
*/
iacls->nspid = get_namespace_oid(nspname, false);
pg_class_tuple->relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a foreign table",
+ errmsg("\"%s\" is not a foreign table",
NameStr(pg_class_tuple->relname))));
/* Adjust the default permissions based on object type */
this_privileges &= (AclMode) ACL_SELECT;
}
else if (pg_class_tuple->relkind == RELKIND_FOREIGN_TABLE &&
- this_privileges & ~((AclMode) ACL_SELECT))
+ this_privileges & ~((AclMode) ACL_SELECT))
{
/* Foreign tables have the same restriction as sequences. */
ereport(WARNING,
- (errcode(ERRCODE_INVALID_GRANT_OPERATION),
- errmsg("foreign table \"%s\" only supports SELECT column privileges",
- NameStr(pg_class_tuple->relname))));
+ (errcode(ERRCODE_INVALID_GRANT_OPERATION),
+ errmsg("foreign table \"%s\" only supports SELECT column privileges",
+ NameStr(pg_class_tuple->relname))));
this_privileges &= (AclMode) ACL_SELECT;
}
* Note: roles do not have owners per se; instead we use this test in
* places where an ownership-like permissions test is needed for a role.
* Be sure to apply it to the role trying to do the operation, not the
- * role being operated on! Also note that this generally should not be
+ * role being operated on! Also note that this generally should not be
* considered enough privilege if the target role is a superuser.
* (We don't handle that consideration here because we want to give a
* separate error message for such cases, so the caller has to deal with it.)
/*
* forkname_chars
- * We use this to figure out whether a filename could be a relation
- * fork (as opposed to an oddly named stray file that somehow ended
- * up in the database directory). If the passed string begins with
- * a fork name (other than the main fork name), we return its length,
- * and set *fork (if not NULL) to the fork number. If not, we return 0.
+ * We use this to figure out whether a filename could be a relation
+ * fork (as opposed to an oddly named stray file that somehow ended
+ * up in the database directory). If the passed string begins with
+ * a fork name (other than the main fork name), we return its length,
+ * and set *fork (if not NULL) to the fork number. If not, we return 0.
*
* Note that the present coding assumes that there are no fork names which
* are prefixes of other fork names.
for (forkNum = 1; forkNum <= MAX_FORKNUM; forkNum++)
{
- int len = strlen(forkNames[forkNum]);
+ int len = strlen(forkNames[forkNum]);
+
if (strncmp(forkNames[forkNum], str, len) == 0)
{
if (fork)
{
/* OIDCHARS will suffice for an integer, too */
pathlen = 5 + OIDCHARS + 2 + OIDCHARS + 1 + OIDCHARS + 1
- + FORKNAMECHARS + 1;
+ + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "base/%u/t%d_%u_%s",
if (backend == InvalidBackendId)
{
pathlen = 9 + 1 + OIDCHARS + 1
- + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1
- + OIDCHARS + 1 + FORKNAMECHARS + 1;
+ + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1
+ + OIDCHARS + 1 + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u_%s",
{
/* OIDCHARS will suffice for an integer, too */
pathlen = 9 + 1 + OIDCHARS + 1
- + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 2
- + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
+ + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 2
+ + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u_%s",
ForeignServerRelationId, /* OCLASS_FOREIGN_SERVER */
UserMappingRelationId, /* OCLASS_USER_MAPPING */
DefaultAclRelationId, /* OCLASS_DEFACL */
- ExtensionRelationId /* OCLASS_EXTENSION */
+ ExtensionRelationId /* OCLASS_EXTENSION */
};
/*
* Delete any comments or security labels associated with this object.
- * (This is a convenient place to do these things, rather than having every
- * object type know to do it.)
+ * (This is a convenient place to do these things, rather than having
+ * every object type know to do it.)
*/
DeleteComments(object->objectId, object->classId, object->objectSubId);
DeleteSecurityLabel(object);
* whereas 'behavior' is used for everything else.
*
* NOTE: the caller should ensure that a whole-table dependency on the
- * specified relation is created separately, if one is needed. In particular,
+ * specified relation is created separately, if one is needed. In particular,
* a whole-row Var "relation.*" will not cause this routine to emit any
* dependency item. This is appropriate behavior for subexpressions of an
* ordinary query, so other cases need to cope as necessary.
/*
* A whole-row Var references no specific columns, so adds no new
- * dependency. (We assume that there is a whole-table dependency
+ * dependency. (We assume that there is a whole-table dependency
* arising from each underlying rangetable entry. While we could
* record such a dependency when finding a whole-row Var that
* references a relation directly, it's quite unclear how to extend
/*
* We must also depend on the constant's collation: it could be
- * different from the datatype's, if a CollateExpr was const-folded
- * to a simple constant. However we can save work in the most common
+ * different from the datatype's, if a CollateExpr was const-folded to
+ * a simple constant. However we can save work in the most common
* case where the collation is "default", since we know that's pinned.
*/
if (OidIsValid(con->constcollid) &&
}
foreach(ct, rte->funccolcollations)
{
- Oid collid = lfirst_oid(ct);
+ Oid collid = lfirst_oid(ct);
if (OidIsValid(collid) &&
collid != DEFAULT_COLLATION_OID)
HeapTuple collTup;
collTup = SearchSysCache1(COLLOID,
- ObjectIdGetDatum(object->objectId));
+ ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(collTup))
elog(ERROR, "cache lookup failed for collation %u",
object->objectId);
appendStringInfo(&buffer, _("collation %s"),
- NameStr(((Form_pg_collation) GETSTRUCT(collTup))->collname));
+ NameStr(((Form_pg_collation) GETSTRUCT(collTup))->collname));
ReleaseSysCache(collTup);
break;
}
char *
getObjectDescriptionOids(Oid classid, Oid objid)
{
- ObjectAddress address;
+ ObjectAddress address;
address.classId = classid;
address.objectId = objid;
CheckAttributeType(NameStr(tupdesc->attrs[i]->attname),
tupdesc->attrs[i]->atttypid,
tupdesc->attrs[i]->attcollation,
- NIL, /* assume we're creating a new rowtype */
+ NIL, /* assume we're creating a new rowtype */
allow_system_table_mods);
}
}
int i;
/*
- * Check for self-containment. Eventually we might be able to allow
+ * Check for self-containment. Eventually we might be able to allow
* this (just return without complaint, if so) but it's not clear how
* many other places would require anti-recursion defenses before it
* would be safe to allow tables to contain their own rowtype.
if (list_member_oid(containing_rowtypes, atttypid))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
- errmsg("composite type %s cannot be made a member of itself",
- format_type_be(atttypid))));
+ errmsg("composite type %s cannot be made a member of itself",
+ format_type_be(atttypid))));
containing_rowtypes = lcons_oid(atttypid, containing_rowtypes);
}
/*
- * This might not be strictly invalid per SQL standard, but it is
- * pretty useless, and it cannot be dumped, so we must disallow it.
+ * This might not be strictly invalid per SQL standard, but it is pretty
+ * useless, and it cannot be dumped, so we must disallow it.
*/
if (!OidIsValid(attcollation) && type_is_collatable(atttypid))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
- errmsg("no collation was derived for column \"%s\" with collatable type %s",
- attname, format_type_be(atttypid)),
- errhint("Use the COLLATE clause to set the collation explicitly.")));
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+ errmsg("no collation was derived for column \"%s\" with collatable type %s",
+ attname, format_type_be(atttypid)),
+ errhint("Use the COLLATE clause to set the collation explicitly.")));
}
/*
-1, /* typmod */
0, /* array dimensions for typBaseType */
false, /* Type NOT NULL */
- InvalidOid); /* typcollation */
+ InvalidOid); /* typcollation */
}
/* --------------------------------
CheckAttributeNamesTypes(tupdesc, relkind, allow_system_table_mods);
/*
- * If the relation already exists, it's an error, unless the user specifies
- * "IF NOT EXISTS". In that case, we just print a notice and do nothing
- * further.
+ * If the relation already exists, it's an error, unless the user
+ * specifies "IF NOT EXISTS". In that case, we just print a notice and do
+ * nothing further.
*/
existing_relid = get_relname_relid(relname, relnamespace);
if (existing_relid != InvalidOid)
ereport(NOTICE,
(errcode(ERRCODE_DUPLICATE_TABLE),
errmsg("relation \"%s\" already exists, skipping",
- relname)));
+ relname)));
heap_close(pg_class_desc, RowExclusiveLock);
return InvalidOid;
}
if (!OidIsValid(relid))
{
/*
- * Use binary-upgrade override for pg_class.oid/relfilenode,
- * if supplied.
+ * Use binary-upgrade override for pg_class.oid/relfilenode, if
+ * supplied.
*/
if (OidIsValid(binary_upgrade_next_heap_pg_class_oid) &&
(relkind == RELKIND_RELATION || relkind == RELKIND_SEQUENCE ||
-1, /* typmod */
0, /* array dimensions for typBaseType */
false, /* Type NOT NULL */
- InvalidOid); /* typcollation */
+ InvalidOid); /* typcollation */
pfree(relarrayname);
}
register_on_commit_action(relid, oncommit);
/*
- * If this is an unlogged relation, it needs an init fork so that it
- * can be correctly reinitialized on restart. Since we're going to
- * do an immediate sync, we ony need to xlog this if archiving or
- * streaming is enabled. And the immediate sync is required, because
- * otherwise there's no guarantee that this will hit the disk before
- * the next checkpoint moves the redo pointer.
+ * If this is an unlogged relation, it needs an init fork so that it can
+ * be correctly reinitialized on restart. Since we're going to do an
+ * immediate sync, we ony need to xlog this if archiving or streaming is
+ * enabled. And the immediate sync is required, because otherwise there's
+ * no guarantee that this will hit the disk before the next checkpoint
+ * moves the redo pointer.
*/
if (relpersistence == RELPERSISTENCE_UNLOGGED)
{
/*
* There can no longer be anyone *else* touching the relation, but we
- * might still have open queries or cursors, or pending trigger events,
- * in our own session.
+ * might still have open queries or cursors, or pending trigger events, in
+ * our own session.
*/
CheckTableNotInUse(rel, "DROP TABLE");
*/
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
{
- Relation rel;
- HeapTuple tuple;
+ Relation rel;
+ HeapTuple tuple;
rel = heap_open(ForeignTableRelationId, RowExclusiveLock);
CONSTRAINT_CHECK, /* Constraint Type */
false, /* Is Deferrable */
false, /* Is Deferred */
- true, /* Is Validated */
+ true, /* Is Validated */
RelationGetRelid(rel), /* relation */
attNos, /* attrs in the constraint */
keycount, /* # attrs in the constraint */
int i;
/*
- * If ALTER TABLE, check that there isn't already a PRIMARY KEY. In
- * CREATE TABLE, we have faith that the parser rejected multiple pkey
- * clauses; and CREATE INDEX doesn't have a way to say PRIMARY KEY, so
- * it's no problem either.
+ * If ALTER TABLE, check that there isn't already a PRIMARY KEY. In CREATE
+ * TABLE, we have faith that the parser rejected multiple pkey clauses;
+ * and CREATE INDEX doesn't have a way to say PRIMARY KEY, so it's no
+ * problem either.
*/
if (is_alter_table &&
relationHasPrimaryKey(heapRel))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
- errmsg("multiple primary keys for table \"%s\" are not allowed",
- RelationGetRelationName(heapRel))));
+ errmsg("multiple primary keys for table \"%s\" are not allowed",
+ RelationGetRelationName(heapRel))));
}
/*
continue;
atttuple = SearchSysCache2(ATTNUM,
- ObjectIdGetDatum(RelationGetRelid(heapRel)),
+ ObjectIdGetDatum(RelationGetRelid(heapRel)),
Int16GetDatum(attnum));
if (!HeapTupleIsValid(atttuple))
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
}
/*
- * XXX: Shouldn't the ALTER TABLE .. SET NOT NULL cascade to child
- * tables? Currently, since the PRIMARY KEY itself doesn't cascade,
- * we don't cascade the notnull constraint(s) either; but this is
- * pretty debatable.
+ * XXX: Shouldn't the ALTER TABLE .. SET NOT NULL cascade to child tables?
+ * Currently, since the PRIMARY KEY itself doesn't cascade, we don't
+ * cascade the notnull constraint(s) either; but this is pretty debatable.
*
- * XXX: possible future improvement: when being called from ALTER
- * TABLE, it would be more efficient to merge this with the outer
- * ALTER TABLE, so as to avoid two scans. But that seems to
- * complicate DefineIndex's API unduly.
+ * XXX: possible future improvement: when being called from ALTER TABLE,
+ * it would be more efficient to merge this with the outer ALTER TABLE, so
+ * as to avoid two scans. But that seems to complicate DefineIndex's API
+ * unduly.
*/
if (cmds)
AlterTableInternal(RelationGetRelid(heapRel), cmds, false);
if (!OidIsValid(indexRelationId))
{
/*
- * Use binary-upgrade override for pg_class.oid/relfilenode,
- * if supplied.
+ * Use binary-upgrade override for pg_class.oid/relfilenode, if
+ * supplied.
*/
if (OidIsValid(binary_upgrade_next_index_pg_class_oid))
{
* ----------------
*/
UpdateIndexRelation(indexRelationId, heapRelationId, indexInfo,
- collationObjectId, classObjectId, coloptions, isprimary, is_exclusion,
+ collationObjectId, classObjectId, coloptions, isprimary, is_exclusion,
!deferrable,
!concurrent);
/*
* If there are no simply-referenced columns, give the index an
- * auto dependency on the whole table. In most cases, this will
+ * auto dependency on the whole table. In most cases, this will
* be redundant, but it might not be if the index expressions and
* predicate contain no Vars or only whole-row Vars.
*/
/*
* Close the index; but we keep the lock that we acquired above until end
- * of transaction. Closing the heap is caller's responsibility.
+ * of transaction. Closing the heap is caller's responsibility.
*/
index_close(indexRelation, NoLock);
/*
* If the constraint is deferrable, create the deferred uniqueness
- * checking trigger. (The trigger will be given an internal
- * dependency on the constraint by CreateTrigger.)
+ * checking trigger. (The trigger will be given an internal dependency on
+ * the constraint by CreateTrigger.)
*/
if (deferrable)
{
* have been so marked already, so no need to clear the flag in the other
* case.
*
- * Note: this might better be done by callers. We do it here to avoid
+ * Note: this might better be done by callers. We do it here to avoid
* exposing index_update_stats() globally, but that wouldn't be necessary
* if relhaspkey went away.
*/
*/
if (update_pgindex && (mark_as_primary || deferrable))
{
- Relation pg_index;
- HeapTuple indexTuple;
- Form_pg_index indexForm;
- bool dirty = false;
+ Relation pg_index;
+ HeapTuple indexTuple;
+ Form_pg_index indexForm;
+ bool dirty = false;
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
userIndexRelation = index_open(indexId, AccessExclusiveLock);
/*
- * There can no longer be anyone *else* touching the index, but we
- * might still have open queries using it in our own session.
+ * There can no longer be anyone *else* touching the index, but we might
+ * still have open queries using it in our own session.
*/
CheckTableNotInUse(userIndexRelation, "DROP INDEX");
*/
if (heapRelation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
{
- RegProcedure ambuildempty = indexRelation->rd_am->ambuildempty;
+ RegProcedure ambuildempty = indexRelation->rd_am->ambuildempty;
+
RelationOpenSmgr(indexRelation);
smgrcreate(indexRelation->rd_smgr, INIT_FORKNUM, false);
OidFunctionCall1(ambuildempty, PointerGetDatum(indexRelation));
ivinfo.strategy = NULL;
state.tuplesort = tuplesort_begin_datum(TIDOID,
- TIDLessOperator, InvalidOid, false,
+ TIDLessOperator, InvalidOid, false,
maintenance_work_mem,
false);
state.htups = state.itups = state.tups_inserted = 0;
* use catalog indexes while collecting the list.)
*
* To avoid deadlocks, VACUUM FULL or CLUSTER on a system catalog must omit the
- * REINDEX_CHECK_CONSTRAINTS flag. REINDEX should be used to rebuild an index
+ * REINDEX_CHECK_CONSTRAINTS flag. REINDEX should be used to rebuild an index
* if constraint inconsistency is suspected. For optimal performance, other
* callers should include the flag only after transforming the data in a manner
* that risks a change in constraint validity.
if (oldNspOid == nspOid)
ereport(ERROR,
(classid == RelationRelationId ?
- errcode(ERRCODE_DUPLICATE_TABLE) :
+ errcode(ERRCODE_DUPLICATE_TABLE) :
classid == ProcedureRelationId ?
- errcode(ERRCODE_DUPLICATE_FUNCTION) :
- errcode(ERRCODE_DUPLICATE_OBJECT),
+ errcode(ERRCODE_DUPLICATE_FUNCTION) :
+ errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("%s is already in schema \"%s\"",
getObjectDescriptionOids(classid, objid),
get_namespace_name(nspOid))));
if (isAnyTempNamespace(nspOid) || isAnyTempNamespace(oldNspOid))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot move objects into or out of temporary schemas")));
+ errmsg("cannot move objects into or out of temporary schemas")));
/* same for TOAST schema */
if (nspOid == PG_TOAST_NAMESPACE || oldNspOid == PG_TOAST_NAMESPACE)
/*
* get_namespace_oid - given a namespace name, look up the OID
*
- * If missing_ok is false, throw an error if namespace name not found. If
+ * If missing_ok is false, throw an error if namespace name not found. If
* true, just return InvalidOid.
*/
Oid
oid = GetSysCacheOid1(NAMESPACENAME, CStringGetDatum(nspname));
if (!OidIsValid(oid) && !missing_ok)
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_SCHEMA),
- errmsg("schema \"%s\" does not exist", nspname)));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_SCHEMA),
+ errmsg("schema \"%s\" does not exist", nspname)));
return oid;
}
/* See if the namespace name starts with "pg_temp_" or "pg_toast_temp_" */
nspname = get_namespace_name(namespaceId);
if (!nspname)
- return InvalidBackendId; /* no such namespace? */
+ return InvalidBackendId; /* no such namespace? */
if (strncmp(nspname, "pg_temp_", 8) == 0)
result = atoi(nspname + 8);
else if (strncmp(nspname, "pg_toast_temp_", 14) == 0)
*
* It's possible that newpath->useTemp is set but there is no longer any
* active temp namespace, if the path was saved during a transaction that
- * created a temp namespace and was later rolled back. In that case we just
- * ignore useTemp. A plausible alternative would be to create a new temp
+ * created a temp namespace and was later rolled back. In that case we just
+ * ignore useTemp. A plausible alternative would be to create a new temp
* namespace, but for existing callers that's not necessary because an empty
* temp namespace wouldn't affect their results anyway.
*
if (source == PGC_S_TEST)
ereport(NOTICE,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
- errmsg("schema \"%s\" does not exist", curname)));
+ errmsg("schema \"%s\" does not exist", curname)));
else
{
GUC_check_errdetail("schema \"%s\" does not exist", curname);
static ObjectAddress get_object_address_relobject(ObjectType objtype,
List *objname, Relation *relp);
static ObjectAddress get_object_address_attribute(ObjectType objtype,
- List *objname, Relation *relp, LOCKMODE lockmode);
+ List *objname, Relation *relp, LOCKMODE lockmode);
static ObjectAddress get_object_address_opcf(ObjectType objtype, List *objname,
List *objargs);
static bool object_exists(ObjectAddress address);
get_object_address(ObjectType objtype, List *objname, List *objargs,
Relation *relp, LOCKMODE lockmode)
{
- ObjectAddress address;
- Relation relation = NULL;
+ ObjectAddress address;
+ Relation relation = NULL;
/* Some kind of lock must be taken. */
Assert(lockmode != NoLock);
case OBJECT_COLUMN:
address =
get_object_address_attribute(objtype, objname, &relation,
- lockmode);
+ lockmode);
break;
case OBJECT_RULE:
case OBJECT_TRIGGER:
break;
case OBJECT_CAST:
{
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
- Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
- Oid targettypeid = typenameTypeId(NULL, targettype);
+ TypeName *sourcetype = (TypeName *) linitial(objname);
+ TypeName *targettype = (TypeName *) linitial(objargs);
+ Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
+ Oid targettypeid = typenameTypeId(NULL, targettype);
address.classId = CastRelationId;
address.objectId =
/*
* If we're dealing with a relation or attribute, then the relation is
- * already locked. If we're dealing with any other type of object, we need
- * to lock it and then verify that it still exists.
+ * already locked. If we're dealing with any other type of object, we
+ * need to lock it and then verify that it still exists.
*/
if (address.classId != RelationRelationId)
{
break;
default:
elog(ERROR, "unrecognized objtype: %d", (int) objtype);
- msg = NULL; /* placate compiler */
+ msg = NULL; /* placate compiler */
}
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
get_relation_by_qualified_name(ObjectType objtype, List *objname,
LOCKMODE lockmode)
{
- Relation relation;
+ Relation relation;
relation = relation_openrv(makeRangeVarFromNameList(objname), lockmode);
switch (objtype)
nnames = list_length(objname);
if (nnames < 2)
{
- Oid reloid;
+ Oid reloid;
/*
* For compatibility with very old releases, we sometimes allow users
get_object_address_attribute(ObjectType objtype, List *objname,
Relation *relp, LOCKMODE lockmode)
{
- ObjectAddress address;
+ ObjectAddress address;
List *relname;
Oid reloid;
Relation relation;
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("column \"%s\" of relation \"%s\" does not exist",
- attname, RelationGetRelationName(relation))));
+ attname, RelationGetRelationName(relation))));
*relp = relation;
return address;
int cache = -1;
Oid indexoid = InvalidOid;
Relation rel;
- ScanKeyData skey[1];
- SysScanDesc sd;
+ ScanKeyData skey[1];
+ SysScanDesc sd;
bool found;
/* Sub-objects require special treatment. */
/*
* For object types that have a relevant syscache, we use it; for
- * everything else, we'll have to do an index-scan. This switch
- * sets either the cache to be used for the syscache lookup, or the
- * index to be used for the index scan.
+ * everything else, we'll have to do an index-scan. This switch sets
+ * either the cache to be used for the syscache lookup, or the index to be
+ * used for the index scan.
*/
switch (address.classId)
{
cache = OPFAMILYOID;
break;
case LargeObjectRelationId:
+
/*
* Weird backward compatibility hack: ObjectAddress notation uses
* LargeObjectRelationId for large objects, but since PostgreSQL
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be owner of large object %u",
- address.objectId)));
+ address.objectId)));
break;
case OBJECT_CAST:
{
/* We can only check permissions on the source/target types */
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
- Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
- Oid targettypeid = typenameTypeId(NULL, targettype);
+ TypeName *sourcetype = (TypeName *) linitial(objname);
+ TypeName *targettype = (TypeName *) linitial(objargs);
+ Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
+ Oid targettypeid = typenameTypeId(NULL, targettype);
if (!pg_type_ownercheck(sourcetypeid, roleid)
&& !pg_type_ownercheck(targettypeid, roleid))
NameListToString(objname));
break;
case OBJECT_ROLE:
+
/*
* We treat roles as being "owned" by those with CREATEROLE priv,
* except that superusers are only owned by superusers.
HeapTuple tup;
Datum values[Natts_pg_collation];
bool nulls[Natts_pg_collation];
- NameData name_name, name_collate, name_ctype;
+ NameData name_name,
+ name_collate,
+ name_ctype;
Oid oid;
ObjectAddress myself,
referenced;
/*
* Make sure there is no existing collation of same name & encoding.
*
- * This would be caught by the unique index anyway; we're just giving
- * a friendlier error message. The unique index provides a backstop
- * against race conditions.
+ * This would be caught by the unique index anyway; we're just giving a
+ * friendlier error message. The unique index provides a backstop against
+ * race conditions.
*/
if (SearchSysCacheExists3(COLLNAMEENCNSP,
PointerGetDatum(collname),
collname, pg_encoding_to_char(collencoding))));
/*
- * Also forbid matching an any-encoding entry. This test of course is
- * not backed up by the unique index, but it's not a problem since we
- * don't support adding any-encoding entries after initdb.
+ * Also forbid matching an any-encoding entry. This test of course is not
+ * backed up by the unique index, but it's not a problem since we don't
+ * support adding any-encoding entries after initdb.
*/
if (SearchSysCacheExists3(COLLNAMEENCNSP,
PointerGetDatum(collname),
* the rel of interest are Vars with the indicated varno/varlevelsup.
*
* Currently we only check to see if the rel has a primary key that is a
- * subset of the grouping_columns. We could also use plain unique constraints
+ * subset of the grouping_columns. We could also use plain unique constraints
* if all their columns are known not null, but there's a problem: we need
* to be able to represent the not-null-ness as part of the constraints added
- * to *constraintDeps. FIXME whenever not-null constraints get represented
+ * to *constraintDeps. FIXME whenever not-null constraints get represented
* in pg_constraint.
*/
bool
if (isNull)
elog(ERROR, "null conkey for constraint %u",
HeapTupleGetOid(tuple));
- arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
+ arr = DatumGetArrayTypeP(adatum); /* ensure not toasted */
numkeys = ARR_DIMS(arr)[0];
if (ARR_NDIM(arr) != 1 ||
numkeys < 0 ||
/*
* If we are executing a CREATE EXTENSION operation, mark the given object
- * as being a member of the extension. Otherwise, do nothing.
+ * as being a member of the extension. Otherwise, do nothing.
*
* This must be called during creation of any user-definable object type
* that could be a member of an extension.
{
if (creating_extension)
{
- ObjectAddress extension;
+ ObjectAddress extension;
extension.classId = ExtensionRelationId;
extension.objectId = CurrentExtensionObject;
* (possibly with some differences from before).
*
* If skipExtensionDeps is true, we do not delete any dependencies that
- * show that the given object is a member of an extension. This avoids
+ * show that the given object is a member of an extension. This avoids
* needing a lot of extra logic to fetch and recreate that dependency.
*/
long
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
if (skipExtensionDeps &&
- ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
+ ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
continue;
simple_heap_delete(depRel, &tup->t_self);
/* Potentially set by contrib/pg_upgrade_support functions */
-Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
+Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
static int oid_cmp(const void *p1, const void *p2);
num_elems = list_length(vals);
/*
- * We do not bother to check the list of values for duplicates --- if
- * you have any, you'll get a less-than-friendly unique-index violation.
- * It is probably not worth trying harder.
+ * We do not bother to check the list of values for duplicates --- if you
+ * have any, you'll get a less-than-friendly unique-index violation. It is
+ * probably not worth trying harder.
*/
pg_enum = heap_open(EnumRelationId, RowExclusiveLock);
* Allocate OIDs for the enum's members.
*
* While this method does not absolutely guarantee that we generate no
- * duplicate OIDs (since we haven't entered each oid into the table
- * before allocating the next), trouble could only occur if the OID
- * counter wraps all the way around before we finish. Which seems
- * unlikely.
+ * duplicate OIDs (since we haven't entered each oid into the table before
+ * allocating the next), trouble could only occur if the OID counter wraps
+ * all the way around before we finish. Which seems unlikely.
*/
oids = (Oid *) palloc(num_elems * sizeof(Oid));
* tells the comparison functions the OIDs are in the correct sort
* order and can be compared directly.
*/
- Oid new_oid;
+ Oid new_oid;
- do {
+ do
+ {
new_oid = GetNewOid(pg_enum);
} while (new_oid & 1);
oids[elemno] = new_oid;
/*
* Acquire a lock on the enum type, which we won't release until commit.
* This ensures that two backends aren't concurrently modifying the same
- * enum type. Without that, we couldn't be sure to get a consistent
- * view of the enum members via the syscache. Note that this does not
- * block other backends from inspecting the type; see comments for
+ * enum type. Without that, we couldn't be sure to get a consistent view
+ * of the enum members via the syscache. Note that this does not block
+ * other backends from inspecting the type; see comments for
* RenumberEnumType.
*/
LockDatabaseObject(TypeRelationId, enumTypeOid, 0, ExclusiveLock);
/* Get the list of existing members of the enum */
list = SearchSysCacheList1(ENUMTYPOIDNAME,
ObjectIdGetDatum(enumTypeOid));
- nelems = list->n_members;
+ nelems = list->n_members;
/* Sort the existing members by enumsortorder */
existing = (HeapTuple *) palloc(nelems * sizeof(HeapTuple));
if (neighbor == NULL)
{
/*
- * Put the new label at the end of the list.
- * No change to existing tuples is required.
+ * Put the new label at the end of the list. No change to existing
+ * tuples is required.
*/
if (nelems > 0)
{
else
{
/* BEFORE or AFTER was specified */
- int nbr_index;
- int other_nbr_index;
- Form_pg_enum nbr_en;
- Form_pg_enum other_nbr_en;
+ int nbr_index;
+ int other_nbr_index;
+ Form_pg_enum nbr_en;
+ Form_pg_enum other_nbr_en;
/* Locate the neighbor element */
for (nbr_index = 0; nbr_index < nelems; nbr_index++)
nbr_en = (Form_pg_enum) GETSTRUCT(existing[nbr_index]);
/*
- * Attempt to assign an appropriate enumsortorder value: one less
- * than the smallest member, one more than the largest member,
- * or halfway between two existing members.
+ * Attempt to assign an appropriate enumsortorder value: one less than
+ * the smallest member, one more than the largest member, or halfway
+ * between two existing members.
*
* In the "halfway" case, because of the finite precision of float4,
- * we might compute a value that's actually equal to one or the
- * other of its neighbors. In that case we renumber the existing
- * members and try again.
+ * we might compute a value that's actually equal to one or the other
+ * of its neighbors. In that case we renumber the existing members
+ * and try again.
*/
if (newValIsAfter)
other_nbr_index = nbr_index + 1;
/*
* On some machines, newelemorder may be in a register that's
- * wider than float4. We need to force it to be rounded to
- * float4 precision before making the following comparisons,
- * or we'll get wrong results. (Such behavior violates the C
- * standard, but fixing the compilers is out of our reach.)
+ * wider than float4. We need to force it to be rounded to float4
+ * precision before making the following comparisons, or we'll get
+ * wrong results. (Such behavior violates the C standard, but
+ * fixing the compilers is out of our reach.)
*/
newelemorder = DatumGetFloat4(Float4GetDatum(newelemorder));
if (OidIsValid(binary_upgrade_next_pg_enum_oid))
{
/*
- * Use binary-upgrade override for pg_enum.oid, if supplied.
- * During binary upgrade, all pg_enum.oid's are set this way
- * so they are guaranteed to be consistent.
+ * Use binary-upgrade override for pg_enum.oid, if supplied. During
+ * binary upgrade, all pg_enum.oid's are set this way so they are
+ * guaranteed to be consistent.
*/
if (neighbor != NULL)
ereport(ERROR,
*/
for (;;)
{
- bool sorts_ok;
+ bool sorts_ok;
/* Get a new OID (different from all existing pg_enum tuples) */
newOid = GetNewOid(pg_enum);
/*
* Detect whether it sorts correctly relative to existing
* even-numbered labels of the enum. We can ignore existing
- * labels with odd Oids, since a comparison involving one of
- * those will not take the fast path anyway.
+ * labels with odd Oids, since a comparison involving one of those
+ * will not take the fast path anyway.
*/
sorts_ok = true;
for (i = 0; i < nelems; i++)
break;
/*
- * If it's odd, and sorts OK, loop back to get another OID
- * and try again. Probably, the next available even OID
- * will sort correctly too, so it's worth trying.
+ * If it's odd, and sorts OK, loop back to get another OID and
+ * try again. Probably, the next available even OID will sort
+ * correctly too, so it's worth trying.
*/
}
else
* We avoid doing this unless absolutely necessary; in most installations
* it will never happen. The reason is that updating existing pg_enum
* entries creates hazards for other backends that are concurrently reading
- * pg_enum with SnapshotNow semantics. A concurrent SnapshotNow scan could
+ * pg_enum with SnapshotNow semantics. A concurrent SnapshotNow scan could
* see both old and new versions of an updated row as valid, or neither of
* them, if the commit happens between scanning the two versions. It's
* also quite likely for a concurrent scan to see an inconsistent set of
static int
sort_order_cmp(const void *p1, const void *p2)
{
- HeapTuple v1 = *((const HeapTuple *) p1);
- HeapTuple v2 = *((const HeapTuple *) p2);
- Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1);
- Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2);
+ HeapTuple v1 = *((const HeapTuple *) p1);
+ HeapTuple v2 = *((const HeapTuple *) p2);
+ Form_pg_enum en1 = (Form_pg_enum) GETSTRUCT(v1);
+ Form_pg_enum en2 = (Form_pg_enum) GETSTRUCT(v2);
if (en1->enumsortorder < en2->enumsortorder)
return -1;
if (!haspolyarg)
{
/*
- * OK to do full precheck: analyze and rewrite the queries,
- * then verify the result type.
+ * OK to do full precheck: analyze and rewrite the queries, then
+ * verify the result type.
*/
SQLFunctionParseInfoPtr pinfo;
querytree_sublist = pg_analyze_and_rewrite_params(parsetree,
prosrc,
- (ParserSetupHook) sql_fn_parser_setup,
+ (ParserSetupHook) sql_fn_parser_setup,
pinfo);
querytree_list = list_concat(querytree_list,
querytree_sublist);
values[i++] = ObjectIdGetDatum(InvalidOid); /* typbasetype */
values[i++] = Int32GetDatum(-1); /* typtypmod */
values[i++] = Int32GetDatum(0); /* typndims */
- values[i++] = ObjectIdGetDatum(InvalidOid); /* typcollation */
+ values[i++] = ObjectIdGetDatum(InvalidOid); /* typcollation */
nulls[i++] = true; /* typdefaultbin */
nulls[i++] = true; /* typdefault */
values[i++] = ObjectIdGetDatum(baseType); /* typbasetype */
values[i++] = Int32GetDatum(typeMod); /* typtypmod */
values[i++] = Int32GetDatum(typNDims); /* typndims */
- values[i++] = ObjectIdGetDatum(typeCollation); /* typcollation */
+ values[i++] = ObjectIdGetDatum(typeCollation); /* typcollation */
/*
* initialize the default binary value for this type. Check for nulls of
break;
default:
elog(ERROR, "invalid relpersistence: %c", relpersistence);
- return; /* placate compiler */
+ return; /* placate compiler */
}
srel = smgropen(rnode, backend);
* *ptr is set to point to a freshly-palloc'd array of RelFileNodes.
* If there are no relations to be deleted, *ptr is set to NULL.
*
- * Only non-temporary relations are included in the returned list. This is OK
+ * Only non-temporary relations are included in the returned list. This is OK
* because the list is used only in contexts where temporary relations don't
* matter: we're either writing to the two-phase state file (and transactions
* that have touched temp tables can't be prepared) or we're writing to xlog
list_make2("chunk_id", "chunk_seq"),
BTREE_AM_OID,
rel->rd_rel->reltablespace,
- collationObjectId, classObjectId, coloptions, (Datum) 0,
+ collationObjectId, classObjectId, coloptions, (Datum) 0,
true, false, false, false,
true, false, false);
switch (getObjectClass(&dep))
{
case OCLASS_CLASS:
- {
- Relation rel;
- Relation classRel;
+ {
+ Relation rel;
+ Relation classRel;
- rel = relation_open(objid, AccessExclusiveLock);
- oldNspOid = RelationGetNamespace(rel);
+ rel = relation_open(objid, AccessExclusiveLock);
+ oldNspOid = RelationGetNamespace(rel);
- classRel = heap_open(RelationRelationId, RowExclusiveLock);
+ classRel = heap_open(RelationRelationId, RowExclusiveLock);
- AlterRelationNamespaceInternal(classRel,
- objid,
- oldNspOid,
- nspOid,
- true);
+ AlterRelationNamespaceInternal(classRel,
+ objid,
+ oldNspOid,
+ nspOid,
+ true);
- heap_close(classRel, RowExclusiveLock);
+ heap_close(classRel, RowExclusiveLock);
- relation_close(rel, NoLock);
- break;
- }
+ relation_close(rel, NoLock);
+ break;
+ }
case OCLASS_PROC:
oldNspOid = AlterFunctionNamespace_oid(objid, nspOid);
{
Oid classId = RelationGetRelid(rel);
Oid oldNspOid;
- Datum name, namespace;
- bool isnull;
- HeapTuple tup, newtup;
+ Datum name,
+ namespace;
+ bool isnull;
+ HeapTuple tup,
+ newtup;
Datum *values;
bool *nulls;
bool *replaces;
/* Permission checks ... superusers can always do it */
if (!superuser())
{
- Datum owner;
+ Datum owner;
Oid ownerId;
AclResult aclresult;
HeapTuple *rows, int numrows,
MemoryContext col_context);
static VacAttrStats *examine_attribute(Relation onerel, int attnum,
- Node *index_expr);
+ Node *index_expr);
static int acquire_sample_rows(Relation onerel, HeapTuple *rows,
int targrows, double *totalrows, double *totaldeadrows);
static double random_fract(void);
if (IsAutoVacuumWorkerProcess() && Log_autovacuum_min_duration >= 0)
ereport(LOG,
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
- errmsg("skipping analyze of \"%s\" --- lock not available",
- vacstmt->relation->relname)));
+ errmsg("skipping analyze of \"%s\" --- lock not available",
+ vacstmt->relation->relname)));
}
if (!onerel)
return;
/*
* When analyzing an expression index, believe the expression tree's type
* not the column datatype --- the latter might be the opckeytype storage
- * type of the opclass, which is not interesting for our purposes. (Note:
+ * type of the opclass, which is not interesting for our purposes. (Note:
* if we did anything with non-expression index columns, we'd need to
* figure out where to get the correct type info from, but for now that's
- * not a problem.) It's not clear whether anyone will care about the
+ * not a problem.) It's not clear whether anyone will care about the
* typmod, but we store that too just in case.
*/
if (index_expr)
TransactionId OldestXmin;
TransactionId FreezeXid;
RewriteState rwstate;
- bool use_sort;
+ bool use_sort;
Tuplesortstate *tuplesort;
double num_tuples = 0,
tups_vacuumed = 0,
rwstate = begin_heap_rewrite(NewHeap, OldestXmin, FreezeXid, use_wal);
/*
- * Decide whether to use an indexscan or seqscan-and-optional-sort to
- * scan the OldHeap. We know how to use a sort to duplicate the ordering
- * of a btree index, and will use seqscan-and-sort for that case if the
- * planner tells us it's cheaper. Otherwise, always indexscan if an
- * index is provided, else plain seqscan.
+ * Decide whether to use an indexscan or seqscan-and-optional-sort to scan
+ * the OldHeap. We know how to use a sort to duplicate the ordering of a
+ * btree index, and will use seqscan-and-sort for that case if the planner
+ * tells us it's cheaper. Otherwise, always indexscan if an index is
+ * provided, else plain seqscan.
*/
if (OldIndex != NULL && OldIndex->rd_rel->relam == BTREE_AM_OID)
use_sort = plan_cluster_use_sort(OIDOldHeap, OIDOldIndex);
/*
* Scan through the OldHeap, either in OldIndex order or sequentially;
* copy each tuple into the NewHeap, or transiently to the tuplesort
- * module. Note that we don't bother sorting dead tuples (they won't
- * get to the new table anyway).
+ * module. Note that we don't bother sorting dead tuples (they won't get
+ * to the new table anyway).
*/
for (;;)
{
heap_endscan(heapScan);
/*
- * In scan-and-sort mode, complete the sort, then read out all live
- * tuples from the tuplestore and write them to the new relation.
+ * In scan-and-sort mode, complete the sort, then read out all live tuples
+ * from the tuplestore and write them to the new relation.
*/
if (tuplesort != NULL)
{
bool newRelHasOids, RewriteState rwstate)
{
HeapTuple copiedTuple;
- int i;
+ int i;
heap_deform_tuple(tuple, oldTupDesc, values, isnull);
#include "utils/syscache.h"
static void AlterCollationOwner_internal(Relation rel, Oid collationOid,
- Oid newOwnerId);
+ Oid newOwnerId);
/*
* CREATE COLLATION
Oid collNamespace;
AclResult aclresult;
ListCell *pl;
- DefElem *fromEl = NULL;
- DefElem *localeEl = NULL;
- DefElem *lccollateEl = NULL;
- DefElem *lcctypeEl = NULL;
+ DefElem *fromEl = NULL;
+ DefElem *localeEl = NULL;
+ DefElem *lccollateEl = NULL;
+ DefElem *lcctypeEl = NULL;
char *collcollate = NULL;
char *collctype = NULL;
Oid newoid;
foreach(pl, parameters)
{
- DefElem *defel = (DefElem *) lfirst(pl);
+ DefElem *defel = (DefElem *) lfirst(pl);
DefElem **defelp;
if (pg_strcasecmp(defel->defname, "from") == 0)
Oid collid;
HeapTuple tp;
- collid = get_collation_oid(defGetQualifiedName(fromEl), false);
+ collid = get_collation_oid(defGetQualifiedName(fromEl), false);
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for collation %u", collid);
if (!collcollate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("parameter \"lc_collate\" parameter must be specified")));
+ errmsg("parameter \"lc_collate\" parameter must be specified")));
if (!collctype)
ereport(ERROR,
Oid
AlterCollationNamespace_oid(Oid collOid, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
char *collation_name;
void
CommentObject(CommentStmt *stmt)
{
- ObjectAddress address;
- Relation relation;
+ ObjectAddress address;
+ Relation relation;
/*
* When loading a dump, we may see a COMMENT ON DATABASE for the old name
* (which is really pg_restore's fault, but for now we will work around
* the problem here). Consensus is that the best fix is to treat wrong
* database name as a WARNING not an ERROR; hence, the following special
- * case. (If the length of stmt->objname is not 1, get_object_address will
- * throw an error below; that's OK.)
+ * case. (If the length of stmt->objname is not 1, get_object_address
+ * will throw an error below; that's OK.)
*/
if (stmt->objtype == OBJECT_DATABASE && list_length(stmt->objname) == 1)
{
- char *database = strVal(linitial(stmt->objname));
+ char *database = strVal(linitial(stmt->objname));
+
if (!OidIsValid(get_database_oid(database, true)))
{
ereport(WARNING,
}
/*
- * Translate the parser representation that identifies this object into
- * an ObjectAddress. get_object_address() will throw an error if the
- * object does not exist, and will also acquire a lock on the target
- * to guard against concurrent DROP operations.
+ * Translate the parser representation that identifies this object into an
+ * ObjectAddress. get_object_address() will throw an error if the object
+ * does not exist, and will also acquire a lock on the target to guard
+ * against concurrent DROP operations.
*/
address = get_object_address(stmt->objtype, stmt->objname, stmt->objargs,
&relation, ShareUpdateExclusiveLock);
switch (stmt->objtype)
{
case OBJECT_COLUMN:
+
/*
* Allow comments only on columns of tables, views, composite
* types, and foreign tables (which are the only relkinds for
void
AlterConversionNamespace(List *name, const char *newschema)
{
- Oid convOid, nspOid;
+ Oid convOid,
+ nspOid;
Relation rel;
rel = heap_open(ConversionRelationId, RowExclusiveLock);
Oid
AlterConversionNamespace_oid(Oid convOid, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(ConversionRelationId, RowExclusiveLock);
char *quote; /* CSV quote char (must be 1 byte) */
char *escape; /* CSV escape char (must be 1 byte) */
List *force_quote; /* list of column names */
- bool force_quote_all; /* FORCE QUOTE *? */
+ bool force_quote_all; /* FORCE QUOTE *? */
bool *force_quote_flags; /* per-column CSV FQ flags */
List *force_notnull; /* list of column names */
bool *force_notnull_flags; /* per-column CSV FNN flags */
/* field raw data pointers found by COPY FROM */
- int max_fields;
- char ** raw_fields;
+ int max_fields;
+ char **raw_fields;
/*
* Similarly, line_buf holds the whole input line being processed. The
/* non-export function prototypes */
static CopyState BeginCopy(bool is_from, Relation rel, Node *raw_query,
- const char *queryString, List *attnamelist, List *options);
+ const char *queryString, List *attnamelist, List *options);
static void EndCopy(CopyState cstate);
static CopyState BeginCopyTo(Relation rel, Node *query, const char *queryString,
- const char *filename, List *attnamelist, List *options);
+ const char *filename, List *attnamelist, List *options);
static void EndCopyTo(CopyState cstate);
static uint64 DoCopyTo(CopyState cstate);
static uint64 CopyTo(CopyState cstate);
static uint64 CopyFrom(CopyState cstate);
static bool CopyReadLine(CopyState cstate);
static bool CopyReadLineText(CopyState cstate);
-static int CopyReadAttributesText(CopyState cstate);
-static int CopyReadAttributesCSV(CopyState cstate);
+static int CopyReadAttributesText(CopyState cstate);
+static int CopyReadAttributesCSV(CopyState cstate);
static Datum CopyReadBinaryAttribute(CopyState cstate,
int column_no, FmgrInfo *flinfo,
Oid typioparam, int32 typmod,
if (stmt->relation)
{
- TupleDesc tupDesc;
- AclMode required_access = (is_from ? ACL_INSERT : ACL_SELECT);
- RangeTblEntry *rte;
- List *attnums;
- ListCell *cur;
+ TupleDesc tupDesc;
+ AclMode required_access = (is_from ? ACL_INSERT : ACL_SELECT);
+ RangeTblEntry *rte;
+ List *attnums;
+ ListCell *cur;
Assert(!stmt->query);
/* Open and lock the relation, using the appropriate lock type. */
rel = heap_openrv(stmt->relation,
- (is_from ? RowExclusiveLock : AccessShareLock));
+ (is_from ? RowExclusiveLock : AccessShareLock));
rte = makeNode(RangeTblEntry);
rte->rtekind = RTE_RELATION;
attnums = CopyGetAttnums(tupDesc, rel, stmt->attlist);
foreach(cur, attnums)
{
- int attno = lfirst_int(cur) -
- FirstLowInvalidHeapAttributeNumber;
+ int attno = lfirst_int(cur) -
+ FirstLowInvalidHeapAttributeNumber;
if (is_from)
rte->modifiedCols = bms_add_member(rte->modifiedCols, attno);
cstate = (CopyStateData *) palloc0(sizeof(CopyStateData));
/*
- * We allocate everything used by a cstate in a new memory context.
- * This avoids memory leaks during repeated use of COPY in a query.
+ * We allocate everything used by a cstate in a new memory context. This
+ * avoids memory leaks during repeated use of COPY in a query.
*/
cstate->copycontext = AllocSetContextCreate(CurrentMemoryContext,
"COPY",
cstate->file_encoding = pg_get_client_encoding();
/*
- * Set up encoding conversion info. Even if the file and server
- * encodings are the same, we must apply pg_any_to_server() to validate
- * data in multibyte encodings.
+ * Set up encoding conversion info. Even if the file and server encodings
+ * are the same, we must apply pg_any_to_server() to validate data in
+ * multibyte encodings.
*/
cstate->need_transcoding =
(cstate->file_encoding != GetDatabaseEncoding() ||
*/
if (cstate->need_transcoding)
cstate->null_print_client = pg_server_to_any(cstate->null_print,
- cstate->null_print_len,
- cstate->file_encoding);
+ cstate->null_print_len,
+ cstate->file_encoding);
/* if a header has been requested send the line */
if (cstate->header_line)
{
slot = ExecBRInsertTriggers(estate, resultRelInfo, slot);
- if (slot == NULL) /* "do nothing" */
+ if (slot == NULL) /* "do nothing" */
skip_tuple = true;
- else /* trigger might have changed tuple */
+ else /* trigger might have changed tuple */
tuple = ExecMaterializeSlot(slot);
}
{
/* Initialize expressions in copycontext. */
defexprs[num_defaults] = ExecInitExpr(
- expression_planner((Expr *) defexpr), NULL);
+ expression_planner((Expr *) defexpr), NULL);
defmap[num_defaults] = attnum - 1;
num_defaults++;
}
if (!cstate->binary)
{
AttrNumber attr_count = list_length(cstate->attnumlist);
- int nfields = cstate->file_has_oids ? (attr_count + 1) : attr_count;
+ int nfields = cstate->file_has_oids ? (attr_count + 1) : attr_count;
cstate->max_fields = nfields;
cstate->raw_fields = (char **) palloc(nfields * sizeof(char *));
{
cstate->cur_lineno++;
if (CopyReadLine(cstate))
- return false; /* done */
+ return false; /* done */
}
cstate->cur_lineno++;
done = CopyReadLine(cstate);
/*
- * EOF at start of line means we're done. If we see EOF after
- * some characters, we act as though it was newline followed by
- * EOF, ie, process the line and then exit loop on next iteration.
+ * EOF at start of line means we're done. If we see EOF after some
+ * characters, we act as though it was newline followed by EOF, ie,
+ * process the line and then exit loop on next iteration.
*/
if (done && cstate->line_buf.len == 0)
return false;
FmgrInfo *in_functions = cstate->in_functions;
Oid *typioparams = cstate->typioparams;
int i;
- int nfields;
+ int nfields;
bool isnull;
bool file_has_oids = cstate->file_has_oids;
int *defmap = cstate->defmap;
if (fld_count == -1)
{
/*
- * Received EOF marker. In a V3-protocol copy, wait for
- * the protocol-level EOF, and complain if it doesn't come
- * immediately. This ensures that we correctly handle
- * CopyFail, if client chooses to send that now.
+ * Received EOF marker. In a V3-protocol copy, wait for the
+ * protocol-level EOF, and complain if it doesn't come
+ * immediately. This ensures that we correctly handle CopyFail,
+ * if client chooses to send that now.
*
- * Note that we MUST NOT try to read more data in an
- * old-protocol copy, since there is no protocol-level EOF
- * marker then. We could go either way for copy from file,
- * but choose to throw error if there's data after the EOF
- * marker, for consistency with the new-protocol case.
+ * Note that we MUST NOT try to read more data in an old-protocol
+ * copy, since there is no protocol-level EOF marker then. We
+ * could go either way for copy from file, but choose to throw
+ * error if there's data after the EOF marker, for consistency
+ * with the new-protocol case.
*/
- char dummy;
+ char dummy;
if (cstate->copy_dest != COPY_OLD_FE &&
CopyGetData(cstate, &dummy, 1, 1) > 0)
if (file_has_oids)
{
- Oid loaded_oid;
+ Oid loaded_oid;
cstate->cur_attname = "oid";
loaded_oid =
DatumGetObjectId(CopyReadBinaryAttribute(cstate,
0,
- &cstate->oid_in_function,
- cstate->oid_typioparam,
+ &cstate->oid_in_function,
+ cstate->oid_typioparam,
-1,
&isnull));
if (isnull || loaded_oid == InvalidOid)
/*
* Now compute and insert any defaults available for the columns not
- * provided by the input data. Anything not processed here or above
- * will remain NULL.
+ * provided by the input data. Anything not processed here or above will
+ * remain NULL.
*/
for (i = 0; i < num_defaults; i++)
{
* performing de-escaping as needed.
*
* The input is in line_buf. We use attribute_buf to hold the result
- * strings. cstate->raw_fields[k] is set to point to the k'th attribute
- * string, or NULL when the input matches the null marker string.
+ * strings. cstate->raw_fields[k] is set to point to the k'th attribute
+ * string, or NULL when the input matches the null marker string.
* This array is expanded as necessary.
*
- * (Note that the caller cannot check for nulls since the returned
- * string would be the post-de-escaping equivalent, which may look
+ * (Note that the caller cannot check for nulls since the returned
+ * string would be the post-de-escaping equivalent, which may look
* the same as some valid data string.)
*
* delim is the column delimiter string (must be just one byte for now).
if (fieldno >= cstate->max_fields)
{
cstate->max_fields *= 2;
- cstate->raw_fields =
- repalloc(cstate->raw_fields, cstate->max_fields*sizeof(char *));
+ cstate->raw_fields =
+ repalloc(cstate->raw_fields, cstate->max_fields * sizeof(char *));
}
/* Remember start of field on both input and output sides */
if (fieldno >= cstate->max_fields)
{
cstate->max_fields *= 2;
- cstate->raw_fields =
- repalloc(cstate->raw_fields, cstate->max_fields*sizeof(char *));
+ cstate->raw_fields =
+ repalloc(cstate->raw_fields, cstate->max_fields * sizeof(char *));
}
/* Remember start of field on both input and output sides */
void
check_encoding_locale_matches(int encoding, const char *collate, const char *ctype)
{
- int ctype_encoding = pg_get_encoding_from_locale(ctype, true);
- int collate_encoding = pg_get_encoding_from_locale(collate, true);
+ int ctype_encoding = pg_get_encoding_from_locale(ctype, true);
+ int collate_encoding = pg_get_encoding_from_locale(collate, true);
if (!(ctype_encoding == encoding ||
ctype_encoding == PG_SQL_ASCII ||
heap_close(pg_database, AccessShareLock);
if (!OidIsValid(oid) && !missing_ok)
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_DATABASE),
- errmsg("database \"%s\" does not exist",
- dbname)));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_DATABASE),
+ errmsg("database \"%s\" does not exist",
+ dbname)));
return oid;
}
const char *relationship, const char *plan_name,
ExplainState *es);
static void show_plan_tlist(PlanState *planstate, List *ancestors,
- ExplainState *es);
+ ExplainState *es);
static void show_expression(Node *node, const char *qlabel,
PlanState *planstate, List *ancestors,
bool useprefix, ExplainState *es);
static void show_qual(List *qual, const char *qlabel,
- PlanState *planstate, List *ancestors,
- bool useprefix, ExplainState *es);
+ PlanState *planstate, List *ancestors,
+ bool useprefix, ExplainState *es);
static void show_scan_qual(List *qual, const char *qlabel,
- PlanState *planstate, List *ancestors,
- ExplainState *es);
+ PlanState *planstate, List *ancestors,
+ ExplainState *es);
static void show_upper_qual(List *qual, const char *qlabel,
- PlanState *planstate, List *ancestors,
- ExplainState *es);
+ PlanState *planstate, List *ancestors,
+ ExplainState *es);
static void show_sort_keys(SortState *sortstate, List *ancestors,
- ExplainState *es);
+ ExplainState *es);
static void show_merge_append_keys(MergeAppendState *mstate, List *ancestors,
- ExplainState *es);
+ ExplainState *es);
static void show_sort_keys_common(PlanState *planstate,
- int nkeys, AttrNumber *keycols,
- List *ancestors, ExplainState *es);
+ int nkeys, AttrNumber *keycols,
+ List *ancestors, ExplainState *es);
static void show_sort_info(SortState *sortstate, ExplainState *es);
static void show_hash_info(HashState *hashstate, ExplainState *es);
static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es);
static void ExplainMemberNodes(List *plans, PlanState **planstates,
List *ancestors, ExplainState *es);
static void ExplainSubPlans(List *plans, List *ancestors,
- const char *relationship, ExplainState *es);
+ const char *relationship, ExplainState *es);
static void ExplainProperty(const char *qlabel, const char *value,
bool numeric, ExplainState *es);
static void ExplainOpenGroup(const char *objtype, const char *labelname,
{
bool useprefix;
- useprefix = (IsA(planstate->plan, SubqueryScan) || es->verbose);
+ useprefix = (IsA(planstate->plan, SubqueryScan) ||es->verbose);
show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
}
/* Globally visible state variables */
-bool creating_extension = false;
-Oid CurrentExtensionObject = InvalidOid;
+bool creating_extension = false;
+Oid CurrentExtensionObject = InvalidOid;
/*
* Internal data structure to hold the results of parsing a control file
{
char *name; /* name of the extension */
char *directory; /* directory for script files */
- char *default_version; /* default install target version, if any */
- char *module_pathname; /* string to substitute for MODULE_PATHNAME */
+ char *default_version; /* default install target version, if any */
+ char *module_pathname; /* string to substitute for MODULE_PATHNAME */
char *comment; /* comment, if any */
char *schema; /* target schema (allowed if !relocatable) */
bool relocatable; /* is ALTER EXTENSION SET SCHEMA supported? */
List *reachable; /* List of ExtensionVersionInfo's */
bool installable; /* does this version have an install script? */
/* working state for Dijkstra's algorithm: */
- bool distance_known; /* is distance from start known yet? */
+ bool distance_known; /* is distance from start known yet? */
int distance; /* current worst-case distance estimate */
- struct ExtensionVersionInfo *previous; /* current best predecessor */
+ struct ExtensionVersionInfo *previous; /* current best predecessor */
} ExtensionVersionInfo;
/* Local functions */
/*
* get_extension_oid - given an extension name, look up the OID
*
- * If missing_ok is false, throw an error if extension name not found. If
+ * If missing_ok is false, throw an error if extension name not found. If
* true, just return InvalidOid.
*/
Oid
heap_close(rel, AccessShareLock);
if (!OidIsValid(result) && !missing_ok)
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("extension \"%s\" does not exist",
- extname)));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("extension \"%s\" does not exist",
+ extname)));
return result;
}
int namelen = strlen(extensionname);
/*
- * Disallow empty names (the parser rejects empty identifiers anyway,
- * but let's check).
+ * Disallow empty names (the parser rejects empty identifiers anyway, but
+ * let's check).
*/
if (namelen == 0)
ereport(ERROR,
errdetail("Extension names must not contain \"--\".")));
/*
- * No leading or trailing dash either. (We could probably allow this,
- * but it would require much care in filename parsing and would make
- * filenames visually if not formally ambiguous. Since there's no
- * real-world use case, let's just forbid it.)
+ * No leading or trailing dash either. (We could probably allow this, but
+ * it would require much care in filename parsing and would make filenames
+ * visually if not formally ambiguous. Since there's no real-world use
+ * case, let's just forbid it.)
*/
if (extensionname[0] == '-' || extensionname[namelen - 1] == '-')
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid extension name: \"%s\"", extensionname),
- errdetail("Extension names must not begin or end with \"-\".")));
+ errdetail("Extension names must not begin or end with \"-\".")));
/*
* No directory separators either (this is sufficient to prevent ".."
if (namelen == 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid extension version name: \"%s\"", versionname),
+ errmsg("invalid extension version name: \"%s\"", versionname),
errdetail("Version names must not be empty.")));
/*
if (strstr(versionname, "--"))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid extension version name: \"%s\"", versionname),
+ errmsg("invalid extension version name: \"%s\"", versionname),
errdetail("Version names must not contain \"--\".")));
/*
if (versionname[0] == '-' || versionname[namelen - 1] == '-')
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid extension version name: \"%s\"", versionname),
- errdetail("Version names must not begin or end with \"-\".")));
+ errmsg("invalid extension version name: \"%s\"", versionname),
+ errdetail("Version names must not begin or end with \"-\".")));
/*
* No directory separators either (this is sufficient to prevent ".."
if (first_dir_separator(versionname) != NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("invalid extension version name: \"%s\"", versionname),
+ errmsg("invalid extension version name: \"%s\"", versionname),
errdetail("Version names must not contain directory separator characters.")));
}
get_share_path(my_exec_path, sharepath);
result = (char *) palloc(MAXPGPATH);
- snprintf(result, MAXPGPATH, "%s/%s", sharepath, control->directory);
+ snprintf(result, MAXPGPATH, "%s/%s", sharepath, control->directory);
return result;
}
/*
* Parse contents of primary or auxiliary control file, and fill in
- * fields of *control. We parse primary file if version == NULL,
+ * fields of *control. We parse primary file if version == NULL,
* else the optional auxiliary file for that version.
*
* Control files are supposed to be very short, half a dozen lines,
char *filename;
FILE *file;
ConfigVariable *item,
- *head = NULL,
- *tail = NULL;
+ *head = NULL,
+ *tail = NULL;
/*
* Locate the file to read. Auxiliary files are optional.
/* syntax error in name list */
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("parameter \"%s\" must be a list of extension names",
- item->name)));
+ errmsg("parameter \"%s\" must be a list of extension names",
+ item->name)));
}
}
else
read_extension_script_file(const ExtensionControlFile *control,
const char *filename)
{
- int src_encoding;
- int dest_encoding = GetDatabaseEncoding();
- bytea *content;
+ int src_encoding;
+ int dest_encoding = GetDatabaseEncoding();
+ bytea *content;
char *src_str;
- char *dest_str;
- int len;
+ char *dest_str;
+ int len;
content = read_binary_file(filename, 0, -1);
* filename is used only to report errors.
*
* Note: it's tempting to just use SPI to execute the string, but that does
- * not work very well. The really serious problem is that SPI will parse,
+ * not work very well. The really serious problem is that SPI will parse,
* analyze, and plan the whole string before executing any of it; of course
* this fails if there are any plannable statements referring to objects
* created earlier in the script. A lesser annoyance is that SPI insists
List *requiredSchemas,
const char *schemaName, Oid schemaOid)
{
- char *filename;
+ char *filename;
char *save_client_min_messages,
*save_log_min_messages,
*save_search_path;
* so that we won't spam the user with useless NOTICE messages from common
* script actions like creating shell types.
*
- * We use the equivalent of SET LOCAL to ensure the setting is undone
- * upon error.
+ * We use the equivalent of SET LOCAL to ensure the setting is undone upon
+ * error.
*/
save_client_min_messages =
pstrdup(GetConfigOption("client_min_messages", false));
* makes the target schema be the default creation target namespace.
*
* Note: it might look tempting to use PushOverrideSearchPath for this,
- * but we cannot do that. We have to actually set the search_path GUC
- * in case the extension script examines or changes it.
+ * but we cannot do that. We have to actually set the search_path GUC in
+ * case the extension script examines or changes it.
*/
save_search_path = pstrdup(GetConfigOption("search_path", false));
/*
* Set creating_extension and related variables so that
* recordDependencyOnCurrentExtension and other functions do the right
- * things. On failure, ensure we reset these variables.
+ * things. On failure, ensure we reset these variables.
*/
creating_extension = true;
CurrentExtensionObject = extensionOid;
PG_TRY();
{
- char *sql = read_extension_script_file(control, filename);
+ char *sql = read_extension_script_file(control, filename);
/*
* If it's not relocatable, substitute the target schema name for
* occcurrences of @extschema@.
*
- * For a relocatable extension, we just run the script as-is.
- * There cannot be any need for @extschema@, else it wouldn't
- * be relocatable.
+ * For a relocatable extension, we just run the script as-is. There
+ * cannot be any need for @extschema@, else it wouldn't be
+ * relocatable.
*/
if (!control->relocatable)
{
- const char *qSchemaName = quote_identifier(schemaName);
+ const char *qSchemaName = quote_identifier(schemaName);
sql = text_to_cstring(
- DatumGetTextPP(
- DirectFunctionCall3(replace_text,
- CStringGetTextDatum(sql),
- CStringGetTextDatum("@extschema@"),
- CStringGetTextDatum(qSchemaName))));
+ DatumGetTextPP(
+ DirectFunctionCall3(replace_text,
+ CStringGetTextDatum(sql),
+ CStringGetTextDatum("@extschema@"),
+ CStringGetTextDatum(qSchemaName))));
}
/*
if (control->module_pathname)
{
sql = text_to_cstring(
- DatumGetTextPP(
- DirectFunctionCall3(replace_text,
- CStringGetTextDatum(sql),
- CStringGetTextDatum("MODULE_PATHNAME"),
- CStringGetTextDatum(control->module_pathname))));
+ DatumGetTextPP(
+ DirectFunctionCall3(replace_text,
+ CStringGetTextDatum(sql),
+ CStringGetTextDatum("MODULE_PATHNAME"),
+ CStringGetTextDatum(control->module_pathname))));
}
execute_sql_string(sql, filename);
struct dirent *de;
location = get_extension_script_directory(control);
- dir = AllocateDir(location);
+ dir = AllocateDir(location);
while ((de = ReadDir(dir, location)) != NULL)
{
char *vername;
* is still good.
*
* Result is a List of names of versions to transition through (the initial
- * version is *not* included). Returns NIL if no such path.
+ * version is *not* included). Returns NIL if no such path.
*/
static List *
find_update_path(List *evi_list,
foreach(lc, evi->reachable)
{
ExtensionVersionInfo *evi2 = (ExtensionVersionInfo *) lfirst(lc);
- int newdist;
+ int newdist;
newdist = evi->distance + 1;
if (newdist < evi2->distance)
DefElem *d_schema = NULL;
DefElem *d_new_version = NULL;
DefElem *d_old_version = NULL;
- char *schemaName;
+ char *schemaName;
Oid schemaOid;
- char *versionName;
- char *oldVersionName;
+ char *versionName;
+ char *oldVersionName;
Oid extowner = GetUserId();
ExtensionControlFile *pcontrol;
ExtensionControlFile *control;
check_valid_extension_name(stmt->extname);
/*
- * Check for duplicate extension name. The unique index on
+ * Check for duplicate extension name. The unique index on
* pg_extension.extname would catch this anyway, and serves as a backstop
- * in case of race conditions; but this is a friendlier error message,
- * and besides we need a check to support IF NOT EXISTS.
+ * in case of race conditions; but this is a friendlier error message, and
+ * besides we need a check to support IF NOT EXISTS.
*/
if (get_extension_oid(stmt->extname, true) != InvalidOid)
{
}
/*
- * We use global variables to track the extension being created, so we
- * can create only one extension at the same time.
+ * We use global variables to track the extension being created, so we can
+ * create only one extension at the same time.
*/
if (creating_extension)
ereport(ERROR,
if (list_length(updateVersions) == 1)
{
/*
- * Simple case where there's just one update script to run.
- * We will not need any follow-on update steps.
+ * Simple case where there's just one update script to run. We
+ * will not need any follow-on update steps.
*/
Assert(strcmp((char *) linitial(updateVersions), versionName) == 0);
updateVersions = NIL;
strcmp(control->schema, schemaName) != 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("extension \"%s\" must be installed in schema \"%s\"",
- control->name,
- control->schema)));
+ errmsg("extension \"%s\" must be installed in schema \"%s\"",
+ control->name,
+ control->schema)));
/* If the user is giving us the schema name, it must exist already */
schemaOid = get_namespace_oid(schemaName, false);
{
/*
* The extension is not relocatable and the author gave us a schema
- * for it. We create the schema here if it does not already exist.
+ * for it. We create the schema here if it does not already exist.
*/
schemaName = control->schema;
schemaOid = get_namespace_oid(schemaName, true);
* Else, use the current default creation namespace, which is the
* first explicit entry in the search_path.
*/
- List *search_path = fetch_search_path(false);
+ List *search_path = fetch_search_path(false);
- if (search_path == NIL) /* probably can't happen */
+ if (search_path == NIL) /* probably can't happen */
elog(ERROR, "there is no default creation target");
schemaOid = linitial_oid(search_path);
schemaName = get_namespace_name(schemaOid);
- if (schemaName == NULL) /* recently-deleted namespace? */
+ if (schemaName == NULL) /* recently-deleted namespace? */
elog(ERROR, "there is no default creation target");
list_free(search_path);
* extension script actually creates any objects there, it will fail if
* the user doesn't have such permissions. But there are cases such as
* procedural languages where it's convenient to set schema = pg_catalog
- * yet we don't want to restrict the command to users with ACL_CREATE
- * for pg_catalog.
+ * yet we don't want to restrict the command to users with ACL_CREATE for
+ * pg_catalog.
*/
/*
- * Look up the prerequisite extensions, and build lists of their OIDs
- * and the OIDs of their target schemas.
+ * Look up the prerequisite extensions, and build lists of their OIDs and
+ * the OIDs of their target schemas.
*/
requiredExtensions = NIL;
requiredSchemas = NIL;
schemaName, schemaOid);
/*
- * If additional update scripts have to be executed, apply the updates
- * as though a series of ALTER EXTENSION UPDATE commands were given
+ * If additional update scripts have to be executed, apply the updates as
+ * though a series of ALTER EXTENSION UPDATE commands were given
*/
ApplyExtensionUpdates(extensionOid, pcontrol,
versionName, updateVersions);
/*
* This function lists the available extensions (one row per primary control
- * file in the control directory). We parse each control file and report the
+ * file in the control directory). We parse each control file and report the
* interesting fields.
*
* The system view pg_available_extensions provides a user interface to this
Datum
pg_available_extensions(PG_FUNCTION_ARGS)
{
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
- char *location;
- DIR *dir;
- struct dirent *de;
+ ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
+ TupleDesc tupdesc;
+ Tuplestorestate *tupstore;
+ MemoryContext per_query_ctx;
+ MemoryContext oldcontext;
+ char *location;
+ DIR *dir;
+ struct dirent *de;
/* check to see if caller supports us returning a tuplestore */
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
MemoryContextSwitchTo(oldcontext);
location = get_extension_control_directory();
- dir = AllocateDir(location);
+ dir = AllocateDir(location);
/*
- * If the control directory doesn't exist, we want to silently return
- * an empty set. Any other error will be reported by ReadDir.
+ * If the control directory doesn't exist, we want to silently return an
+ * empty set. Any other error will be reported by ReadDir.
*/
if (dir == NULL && errno == ENOENT)
{
/*
* This function lists the available extension versions (one row per
- * extension installation script). For each version, we parse the related
+ * extension installation script). For each version, we parse the related
* control file(s) and report the interesting fields.
*
* The system view pg_available_extension_versions provides a user interface
Datum
pg_available_extension_versions(PG_FUNCTION_ARGS)
{
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
- char *location;
- DIR *dir;
- struct dirent *de;
+ ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
+ TupleDesc tupdesc;
+ Tuplestorestate *tupstore;
+ MemoryContext per_query_ctx;
+ MemoryContext oldcontext;
+ char *location;
+ DIR *dir;
+ struct dirent *de;
/* check to see if caller supports us returning a tuplestore */
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
MemoryContextSwitchTo(oldcontext);
location = get_extension_control_directory();
- dir = AllocateDir(location);
+ dir = AllocateDir(location);
/*
- * If the control directory doesn't exist, we want to silently return
- * an empty set. Any other error will be reported by ReadDir.
+ * If the control directory doesn't exist, we want to silently return an
+ * empty set. Any other error will be reported by ReadDir.
*/
if (dir == NULL && errno == ENOENT)
{
struct dirent *de;
location = get_extension_script_directory(pcontrol);
- dir = AllocateDir(location);
+ dir = AllocateDir(location);
/* Note this will fail if script directory doesn't exist */
while ((de = ReadDir(dir, location)) != NULL)
{
pg_extension_update_paths(PG_FUNCTION_ARGS)
{
Name extname = PG_GETARG_NAME(0);
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
+ ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
+ TupleDesc tupdesc;
+ Tuplestorestate *tupstore;
+ MemoryContext per_query_ctx;
+ MemoryContext oldcontext;
List *evi_list;
ExtensionControlFile *control;
ListCell *lc1;
text *wherecond = PG_GETARG_TEXT_P(1);
char *tablename;
Relation extRel;
- ScanKeyData key[1];
- SysScanDesc extScan;
+ ScanKeyData key[1];
+ SysScanDesc extScan;
HeapTuple extTup;
Datum arrayDatum;
Datum elementDatum;
ArrayType *a;
/*
- * We only allow this to be called from an extension's SQL script.
- * We shouldn't need any permissions check beyond that.
+ * We only allow this to be called from an extension's SQL script. We
+ * shouldn't need any permissions check beyond that.
*/
if (!creating_extension)
ereport(ERROR,
/*
* Check that the table exists and is a member of the extension being
- * created. This ensures that we don't need to register a dependency
- * to protect the extconfig entry.
+ * created. This ensures that we don't need to register a dependency to
+ * protect the extconfig entry.
*/
tablename = get_rel_name(tableoid);
if (tablename == NULL)
CurrentExtensionObject)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("table \"%s\" is not a member of the extension being created",
- tablename)));
+ errmsg("table \"%s\" is not a member of the extension being created",
+ tablename)));
/*
- * Add the table OID and WHERE condition to the extension's extconfig
- * and extcondition arrays.
+ * Add the table OID and WHERE condition to the extension's extconfig and
+ * extcondition arrays.
*/
/* Find the pg_extension tuple */
extTup = systable_getnext(extScan);
- if (!HeapTupleIsValid(extTup)) /* should not happen */
+ if (!HeapTupleIsValid(extTup)) /* should not happen */
elog(ERROR, "extension with oid %u does not exist",
CurrentExtensionObject);
Assert(ARR_NDIM(a) == 1);
Assert(ARR_LBOUND(a)[0] == 1);
- arrayIndex = ARR_DIMS(a)[0] + 1; /* add after end */
+ arrayIndex = ARR_DIMS(a)[0] + 1; /* add after end */
a = array_set(a, 1, &arrayIndex,
elementDatum,
Assert(ARR_NDIM(a) == 1);
Assert(ARR_LBOUND(a)[0] == 1);
- arrayIndex = ARR_DIMS(a)[0] + 1; /* add after end */
+ arrayIndex = ARR_DIMS(a)[0] + 1; /* add after end */
a = array_set(a, 1, &arrayIndex,
elementDatum,
Oid oldNspOid = InvalidOid;
AclResult aclresult;
Relation extRel;
- ScanKeyData key[2];
- SysScanDesc extScan;
+ ScanKeyData key[2];
+ SysScanDesc extScan;
HeapTuple extTup;
Form_pg_extension extForm;
Relation depRel;
- SysScanDesc depScan;
+ SysScanDesc depScan;
HeapTuple depTup;
if (list_length(names) != 1)
extTup = systable_getnext(extScan);
- if (!HeapTupleIsValid(extTup)) /* should not happen */
+ if (!HeapTupleIsValid(extTup)) /* should not happen */
elog(ERROR, "extension with oid %u does not exist", extensionOid);
/* Copy tuple so we can modify it below */
systable_endscan(extScan);
/*
- * If the extension is already in the target schema, just silently
- * do nothing.
+ * If the extension is already in the target schema, just silently do
+ * nothing.
*/
if (extForm->extnamespace == nspOid)
{
{
Form_pg_depend pg_depend = (Form_pg_depend) GETSTRUCT(depTup);
ObjectAddress dep;
- Oid dep_oldNspOid;
+ Oid dep_oldNspOid;
/*
- * Ignore non-membership dependencies. (Currently, the only other
+ * Ignore non-membership dependencies. (Currently, the only other
* case we could see here is a normal dependency from another
* extension.)
*/
ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
{
DefElem *d_new_version = NULL;
- char *versionName;
- char *oldVersionName;
+ char *versionName;
+ char *oldVersionName;
ExtensionControlFile *control;
Oid extensionOid;
Relation extRel;
- ScanKeyData key[1];
- SysScanDesc extScan;
+ ScanKeyData key[1];
+ SysScanDesc extScan;
HeapTuple extTup;
List *updateVersions;
Datum datum;
ListCell *lc;
/*
- * We use global variables to track the extension being created, so we
- * can create/update only one extension at the same time.
+ * We use global variables to track the extension being created, so we can
+ * create/update only one extension at the same time.
*/
if (creating_extension)
ereport(ERROR,
extTup = systable_getnext(extScan);
if (!HeapTupleIsValid(extTup))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("extension \"%s\" does not exist",
- stmt->extname)));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("extension \"%s\" does not exist",
+ stmt->extname)));
extensionOid = HeapTupleGetOid(extTup);
if (strcmp(oldVersionName, versionName) == 0)
{
ereport(NOTICE,
- (errmsg("version \"%s\" of extension \"%s\" is already installed",
- versionName, stmt->extname)));
+ (errmsg("version \"%s\" of extension \"%s\" is already installed",
+ versionName, stmt->extname)));
return;
}
List *requiredExtensions;
List *requiredSchemas;
Relation extRel;
- ScanKeyData key[1];
- SysScanDesc extScan;
+ ScanKeyData key[1];
+ SysScanDesc extScan;
HeapTuple extTup;
Form_pg_extension extForm;
Datum values[Natts_pg_extension];
extTup = systable_getnext(extScan);
- if (!HeapTupleIsValid(extTup)) /* should not happen */
+ if (!HeapTupleIsValid(extTup)) /* should not happen */
elog(ERROR, "extension with oid %u does not exist",
extensionOid);
schemaName, schemaOid);
/*
- * Update prior-version name and loop around. Since execute_sql_string
- * did a final CommandCounterIncrement, we can update the pg_extension
- * row again.
+ * Update prior-version name and loop around. Since
+ * execute_sql_string did a final CommandCounterIncrement, we can
+ * update the pg_extension row again.
*/
oldVersionName = versionName;
}
void
ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt)
{
- ObjectAddress extension;
- ObjectAddress object;
- Relation relation;
- Oid oldExtension;
+ ObjectAddress extension;
+ ObjectAddress object;
+ Relation relation;
+ Oid oldExtension;
extension.classId = ExtensionRelationId;
extension.objectId = get_extension_oid(stmt->extname, false);
stmt->extname);
/*
- * Translate the parser representation that identifies the object into
- * an ObjectAddress. get_object_address() will throw an error if the
- * object does not exist, and will also acquire a lock on the object to
- * guard against concurrent DROP and ALTER EXTENSION ADD/DROP operations.
+ * Translate the parser representation that identifies the object into an
+ * ObjectAddress. get_object_address() will throw an error if the object
+ * does not exist, and will also acquire a lock on the object to guard
+ * against concurrent DROP and ALTER EXTENSION ADD/DROP operations.
*/
object = get_object_address(stmt->objtype, stmt->objname, stmt->objargs,
&relation, ShareUpdateExclusiveLock);
*/
if (OidIsValid(fdwvalidator))
ereport(WARNING,
- (errmsg("changing the foreign-data wrapper validator can cause "
- "the options for dependent objects to become invalid")));
+ (errmsg("changing the foreign-data wrapper validator can cause "
+ "the options for dependent objects to become invalid")));
}
else
{
ObjectAddress referenced;
/*
- * Flush all existing dependency records of this FDW on functions;
- * we assume there can be none other than the ones we are fixing.
+ * Flush all existing dependency records of this FDW on functions; we
+ * assume there can be none other than the ones we are fixing.
*/
deleteDependencyRecordsForClass(ForeignDataWrapperRelationId,
fdwId,
* We also disallow creating binary-compatibility casts involving
* domains. Casting from a domain to its base type is already
* allowed, and casting the other way ought to go through domain
- * coercion to permit constraint checking. Again, if you're intent on
+ * coercion to permit constraint checking. Again, if you're intent on
* having your own semantics for that, create a no-op cast function.
*
* NOTE: if we were to relax this, the above checks for composites
Oid
get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
{
- Oid oid;
+ Oid oid;
oid = GetSysCacheOid2(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
indexRelationId =
index_create(rel, indexRelationName, indexRelationId,
indexInfo, indexColNames,
- accessMethodId, tablespaceId, collationObjectId, classObjectId,
+ accessMethodId, tablespaceId, collationObjectId, classObjectId,
coloptions, reloptions, primary,
isconstraint, deferrable, initdeferred,
allowSystemTableMods,
else
{
/* Index expression */
- Node *expr = attribute->expr;
+ Node *expr = attribute->expr;
Assert(expr != NULL);
atttype = exprType(expr);
attcollation = exprCollation(expr);
/*
- * Strip any top-level COLLATE clause. This ensures that we treat
+ * Strip any top-level COLLATE clause. This ensures that we treat
* "x COLLATE y" and "(x COLLATE y)" alike.
*/
while (IsA(expr, CollateExpr))
}
else
{
- indexInfo->ii_KeyAttrNumbers[attn] = 0; /* marks expression */
+ indexInfo->ii_KeyAttrNumbers[attn] = 0; /* marks expression */
indexInfo->ii_Expressions = lappend(indexInfo->ii_Expressions,
expr);
if (contain_subplans(expr))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot use subquery in index expression")));
+ errmsg("cannot use subquery in index expression")));
if (contain_agg_clause(expr))
ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
/*
* Check we have a collation iff it's a collatable type. The only
* expected failures here are (1) COLLATE applied to a noncollatable
- * type, or (2) index expression had an unresolved collation. But
- * we might as well code this to be a complete consistency check.
+ * type, or (2) index expression had an unresolved collation. But we
+ * might as well code this to be a complete consistency check.
*/
if (type_is_collatable(atttype))
{
if (!HeapTupleIsValid(htup) && !missing_ok)
{
- HeapTuple amtup;
+ HeapTuple amtup;
amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(amID));
if (!HeapTupleIsValid(amtup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
- NameListToString(opfamilyname),
- NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
+ NameListToString(opfamilyname),
+ NameStr(((Form_pg_am) GETSTRUCT(amtup))->amname))));
}
return htup;
/*
* get_opfamily_oid
- * find an opfamily OID by possibly qualified name
+ * find an opfamily OID by possibly qualified name
*
* If not found, returns InvalidOid if missing_ok, else throws error.
*/
if (!HeapTupleIsValid(htup) && !missing_ok)
{
- HeapTuple amtup;
+ HeapTuple amtup;
amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(amID));
if (!HeapTupleIsValid(amtup))
/*
* get_opclass_oid
- * find an opclass OID by possibly qualified name
+ * find an opclass OID by possibly qualified name
*
* If not found, returns InvalidOid if missing_ok, else throws error.
*/
if (OidIsValid(member->sortfamily))
{
/*
- * Ordering op, check index supports that. (We could perhaps also
+ * Ordering op, check index supports that. (We could perhaps also
* check that the operator returns a type supported by the sortfamily,
* but that seems more trouble than it's worth here. If it does not,
- * the operator will never be matchable to any ORDER BY clause, but
- * no worse consequences can ensue. Also, trying to check that would
+ * the operator will never be matchable to any ORDER BY clause, but no
+ * worse consequences can ensue. Also, trying to check that would
* create an ordering hazard during dump/reload: it's possible that
* the family has been created but not yet populated with the required
* operators.)
if (!pg_am->amcanorderbyop)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("access method \"%s\" does not support ordering operators",
- NameStr(pg_am->amname))));
+ errmsg("access method \"%s\" does not support ordering operators",
+ NameStr(pg_am->amname))));
ReleaseSysCache(amtup);
}
foreach(l, operators)
{
OpFamilyMember *op = (OpFamilyMember *) lfirst(l);
- char oppurpose;
+ char oppurpose;
/*
* If adding to an existing family, check for conflict with an
{
ereport(NOTICE,
(errmsg("operator class \"%s\" does not exist for access method \"%s\"",
- NameListToString(stmt->opclassname), stmt->amname)));
+ NameListToString(stmt->opclassname), stmt->amname)));
return;
}
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
- NameListToString(stmt->opfamilyname), stmt->amname)));
+ NameListToString(stmt->opfamilyname), stmt->amname)));
return;
}
Oid
AlterOpClassNamespace_oid(Oid opclassOid, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
Oid
AlterOpFamilyNamespace_oid(Oid opfamilyOid, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
List *operatorName = names;
TypeName *typeName1 = (TypeName *) linitial(argtypes);
TypeName *typeName2 = (TypeName *) lsecond(argtypes);
- Oid operOid, nspOid;
+ Oid operOid,
+ nspOid;
Relation rel;
rel = heap_open(OperatorRelationId, RowExclusiveLock);
Oid
AlterOperatorNamespace_oid(Oid operOid, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorRelationId, RowExclusiveLock);
if (queryDesc)
{
/*
- * Reset the queryDesc before anything else. This prevents us
- * from trying to shut down the executor twice, in case of an
- * error below. The transaction abort mechanisms will take care
- * of resource cleanup in such a case.
+ * Reset the queryDesc before anything else. This prevents us from
+ * trying to shut down the executor twice, in case of an error below.
+ * The transaction abort mechanisms will take care of resource cleanup
+ * in such a case.
*/
portal->queryDesc = NULL;
/* sizeof(ParamListInfoData) includes the first array element */
paramLI = (ParamListInfo)
palloc(sizeof(ParamListInfoData) +
- (num_params - 1) *sizeof(ParamExternData));
+ (num_params - 1) * sizeof(ParamExternData));
/* we have static list of params, so no hooks needed */
paramLI->paramFetch = NULL;
paramLI->paramFetchArg = NULL;
/* -------------------------------------------------------------------------
*
* seclabel.c
- * routines to support security label feature.
+ * routines to support security label feature.
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
typedef struct
{
const char *provider_name;
- check_object_relabel_type hook;
+ check_object_relabel_type hook;
} LabelProvider;
static List *label_provider_list = NIL;
ExecSecLabelStmt(SecLabelStmt *stmt)
{
LabelProvider *provider = NULL;
- ObjectAddress address;
- Relation relation;
- ListCell *lc;
+ ObjectAddress address;
+ Relation relation;
+ ListCell *lc;
/*
* Find the named label provider, or if none specified, check whether
if (label_provider_list == NIL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("no security label providers have been loaded")));
+ errmsg("no security label providers have been loaded")));
if (lnext(list_head(label_provider_list)) != NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("must specify provider when multiple security label providers have been loaded")));
+ errmsg("must specify provider when multiple security label providers have been loaded")));
provider = (LabelProvider *) linitial(label_provider_list);
}
else
{
- foreach (lc, label_provider_list)
+ foreach(lc, label_provider_list)
{
LabelProvider *lp = lfirst(lc);
}
/*
- * Translate the parser representation which identifies this object
- * into an ObjectAddress. get_object_address() will throw an error if
- * the object does not exist, and will also acquire a lock on the
- * target to guard against concurrent modifications.
+ * Translate the parser representation which identifies this object into
+ * an ObjectAddress. get_object_address() will throw an error if the
+ * object does not exist, and will also acquire a lock on the target to
+ * guard against concurrent modifications.
*/
address = get_object_address(stmt->objtype, stmt->objname, stmt->objargs,
&relation, ShareUpdateExclusiveLock);
switch (stmt->objtype)
{
case OBJECT_COLUMN:
+
/*
* Allow security labels only on columns of tables, views,
* composite types, and foreign tables (which are the only
}
/* Provider gets control here, may throw ERROR to veto new label. */
- (*provider->hook)(&address, stmt->label);
+ (*provider->hook) (&address, stmt->label);
/* Apply new label. */
SetSecurityLabel(&address, provider->provider_name, stmt->label);
GetSecurityLabel(const ObjectAddress *object, const char *provider)
{
Relation pg_seclabel;
- ScanKeyData keys[4];
- SysScanDesc scan;
+ ScanKeyData keys[4];
+ SysScanDesc scan;
HeapTuple tuple;
Datum datum;
bool isnull;
const char *provider, const char *label)
{
Relation pg_seclabel;
- ScanKeyData keys[4];
- SysScanDesc scan;
+ ScanKeyData keys[4];
+ SysScanDesc scan;
HeapTuple oldtup;
HeapTuple newtup = NULL;
Datum values[Natts_pg_seclabel];
DeleteSecurityLabel(const ObjectAddress *object)
{
Relation pg_seclabel;
- ScanKeyData skey[3];
- SysScanDesc scan;
+ ScanKeyData skey[3];
+ SysScanDesc scan;
HeapTuple oldtup;
int nkeys;
void
register_label_provider(const char *provider_name, check_object_relabel_type hook)
{
- LabelProvider *provider;
- MemoryContext oldcxt;
+ LabelProvider *provider;
+ MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
provider = palloc(sizeof(LabelProvider));
seq->log_cnt = 1;
/*
- * Create a new storage file for the sequence. We want to keep the
+ * Create a new storage file for the sequence. We want to keep the
* sequence's relfrozenxid at 0, since it won't contain any unfrozen XIDs.
*/
RelationSetNewRelfilenode(seq_rel, InvalidTransactionId);
/*
* If the sequence has been transactionally replaced since we last saw it,
- * discard any cached-but-unissued values. We do not touch the currval()
+ * discard any cached-but-unissued values. We do not touch the currval()
* state, however.
*/
if (seqrel->rd_rel->relfilenode != elm->filenode)
static void ATSimpleRecursion(List **wqueue, Relation rel,
AlterTableCmd *cmd, bool recurse, LOCKMODE lockmode);
static void ATTypedTableRecursion(List **wqueue, Relation rel, AlterTableCmd *cmd,
- LOCKMODE lockmode);
+ LOCKMODE lockmode);
static List *find_typed_table_dependencies(Oid typeOid, const char *typeName,
- DropBehavior behavior);
+ DropBehavior behavior);
static void ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
AlterTableCmd *cmd, LOCKMODE lockmode);
static void ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
static void ATExecSetStorage(Relation rel, const char *colName,
Node *newValue, LOCKMODE lockmode);
static void ATPrepDropColumn(List **wqueue, Relation rel, bool recurse, bool recursing,
- AlterTableCmd *cmd, LOCKMODE lockmode);
+ AlterTableCmd *cmd, LOCKMODE lockmode);
static void ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
DropBehavior behavior,
bool recurse, bool recursing,
IndexStmt *stmt, bool is_rebuild, LOCKMODE lockmode);
static void ATExecAddConstraint(List **wqueue,
AlteredTableInfo *tab, Relation rel,
- Constraint *newConstraint, bool recurse, LOCKMODE lockmode);
+ Constraint *newConstraint, bool recurse, LOCKMODE lockmode);
static void ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
- IndexStmt *stmt, LOCKMODE lockmode);
+ IndexStmt *stmt, LOCKMODE lockmode);
static void ATAddCheckConstraint(List **wqueue,
AlteredTableInfo *tab, Relation rel,
Constraint *constr,
AlterTableCmd *cmd, LOCKMODE lockmode);
static bool ATColumnChangeRequiresRewrite(Node *expr, AttrNumber varattno);
static void ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
- AlterTableCmd *cmd, LOCKMODE lockmode);
+ AlterTableCmd *cmd, LOCKMODE lockmode);
static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab, LOCKMODE lockmode);
static void ATPostAlterTypeParse(char *cmd, List **wqueue, LOCKMODE lockmode);
static void change_owner_recurse_to_sequences(Oid relationOid,
static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode);
static void ATExecSetRelOptions(Relation rel, List *defList, bool isReset, LOCKMODE lockmode);
static void ATExecEnableDisableTrigger(Relation rel, char *trigname,
- char fires_when, bool skip_system, LOCKMODE lockmode);
+ char fires_when, bool skip_system, LOCKMODE lockmode);
static void ATExecEnableDisableRule(Relation rel, char *rulename,
char fires_when, LOCKMODE lockmode);
static void ATPrepAddInherit(Relation child_rel);
/*
* Check consistency of arguments
*/
- if (stmt->oncommit != ONCOMMIT_NOOP
+ if (stmt->oncommit != ONCOMMIT_NOOP
&& stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
if (relkind == RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("default values on foreign tables are not supported")));
+ errmsg("default values on foreign tables are not supported")));
Assert(colDef->cooked_default == NULL);
/*
* RemoveRelations
* Implements DROP TABLE, DROP INDEX, DROP SEQUENCE, DROP VIEW,
- * DROP FOREIGN TABLE
+ * DROP FOREIGN TABLE
*/
void
RemoveRelations(DropStmt *drop)
if (defCollId != attribute->attcollation)
ereport(ERROR,
(errcode(ERRCODE_COLLATION_MISMATCH),
- errmsg("inherited column \"%s\" has a collation conflict",
- attributeName),
+ errmsg("inherited column \"%s\" has a collation conflict",
+ attributeName),
errdetail("\"%s\" versus \"%s\"",
get_collation_name(defCollId),
- get_collation_name(attribute->attcollation))));
+ get_collation_name(attribute->attcollation))));
/* Copy storage parameter */
if (def->storage == 0)
relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, composite type, index or foreign table",
- RelationGetRelationName(targetrelation))));
+ errmsg("\"%s\" is not a table, view, composite type, index or foreign table",
+ RelationGetRelationName(targetrelation))));
/*
* permissions checking. only the owner of a class can change its schema.
ListCell *lo;
child_oids = find_typed_table_dependencies(targetrelation->rd_rel->reltype,
- RelationGetRelationName(targetrelation),
+ RelationGetRelationName(targetrelation),
behavior);
foreach(lo, child_oids)
renameatt(Oid myrelid, RenameStmt *stmt)
{
renameatt_internal(myrelid,
- stmt->subname, /* old att name */
- stmt->newname, /* new att name */
- interpretInhOption(stmt->relation->inhOpt), /* recursive? */
- false, /* recursing? */
- 0, /* expected inhcount */
+ stmt->subname, /* old att name */
+ stmt->newname, /* new att name */
+ interpretInhOption(stmt->relation->inhOpt), /* recursive? */
+ false, /* recursing? */
+ 0, /* expected inhcount */
stmt->behavior);
}
AlterTable(AlterTableStmt *stmt)
{
Relation rel;
- LOCKMODE lockmode = AlterTableGetLockLevel(stmt->cmds);
+ LOCKMODE lockmode = AlterTableGetLockLevel(stmt->cmds);
/*
* Acquire same level of lock as already acquired during parsing.
}
ATController(rel, stmt->cmds, interpretInhOption(stmt->relation->inhOpt),
- lockmode);
+ lockmode);
}
/*
AlterTableInternal(Oid relid, List *cmds, bool recurse)
{
Relation rel;
- LOCKMODE lockmode = AlterTableGetLockLevel(cmds);
+ LOCKMODE lockmode = AlterTableGetLockLevel(cmds);
rel = relation_open(relid, lockmode);
AlterTableGetLockLevel(List *cmds)
{
ListCell *lcmd;
- LOCKMODE lockmode = ShareUpdateExclusiveLock;
+ LOCKMODE lockmode = ShareUpdateExclusiveLock;
foreach(lcmd, cmds)
{
AlterTableCmd *cmd = (AlterTableCmd *) lfirst(lcmd);
- LOCKMODE cmd_lockmode = AccessExclusiveLock; /* default for compiler */
+ LOCKMODE cmd_lockmode = AccessExclusiveLock; /* default for compiler */
switch (cmd->subtype)
{
- /*
- * Need AccessExclusiveLock for these subcommands because they
- * affect or potentially affect both read and write operations.
- *
- * New subcommand types should be added here by default.
- */
- case AT_AddColumn: /* may rewrite heap, in some cases and visible to SELECT */
- case AT_DropColumn: /* change visible to SELECT */
+ /*
+ * Need AccessExclusiveLock for these subcommands because they
+ * affect or potentially affect both read and write
+ * operations.
+ *
+ * New subcommand types should be added here by default.
+ */
+ case AT_AddColumn: /* may rewrite heap, in some cases and visible
+ * to SELECT */
+ case AT_DropColumn: /* change visible to SELECT */
case AT_AddColumnToView: /* CREATE VIEW */
case AT_AlterColumnType: /* must rewrite heap */
case AT_DropConstraint: /* as DROP INDEX */
- case AT_AddOids: /* must rewrite heap */
- case AT_DropOids: /* calls AT_DropColumn */
+ case AT_AddOids: /* must rewrite heap */
+ case AT_DropOids: /* calls AT_DropColumn */
case AT_EnableAlwaysRule: /* may change SELECT rules */
case AT_EnableReplicaRule: /* may change SELECT rules */
- case AT_EnableRule: /* may change SELECT rules */
+ case AT_EnableRule: /* may change SELECT rules */
case AT_DisableRule: /* may change SELECT rules */
case AT_ChangeOwner: /* change visible to SELECT */
case AT_SetTableSpace: /* must rewrite heap */
cmd_lockmode = AccessExclusiveLock;
break;
- /*
- * These subcommands affect write operations only.
- */
+ /*
+ * These subcommands affect write operations only.
+ */
case AT_ColumnDefault:
- case AT_ProcessedConstraint: /* becomes AT_AddConstraint */
- case AT_AddConstraintRecurse: /* becomes AT_AddConstraint */
+ case AT_ProcessedConstraint: /* becomes AT_AddConstraint */
+ case AT_AddConstraintRecurse: /* becomes AT_AddConstraint */
case AT_EnableTrig:
case AT_EnableAlwaysTrig:
case AT_EnableReplicaTrig:
case AT_DisableTrig:
case AT_DisableTrigAll:
case AT_DisableTrigUser:
- case AT_AddIndex: /* from ADD CONSTRAINT */
+ case AT_AddIndex: /* from ADD CONSTRAINT */
case AT_AddIndexConstraint:
cmd_lockmode = ShareRowExclusiveLock;
break;
case CONSTR_EXCLUSION:
case CONSTR_PRIMARY:
case CONSTR_UNIQUE:
+
/*
* Cases essentially the same as CREATE INDEX. We
- * could reduce the lock strength to ShareLock if we
- * can work out how to allow concurrent catalog updates.
+ * could reduce the lock strength to ShareLock if
+ * we can work out how to allow concurrent catalog
+ * updates.
*/
cmd_lockmode = ShareRowExclusiveLock;
break;
case CONSTR_FOREIGN:
+
/*
* We add triggers to both tables when we add a
* Foreign Key, so the lock level must be at least
}
break;
- /*
- * These subcommands affect inheritance behaviour. Queries started before us
- * will continue to see the old inheritance behaviour, while queries started
- * after we commit will see new behaviour. No need to prevent reads or writes
- * to the subtable while we hook it up though. In both cases the parent table
- * is locked with AccessShareLock.
- */
+ /*
+ * These subcommands affect inheritance behaviour. Queries
+ * started before us will continue to see the old inheritance
+ * behaviour, while queries started after we commit will see
+ * new behaviour. No need to prevent reads or writes to the
+ * subtable while we hook it up though. In both cases the
+ * parent table is locked with AccessShareLock.
+ */
case AT_AddInherit:
case AT_DropInherit:
cmd_lockmode = ShareUpdateExclusiveLock;
break;
- /*
- * These subcommands affect general strategies for performance and maintenance,
- * though don't change the semantic results from normal data reads and writes.
- * Delaying an ALTER TABLE behind currently active writes only delays the point
- * where the new strategy begins to take effect, so there is no benefit in waiting.
- * In this case the minimum restriction applies: we don't currently allow
- * concurrent catalog updates.
- */
+ /*
+ * These subcommands affect general strategies for performance
+ * and maintenance, though don't change the semantic results
+ * from normal data reads and writes. Delaying an ALTER TABLE
+ * behind currently active writes only delays the point where
+ * the new strategy begins to take effect, so there is no
+ * benefit in waiting. In this case the minimum restriction
+ * applies: we don't currently allow concurrent catalog
+ * updates.
+ */
case AT_SetStatistics:
case AT_ClusterOn:
case AT_DropCluster:
cmd_lockmode = ShareUpdateExclusiveLock;
break;
- default: /* oops */
+ default: /* oops */
elog(ERROR, "unrecognized alter table type: %d",
(int) cmd->subtype);
break;
{
case AT_AddColumn: /* ADD COLUMN */
ATSimplePermissions(rel,
- ATT_TABLE|ATT_COMPOSITE_TYPE|ATT_FOREIGN_TABLE);
+ ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
ATPrepAddColumn(wqueue, rel, recurse, recursing, cmd, lockmode);
/* Recursion occurs during execution phase */
pass = AT_PASS_ADD_COL;
* substitutes default values into INSERTs before it expands
* rules.
*/
- ATSimplePermissions(rel, ATT_TABLE|ATT_VIEW);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_VIEW);
ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode);
/* No command-specific prep needed */
pass = cmd->def ? AT_PASS_ADD_CONSTR : AT_PASS_DROP;
break;
case AT_DropNotNull: /* ALTER COLUMN DROP NOT NULL */
- ATSimplePermissions(rel, ATT_TABLE|ATT_FOREIGN_TABLE);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode);
/* No command-specific prep needed */
pass = AT_PASS_DROP;
break;
case AT_SetNotNull: /* ALTER COLUMN SET NOT NULL */
- ATSimplePermissions(rel, ATT_TABLE|ATT_FOREIGN_TABLE);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_FOREIGN_TABLE);
ATSimpleRecursion(wqueue, rel, cmd, recurse, lockmode);
/* No command-specific prep needed */
pass = AT_PASS_ADD_CONSTR;
break;
case AT_SetOptions: /* ALTER COLUMN SET ( options ) */
case AT_ResetOptions: /* ALTER COLUMN RESET ( options ) */
- ATSimplePermissions(rel, ATT_TABLE|ATT_INDEX);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_INDEX);
/* This command never recurses */
pass = AT_PASS_MISC;
break;
break;
case AT_DropColumn: /* DROP COLUMN */
ATSimplePermissions(rel,
- ATT_TABLE|ATT_COMPOSITE_TYPE|ATT_FOREIGN_TABLE);
+ ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
ATPrepDropColumn(wqueue, rel, recurse, recursing, cmd, lockmode);
/* Recursion occurs during execution phase */
pass = AT_PASS_DROP;
cmd->subtype = AT_AddConstraintRecurse;
pass = AT_PASS_ADD_CONSTR;
break;
- case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
+ case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
ATSimplePermissions(rel, ATT_TABLE);
/* This command never recurses */
/* No command-specific prep needed */
break;
case AT_AlterColumnType: /* ALTER COLUMN TYPE */
ATSimplePermissions(rel,
- ATT_TABLE|ATT_COMPOSITE_TYPE|ATT_FOREIGN_TABLE);
+ ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE);
/* Performs own recursion */
ATPrepAlterColumnType(wqueue, tab, rel, recurse, recursing, cmd, lockmode);
pass = AT_PASS_ALTER_TYPE;
pass = AT_PASS_DROP;
break;
case AT_SetTableSpace: /* SET TABLESPACE */
- ATSimplePermissions(rel, ATT_TABLE|ATT_INDEX);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_INDEX);
/* This command never recurses */
ATPrepSetTableSpace(tab, rel, cmd->name, lockmode);
pass = AT_PASS_MISC; /* doesn't actually matter */
break;
case AT_SetRelOptions: /* SET (...) */
case AT_ResetRelOptions: /* RESET (...) */
- ATSimplePermissions(rel, ATT_TABLE|ATT_INDEX);
+ ATSimplePermissions(rel, ATT_TABLE | ATT_INDEX);
/* This command never recurses */
/* No command-specific prep needed */
pass = AT_PASS_MISC;
break;
case AT_DropColumn: /* DROP COLUMN */
ATExecDropColumn(wqueue, rel, cmd->name,
- cmd->behavior, false, false, cmd->missing_ok, lockmode);
+ cmd->behavior, false, false, cmd->missing_ok, lockmode);
break;
case AT_DropColumnRecurse: /* DROP COLUMN with recursion */
ATExecDropColumn(wqueue, rel, cmd->name,
- cmd->behavior, true, false, cmd->missing_ok, lockmode);
+ cmd->behavior, true, false, cmd->missing_ok, lockmode);
break;
case AT_AddIndex: /* ADD INDEX */
ATExecAddIndex(tab, rel, (IndexStmt *) cmd->def, false, lockmode);
ATExecAddConstraint(wqueue, tab, rel, (Constraint *) cmd->def,
true, lockmode);
break;
- case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
+ case AT_AddIndexConstraint: /* ADD CONSTRAINT USING INDEX */
ATExecAddIndexConstraint(tab, rel, (IndexStmt *) cmd->def, lockmode);
break;
case AT_ValidateConstraint:
case AT_EnableTrig: /* ENABLE TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
- TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
+ TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
break;
case AT_EnableAlwaysTrig: /* ENABLE ALWAYS TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
break;
case AT_EnableReplicaTrig: /* ENABLE REPLICA TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
- TRIGGER_FIRES_ON_REPLICA, false, lockmode);
+ TRIGGER_FIRES_ON_REPLICA, false, lockmode);
break;
case AT_DisableTrig: /* DISABLE TRIGGER name */
ATExecEnableDisableTrigger(rel, cmd->name,
break;
case AT_EnableTrigAll: /* ENABLE TRIGGER ALL */
ATExecEnableDisableTrigger(rel, NULL,
- TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
+ TRIGGER_FIRES_ON_ORIGIN, false, lockmode);
break;
case AT_DisableTrigAll: /* DISABLE TRIGGER ALL */
ATExecEnableDisableTrigger(rel, NULL,
break;
case AT_EnableTrigUser: /* ENABLE TRIGGER USER */
ATExecEnableDisableTrigger(rel, NULL,
- TRIGGER_FIRES_ON_ORIGIN, true, lockmode);
+ TRIGGER_FIRES_ON_ORIGIN, true, lockmode);
break;
case AT_DisableTrigUser: /* DISABLE TRIGGER USER */
ATExecEnableDisableTrigger(rel, NULL,
* (Eventually we'll probably need to check for composite type
* dependencies even when we're just scanning the table without a
* rewrite, but at the moment a composite type does not enforce any
- * constraints, so it's not necessary/appropriate to enforce them
- * just during ALTER.)
+ * constraints, so it's not necessary/appropriate to enforce them just
+ * during ALTER.)
*/
if (tab->newvals != NIL || tab->rewrite)
{
con->conid);
/*
- * No need to mark the constraint row as validated,
- * we did that when we inserted the row earlier.
+ * No need to mark the constraint row as validated, we did
+ * that when we inserted the row earlier.
*/
heap_close(refrel, NoLock);
static void
ATSimplePermissions(Relation rel, int allowed_targets)
{
- int actual_target;
+ int actual_target;
switch (rel->rd_rel->relkind)
{
case ATT_TABLE:
msg = _("\"%s\" is not a table");
break;
- case ATT_TABLE|ATT_INDEX:
+ case ATT_TABLE | ATT_INDEX:
msg = _("\"%s\" is not a table or index");
break;
- case ATT_TABLE|ATT_VIEW:
+ case ATT_TABLE | ATT_VIEW:
msg = _("\"%s\" is not a table or view");
break;
- case ATT_TABLE|ATT_FOREIGN_TABLE:
+ case ATT_TABLE | ATT_FOREIGN_TABLE:
msg = _("\"%s\" is not a table or foreign table");
break;
- case ATT_TABLE|ATT_COMPOSITE_TYPE|ATT_FOREIGN_TABLE:
+ case ATT_TABLE | ATT_COMPOSITE_TYPE | ATT_FOREIGN_TABLE:
msg = _("\"%s\" is not a table, composite type, or foreign table");
break;
case ATT_VIEW:
(errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
errmsg("cannot alter type \"%s\" because it is the type of a typed table",
typeName),
- errhint("Use ALTER ... CASCADE to alter the typed tables too.")));
+ errhint("Use ALTER ... CASCADE to alter the typed tables too.")));
else
result = lappend_oid(result, HeapTupleGetOid(tuple));
}
/*
* Are we adding the column to a recursion child? If so, check whether to
- * merge with an existing definition for the column. If we do merge,
- * we must not recurse. Children will already have the column, and
- * recursing into them would mess up attinhcount.
+ * merge with an existing definition for the column. If we do merge, we
+ * must not recurse. Children will already have the column, and recursing
+ * into them would mess up attinhcount.
*/
if (colDef->inhcount > 0)
{
ereport(ERROR,
(errcode(ERRCODE_COLLATION_MISMATCH),
errmsg("child table \"%s\" has different collation for column \"%s\"",
- RelationGetRelationName(rel), colDef->colname),
+ RelationGetRelationName(rel), colDef->colname),
errdetail("\"%s\" versus \"%s\"",
get_collation_name(ccollid),
- get_collation_name(childatt->attcollation))));
+ get_collation_name(childatt->attcollation))));
/* If it's OID, child column must actually be OID */
if (isOid && childatt->attnum != ObjectIdAttributeNumber)
if (relkind == RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("default values on foreign tables are not supported")));
+ errmsg("default values on foreign tables are not supported")));
rawEnt = (RawColumnDefault *) palloc(sizeof(RawColumnDefault));
rawEnt->attnum = attribute.attnum;
elog(ERROR, "index \"%s\" is not unique", indexName);
/*
- * Determine name to assign to constraint. We require a constraint to
+ * Determine name to assign to constraint. We require a constraint to
* have the same name as the underlying index; therefore, use the index's
- * existing name as the default constraint name, and if the user explicitly
- * gives some other name for the constraint, rename the index to match.
+ * existing name as the default constraint name, and if the user
+ * explicitly gives some other name for the constraint, rename the index
+ * to match.
*/
constraintName = stmt->idxname;
if (constraintName == NULL)
*/
static void
ATExecAddConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
- Constraint *newConstraint, bool recurse, LOCKMODE lockmode)
+ Constraint *newConstraint, bool recurse, LOCKMODE lockmode)
{
Assert(IsA(newConstraint, Constraint));
/*
* If the constraint got merged with an existing constraint, we're done.
- * We mustn't recurse to child tables in this case, because they've already
- * got the constraint, and visiting them again would lead to an incorrect
- * value for coninhcount.
+ * We mustn't recurse to child tables in this case, because they've
+ * already got the constraint, and visiting them again would lead to an
+ * incorrect value for coninhcount.
*/
if (newcons == NIL)
return;
/*
* Tell Phase 3 to check that the constraint is satisfied by existing rows
- * We can skip this during table creation or if requested explicitly
- * by specifying NOT VALID on an alter table statement.
+ * We can skip this during table creation or if requested explicitly by
+ * specifying NOT VALID on an alter table statement.
*/
if (!fkconstraint->skip_validation)
{
if (!found)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("foreign key constraint \"%s\" of relation \"%s\" does not exist",
- constrName, RelationGetRelationName(rel))));
+ errmsg("foreign key constraint \"%s\" of relation \"%s\" does not exist",
+ constrName, RelationGetRelationName(rel))));
if (!con->convalidated)
{
Relation refrel;
/*
- * Triggers are already in place on both tables, so a
- * concurrent write that alters the result here is not
- * possible. Normally we can run a query here to do the
- * validation, which would only require AccessShareLock.
- * In some cases, it is possible that we might need to
- * fire triggers to perform the check, so we take a lock
- * at RowShareLock level just in case.
+ * Triggers are already in place on both tables, so a concurrent write
+ * that alters the result here is not possible. Normally we can run a
+ * query here to do the validation, which would only require
+ * AccessShareLock. In some cases, it is possible that we might need
+ * to fire triggers to perform the check, so we take a lock at
+ * RowShareLock level just in case.
*/
refrel = heap_open(con->confrelid, RowShareLock);
- validateForeignKeyConstraint((char *)constrName, rel, refrel,
+ validateForeignKeyConstraint((char *) constrName, rel, refrel,
con->conindid,
conid);
if (tab->relkind == RELKIND_RELATION)
{
/*
- * Set up an expression to transform the old data value to the new type.
- * If a USING option was given, transform and use that expression, else
- * just take the old value and try to coerce it. We do this first so that
- * type incompatibility can be detected before we waste effort, and
- * because we need the expression to be parsed against the original table
- * rowtype.
+ * Set up an expression to transform the old data value to the new
+ * type. If a USING option was given, transform and use that
+ * expression, else just take the old value and try to coerce it. We
+ * do this first so that type incompatibility can be detected before
+ * we waste effort, and because we need the expression to be parsed
+ * against the original table rowtype.
*/
if (transform)
{
if (expression_returns_set(transform))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("transform expression must not return a set")));
+ errmsg("transform expression must not return a set")));
/* No subplans or aggregates, either... */
if (pstate->p_hasSubLinks)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot use subquery in transform expression")));
+ errmsg("cannot use subquery in transform expression")));
if (pstate->p_hasAggs)
ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
else
{
transform = (Node *) makeVar(1, attnum,
- attTup->atttypid, attTup->atttypmod, attTup->attcollation,
+ attTup->atttypid, attTup->atttypmod, attTup->attcollation,
0);
}
else if (transform)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("ALTER TYPE USING is only supported on plain tables")));
+ errmsg("ALTER TYPE USING is only supported on plain tables")));
if (tab->relkind == RELKIND_COMPOSITE_TYPE ||
tab->relkind == RELKIND_FOREIGN_TABLE)
{
/*
- * For composite types, do this check now. Tables will check
- * it later when the table is being rewritten.
+ * For composite types, do this check now. Tables will check it later
+ * when the table is being rewritten.
*/
find_composite_type_dependencies(rel->rd_rel->reltype, rel, NULL);
}
for (;;)
{
/* only one varno, so no need to check that */
- if (IsA(expr, Var) && ((Var *) expr)->varattno == varattno)
+ if (IsA(expr, Var) &&((Var *) expr)->varattno == varattno)
return false;
else if (IsA(expr, RelabelType))
expr = (Node *) ((RelabelType *) expr)->arg;
break;
case OCLASS_TRIGGER:
+
/*
* A trigger can depend on a column because the column is
* specified as an update target, or because the column is
* used in the trigger's WHEN condition. The first case would
* not require any extra work, but the second case would
* require updating the WHEN expression, which will take a
- * significant amount of new code. Since we can't easily tell
+ * significant amount of new code. Since we can't easily tell
* which case applies, we punt for both. FIXME someday.
*/
ereport(ERROR,
*/
static void
ATExecEnableDisableTrigger(Relation rel, char *trigname,
- char fires_when, bool skip_system, LOCKMODE lockmode)
+ char fires_when, bool skip_system, LOCKMODE lockmode)
{
EnableDisableTrigger(rel, trigname, fires_when, skip_system);
}
static void
ATExecGenericOptions(Relation rel, List *options)
{
- Relation ftrel;
- ForeignServer *server;
+ Relation ftrel;
+ ForeignServer *server;
ForeignDataWrapper *fdw;
- HeapTuple tuple;
- bool isnull;
- Datum repl_val[Natts_pg_foreign_table];
- bool repl_null[Natts_pg_foreign_table];
- bool repl_repl[Natts_pg_foreign_table];
- Datum datum;
- Form_pg_foreign_table tableform;
-
- if (options == NIL)
+ HeapTuple tuple;
+ bool isnull;
+ Datum repl_val[Natts_pg_foreign_table];
+ bool repl_null[Natts_pg_foreign_table];
+ bool repl_repl[Natts_pg_foreign_table];
+ Datum datum;
+ Form_pg_foreign_table tableform;
+
+ if (options == NIL)
return;
ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("foreign table \"%s\" does not exist",
- RelationGetRelationName(rel))));
+ RelationGetRelationName(rel))));
tableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
server = GetForeignServer(tableform->ftserver);
fdw = GetForeignDataWrapper(server->fdwid);
default:
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, sequence, or foreign table",
- RelationGetRelationName(rel))));
+ errmsg("\"%s\" is not a table, view, sequence, or foreign table",
+ RelationGetRelationName(rel))));
}
/* get schema OID and check its permissions */
*/
static void
AlterSeqNamespaces(Relation classRel, Relation rel,
- Oid oldNspOid, Oid newNspOid, const char *newNspName, LOCKMODE lockmode)
+ Oid oldNspOid, Oid newNspOid, const char *newNspName, LOCKMODE lockmode)
{
Relation depRel;
SysScanDesc scan;
(errcode(ERRCODE_UNDEFINED_FILE),
errmsg("directory \"%s\" does not exist", location),
InRecovery ? errhint("Create this directory for the tablespace before "
- "restarting the server."): 0));
+ "restarting the server.") : 0));
else
ereport(ERROR,
(errcode_for_file_access(),
/*
* Our theory for replaying a CREATE is to forcibly drop the target
- * subdirectory if present, and then recreate it. This may be
- * more work than needed, but it is simple to implement.
+ * subdirectory if present, and then recreate it. This may be more
+ * work than needed, but it is simple to implement.
*/
if (stat(location_with_version_dir, &st) == 0 && S_ISDIR(st.st_mode))
{
heap_close(rel, AccessShareLock);
if (!OidIsValid(result) && !missing_ok)
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("tablespace \"%s\" does not exist",
- tablespacename)));
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("tablespace \"%s\" does not exist",
+ tablespacename)));
return result;
}
referenced;
/*
- * ShareRowExclusiveLock is sufficient to prevent concurrent write activity
- * to the relation, and thus to lock out any operations that might want to
- * fire triggers on the relation. If we had ON SELECT triggers we would
- * need to take an AccessExclusiveLock to add one of those, just as we do
- * with ON SELECT rules.
+ * ShareRowExclusiveLock is sufficient to prevent concurrent write
+ * activity to the relation, and thus to lock out any operations that
+ * might want to fire triggers on the relation. If we had ON SELECT
+ * triggers we would need to take an AccessExclusiveLock to add one of
+ * those, just as we do with ON SELECT rules.
*/
rel = heap_openrv(stmt->relation, ShareRowExclusiveLock);
if (stmt->whenClause)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("INSTEAD OF triggers cannot have WHEN conditions")));
+ errmsg("INSTEAD OF triggers cannot have WHEN conditions")));
if (stmt->columns != NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
* can skip this for internally generated triggers, since the name
* modification above should be sufficient.
*
- * NOTE that this is cool only because we have ShareRowExclusiveLock on the
- * relation, so the trigger set won't be changing underneath us.
+ * NOTE that this is cool only because we have ShareRowExclusiveLock on
+ * the relation, so the trigger set won't be changing underneath us.
*/
if (!isInternal)
{
if (!OidIsValid(object.objectId))
{
ereport(NOTICE,
- (errmsg("trigger \"%s\" for table \"%s\" does not exist, skipping",
- trigname, get_rel_name(relid))));
+ (errmsg("trigger \"%s\" for table \"%s\" does not exist, skipping",
+ trigname, get_rel_name(relid))));
return;
}
/*
* Open and lock the relation the trigger belongs to. As in
- * CreateTrigger, this is sufficient to lock out all operations that
- * could fire or add triggers; but it would need to be revisited if
- * we had ON SELECT triggers.
+ * CreateTrigger, this is sufficient to lock out all operations that could
+ * fire or add triggers; but it would need to be revisited if we had ON
+ * SELECT triggers.
*/
relid = ((Form_pg_trigger) GETSTRUCT(tup))->tgrelid;
if (newtuple != slottuple)
{
/*
- * Return the modified tuple using the es_trig_tuple_slot. We assume
+ * Return the modified tuple using the es_trig_tuple_slot. We assume
* the tuple was allocated in per-tuple memory context, and therefore
* will go away by itself. The tuple table slot should not try to
* clear it.
if (newtuple != slottuple)
{
/*
- * Return the modified tuple using the es_trig_tuple_slot. We assume
+ * Return the modified tuple using the es_trig_tuple_slot. We assume
* the tuple was allocated in per-tuple memory context, and therefore
* will go away by itself. The tuple table slot should not try to
* clear it.
if (newtuple != slottuple)
{
/*
- * Return the modified tuple using the es_trig_tuple_slot. We assume
+ * Return the modified tuple using the es_trig_tuple_slot. We assume
* the tuple was allocated in per-tuple memory context, and therefore
* will go away by itself. The tuple table slot should not try to
* clear it.
if (newtuple != slottuple)
{
/*
- * Return the modified tuple using the es_trig_tuple_slot. We assume
+ * Return the modified tuple using the es_trig_tuple_slot. We assume
* the tuple was allocated in per-tuple memory context, and therefore
* will go away by itself. The tuple table slot should not try to
* clear it.
{
TriggerFlags ate_flags; /* status bits and offset to shared data */
ItemPointerData ate_ctid1; /* inserted, deleted, or old updated tuple */
-} AfterTriggerEventDataOneCtid;
+} AfterTriggerEventDataOneCtid;
#define SizeofTriggerEvent(evt) \
(((evt)->ate_flags & AFTER_TRIGGER_2CTIDS) ? \
void
AlterTSParserNamespace(List *name, const char *newschema)
{
- Oid prsId, nspOid;
+ Oid prsId,
+ nspOid;
Relation rel;
rel = heap_open(TSParserRelationId, RowExclusiveLock);
Oid
AlterTSParserNamespace_oid(Oid prsId, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(TSParserRelationId, RowExclusiveLock);
void
AlterTSDictionaryNamespace(List *name, const char *newschema)
{
- Oid dictId, nspOid;
+ Oid dictId,
+ nspOid;
Relation rel;
rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
Oid
AlterTSDictionaryNamespace_oid(Oid dictId, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
void
AlterTSTemplateNamespace(List *name, const char *newschema)
{
- Oid tmplId, nspOid;
+ Oid tmplId,
+ nspOid;
Relation rel;
rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
Oid
AlterTSTemplateNamespace_oid(Oid tmplId, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
void
AlterTSConfigurationNamespace(List *name, const char *newschema)
{
- Oid cfgId, nspOid;
+ Oid cfgId,
+ nspOid;
Relation rel;
rel = heap_open(TSConfigRelationId, RowExclusiveLock);
Oid
AlterTSConfigurationNamespace_oid(Oid cfgId, Oid newNspOid)
{
- Oid oldNspOid;
+ Oid oldNspOid;
Relation rel;
rel = heap_open(TSConfigRelationId, RowExclusiveLock);
DefElem *byValueEl = NULL;
DefElem *alignmentEl = NULL;
DefElem *storageEl = NULL;
- DefElem *collatableEl = NULL;
+ DefElem *collatableEl = NULL;
Oid inputOid;
Oid outputOid;
Oid receiveOid = InvalidOid;
* now have TypeCreate do all the real work.
*
* Note: the pg_type.oid is stored in user tables as array elements (base
- * types) in ArrayType and in composite types in DatumTupleFields. This
+ * types) in ArrayType and in composite types in DatumTupleFields. This
* oid must be preserved by binary upgrades.
*/
typoid =
-1, /* typMod (Domains only) */
0, /* Array dimensions of typbasetype */
false, /* Type NOT NULL */
- InvalidOid); /* typcollation */
+ InvalidOid); /* typcollation */
/* Enter the enum's values into pg_enum */
EnumValuesCreate(enumTypeOid, stmt->vals);
CONSTRAINT_CHECK, /* Constraint Type */
false, /* Is Deferrable */
false, /* Is Deferred */
- true, /* Is Validated */
+ true, /* Is Validated */
InvalidOid, /* not a relation constraint */
NULL,
0,
bool createrole = false; /* Can this user create roles? */
bool createdb = false; /* Can the user create databases? */
bool canlogin = false; /* Can this user login? */
- bool isreplication = false; /* Is this a replication role? */
+ bool isreplication = false; /* Is this a replication role? */
int connlimit = -1; /* maximum connections allowed */
List *addroleto = NIL; /* roles to make this a member of */
List *rolemembers = NIL; /* roles to be members of this role */
DefElem *dcreaterole = NULL;
DefElem *dcreatedb = NULL;
DefElem *dcanlogin = NULL;
- DefElem *disreplication = NULL;
+ DefElem *disreplication = NULL;
DefElem *dconnlimit = NULL;
DefElem *daddroleto = NULL;
DefElem *drolemembers = NULL;
if (dissuper)
{
issuper = intVal(dissuper->arg) != 0;
+
/*
- * Superusers get replication by default, but only if
- * NOREPLICATION wasn't explicitly mentioned
+ * Superusers get replication by default, but only if NOREPLICATION
+ * wasn't explicitly mentioned
*/
if (!(disreplication && intVal(disreplication->arg) == 0))
isreplication = 1;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to create replication users")));
+ errmsg("must be superuser to create replication users")));
}
else
{
tuple = heap_form_tuple(pg_authid_dsc, new_record, new_record_nulls);
/*
- * pg_largeobject_metadata contains pg_authid.oid's, so we
- * use the binary-upgrade override, if specified.
+ * pg_largeobject_metadata contains pg_authid.oid's, so we use the
+ * binary-upgrade override, if specified.
*/
if (OidIsValid(binary_upgrade_next_pg_authid_oid))
{
int createrole = -1; /* Can this user create roles? */
int createdb = -1; /* Can the user create databases? */
int canlogin = -1; /* Can this user login? */
- int isreplication = -1; /* Is this a replication role? */
+ int isreplication = -1; /* Is this a replication role? */
int connlimit = -1; /* maximum connections allowed */
List *rolemembers = NIL; /* roles to be added/removed */
char *validUntil = NULL; /* time the login is valid until */
DefElem *dcreaterole = NULL;
DefElem *dcreatedb = NULL;
DefElem *dcanlogin = NULL;
- DefElem *disreplication = NULL;
+ DefElem *disreplication = NULL;
DefElem *dconnlimit = NULL;
DefElem *drolemembers = NULL;
DefElem *dvalidUntil = NULL;
/*
* If we have discovered that there are no indexes, then there's no
- * primary key either. This could be done more thoroughly...
+ * primary key either. This could be done more thoroughly...
*/
if (pgcform->relhaspkey && !hasindex)
{
* There's a race condition here: the rel may have gone away since the
* last time we saw it. If so, we don't need to vacuum it.
*
- * If we've been asked not to wait for the relation lock, acquire it
- * first in non-blocking mode, before calling try_relation_open().
+ * If we've been asked not to wait for the relation lock, acquire it first
+ * in non-blocking mode, before calling try_relation_open().
*/
if (!(vacstmt->options & VACOPT_NOWAIT))
onerel = try_relation_open(relid, lmode);
if (IsAutoVacuumWorkerProcess() && Log_autovacuum_min_duration >= 0)
ereport(LOG,
(errcode(ERRCODE_LOCK_NOT_AVAILABLE),
- errmsg("skipping vacuum of \"%s\" --- lock not available",
- vacstmt->relation->relname)));
+ errmsg("skipping vacuum of \"%s\" --- lock not available",
+ vacstmt->relation->relname)));
}
if (!onerel)
PageSetAllVisible(page);
SetBufferCommitInfoNeedsSave(buf);
}
+
/*
* It's possible for the value returned by GetOldestXmin() to move
* backwards, so it's not wrong for us to see tuples that appear to
* not be visible to everyone yet, while PD_ALL_VISIBLE is already
* set. The real safe xmin value never moves backwards, but
* GetOldestXmin() is conservative and sometimes returns a value
- * that's unnecessarily small, so if we see that contradiction it
- * just means that the tuples that we think are not visible to
- * everyone yet actually are, and the PD_ALL_VISIBLE flag is correct.
+ * that's unnecessarily small, so if we see that contradiction it just
+ * means that the tuples that we think are not visible to everyone yet
+ * actually are, and the PD_ALL_VISIBLE flag is correct.
*
* There should never be dead tuples on a page with PD_ALL_VISIBLE
* set, however.
* We can't simply "return check_datestyle(...)" because we need
* to handle constructs like "DEFAULT, ISO".
*/
- char *subval;
- void *subextra = NULL;
+ char *subval;
+ void *subextra = NULL;
subval = strdup(GetConfigOptionResetString("datestyle"));
if (!subval)
{
/*
* The boot_val given for TimeZone in guc.c is NULL. When we see this
- * we just do nothing. If this isn't overridden from the config file
+ * we just do nothing. If this isn't overridden from the config file
* then pg_timezone_initialize() will eventually select a default
- * value from the environment. This hack has two purposes: to avoid
+ * value from the environment. This hack has two purposes: to avoid
* wasting cycles loading values that might soon be overridden from
* the config file, and to avoid trying to read the timezone files
* during InitializeGUCOptions(). The latter doesn't work in an
if (pg_strncasecmp(*newval, "interval", 8) == 0)
{
/*
- * Support INTERVAL 'foo'. This is for SQL spec compliance, not
+ * Support INTERVAL 'foo'. This is for SQL spec compliance, not
* because it has any actual real-world usefulness.
*/
const char *valueptr = *newval;
*
* Note: the result string should be something that we'd accept as input.
* We use the numeric format for interval cases, because it's simpler to
- * reload. In the named-timezone case, *newval is already OK and need not
+ * reload. In the named-timezone case, *newval is already OK and need not
* be changed; it might not have the canonical casing, but that's taken
* care of by show_timezone.
*/
if (myextra.HasCTZSet)
{
- char *result = (char *) malloc(64);
+ char *result = (char *) malloc(64);
if (!result)
return false;
* We allow idempotent changes (r/w -> r/w and r/o -> r/o) at any time, and
* we also always allow changes from read-write to read-only. However,
* read-only may be changed to read-write only when in a top-level transaction
- * that has not yet taken an initial snapshot. Can't do it in a hot standby
+ * that has not yet taken an initial snapshot. Can't do it in a hot standby
* slave, either.
*/
bool
*
* We can't roll back the random sequence on error, and we don't want
* config file reloads to affect it, so we only want interactive SET SEED
- * commands to set it. We use the "extra" storage to ensure that rollbacks
+ * commands to set it. We use the "extra" storage to ensure that rollbacks
* don't try to do the operation again.
*/
{
/*
* Can't do catalog lookups, so fail. The result of this is that
- * session_authorization cannot be set in postgresql.conf, which
- * seems like a good thing anyway, so we don't work hard to avoid it.
+ * session_authorization cannot be set in postgresql.conf, which seems
+ * like a good thing anyway, so we don't work hard to avoid it.
*/
return false;
}
show_role(void)
{
/*
- * Check whether SET ROLE is active; if not return "none". This is a
+ * Check whether SET ROLE is active; if not return "none". This is a
* kluge to deal with the fact that SET SESSION AUTHORIZATION logically
* resets SET ROLE to NONE, but we cannot set the GUC role variable from
* assign_session_authorization (because we haven't got enough info to
def->colname = pstrdup(tle->resname);
def->typeName = makeTypeNameFromOid(exprType((Node *) tle->expr),
- exprTypmod((Node *) tle->expr));
+ exprTypmod((Node *) tle->expr));
def->inhcount = 0;
def->is_local = true;
def->is_not_null = false;
def->cooked_default = NULL;
def->collClause = NULL;
def->collOid = exprCollation((Node *) tle->expr);
+
/*
* It's possible that the column is of a collatable type but the
* collation could not be resolved, so double-check.
}
else
{
- Oid relid;
+ Oid relid;
/*
* now set the parameters for keys/inheritance etc. All of these are
/*
* Check for unsupported cases. These tests are redundant with ones in
- * DefineQueryRewrite(), but that function will complain about a bogus
- * ON SELECT rule, and we'd rather the message complain about a view.
+ * DefineQueryRewrite(), but that function will complain about a bogus ON
+ * SELECT rule, and we'd rather the message complain about a view.
*/
if (viewParse->intoClause != NULL)
ereport(ERROR,
if (viewParse->hasModifyingCTE)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("views must not contain data-modifying statements in WITH")));
+ errmsg("views must not contain data-modifying statements in WITH")));
/*
* If a list of column names was given, run through and insert these into
if (view->relpersistence == RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("views cannot be unlogged because they do not have storage")));
+ errmsg("views cannot be unlogged because they do not have storage")));
/*
* Create the view relation
* ExecutorRun accepts direction and count arguments that specify whether
* the plan is to be executed forwards, backwards, and for how many tuples.
* In some cases ExecutorRun may be called multiple times to process all
- * the tuples for a plan. It is also acceptable to stop short of executing
+ * the tuples for a plan. It is also acceptable to stop short of executing
* the whole plan (but only if it is a SELECT).
*
* ExecutorFinish must be called after the final ExecutorRun call and
switch (queryDesc->operation)
{
case CMD_SELECT:
+
/*
* SELECT INTO, SELECT FOR UPDATE/SHARE and modifying CTEs need to
* mark tuples
* ExecutorFinish
*
* This routine must be called after the last ExecutorRun call.
- * It performs cleanup such as firing AFTER triggers. It is
+ * It performs cleanup such as firing AFTER triggers. It is
* separate from ExecutorEnd because EXPLAIN ANALYZE needs to
* include these actions in the total runtime.
*
* We provide a function hook variable that lets loadable plugins
- * get control when ExecutorFinish is called. Such a plugin would
+ * get control when ExecutorFinish is called. Such a plugin would
* normally call standard_ExecutorFinish().
*
* ----------------------------------------------------------------
Assert(estate != NULL);
/*
- * Check that ExecutorFinish was called, unless in EXPLAIN-only mode.
- * This Assert is needed because ExecutorFinish is new as of 9.1, and
- * callers might forget to call it.
+ * Check that ExecutorFinish was called, unless in EXPLAIN-only mode. This
+ * Assert is needed because ExecutorFinish is new as of 9.1, and callers
+ * might forget to call it.
*/
Assert(estate->es_finished ||
(estate->es_top_eflags & EXEC_FLAG_EXPLAIN_ONLY));
foreach(l, rangeTable)
{
- RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
+ RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
result = ExecCheckRTEPerms(rte);
if (!result)
}
if (ExecutorCheckPerms_hook)
- result = (*ExecutorCheckPerms_hook)(rangeTable,
- ereport_on_violation);
+ result = (*ExecutorCheckPerms_hook) (rangeTable,
+ ereport_on_violation);
return result;
}
void
CheckValidResultRel(Relation resultRel, CmdType operation)
{
- TriggerDesc *trigDesc = resultRel->trigdesc;
+ TriggerDesc *trigDesc = resultRel->trigdesc;
switch (resultRel->rd_rel->relkind)
{
case CMD_INSERT:
if (!trigDesc || !trigDesc->trig_insert_instead_row)
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("cannot insert into view \"%s\"",
- RelationGetRelationName(resultRel)),
- errhint("You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("cannot insert into view \"%s\"",
+ RelationGetRelationName(resultRel)),
+ errhint("You need an unconditional ON INSERT DO INSTEAD rule or an INSTEAD OF INSERT trigger.")));
break;
case CMD_UPDATE:
if (!trigDesc || !trigDesc->trig_update_instead_row)
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("cannot update view \"%s\"",
- RelationGetRelationName(resultRel)),
- errhint("You need an unconditional ON UPDATE DO INSTEAD rule or an INSTEAD OF UPDATE trigger.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("cannot update view \"%s\"",
+ RelationGetRelationName(resultRel)),
+ errhint("You need an unconditional ON UPDATE DO INSTEAD rule or an INSTEAD OF UPDATE trigger.")));
break;
case CMD_DELETE:
if (!trigDesc || !trigDesc->trig_delete_instead_row)
ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("cannot delete from view \"%s\"",
- RelationGetRelationName(resultRel)),
- errhint("You need an unconditional ON DELETE DO INSTEAD rule or an INSTEAD OF DELETE trigger.")));
+ (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ errmsg("cannot delete from view \"%s\"",
+ RelationGetRelationName(resultRel)),
+ errhint("You need an unconditional ON DELETE DO INSTEAD rule or an INSTEAD OF DELETE trigger.")));
break;
default:
elog(ERROR, "unrecognized CmdType: %d", (int) operation);
/*
* Open the target relation's relcache entry. We assume that an
* appropriate lock is still held by the backend from whenever the trigger
- * event got queued, so we need take no new lock here. Also, we need
- * not recheck the relkind, so no need for CheckValidResultRel.
+ * event got queued, so we need take no new lock here. Also, we need not
+ * recheck the relkind, so no need for CheckValidResultRel.
*/
rel = heap_open(relid, NoLock);
/*
* Run any secondary ModifyTable nodes to completion, in case the main
- * query did not fetch all rows from them. (We do this to ensure that
+ * query did not fetch all rows from them. (We do this to ensure that
* such nodes have predictable results.)
*/
foreach(lc, estate->es_auxmodifytables)
{
- PlanState *ps = (PlanState *) lfirst(lc);
+ PlanState *ps = (PlanState *) lfirst(lc);
for (;;)
{
* ExecInitSubPlan expects to be able to find these entries. Some of the
* SubPlans might not be used in the part of the plan tree we intend to
* run, but since it's not easy to tell which, we just initialize them
- * all. (However, if the subplan is headed by a ModifyTable node, then
- * it must be a data-modifying CTE, which we will certainly not need to
- * re-run, so we can skip initializing it. This is just an efficiency
+ * all. (However, if the subplan is headed by a ModifyTable node, then it
+ * must be a data-modifying CTE, which we will certainly not need to
+ * re-run, so we can skip initializing it. This is just an efficiency
* hack; it won't skip data-modifying CTEs for which the ModifyTable node
* is not at the top.)
*/
static Datum ExecEvalConst(ExprState *exprstate, ExprContext *econtext,
bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalParamExec(ExprState *exprstate, ExprContext *econtext,
- bool *isNull, ExprDoneCond *isDone);
+ bool *isNull, ExprDoneCond *isDone);
static Datum ExecEvalParamExtern(ExprState *exprstate, ExprContext *econtext,
- bool *isNull, ExprDoneCond *isDone);
+ bool *isNull, ExprDoneCond *isDone);
static void init_fcache(Oid foid, Oid input_collation, FuncExprState *fcache,
MemoryContext fcacheCxt, bool needDescForSets);
static void ShutdownFuncExpr(Datum arg);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("no value found for parameter %d", thisParamId)));
- return (Datum) 0; /* keep compiler quiet */
+ return (Datum) 0; /* keep compiler quiet */
}
/*
* Ordinarily, at this point the search should have found the originally
* inserted tuple, unless we exited the loop early because of conflict.
- * However, it is possible to define exclusion constraints for which
- * that wouldn't be true --- for instance, if the operator is <>.
- * So we no longer complain if found_self is still false.
+ * However, it is possible to define exclusion constraints for which that
+ * wouldn't be true --- for instance, if the operator is <>. So we no
+ * longer complain if found_self is still false.
*/
econtext->ecxt_scantuple = save_scantuple;
char *fname; /* function name (for error msgs) */
char *src; /* function body text (for error msgs) */
- SQLFunctionParseInfoPtr pinfo; /* data for parser callback hooks */
+ SQLFunctionParseInfoPtr pinfo; /* data for parser callback hooks */
Oid rettype; /* actual return type */
int16 typlen; /* length of the return type */
Oid *argtypes; /* resolved types of input arguments */
int nargs; /* number of input arguments */
Oid collation; /* function's input collation, if known */
-} SQLFunctionParseInfo;
+} SQLFunctionParseInfo;
/* non-export function prototypes */
* Set up the per-query execution_state records for a SQL function.
*
* The input is a List of Lists of parsed and rewritten, but not planned,
- * querytrees. The sublist structure denotes the original query boundaries.
+ * querytrees. The sublist structure denotes the original query boundaries.
*/
static List *
init_execution_state(List *queryTree_list,
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
/* translator: %s is a SQL statement name */
- errmsg("%s is not allowed in a non-volatile function",
- CreateCommandTag(stmt))));
+ errmsg("%s is not allowed in a non-volatile function",
+ CreateCommandTag(stmt))));
/* OK, build the execution_state for this query */
newes = (execution_state *) palloc(sizeof(execution_state));
newes->next = NULL;
newes->status = F_EXEC_START;
- newes->setsResult = false; /* might change below */
- newes->lazyEval = false; /* might change below */
+ newes->setsResult = false; /* might change below */
+ newes->lazyEval = false; /* might change below */
newes->stmt = stmt;
newes->qd = NULL;
fcache->src = TextDatumGetCString(tmp);
/*
- * Parse and rewrite the queries in the function text. Use sublists to
+ * Parse and rewrite the queries in the function text. Use sublists to
* keep track of the original query boundaries. But we also build a
* "flat" list of the rewritten queries to pass to check_sql_fn_retval.
* This is because the last canSetTag query determines the result type
queryTree_sublist = pg_analyze_and_rewrite_params(parsetree,
fcache->src,
- (ParserSetupHook) sql_fn_parser_setup,
+ (ParserSetupHook) sql_fn_parser_setup,
fcache->pinfo);
queryTree_list = lappend(queryTree_list, queryTree_sublist);
flat_query_list = list_concat(flat_query_list,
{
/* sizeof(ParamListInfoData) includes the first array element */
paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
- (nargs - 1) *sizeof(ParamExternData));
+ (nargs - 1) * sizeof(ParamExternData));
/* we have static list of params, so no hooks needed */
paramLI->paramFetch = NULL;
paramLI->paramFetchArg = NULL;
execution_state *es;
TupleTableSlot *slot;
Datum result;
- List *eslist;
- ListCell *eslc;
+ List *eslist;
+ ListCell *eslc;
/*
* Switch to context in which the fcache lives. This ensures that
*
* In a non-read-only function, we rely on the fact that we'll never
* suspend execution between queries of the function: the only reason to
- * suspend execution before completion is if we are returning a row from
- * a lazily-evaluated SELECT. So, when first entering this loop, we'll
+ * suspend execution before completion is if we are returning a row from a
+ * lazily-evaluated SELECT. So, when first entering this loop, we'll
* either start a new query (and push a fresh snapshot) or re-establish
- * the active snapshot from the existing query descriptor. If we need to
+ * the active snapshot from the existing query descriptor. If we need to
* start a new query in a subsequent execution of the loop, either we need
* a fresh snapshot (and pushed_snapshot is false) or the existing
* snapshot is on the active stack and we can just bump its command ID.
es = (execution_state *) lfirst(eslc);
/*
- * Flush the current snapshot so that we will take a new one
- * for the new query list. This ensures that new snaps are
- * taken at original-query boundaries, matching the behavior
- * of interactive execution.
+ * Flush the current snapshot so that we will take a new one for
+ * the new query list. This ensures that new snaps are taken at
+ * original-query boundaries, matching the behavior of interactive
+ * execution.
*/
if (pushed_snapshot)
{
{
SQLFunctionCachePtr fcache = (SQLFunctionCachePtr) DatumGetPointer(arg);
execution_state *es;
- ListCell *lc;
+ ListCell *lc;
foreach(lc, fcache->func_state)
{
* the function that's calling it.
*
* XXX Note that if rettype is RECORD, the IsBinaryCoercible check
- * will succeed for any composite restype. For the moment we rely on
+ * will succeed for any composite restype. For the moment we rely on
* runtime type checking to catch any discrepancy, but it'd be nice to
* do better at parse time.
*/
tle->expr = (Expr *) makeRelabelType(tle->expr,
rettype,
-1,
- get_typcollation(rettype),
+ get_typcollation(rettype),
COERCE_DONTCARE);
/* Relabel is dangerous if sort/group or setop column */
if (tle->ressortgroupref != 0 || parse->setOperations)
tle->expr = (Expr *) makeRelabelType(tle->expr,
atttype,
-1,
- get_typcollation(atttype),
+ get_typcollation(atttype),
COERCE_DONTCARE);
/* Relabel is dangerous if sort/group or setop column */
if (tle->ressortgroupref != 0 || parse->setOperations)
*/
Tuplesortstate *sortstate; /* sort object, if DISTINCT or ORDER BY */
-} AggStatePerAggData;
+} AggStatePerAggData;
/*
* AggStatePerGroupData - per-aggregate-per-group working state
TupleHashEntryData shared; /* common header for hash table entries */
/* per-aggregate transition status array - must be last! */
AggStatePerGroupData pergroup[1]; /* VARIABLE LENGTH ARRAY */
-} AggHashEntryData; /* VARIABLE LENGTH STRUCT */
+} AggHashEntryData; /* VARIABLE LENGTH STRUCT */
static void initialize_aggregates(AggState *aggstate,
Assert(node->numGroups > 0);
entrysize = sizeof(AggHashEntryData) +
- (aggstate->numaggs - 1) *sizeof(AggStatePerGroupData);
+ (aggstate->numaggs - 1) * sizeof(AggStatePerGroupData);
aggstate->hashtable = BuildTupleHashTable(node->numCols,
node->grpColIdx,
/* This must match build_hash_table */
entrysize = sizeof(AggHashEntryData) +
- (numAggs - 1) *sizeof(AggStatePerGroupData);
+ (numAggs - 1) * sizeof(AggStatePerGroupData);
entrysize = MAXALIGN(entrysize);
/* Account for hashtable overhead (assuming fill factor = 1) */
entrysize += 3 * sizeof(void *);
indexstate->biss_NumScanKeys);
/*
- * If no run-time keys to calculate, go ahead and pass the scankeys to
- * the index AM.
+ * If no run-time keys to calculate, go ahead and pass the scankeys to the
+ * index AM.
*/
if (indexstate->biss_NumRuntimeKeys == 0 &&
indexstate->biss_NumArrayKeys == 0)
ForeignNext(ForeignScanState *node)
{
TupleTableSlot *slot;
- ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
+ ForeignScan *plan = (ForeignScan *) node->ss.ps.plan;
ExprContext *econtext = node->ss.ps.ps_ExprContext;
MemoryContext oldcontext;
ExecPrepHashTableForUnmatched(HashJoinState *hjstate)
{
/*
- *----------
- * During this scan we use the HashJoinState fields as follows:
+ * ---------- During this scan we use the HashJoinState fields as follows:
*
- * hj_CurBucketNo: next regular bucket to scan
- * hj_CurSkewBucketNo: next skew bucket (an index into skewBucketNums)
- * hj_CurTuple: last tuple returned, or NULL to start next bucket
- *----------
+ * hj_CurBucketNo: next regular bucket to scan hj_CurSkewBucketNo: next
+ * skew bucket (an index into skewBucketNums) hj_CurTuple: last tuple
+ * returned, or NULL to start next bucket ----------
*/
hjstate->hj_CurBucketNo = 0;
hjstate->hj_CurSkewBucketNo = 0;
}
else if (hjstate->hj_CurSkewBucketNo < hashtable->nSkewBuckets)
{
- int j = hashtable->skewBucketNums[hjstate->hj_CurSkewBucketNo];
+ int j = hashtable->skewBucketNums[hjstate->hj_CurSkewBucketNo];
hashTuple = hashtable->skewBucket[j]->tuples;
hjstate->hj_CurSkewBucketNo++;
/* insert hashtable's tuple into exec slot */
inntuple = ExecStoreMinimalTuple(HJTUPLE_MINTUPLE(hashTuple),
hjstate->hj_HashTupleSlot,
- false); /* do not pfree */
+ false); /* do not pfree */
econtext->ecxt_innertuple = inntuple;
/*
/* ... and the same for the skew buckets, if any */
for (i = 0; i < hashtable->nSkewBuckets; i++)
{
- int j = hashtable->skewBucketNums[i];
+ int j = hashtable->skewBucketNums[i];
HashSkewBucket *skewBucket = hashtable->skewBucket[j];
for (tuple = skewBucket->tuples; tuple != NULL; tuple = tuple->next)
switch (node->hj_JoinState)
{
case HJ_BUILD_HASHTABLE:
+
/*
* First time through: build hash table for inner relation.
*/
* right/full join, we can quit without building the hash
* table. However, for an inner join it is only a win to
* check this when the outer relation's startup cost is less
- * than the projected cost of building the hash
- * table. Otherwise it's best to build the hash table first
- * and see if the inner relation is empty. (When it's a left
- * join, we should always make this check, since we aren't
- * going to be able to skip the join on the strength of an
- * empty inner relation anyway.)
+ * than the projected cost of building the hash table.
+ * Otherwise it's best to build the hash table first and see
+ * if the inner relation is empty. (When it's a left join, we
+ * should always make this check, since we aren't going to be
+ * able to skip the join on the strength of an empty inner
+ * relation anyway.)
*
* If we are rescanning the join, we make use of information
* gained on the previous scan: don't bother to try the
return NULL;
/*
- * need to remember whether nbatch has increased since we began
- * scanning the outer relation
+ * need to remember whether nbatch has increased since we
+ * began scanning the outer relation
*/
hashtable->nbatch_outstart = hashtable->nbatch;
/* FALL THRU */
case HJ_NEED_NEW_OUTER:
+
/*
* We don't have an outer tuple, try to get the next one
*/
Assert(batchno > hashtable->curbatch);
ExecHashJoinSaveTuple(ExecFetchSlotMinimalTuple(outerTupleSlot),
hashvalue,
- &hashtable->outerBatchFile[batchno]);
+ &hashtable->outerBatchFile[batchno]);
/* Loop around, staying in HJ_NEED_NEW_OUTER state */
continue;
}
/* FALL THRU */
case HJ_SCAN_BUCKET:
+
/*
* Scan the selected hash bucket for matches to current outer
*/
}
/*
- * In a semijoin, we'll consider returning the first match,
- * but after that we're done with this outer tuple.
+ * In a semijoin, we'll consider returning the first
+ * match, but after that we're done with this outer tuple.
*/
if (node->js.jointype == JOIN_SEMI)
node->hj_JoinState = HJ_NEED_NEW_OUTER;
break;
case HJ_FILL_OUTER_TUPLE:
+
/*
* The current outer tuple has run out of matches, so check
- * whether to emit a dummy outer-join tuple. Whether we
- * emit one or not, the next state is NEED_NEW_OUTER.
+ * whether to emit a dummy outer-join tuple. Whether we emit
+ * one or not, the next state is NEED_NEW_OUTER.
*/
node->hj_JoinState = HJ_NEED_NEW_OUTER;
break;
case HJ_FILL_INNER_TUPLES:
+
/*
* We have finished a batch, but we are doing right/full join,
* so any unmatched inner tuples in the hashtable have to be
break;
case HJ_NEED_NEW_BATCH:
+
/*
* Try to advance to next batch. Done if there are no more.
*/
if (!ExecHashJoinNewBatch(node))
- return NULL; /* end of join */
+ return NULL; /* end of join */
node->hj_JoinState = HJ_NEED_NEW_OUTER;
break;
}
if (curbatch >= nbatch)
- return false; /* no more batches */
+ return false; /* no more batches */
hashtable->curbatch = curbatch;
if (BufFileSeek(hashtable->outerBatchFile[curbatch], 0, 0L, SEEK_SET))
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not rewind hash-join temporary file: %m")));
+ errmsg("could not rewind hash-join temporary file: %m")));
}
return true;
ExecHashTableResetMatchFlags(node->hj_HashTable);
/*
- * Also, we need to reset our state about the emptiness of
- * the outer relation, so that the new scan of the outer will
- * update it correctly if it turns out to be empty this time.
- * (There's no harm in clearing it now because ExecHashJoin won't
- * need the info. In the other cases, where the hash table
- * doesn't exist or we are destroying it, we leave this state
- * alone because ExecHashJoin will need it the first time
- * through.)
+ * Also, we need to reset our state about the emptiness of the
+ * outer relation, so that the new scan of the outer will update
+ * it correctly if it turns out to be empty this time. (There's no
+ * harm in clearing it now because ExecHashJoin won't need the
+ * info. In the other cases, where the hash table doesn't exist
+ * or we are destroying it, we leave this state alone because
+ * ExecHashJoin will need it the first time through.)
*/
node->hj_OuterNotEmpty = false;
/*
* For each run-time key, extract the run-time expression and evaluate
- * it with respect to the current context. We then stick the result
+ * it with respect to the current context. We then stick the result
* into the proper scan key.
*
* Note: the result of the eval could be a pass-by-ref value that's
indexstate->iss_RelationDesc,
estate->es_snapshot,
indexstate->iss_NumScanKeys,
- indexstate->iss_NumOrderByKeys);
+ indexstate->iss_NumOrderByKeys);
/*
- * If no run-time keys to calculate, go ahead and pass the scankeys to
- * the index AM.
+ * If no run-time keys to calculate, go ahead and pass the scankeys to the
+ * index AM.
*/
if (indexstate->iss_NumRuntimeKeys == 0)
index_rescan(indexstate->iss_ScanDesc,
indexstate->iss_ScanKeys, indexstate->iss_NumScanKeys,
- indexstate->iss_OrderByKeys, indexstate->iss_NumOrderByKeys);
+ indexstate->iss_OrderByKeys, indexstate->iss_NumOrderByKeys);
/*
* all done.
scan_keys = (ScanKey) palloc(n_scan_keys * sizeof(ScanKeyData));
/*
- * runtime_keys array is dynamically resized as needed. We handle it
- * this way so that the same runtime keys array can be shared between
- * indexquals and indexorderbys, which will be processed in separate
- * calls of this function. Caller must be sure to pass in NULL/0 for
- * first call.
+ * runtime_keys array is dynamically resized as needed. We handle it this
+ * way so that the same runtime keys array can be shared between
+ * indexquals and indexorderbys, which will be processed in separate calls
+ * of this function. Caller must be sure to pass in NULL/0 for first
+ * call.
*/
runtime_keys = *runtimeKeys;
n_runtime_keys = max_runtime_keys = *numRuntimeKeys;
else if (IsA(child_node, ResultState))
{
/*
- * An extra consideration here is that if the Result is projecting
- * a targetlist that contains any SRFs, we can't assume that every
- * input tuple generates an output tuple, so a Sort underneath
- * might need to return more than N tuples to satisfy LIMIT N.
- * So we cannot use bounded sort.
+ * An extra consideration here is that if the Result is projecting a
+ * targetlist that contains any SRFs, we can't assume that every input
+ * tuple generates an output tuple, so a Sort underneath might need to
+ * return more than N tuples to satisfy LIMIT N. So we cannot use
+ * bounded sort.
*
- * If Result supported qual checking, we'd have to punt on seeing
- * a qual, too. Note that having a resconstantqual is not a
+ * If Result supported qual checking, we'd have to punt on seeing a
+ * qual, too. Note that having a resconstantqual is not a
* showstopper: if that fails we're not getting any rows at all.
*/
if (outerPlanState(child_node) &&
/*
* Locate the ExecRowMark(s) that this node is responsible for, and
- * construct ExecAuxRowMarks for them. (InitPlan should already have
+ * construct ExecAuxRowMarks for them. (InitPlan should already have
* built the global list of ExecRowMarks.)
*/
lrstate->lr_arowMarks = NIL;
* contains integers which index into the slots array. These typedefs try to
* clear it up, but they're only documentation.
*/
-typedef int SlotNumber;
-typedef int HeapPosition;
+typedef int SlotNumber;
+typedef int HeapPosition;
static void heap_insert_slot(MergeAppendState *node, SlotNumber new_slot);
static void heap_siftup_slot(MergeAppendState *node);
* initialize sort-key information
*/
mergestate->ms_nkeys = node->numCols;
- mergestate->ms_scankeys = palloc0(sizeof(ScanKeyData) * node->numCols);
+ mergestate->ms_scankeys = palloc0(sizeof(ScanKeyData) * node->numCols);
for (i = 0; i < node->numCols; i++)
{
- Oid sortFunction;
- bool reverse;
- int flags;
+ Oid sortFunction;
+ bool reverse;
+ int flags;
if (!get_compare_function_for_ordering_op(node->sortOperators[i],
&sortFunction, &reverse))
if (!node->ms_initialized)
{
/*
- * First time through: pull the first tuple from each subplan,
- * and set up the heap.
+ * First time through: pull the first tuple from each subplan, and set
+ * up the heap.
*/
for (i = 0; i < node->ms_nplans; i++)
{
j = node->ms_heap_size++; /* j is where the "hole" is */
while (j > 0)
{
- int i = (j-1)/2;
+ int i = (j - 1) / 2;
if (heap_compare_slots(node, new_slot, node->ms_heap[i]) >= 0)
break;
i = 0; /* i is where the "hole" is */
for (;;)
{
- int j = 2 * i + 1;
+ int j = 2 * i + 1;
if (j >= n)
break;
- if (j+1 < n && heap_compare_slots(node, heap[j], heap[j+1]) > 0)
+ if (j + 1 < n && heap_compare_slots(node, heap[j], heap[j + 1]) > 0)
j++;
if (heap_compare_slots(node, heap[n], heap[j]) <= 0)
break;
for (nkey = 0; nkey < node->ms_nkeys; nkey++)
{
- ScanKey scankey = node->ms_scankeys + nkey;
- AttrNumber attno = scankey->sk_attno;
- Datum datum1,
- datum2;
- bool isNull1,
- isNull2;
- int32 compare;
+ ScanKey scankey = node->ms_scankeys + nkey;
+ AttrNumber attno = scankey->sk_attno;
+ Datum datum1,
+ datum2;
+ bool isNull1,
+ isNull2;
+ int32 compare;
datum1 = slot_getattr(s1, attno, &isNull1);
datum2 = slot_getattr(s2, attno, &isNull2);
bool reverse; /* if true, negate the cmpfn's output */
bool nulls_first; /* if true, nulls sort low */
FmgrInfo cmpfinfo;
-} MergeJoinClauseData;
+} MergeJoinClauseData;
/* Result type for MJEvalOuterValues and MJEvalInnerValues */
typedef enum
*
* If we generate a new candidate tuple after EvalPlanQual testing, we
* must loop back here and recheck constraints. (We don't need to
- * redo triggers, however. If there are any BEFORE triggers then
+ * redo triggers, however. If there are any BEFORE triggers then
* trigger.c will have done heap_lock_tuple to lock the correct tuple,
* so there's no need to do them again.)
*/
/*
* Note: instead of having to update the old index tuples associated
- * with the heap tuple, all we do is form and insert new index
- * tuples. This is because UPDATEs are actually DELETEs and INSERTs,
- * and index tuple deletion is done later by VACUUM (see notes in
- * ExecDelete). All we do here is insert new index tuples. -cim
- * 9/27/89
+ * with the heap tuple, all we do is form and insert new index tuples.
+ * This is because UPDATEs are actually DELETEs and INSERTs, and index
+ * tuple deletion is done later by VACUUM (see notes in ExecDelete).
+ * All we do here is insert new index tuples. -cim 9/27/89
*/
/*
TupleTableSlot *planSlot;
ItemPointer tupleid = NULL;
ItemPointerData tuple_ctid;
- HeapTupleHeader oldtuple = NULL;
+ HeapTupleHeader oldtuple = NULL;
/*
* If we've already completed processing, don't try to do more. We need
/*
* es_result_relation_info must point to the currently active result
- * relation while we are within this ModifyTable node. Even though
+ * relation while we are within this ModifyTable node. Even though
* ModifyTable nodes can't be nested statically, they can be nested
* dynamically (since our subplan could include a reference to a modifying
* CTE). So we have to save and restore the caller's value.
for (;;)
{
/*
- * Reset the per-output-tuple exprcontext. This is needed because
+ * Reset the per-output-tuple exprcontext. This is needed because
* triggers expect to use that context as workspace. It's a bit ugly
* to do this below the top level of the plan, however. We might need
* to rethink this later.
elog(ERROR, "ctid is NULL");
tupleid = (ItemPointer) DatumGetPointer(datum);
- tuple_ctid = *tupleid; /* be sure we don't free ctid!! */
+ tuple_ctid = *tupleid; /* be sure we don't free
+ * ctid!! */
tupleid = &tuple_ctid;
}
else
break;
case CMD_UPDATE:
slot = ExecUpdate(tupleid, oldtuple, slot, planSlot,
- &node->mt_epqstate, estate, node->canSetTag);
+ &node->mt_epqstate, estate, node->canSetTag);
break;
case CMD_DELETE:
slot = ExecDelete(tupleid, oldtuple, planSlot,
- &node->mt_epqstate, estate, node->canSetTag);
+ &node->mt_epqstate, estate, node->canSetTag);
break;
default:
elog(ERROR, "unknown operation");
/*
* call ExecInitNode on each of the plans to be executed and save the
- * results into the array "mt_plans". This is also a convenient place
- * to verify that the proposed target relations are valid and open their
- * indexes for insertion of new index entries. Note we *must* set
+ * results into the array "mt_plans". This is also a convenient place to
+ * verify that the proposed target relations are valid and open their
+ * indexes for insertion of new index entries. Note we *must* set
* estate->es_result_relation_info correctly while we initialize each
* sub-plan; ExecContextForcesOids depends on that!
*/
/*
* If there are indices on the result relation, open them and save
* descriptors in the result relation info, so that we can add new
- * index entries for the tuples we add/update. We need not do this
+ * index entries for the tuples we add/update. We need not do this
* for a DELETE, however, since deletion doesn't affect indexes.
*/
if (resultRelInfo->ri_RelationDesc->rd_rel->relhasindex &&
* Lastly, if this is not the primary (canSetTag) ModifyTable node, add it
* to estate->es_auxmodifytables so that it will be run to completion by
* ExecPostprocessPlan. (It'd actually work fine to add the primary
- * ModifyTable node too, but there's no need.) Note the use of lcons
- * not lappend: we need later-initialized ModifyTable nodes to be shut
- * down before earlier ones. This ensures that we don't throw away
- * RETURNING rows that need to be seen by a later CTE subplan.
+ * ModifyTable node too, but there's no need.) Note the use of lcons not
+ * lappend: we need later-initialized ModifyTable nodes to be shut down
+ * before earlier ones. This ensures that we don't throw away RETURNING
+ * rows that need to be seen by a later CTE subplan.
*/
if (!mtstate->canSetTag)
estate->es_auxmodifytables = lcons(mtstate,
node->nl_MatchedOuter = false;
/*
- * fetch the values of any outer Vars that must be passed to
- * the inner scan, and store them in the appropriate PARAM_EXEC
- * slots.
+ * fetch the values of any outer Vars that must be passed to the
+ * inner scan, and store them in the appropriate PARAM_EXEC slots.
*/
foreach(lc, nl->nestParams)
{
*
* If we have no parameters to pass into the inner rel from the outer,
* tell the inner child that cheap rescans would be good. If we do have
- * such parameters, then there is no point in REWIND support at all in
- * the inner child, because it will always be rescanned with fresh
- * parameter values.
+ * such parameters, then there is no point in REWIND support at all in the
+ * inner child, because it will always be rescanned with fresh parameter
+ * values.
*/
outerPlanState(nlstate) = ExecInitNode(outerPlan(node), estate, eflags);
if (node->nestParams == NIL)
typedef struct RUHashEntryData
{
TupleHashEntryData shared; /* common header for hash table entries */
-} RUHashEntryData;
+} RUHashEntryData;
/*
{
TupleHashEntryData shared; /* common header for hash table entries */
SetOpStatePerGroupData pergroup;
-} SetOpHashEntryData;
+} SetOpHashEntryData;
static TupleTableSlot *setop_retrieve_direct(SetOpState *setopstate);
int aggno; /* if so, index of its PerAggData */
WindowObject winobj; /* object used in window function API */
-} WindowStatePerFuncData;
+} WindowStatePerFuncData;
/*
* For plain aggregate window functions, we also have one of these.
* snapshot != InvalidSnapshot, read_only = true: use exactly the given
* snapshot.
*
- * snapshot != InvalidSnapshot, read_only = false: use the given
- * snapshot, modified by advancing its command ID before each querytree.
+ * snapshot != InvalidSnapshot, read_only = false: use the given snapshot,
+ * modified by advancing its command ID before each querytree.
*
* snapshot == InvalidSnapshot, read_only = true: use the entry-time
* ActiveSnapshot, if any (if there isn't one, we run with no snapshot).
* snapshot for each user command, and advance its command ID before each
* querytree within the command.
*
- * In the first two cases, we can just push the snap onto the stack
- * once for the whole plan list.
+ * In the first two cases, we can just push the snap onto the stack once
+ * for the whole plan list.
*/
if (snapshot != InvalidSnapshot)
{
/* sizeof(ParamListInfoData) includes the first array element */
paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
- (nargs - 1) *sizeof(ParamExternData));
+ (nargs - 1) * sizeof(ParamExternData));
/* we have static list of params, so no hooks needed */
paramLI->paramFetch = NULL;
paramLI->paramFetchArg = NULL;
#define IDENT_PORT 113
static int ident_inet(hbaPort *port);
+
#ifdef HAVE_UNIX_SOCKETS
static int auth_peer(hbaPort *port);
#endif
*----------------------------------------------------------------
*/
#ifdef ENABLE_SSPI
-typedef SECURITY_STATUS
+typedef SECURITY_STATUS
(WINAPI * QUERY_SECURITY_CONTEXT_TOKEN_FN) (
PCtxtHandle, void **);
static int pg_SSPI_recvauth(Port *port);
}
#endif
status = auth_peer(port);
-#else /* HAVE_UNIX_SOCKETS */
+#else /* HAVE_UNIX_SOCKETS */
Assert(false);
#endif
break;
}
if (ClientAuthentication_hook)
- (*ClientAuthentication_hook)(port, status);
+ (*ClientAuthentication_hook) (port, status);
if (status == STATUS_OK)
sendAuthRequest(port, AUTH_REQ_OK);
return ret;
retval = krb5_recvauth(pg_krb5_context, &auth_context,
- (krb5_pointer) & port->sock, pg_krb_srvnam,
+ (krb5_pointer) &port->sock, pg_krb_srvnam,
pg_krb5_server, 0, pg_krb5_keytab, &ticket);
if (retval)
{
}
strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
-
#elif defined(SO_PEERCRED)
/* Linux style: use getsockopt(SO_PEERCRED) */
struct ucred peercred;
}
strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
-
#elif defined(HAVE_GETPEERUCRED)
/* Solaris > 10 */
uid_t uid;
}
strlcpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1);
-
#elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))
struct msghdr msg;
}
strlcpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1);
-
#else
ereport(LOG,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
pg_freeaddrinfo_all(hint.ai_family, serveraddrs);
/*
- * Figure out at what time we should time out. We can't just use
- * a single call to select() with a timeout, since somebody can
- * be sending invalid packets to our port thus causing us to
- * retry in a loop and never time out.
+ * Figure out at what time we should time out. We can't just use a single
+ * call to select() with a timeout, since somebody can be sending invalid
+ * packets to our port thus causing us to retry in a loop and never time
+ * out.
*/
gettimeofday(&endtime, NULL);
endtime.tv_sec += RADIUS_TIMEOUT;
{
struct timeval timeout;
struct timeval now;
- int64 timeoutval;
+ int64 timeoutval;
gettimeofday(&now, NULL);
timeoutval = (endtime.tv_sec * 1000000 + endtime.tv_usec) - (now.tv_sec * 1000000 + now.tv_usec);
/*
* Attempt to read the response packet, and verify the contents.
*
- * Any packet that's not actually a RADIUS packet, or otherwise
- * does not validate as an explicit reject, is just ignored and
- * we retry for another packet (until we reach the timeout). This
- * is to avoid the possibility to denial-of-service the login by
- * flooding the server with invalid packets on the port that
- * we're expecting the RADIUS response on.
+ * Any packet that's not actually a RADIUS packet, or otherwise does
+ * not validate as an explicit reject, is just ignored and we retry
+ * for another packet (until we reach the timeout). This is to avoid
+ * the possibility to denial-of-service the login by flooding the
+ * server with invalid packets on the port that we're expecting the
+ * RADIUS response on.
*/
addrsize = sizeof(remoteaddr);
{
#ifdef HAVE_IPV6
ereport(LOG,
- (errmsg("RADIUS response was sent from incorrect port: %i",
- ntohs(remoteaddr.sin6_port))));
+ (errmsg("RADIUS response was sent from incorrect port: %i",
+ ntohs(remoteaddr.sin6_port))));
#else
ereport(LOG,
- (errmsg("RADIUS response was sent from incorrect port: %i",
- ntohs(remoteaddr.sin_port))));
+ (errmsg("RADIUS response was sent from incorrect port: %i",
+ ntohs(remoteaddr.sin_port))));
#endif
continue;
}
*/
cryptvector = palloc(packetlength + strlen(port->hba->radiussecret));
- memcpy(cryptvector, receivepacket, 4); /* code+id+length */
- memcpy(cryptvector + 4, packet->vector, RADIUS_VECTOR_LENGTH); /* request
- * authenticator, from
- * original packet */
- if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no attributes
- * at all */
+ memcpy(cryptvector, receivepacket, 4); /* code+id+length */
+ memcpy(cryptvector + 4, packet->vector, RADIUS_VECTOR_LENGTH); /* request
+ * authenticator, from
+ * original packet */
+ if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no
+ * attributes at all */
memcpy(cryptvector + RADIUS_HEADER_LENGTH, receive_buffer + RADIUS_HEADER_LENGTH, packetlength - RADIUS_HEADER_LENGTH);
memcpy(cryptvector + packetlength, port->hba->radiussecret, strlen(port->hba->radiussecret));
encryptedpassword))
{
ereport(LOG,
- (errmsg("could not perform MD5 encryption of received packet")));
+ (errmsg("could not perform MD5 encryption of received packet")));
pfree(cryptvector);
continue;
}
else
{
ereport(LOG,
- (errmsg("RADIUS response has invalid code (%i) for user \"%s\"",
- receivepacket->code, port->user_name)));
+ (errmsg("RADIUS response has invalid code (%i) for user \"%s\"",
+ receivepacket->code, port->user_name)));
continue;
}
- } /* while (true) */
+ } /* while (true) */
}
}
static bool
-ipv4eq(struct sockaddr_in *a, struct sockaddr_in *b)
+ipv4eq(struct sockaddr_in * a, struct sockaddr_in * b)
{
return (a->sin_addr.s_addr == b->sin_addr.s_addr);
}
#ifdef HAVE_IPV6
static bool
-ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b)
+ipv6eq(struct sockaddr_in6 * a, struct sockaddr_in6 * b)
{
- int i;
+ int i;
for (i = 0; i < 16; i++)
if (a->sin6_addr.s6_addr[i] != b->sin6_addr.s6_addr[i])
return true;
}
-
-#endif /* HAVE_IPV6 */
+#endif /* HAVE_IPV6 */
/*
* Check whether host name matches pattern.
{
if (pattern[0] == '.') /* suffix match */
{
- size_t plen = strlen(pattern);
- size_t hlen = strlen(actual_hostname);
+ size_t plen = strlen(pattern);
+ size_t hlen = strlen(actual_hostname);
if (hlen < plen)
return false;
static bool
check_hostname(hbaPort *port, const char *hostname)
{
- struct addrinfo *gai_result, *gai;
+ struct addrinfo *gai_result,
+ *gai;
int ret;
bool found;
if (gai->ai_addr->sa_family == AF_INET)
{
if (ipv4eq((struct sockaddr_in *) gai->ai_addr,
- (struct sockaddr_in *) &port->raddr.addr))
+ (struct sockaddr_in *) & port->raddr.addr))
{
found = true;
break;
else if (gai->ai_addr->sa_family == AF_INET6)
{
if (ipv6eq((struct sockaddr_in6 *) gai->ai_addr,
- (struct sockaddr_in6 *) &port->raddr.addr))
+ (struct sockaddr_in6 *) & port->raddr.addr))
{
found = true;
break;
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("specifying both host name and CIDR mask is invalid: \"%s\"",
token),
- errcontext("line %d of configuration file \"%s\"",
- line_num, HbaFileName)));
+ errcontext("line %d of configuration file \"%s\"",
+ line_num, HbaFileName)));
pfree(token);
return false;
}
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
-#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
+#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
#include <mstcpip.h>
#endif
*/
/* --------------------------------
- * pq_set_nonblocking - set socket blocking/non-blocking
+ * pq_set_nonblocking - set socket blocking/non-blocking
*
* Sets the socket non-blocking if nonblocking is TRUE, or sets it
* blocking otherwise.
#ifdef WIN32
pgwin32_noblock = nonblocking ? 1 : 0;
#else
+
/*
- * Use COMMERROR on failure, because ERROR would try to send the error
- * to the client, which might require changing the mode again, leading
- * to infinite recursion.
+ * Use COMMERROR on failure, because ERROR would try to send the error to
+ * the client, which might require changing the mode again, leading to
+ * infinite recursion.
*/
if (nonblocking)
{
if (!pg_set_noblock(MyProcPort->sock))
ereport(COMMERROR,
- (errmsg("could not set socket to non-blocking mode: %m")));
+ (errmsg("could not set socket to non-blocking mode: %m")));
}
else
{
{
/*
* Ok if no data available without blocking or interrupted (though
- * EINTR really shouldn't happen with a non-blocking socket).
- * Report other errors.
+ * EINTR really shouldn't happen with a non-blocking socket). Report
+ * other errors.
*/
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
r = 0;
else
{
/*
- * Careful: an ereport() that tries to write to the client
- * would cause recursion to here, leading to stack overflow
- * and core dump! This message must go *only* to the
- * postmaster log.
+ * Careful: an ereport() that tries to write to the client would
+ * cause recursion to here, leading to stack overflow and core
+ * dump! This message must go *only* to the postmaster log.
*/
ereport(COMMERROR,
(errcode_for_socket_access(),
continue; /* Ok if we were interrupted */
/*
- * Ok if no data writable without blocking, and the socket
- * is in non-blocking mode.
+ * Ok if no data writable without blocking, and the socket is in
+ * non-blocking mode.
*/
if (errno == EAGAIN ||
errno == EWOULDBLOCK)
void
pq_putmessage_noblock(char msgtype, const char *s, size_t len)
{
- int res;
- int required;
+ int res;
+ int required;
/*
* Ensure we have enough space in the output buffer for the message header
PqSendBufferSize = required;
}
res = pq_putmessage(msgtype, s, len);
- Assert(res == 0); /* should not fail when the message fits in buffer */
+ Assert(res == 0); /* should not fail when the message fits in
+ * buffer */
}
static int
pq_setkeepaliveswin32(Port *port, int idle, int interval)
{
- struct tcp_keepalive ka;
- DWORD retsize;
+ struct tcp_keepalive ka;
+ DWORD retsize;
if (idle <= 0)
- idle = 2 * 60 * 60; /* default = 2 hours */
+ idle = 2 * 60 * 60; /* default = 2 hours */
if (interval <= 0)
- interval = 1; /* default = 1 second */
+ interval = 1; /* default = 1 second */
ka.onoff = 1;
ka.keepalivetime = idle * 1000;
elog(LOG, "getsockopt(TCP_KEEPALIVE) failed: %m");
port->default_keepalives_idle = -1; /* don't know */
}
-#endif /* TCP_KEEPIDLE */
-#else /* WIN32 */
+#endif /* TCP_KEEPIDLE */
+#else /* WIN32 */
/* We can't get the defaults on Windows, so return "don't know" */
port->default_keepalives_idle = -1;
-#endif /* WIN32 */
+#endif /* WIN32 */
}
return port->default_keepalives_idle;
#endif
port->keepalives_idle = idle;
-#else /* WIN32 */
+#else /* WIN32 */
return pq_setkeepaliveswin32(port, idle, port->keepalives_interval);
#endif
-#else /* TCP_KEEPIDLE || SIO_KEEPALIVE_VALS */
+#else /* TCP_KEEPIDLE || SIO_KEEPALIVE_VALS */
if (idle != 0)
{
elog(LOG, "setting the keepalive idle time is not supported");
#else
/* We can't get the defaults on Windows, so return "don't know" */
port->default_keepalives_interval = -1;
-#endif /* WIN32 */
+#endif /* WIN32 */
}
return port->default_keepalives_interval;
}
port->keepalives_interval = interval;
-#else /* WIN32 */
+#else /* WIN32 */
return pq_setkeepaliveswin32(port, port->keepalives_idle, interval);
#endif
#else
/*
* Place platform-specific startup hacks here. This is the right
* place to put code that must be executed early in the launch of any new
- * server process. Note that this code will NOT be executed when a backend
+ * server process. Note that this code will NOT be executed when a backend
* or sub-bootstrap process is forked, unless we are in a fork/exec
* environment (ie EXEC_BACKEND is defined).
*
/*
* On some platforms, unaligned memory accesses result in a kernel trap;
* the default kernel behavior is to emulate the memory access, but this
- * results in a significant performance penalty. We want PG never to
- * make such unaligned memory accesses, so this code disables the kernel
+ * results in a significant performance penalty. We want PG never to make
+ * such unaligned memory accesses, so this code disables the kernel
* emulation: unaligned accesses will result in SIGBUS instead.
*/
#ifdef NOFIXADE
#if defined(__alpha) /* no __alpha__ ? */
{
- int buffer[] = {SSIN_UACPROC, UAC_SIGBUS | UAC_NOPRINT};
+ int buffer[] = {SSIN_UACPROC, UAC_SIGBUS | UAC_NOPRINT};
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
(unsigned long) NULL) < 0)
progname, strerror(errno));
}
#endif /* __alpha */
-
#endif /* NOFIXADE */
/*
static FdwPlan *
_copyFdwPlan(FdwPlan *from)
{
- FdwPlan *newnode = makeNode(FdwPlan);
+ FdwPlan *newnode = makeNode(FdwPlan);
COPY_SCALAR_FIELD(startup_cost);
COPY_SCALAR_FIELD(total_cost);
static CollateExpr *
_copyCollateExpr(CollateExpr *from)
{
- CollateExpr *newnode = makeNode(CollateExpr);
+ CollateExpr *newnode = makeNode(CollateExpr);
COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(collOid);
static CollateClause *
_copyCollateClause(CollateClause *from)
{
- CollateClause *newnode = makeNode(CollateClause);
+ CollateClause *newnode = makeNode(CollateClause);
COPY_NODE_FIELD(arg);
COPY_NODE_FIELD(collname);
coll = ((NullIfExpr *) expr)->opcollid;
break;
case T_ScalarArrayOpExpr:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_BoolExpr:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_SubLink:
{
coll = ((FieldSelect *) expr)->resultcollid;
break;
case T_FieldStore:
- coll = InvalidOid; /* result is always composite */
+ coll = InvalidOid; /* result is always composite */
break;
case T_RelabelType:
coll = ((RelabelType *) expr)->resultcollid;
coll = ((ArrayCoerceExpr *) expr)->resultcollid;
break;
case T_ConvertRowtypeExpr:
- coll = InvalidOid; /* result is always composite */
+ coll = InvalidOid; /* result is always composite */
break;
case T_CollateExpr:
coll = ((CollateExpr *) expr)->collOid;
coll = ((ArrayExpr *) expr)->array_collid;
break;
case T_RowExpr:
- coll = InvalidOid; /* result is always composite */
+ coll = InvalidOid; /* result is always composite */
break;
case T_RowCompareExpr:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_CoalesceExpr:
coll = ((CoalesceExpr *) expr)->coalescecollid;
coll = ((MinMaxExpr *) expr)->minmaxcollid;
break;
case T_XmlExpr:
+
/*
* XMLSERIALIZE returns text from non-collatable inputs, so its
- * collation is always default. The other cases return boolean
- * or XML, which are non-collatable.
+ * collation is always default. The other cases return boolean or
+ * XML, which are non-collatable.
*/
if (((XmlExpr *) expr)->op == IS_XMLSERIALIZE)
coll = DEFAULT_COLLATION_OID;
coll = InvalidOid;
break;
case T_NullTest:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_BooleanTest:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_CoerceToDomain:
coll = ((CoerceToDomain *) expr)->resultcollid;
coll = ((SetToDefault *) expr)->collation;
break;
case T_CurrentOfExpr:
- coll = InvalidOid; /* result is always boolean */
+ coll = InvalidOid; /* result is always boolean */
break;
case T_PlaceHolderVar:
coll = exprCollation((Node *) ((PlaceHolderVar *) expr)->phexpr);
((NullIfExpr *) expr)->opcollid = collation;
break;
case T_ScalarArrayOpExpr:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_BoolExpr:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_SubLink:
#ifdef USE_ASSERT_CHECKING
Assert(!OidIsValid(collation));
}
}
-#endif /* USE_ASSERT_CHECKING */
+#endif /* USE_ASSERT_CHECKING */
break;
case T_FieldSelect:
((FieldSelect *) expr)->resultcollid = collation;
break;
case T_FieldStore:
- Assert(!OidIsValid(collation)); /* result is always composite */
+ Assert(!OidIsValid(collation)); /* result is always composite */
break;
case T_RelabelType:
((RelabelType *) expr)->resultcollid = collation;
((ArrayCoerceExpr *) expr)->resultcollid = collation;
break;
case T_ConvertRowtypeExpr:
- Assert(!OidIsValid(collation)); /* result is always composite */
+ Assert(!OidIsValid(collation)); /* result is always composite */
break;
case T_CaseExpr:
((CaseExpr *) expr)->casecollid = collation;
((ArrayExpr *) expr)->array_collid = collation;
break;
case T_RowExpr:
- Assert(!OidIsValid(collation)); /* result is always composite */
+ Assert(!OidIsValid(collation)); /* result is always composite */
break;
case T_RowCompareExpr:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_CoalesceExpr:
((CoalesceExpr *) expr)->coalescecollid = collation;
(collation == InvalidOid));
break;
case T_NullTest:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_BooleanTest:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
case T_CoerceToDomain:
((CoerceToDomain *) expr)->resultcollid = collation;
((SetToDefault *) expr)->collation = collation;
break;
case T_CurrentOfExpr:
- Assert(!OidIsValid(collation)); /* result is always boolean */
+ Assert(!OidIsValid(collation)); /* result is always boolean */
break;
default:
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
/* sizeof(ParamListInfoData) includes the first array element */
size = sizeof(ParamListInfoData) +
- (from->numParams - 1) *sizeof(ParamExternData);
+ (from->numParams - 1) * sizeof(ParamExternData);
retval = (ParamListInfo) palloc(size);
retval->paramFetch = NULL;
static void set_worktable_pathlist(PlannerInfo *root, RelOptInfo *rel,
RangeTblEntry *rte);
static void set_foreign_pathlist(PlannerInfo *root, RelOptInfo *rel,
- RangeTblEntry *rte);
+ RangeTblEntry *rte);
static RelOptInfo *make_rel_from_joinlist(PlannerInfo *root, List *joinlist);
static bool subquery_is_pushdown_safe(Query *subquery, Query *topquery,
bool *differentTypes);
/*
* We have to make child entries in the EquivalenceClass data
- * structures as well. This is needed either if the parent
- * participates in some eclass joins (because we will want to
- * consider inner-indexscan joins on the individual children)
- * or if the parent has useful pathkeys (because we should try
- * to build MergeAppend paths that produce those sort orderings).
+ * structures as well. This is needed either if the parent
+ * participates in some eclass joins (because we will want to consider
+ * inner-indexscan joins on the individual children) or if the parent
+ * has useful pathkeys (because we should try to build MergeAppend
+ * paths that produce those sort orderings).
*/
if (rel->has_eclass_joins || has_useful_pathkeys(root, rel))
add_child_rel_equivalences(root, appinfo, rel, childrel);
/* Have we already seen this ordering? */
foreach(lpk, all_child_pathkeys)
{
- List *existing_pathkeys = (List *) lfirst(lpk);
+ List *existing_pathkeys = (List *) lfirst(lpk);
if (compare_pathkeys(existing_pathkeys,
childkeys) == PATHKEYS_EQUAL)
/*
* Next, build MergeAppend paths based on the collected list of child
- * pathkeys. We consider both cheapest-startup and cheapest-total
- * cases, ie, for each interesting ordering, collect all the cheapest
- * startup subpaths and all the cheapest total paths, and build a
- * MergeAppend path for each list.
+ * pathkeys. We consider both cheapest-startup and cheapest-total cases,
+ * ie, for each interesting ordering, collect all the cheapest startup
+ * subpaths and all the cheapest total paths, and build a MergeAppend path
+ * for each list.
*/
foreach(l, all_child_pathkeys)
{
- List *pathkeys = (List *) lfirst(l);
- List *startup_subpaths = NIL;
- List *total_subpaths = NIL;
- bool startup_neq_total = false;
- ListCell *lcr;
+ List *pathkeys = (List *) lfirst(l);
+ List *startup_subpaths = NIL;
+ List *total_subpaths = NIL;
+ bool startup_neq_total = false;
+ ListCell *lcr;
/* Select the child paths for this ordering... */
foreach(lcr, live_childrels)
/*
* Notice whether we actually have different paths for the
- * "cheapest" and "total" cases; frequently there will be no
- * point in two create_merge_append_path() calls.
+ * "cheapest" and "total" cases; frequently there will be no point
+ * in two create_merge_append_path() calls.
*/
if (cheapest_startup != cheapest_total)
startup_neq_total = true;
{
if (IsA(path, AppendPath))
{
- AppendPath *apath = (AppendPath *) path;
+ AppendPath *apath = (AppendPath *) path;
/* list_copy is important here to avoid sharing list substructure */
return list_concat(subpaths, list_copy(apath->subpaths));
* accesses (XXX can't we refine that guess?)
*
* By default, we charge two operator evals per tuple comparison, which should
- * be in the right ballpark in most cases. The caller can tweak this by
+ * be in the right ballpark in most cases. The caller can tweak this by
* specifying nonzero comparison_cost; typically that's used for any extra
* work that has to be done to prepare the inputs to the comparison operators.
*
* Determines and returns the cost of a MergeAppend node.
*
* MergeAppend merges several pre-sorted input streams, using a heap that
- * at any given instant holds the next tuple from each stream. If there
+ * at any given instant holds the next tuple from each stream. If there
* are N streams, we need about N*log2(N) tuple comparisons to construct
* the heap at startup, and then for each output tuple, about log2(N)
* comparisons to delete the top heap entry and another log2(N) comparisons
List *nrclauses;
nrclauses = select_nonredundant_join_clauses(root,
- path->joinrestrictinfo,
+ path->joinrestrictinfo,
path->innerjoinpath);
*indexed_join_quals = (nrclauses == NIL);
}
/*
* Compute per-output-column width estimates by examining the subquery's
- * targetlist. For any output that is a plain Var, get the width estimate
+ * targetlist. For any output that is a plain Var, get the width estimate
* that was made while planning the subquery. Otherwise, fall back on a
* datatype-based estimate.
*/
if (IsA(texpr, Var) &&
subroot->parse->setOperations == NULL)
{
- Var *var = (Var *) texpr;
+ Var *var = (Var *) texpr;
RelOptInfo *subrel = find_base_rel(subroot, var->varno);
item_width = subrel->attr_widths[var->varattno - subrel->min_attr];
* of estimating baserestrictcost, so we set that, and we also set up width
* using what will be purely datatype-driven estimates from the targetlist.
* There is no way to do anything sane with the rows value, so we just put
- * a default estimate and hope that the wrapper can improve on it. The
+ * a default estimate and hope that the wrapper can improve on it. The
* wrapper's PlanForeignScan function will be called momentarily.
*
* The rel's targetlist and restrictinfo list must have been constructed
ndx = var->varattno - rel->min_attr;
/*
- * If it's a whole-row Var, we'll deal with it below after we
- * have already cached as many attr widths as possible.
+ * If it's a whole-row Var, we'll deal with it below after we have
+ * already cached as many attr widths as possible.
*/
if (var->varattno == 0)
{
}
/*
- * The width may have been cached already (especially if it's
- * a subquery), so don't duplicate effort.
+ * The width may have been cached already (especially if it's a
+ * subquery), so don't duplicate effort.
*/
if (rel->attr_widths[ndx] > 0)
{
*/
if (have_wholerow_var)
{
- int32 wholerow_width = sizeof(HeapTupleHeaderData);
+ int32 wholerow_width = sizeof(HeapTupleHeaderData);
if (reloid != InvalidOid)
{
/* Real relation, so estimate true tuple width */
wholerow_width += get_relation_data_width(reloid,
- rel->attr_widths - rel->min_attr);
+ rel->attr_widths - rel->min_attr);
}
else
{
rel->attr_widths[0 - rel->min_attr] = wholerow_width;
/*
- * Include the whole-row Var as part of the output tuple. Yes,
- * that really is what happens at runtime.
+ * Include the whole-row Var as part of the output tuple. Yes, that
+ * really is what happens at runtime.
*/
tuple_width += wholerow_width;
}
* Also, the expression's exposed collation must match the EC's collation.
* This is important because in comparisons like "foo < bar COLLATE baz",
* only one of the expressions has the correct exposed collation as we receive
- * it from the parser. Forcing both of them to have it ensures that all
+ * it from the parser. Forcing both of them to have it ensures that all
* variant spellings of such a construct behave the same. Again, we can
* stick on a RelabelType to force the right exposed collation. (It might
* work to not label the collation at all in EC members, but this is risky
exprCollation((Node *) expr) != req_collation)
{
/*
- * Strip any existing RelabelType, then add a new one if needed.
- * This is to preserve the invariant of no redundant RelabelTypes.
+ * Strip any existing RelabelType, then add a new one if needed. This
+ * is to preserve the invariant of no redundant RelabelTypes.
*
* If we have to change the exposed type of the stripped expression,
* set typmod to -1 (since the new type may not have the same typmod
- * interpretation). If we only have to change collation, preserve
- * the exposed typmod.
+ * interpretation). If we only have to change collation, preserve the
+ * exposed typmod.
*/
while (expr && IsA(expr, RelabelType))
expr = (Expr *) ((RelabelType *) expr)->arg;
ListCell *lc2;
/*
- * If this EC contains a constant, then it's not useful for sorting
- * or driving an inner index-scan, so we skip generating child EMs.
+ * If this EC contains a constant, then it's not useful for sorting or
+ * driving an inner index-scan, so we skip generating child EMs.
*
* If this EC contains a volatile expression, then generating child
* EMs would be downright dangerous. We rely on a volatile EC having
static Expr *expand_boolean_index_clause(Node *clause, int indexcol,
IndexOptInfo *index);
static List *expand_indexqual_opclause(RestrictInfo *rinfo,
- Oid opfamily, Oid idxcollation);
+ Oid opfamily, Oid idxcollation);
static RestrictInfo *expand_indexqual_rowcompare(RestrictInfo *rinfo,
IndexOptInfo *index,
int indexcol);
* (2) must contain an operator which is in the same family as the index
* operator for this column, or is a "special" operator as recognized
* by match_special_index_operator();
- * and
- * (3) must match the collation of the index, if collation is relevant.
+ * and
+ * (3) must match the collation of the index, if collation is relevant.
*
* Our definition of "const" is pretty liberal: we allow Vars belonging
* to the caller-specified outer_relids relations (which had better not
* is a "special" indexable operator.
*/
if (plain_op &&
- match_special_index_operator(clause, opfamily, idxcollation, true))
+ match_special_index_operator(clause, opfamily, idxcollation, true))
return true;
return false;
}
/****************************************************************************
- * ---- ROUTINES TO CHECK ORDERING OPERATORS ----
+ * ---- ROUTINES TO CHECK ORDERING OPERATORS ----
****************************************************************************/
/*
foreach(lc1, pathkeys)
{
- PathKey *pathkey = (PathKey *) lfirst(lc1);
+ PathKey *pathkey = (PathKey *) lfirst(lc1);
bool found = false;
ListCell *lc2;
foreach(lc2, pathkey->pk_eclass->ec_members)
{
EquivalenceMember *member = (EquivalenceMember *) lfirst(lc2);
- int indexcol;
+ int indexcol;
/* No possibility of match if it references other relations */
if (!bms_equal(member->em_relids, index->rel->relids))
for (indexcol = 0; indexcol < index->ncolumns; indexcol++)
{
- Expr *expr;
+ Expr *expr;
expr = match_clause_to_ordering_op(index,
indexcol,
* Note that we currently do not consider the collation of the ordering
* operator's result. In practical cases the result type will be numeric
* and thus have no collation, and it's not very clear what to match to
- * if it did have a collation. The index's collation should match the
+ * if it did have a collation. The index's collation should match the
* ordering operator's input collation, not its result.
*
* If successful, return 'clause' as-is if the indexkey is on the left,
return NULL;
/*
- * Is the (commuted) operator an ordering operator for the opfamily?
- * And if so, does it yield the right sorting semantics?
+ * Is the (commuted) operator an ordering operator for the opfamily? And
+ * if so, does it yield the right sorting semantics?
*/
sortfamily = get_op_opfamily_sortfamily(expr_op, opfamily);
if (sortfamily != pk_opfamily)
continue;
/*
- * XXX at some point we may need to check collations here
- * too. For the moment we assume all collations reduce to
- * the same notion of equality.
+ * XXX at some point we may need to check collations here too.
+ * For the moment we assume all collations reduce to the same
+ * notion of equality.
*/
/* OK, see if the condition operand matches the index key */
*
* The non-pattern opclasses will not sort the way we need in most non-C
* locales. We can use such an index anyway for an exact match (simple
- * equality), but not for prefix-match cases. Note that we are looking
- * at the index's collation, not the expression's collation -- this test
- * is not dependent on the LIKE/regex operator's collation (which would
- * only affect case folding behavior of ILIKE, anyway).
+ * equality), but not for prefix-match cases. Note that we are looking at
+ * the index's collation, not the expression's collation -- this test is
+ * not dependent on the LIKE/regex operator's collation (which would only
+ * affect case folding behavior of ILIKE, anyway).
*/
switch (expr_op)
{
resultquals = list_concat(resultquals,
expand_indexqual_opclause(rinfo,
curFamily,
- curCollation));
+ curCollation));
}
else if (IsA(clause, ScalarArrayOpExpr))
{
expr = make_opclause(opr1oid, BOOLOID, false,
(Expr *) leftop,
(Expr *) makeConst(datatype, -1,
- InvalidOid, /* not collatable */
+ InvalidOid, /* not collatable */
-1, opr1right,
false, false),
InvalidOid, InvalidOid);
expr = make_opclause(opr2oid, BOOLOID, false,
(Expr *) leftop,
(Expr *) makeConst(datatype, -1,
- InvalidOid, /* not collatable */
+ InvalidOid, /* not collatable */
-1, opr2right,
false, false),
InvalidOid, InvalidOid);
/*
* 1. Consider mergejoin paths where both relations must be explicitly
- * sorted. Skip this if we can't mergejoin.
+ * sorted. Skip this if we can't mergejoin.
*/
if (mergejoin_allowed)
sort_inner_and_outer(root, joinrel, outerrel, innerrel,
- restrictlist, mergeclause_list, jointype, sjinfo);
+ restrictlist, mergeclause_list, jointype, sjinfo);
/*
* 2. Consider paths where the outer relation need not be explicitly
*/
if (mergejoin_allowed)
match_unsorted_outer(root, joinrel, outerrel, innerrel,
- restrictlist, mergeclause_list, jointype, sjinfo);
+ restrictlist, mergeclause_list, jointype, sjinfo);
#ifdef NOT_USED
*/
if (mergejoin_allowed)
match_unsorted_inner(root, joinrel, outerrel, innerrel,
- restrictlist, mergeclause_list, jointype, sjinfo);
+ restrictlist, mergeclause_list, jointype, sjinfo);
#endif
/*
static bool is_dummy_rel(RelOptInfo *rel);
static void mark_dummy_rel(RelOptInfo *rel);
static bool restriction_is_constant_false(List *restrictlist,
- bool only_pushed_down);
+ bool only_pushed_down);
/*
*
* Also, a provably constant-false join restriction typically means that
* we can skip evaluating one or both sides of the join. We do this by
- * marking the appropriate rel as dummy. For outer joins, a constant-false
- * restriction that is pushed down still means the whole join is dummy,
- * while a non-pushed-down one means that no inner rows will join so we
- * can treat the inner rel as dummy.
+ * marking the appropriate rel as dummy. For outer joins, a
+ * constant-false restriction that is pushed down still means the whole
+ * join is dummy, while a non-pushed-down one means that no inner rows
+ * will join so we can treat the inner rel as dummy.
*
* We need only consider the jointypes that appear in join_info_list, plus
* JOIN_INNER.
/*
* EquivalenceClasses need to contain opfamily lists based on the family
* membership of mergejoinable equality operators, which could belong to
- * more than one opfamily. So we have to look up the opfamily's equality
+ * more than one opfamily. So we have to look up the opfamily's equality
* operator and get its membership.
*/
equality_op = get_opfamily_member(opfamily,
true);
/*
- * If the sort key isn't already present in any EquivalenceClass,
- * then it's not an interesting sort order for this query. So
- * we can stop now --- lower-order sort keys aren't useful either.
+ * If the sort key isn't already present in any EquivalenceClass, then
+ * it's not an interesting sort order for this query. So we can stop
+ * now --- lower-order sort keys aren't useful either.
*/
if (!cpathkey)
break;
continue;
/*
- * Build a representation of this targetlist entry as
- * an outer Var.
+ * Build a representation of this targetlist entry as an
+ * outer Var.
*/
outer_expr = (Expr *) makeVarFromTargetEntry(rel->relid,
tle);
* right sides.
*
* Note this is called before EC merging is complete, so the links won't
- * necessarily point to canonical ECs. Before they are actually used for
+ * necessarily point to canonical ECs. Before they are actually used for
* anything, update_mergeclause_eclasses must be called to ensure that
* they've been updated to point to canonical ECs.
*/
/* local functions */
static bool join_is_removable(PlannerInfo *root, SpecialJoinInfo *sjinfo);
static void remove_rel_from_query(PlannerInfo *root, int relid,
- Relids joinrelids);
+ Relids joinrelids);
static List *remove_rel_from_joinlist(List *joinlist, int relid, int *nremoved);
!bms_equal(restrictinfo->required_relids, joinrelids))
{
/*
- * If such a clause actually references the inner rel then
- * join removal has to be disallowed. We have to check this
- * despite the previous attr_needed checks because of the
- * possibility of pushed-down clauses referencing the rel.
+ * If such a clause actually references the inner rel then join
+ * removal has to be disallowed. We have to check this despite
+ * the previous attr_needed checks because of the possibility of
+ * pushed-down clauses referencing the rel.
*/
if (bms_is_member(innerrelid, restrictinfo->clause_relids))
return false;
* Likewise remove references from SpecialJoinInfo data structures.
*
* This is relevant in case the outer join we're deleting is nested inside
- * other outer joins: the upper joins' relid sets have to be adjusted.
- * The RHS of the target outer join will be made empty here, but that's OK
+ * other outer joins: the upper joins' relid sets have to be adjusted. The
+ * RHS of the target outer join will be made empty here, but that's OK
* since caller will delete that SpecialJoinInfo entirely.
*/
foreach(l, root->join_info_list)
{
/* Recheck that qual doesn't actually reference the target rel */
Assert(!bms_is_member(relid, rinfo->clause_relids));
+
/*
* The required_relids probably aren't shared with anything else,
* but let's copy them just to be sure.
List *tidquals);
static FunctionScan *make_functionscan(List *qptlist, List *qpqual,
Index scanrelid, Node *funcexpr, List *funccolnames,
- List *funccoltypes, List *funccoltypmods, List *funccolcollations);
+ List *funccoltypes, List *funccoltypmods, List *funccolcollations);
static ValuesScan *make_valuesscan(List *qptlist, List *qpqual,
Index scanrelid, List *values_lists);
static CteScan *make_ctescan(List *qptlist, List *qpqual,
bool *mergenullsfirst,
Plan *lefttree, Plan *righttree,
JoinType jointype);
-static Sort *make_sort(PlannerInfo *root, Plan *lefttree, int numCols,
- AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst,
+static Sort *
+make_sort(PlannerInfo *root, Plan *lefttree, int numCols,
+AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst,
double limit_tuples);
static Plan *prepare_sort_from_pathkeys(PlannerInfo *root,
- Plan *lefttree, List *pathkeys,
- bool adjust_tlist_in_place,
- int *p_numsortkeys,
- AttrNumber **p_sortColIdx,
- Oid **p_sortOperators,
- Oid **p_collations,
- bool **p_nullsFirst);
+ Plan *lefttree, List *pathkeys,
+ bool adjust_tlist_in_place,
+ int *p_numsortkeys,
+ AttrNumber **p_sortColIdx,
+ Oid **p_sortOperators,
+ Oid **p_collations,
+ bool **p_nullsFirst);
static Material *make_material(Plan *lefttree);
/*
* create_plan
* Creates the access plan for a query by recursively processing the
- * desired tree of pathnodes, starting at the node 'best_path'. For
+ * desired tree of pathnodes, starting at the node 'best_path'. For
* every pathnode found, we create a corresponding plan node containing
* appropriate id, target list, and qualification information.
*
/* Now, insert a Sort node if subplan isn't sufficiently ordered */
if (!pathkeys_contained_in(pathkeys, subpath->pathkeys))
subplan = (Plan *) make_sort(root, subplan, numsortkeys,
- sortColIdx, sortOperators, collations, nullsFirst,
+ sortColIdx, sortOperators, collations, nullsFirst,
best_path->limit_tuples);
subplans = lappend(subplans, subplan);
sortcl->eqop = eqop;
sortcl->sortop = sortop;
sortcl->nulls_first = false;
- sortcl->hashable = false; /* no need to make this accurate */
+ sortcl->hashable = false; /* no need to make this accurate */
sortList = lappend(sortList, sortcl);
groupColPos++;
}
qpqual = extract_actual_clauses(qpqual, false);
/*
- * We have to replace any outer-relation variables with nestloop params
- * in the indexqualorig, qpqual, and indexorderbyorig expressions. A bit
+ * We have to replace any outer-relation variables with nestloop params in
+ * the indexqualorig, qpqual, and indexorderbyorig expressions. A bit
* annoying to have to do this separately from the processing in
* fix_indexqual_references --- rethink this when generalizing the inner
* indexscan support. But note we can't really do this earlier because
*indexqual = lappend(*indexqual, pred);
}
}
+
/*
* Replace outer-relation variables with nestloop params, but only
* after doing the above comparisons to index predicates.
return NULL;
if (IsA(node, Var))
{
- Var *var = (Var *) node;
- Param *param;
+ Var *var = (Var *) node;
+ Param *param;
NestLoopParam *nlp;
- ListCell *lc;
+ ListCell *lc;
/* Upper-level Vars should be long gone at this point */
Assert(var->varlevelsup == 0);
*
* This is a simplified version of fix_indexqual_references. The input does
* not have RestrictInfo nodes, and we assume that indxqual.c already
- * commuted the clauses to put the index keys on the left. Also, we don't
+ * commuted the clauses to put the index keys on the left. Also, we don't
* bother to support any cases except simple OpExprs, since nothing else
* is allowed for ordering operators.
*/
* If you change this, see also create_append_path(). Also, the size
* calculations should match set_append_rel_pathlist(). It'd be better
* not to duplicate all this logic, but some callers of this function
- * aren't working from an appendrel or AppendPath, so there's noplace
- * to copy the data from.
+ * aren't working from an appendrel or AppendPath, so there's noplace to
+ * copy the data from.
*/
plan->startup_cost = 0;
plan->total_cost = 0;
*/
static Sort *
make_sort(PlannerInfo *root, Plan *lefttree, int numCols,
- AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst,
+AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst,
double limit_tuples)
{
Sort *node = makeNode(Sort);
* prepare_sort_from_pathkeys
* Prepare to sort according to given pathkeys
*
- * This is used to set up for both Sort and MergeAppend nodes. It calculates
+ * This is used to set up for both Sort and MergeAppend nodes. It calculates
* the executor's representation of the sort key information, and adjusts the
* plan targetlist if needed to add resjunk sort columns.
*
pathkey->pk_eclass->ec_collation,
pathkey->pk_nulls_first,
numsortkeys,
- sortColIdx, sortOperators, collations, nullsFirst);
+ sortColIdx, sortOperators, collations, nullsFirst);
}
Assert(numsortkeys > 0);
/* Now build the Sort node */
return make_sort(root, lefttree, numsortkeys,
- sortColIdx, sortOperators, collations, nullsFirst, limit_tuples);
+ sortColIdx, sortOperators, collations, nullsFirst, limit_tuples);
}
/*
exprCollation((Node *) tle->expr),
sortcl->nulls_first,
numsortkeys,
- sortColIdx, sortOperators, collations, nullsFirst);
+ sortColIdx, sortOperators, collations, nullsFirst);
}
Assert(numsortkeys > 0);
exprCollation((Node *) tle->expr),
grpcl->nulls_first,
numsortkeys,
- sortColIdx, sortOperators, collations, nullsFirst);
+ sortColIdx, sortOperators, collations, nullsFirst);
grpno++;
}
phinfo->ph_needed = bms_add_members(phinfo->ph_needed,
where_needed);
+
/*
- * Update ph_may_need too. This is currently only necessary
- * when being called from build_base_rel_tlists, but we may as
- * well do it always.
+ * Update ph_may_need too. This is currently only necessary when
+ * being called from build_base_rel_tlists, but we may as well do
+ * it always.
*/
phinfo->ph_may_need = bms_add_members(phinfo->ph_may_need,
where_needed);
* this join's nullable side, and it may get used above this join, then
* ensure that min_righthand contains the full eval_at set of the PHV.
* This ensures that the PHV actually can be evaluated within the RHS.
- * Note that this works only because we should already have determined
- * the final eval_at level for any PHV syntactically within this join.
+ * Note that this works only because we should already have determined the
+ * final eval_at level for any PHV syntactically within this join.
*/
foreach(l, root->placeholder_list)
{
*
* In all cases, it's important to initialize the left_ec and right_ec
* fields of a mergejoinable clause, so that all possibly mergejoinable
- * expressions have representations in EquivalenceClasses. If
+ * expressions have representations in EquivalenceClasses. If
* process_equivalence is successful, it will take care of that;
* otherwise, we have to call initialize_mergeclause_eclasses to do it.
*/
* ORDER BY col ASC/DESC
* LIMIT 1)
* Given a suitable index on tab.col, this can be much faster than the
- * generic scan-all-the-rows aggregation plan. We can handle multiple
+ * generic scan-all-the-rows aggregation plan. We can handle multiple
* MIN/MAX aggregates by generating multiple subqueries, and their
- * orderings can be different. However, if the query contains any
+ * orderings can be different. However, if the query contains any
* non-optimizable aggregates, there's no point since we'll have to
* scan all the rows anyway.
*
*
* We don't handle GROUP BY or windowing, because our current
* implementations of grouping require looking at all the rows anyway, and
- * so there's not much point in optimizing MIN/MAX. (Note: relaxing
- * this would likely require some restructuring in grouping_planner(),
- * since it performs assorted processing related to these features between
- * calling preprocess_minmax_aggregates and optimize_minmax_aggregates.)
+ * so there's not much point in optimizing MIN/MAX. (Note: relaxing this
+ * would likely require some restructuring in grouping_planner(), since it
+ * performs assorted processing related to these features between calling
+ * preprocess_minmax_aggregates and optimize_minmax_aggregates.)
*/
if (parse->groupClause || parse->hasWindowFuncs)
return;
/*
* Scan the tlist and HAVING qual to find all the aggregates and verify
- * all are MIN/MAX aggregates. Stop as soon as we find one that isn't.
+ * all are MIN/MAX aggregates. Stop as soon as we find one that isn't.
*/
aggs_list = NIL;
if (find_minmax_aggs_walker((Node *) tlist, &aggs_list))
* ordering operator.
*/
eqop = get_equality_op_for_ordering_op(mminfo->aggsortop, &reverse);
- if (!OidIsValid(eqop)) /* shouldn't happen */
+ if (!OidIsValid(eqop)) /* shouldn't happen */
elog(ERROR, "could not find equality operator for ordering operator %u",
mminfo->aggsortop);
* We can use either an ordering that gives NULLS FIRST or one that
* gives NULLS LAST; furthermore there's unlikely to be much
* performance difference between them, so it doesn't seem worth
- * costing out both ways if we get a hit on the first one. NULLS
+ * costing out both ways if we get a hit on the first one. NULLS
* FIRST is more likely to be available if the operator is a
* reverse-sort operator, so try that first if reverse.
*/
/*
* We're done until path generation is complete. Save info for later.
- * (Setting root->minmax_aggs non-NIL signals we succeeded in making
- * index access paths for all the aggregates.)
+ * (Setting root->minmax_aggs non-NIL signals we succeeded in making index
+ * access paths for all the aggregates.)
*/
root->minmax_aggs = aggs_list;
}
mminfo->aggfnoid = aggref->aggfnoid;
mminfo->aggsortop = aggsortop;
mminfo->target = curTarget->expr;
- mminfo->subroot = NULL; /* don't compute path yet */
+ mminfo->subroot = NULL; /* don't compute path yet */
mminfo->path = NULL;
mminfo->pathcost = 0;
mminfo->param = NULL;
sortcl->eqop = eqop;
sortcl->sortop = sortop;
sortcl->nulls_first = nulls_first;
- sortcl->hashable = false; /* no need to make this accurate */
+ sortcl->hashable = false; /* no need to make this accurate */
parse->sortClause = list_make1(sortcl);
/* set up expressions for LIMIT 1 */
subroot->query_pathkeys = subroot->sort_pathkeys;
/*
- * Generate the best paths for this query, telling query_planner that
- * we have LIMIT 1.
+ * Generate the best paths for this query, telling query_planner that we
+ * have LIMIT 1.
*/
query_planner(subroot, parse->targetList, 1.0, 1.0,
&cheapest_path, &sorted_path, &dNumGroups);
exprCollation((Node *) mminfo->target));
/*
- * Make sure the initplan gets into the outer PlannerInfo, along with
- * any other initplans generated by the sub-planning run. We had to
- * include the outer PlannerInfo's pre-existing initplans into the
- * inner one's init_plans list earlier, so make sure we don't put back
- * any duplicate entries.
+ * Make sure the initplan gets into the outer PlannerInfo, along with any
+ * other initplans generated by the sub-planning run. We had to include
+ * the outer PlannerInfo's pre-existing initplans into the inner one's
+ * init_plans list earlier, so make sure we don't put back any duplicate
+ * entries.
*/
root->init_plans = list_concat_unique_ptr(root->init_plans,
subroot->init_plans);
/*
* Examine the targetlist and join tree, adding entries to baserel
* targetlists for all referenced Vars, and generating PlaceHolderInfo
- * entries for all referenced PlaceHolderVars. Restrict and join clauses
- * are added to appropriate lists belonging to the mentioned relations.
- * We also build EquivalenceClasses for provably equivalent expressions.
- * The SpecialJoinInfo list is also built to hold information about join
- * order restrictions. Finally, we form a target joinlist for
- * make_one_rel() to work from.
+ * entries for all referenced PlaceHolderVars. Restrict and join clauses
+ * are added to appropriate lists belonging to the mentioned relations. We
+ * also build EquivalenceClasses for provably equivalent expressions. The
+ * SpecialJoinInfo list is also built to hold information about join order
+ * restrictions. Finally, we form a target joinlist for make_one_rel() to
+ * work from.
*/
build_base_rel_tlists(root, tlist);
/*
* Examine any "placeholder" expressions generated during subquery pullup.
* Make sure that the Vars they need are marked as needed at the relevant
- * join level. This must be done before join removal because it might
+ * join level. This must be done before join removal because it might
* cause Vars or placeholders to be needed above a join when they weren't
* so marked before.
*/
inline_set_returning_functions(root);
/*
- * Check to see if any subqueries in the jointree can be merged into
- * this query.
+ * Check to see if any subqueries in the jointree can be merged into this
+ * query.
*/
parse->jointree = (FromExpr *)
pull_up_subqueries(root, (Node *) parse->jointree, NULL, NULL);
/*
- * If this is a simple UNION ALL query, flatten it into an appendrel.
- * We do this now because it requires applying pull_up_subqueries to the
- * leaf queries of the UNION ALL, which weren't touched above because they
+ * If this is a simple UNION ALL query, flatten it into an appendrel. We
+ * do this now because it requires applying pull_up_subqueries to the leaf
+ * queries of the UNION ALL, which weren't touched above because they
* weren't referenced by the jointree (they will be after we do this).
*/
if (parse->setOperations)
plan = (Plan *) make_modifytable(parse->commandType,
parse->canSetTag,
- list_make1_int(parse->resultRelation),
+ list_make1_int(parse->resultRelation),
list_make1(plan),
returningLists,
rowMarks,
/*
* Determine eval cost of the index expressions, if any. We need to
- * charge twice that amount for each tuple comparison that happens
- * during the sort, since tuplesort.c will have to re-evaluate the
- * index expressions each time. (XXX that's pretty inefficient...)
+ * charge twice that amount for each tuple comparison that happens during
+ * the sort, since tuplesort.c will have to re-evaluate the index
+ * expressions each time. (XXX that's pretty inefficient...)
*/
cost_qual_eval(&indexExprCost, indexInfo->indexprs, root);
comparisonCost = 2.0 * (indexExprCost.startup + indexExprCost.per_tuple);
*
* If a query's setOperations tree consists entirely of simple UNION ALL
* operations, flatten it into an append relation, which we can process more
- * intelligently than the general setops case. Otherwise, do nothing.
+ * intelligently than the general setops case. Otherwise, do nothing.
*
* In most cases, this can succeed only for a top-level query, because for a
* subquery in FROM, the parent query's invocation of pull_up_subqueries would
/*
* Make a copy of the leftmost RTE and add it to the rtable. This copy
- * will represent the leftmost leaf query in its capacity as a member
- * of the appendrel. The original will represent the appendrel as a
- * whole. (We must do things this way because the upper query's Vars
- * have to be seen as referring to the whole appendrel.)
+ * will represent the leftmost leaf query in its capacity as a member of
+ * the appendrel. The original will represent the appendrel as a whole.
+ * (We must do things this way because the upper query's Vars have to be
+ * seen as referring to the whole appendrel.)
*/
childRTE = copyObject(leftmostRTE);
parse->rtable = lappend(parse->rtable, childRTE);
parse->jointree->fromlist = list_make1(rtr);
/*
- * Now pretend the query has no setops. We must do this before trying
- * to do subquery pullup, because of Assert in pull_up_simple_subquery.
+ * Now pretend the query has no setops. We must do this before trying to
+ * do subquery pullup, because of Assert in pull_up_simple_subquery.
*/
parse->setOperations = NULL;
* never both, to the children of an outer join.
*
* Note that a SEMI join works like an inner join here: it's okay
- * to pass down both local and upper constraints. (There can't
- * be any upper constraints affecting its inner side, but it's
- * not worth having a separate code path to avoid passing them.)
+ * to pass down both local and upper constraints. (There can't be
+ * any upper constraints affecting its inner side, but it's not
+ * worth having a separate code path to avoid passing them.)
*
* At a FULL join we just punt and pass nothing down --- is it
* possible to be smarter?
pass_nonnullable_vars = local_nonnullable_vars;
pass_forced_null_vars = local_forced_null_vars;
}
- else if (jointype != JOIN_FULL) /* ie, LEFT or ANTI */
+ else if (jointype != JOIN_FULL) /* ie, LEFT or ANTI */
{
/* can't pass local constraints to non-nullable side */
pass_nonnullable_rels = nonnullable_rels;
* Although this can be invoked on its own, it's mainly intended as a helper
* for eval_const_expressions(), and that context drives several design
* decisions. In particular, if the input is already AND/OR flat, we must
- * preserve that property. We also don't bother to recurse in situations
+ * preserve that property. We also don't bother to recurse in situations
* where we can assume that lower-level executions of eval_const_expressions
* would already have simplified sub-clauses of the input.
*
* The difference between this and a simple make_notclause() is that this
- * tries to get rid of the NOT node by logical simplification. It's clearly
+ * tries to get rid of the NOT node by logical simplification. It's clearly
* always a win if the NOT node can be eliminated altogether. However, our
* use of DeMorgan's laws could result in having more NOT nodes rather than
* fewer. We do that unconditionally anyway, because in WHERE clauses it's
switch (expr->boolop)
{
- /*--------------------
- * Apply DeMorgan's Laws:
- * (NOT (AND A B)) => (OR (NOT A) (NOT B))
- * (NOT (OR A B)) => (AND (NOT A) (NOT B))
- * i.e., swap AND for OR and negate each subclause.
- *
- * If the input is already AND/OR flat and has no NOT
- * directly above AND or OR, this transformation preserves
- * those properties. For example, if no direct child of
- * the given AND clause is an AND or a NOT-above-OR, then
- * the recursive calls of negate_clause() can't return any
- * OR clauses. So we needn't call pull_ors() before
- * building a new OR clause. Similarly for the OR case.
- *--------------------
- */
+ /*--------------------
+ * Apply DeMorgan's Laws:
+ * (NOT (AND A B)) => (OR (NOT A) (NOT B))
+ * (NOT (OR A B)) => (AND (NOT A) (NOT B))
+ * i.e., swap AND for OR and negate each subclause.
+ *
+ * If the input is already AND/OR flat and has no NOT
+ * directly above AND or OR, this transformation preserves
+ * those properties. For example, if no direct child of
+ * the given AND clause is an AND or a NOT-above-OR, then
+ * the recursive calls of negate_clause() can't return any
+ * OR clauses. So we needn't call pull_ors() before
+ * building a new OR clause. Similarly for the OR case.
+ *--------------------
+ */
case AND_EXPR:
{
List *nargs = NIL;
}
break;
case NOT_EXPR:
+
/*
* NOT underneath NOT: they cancel. We assume the
* input is already simplified, so no need to recurse.
break;
case T_BooleanTest:
{
- BooleanTest *expr = (BooleanTest *) node;
- BooleanTest *newexpr = makeNode(BooleanTest);
+ BooleanTest *expr = (BooleanTest *) node;
+ BooleanTest *newexpr = makeNode(BooleanTest);
newexpr->arg = expr->arg;
switch (expr->booltesttype)
* Routines to preprocess the parse tree target list
*
* For INSERT and UPDATE queries, the targetlist must contain an entry for
- * each attribute of the target relation in the correct order. For all query
+ * each attribute of the target relation in the correct order. For all query
* types, we may need to add junk tlist entries for Vars used in the RETURNING
* list and row ID information needed for EvalPlanQual checking.
*
/*
* Add necessary junk columns for rowmarked rels. These values are needed
* for locking of rels selected FOR UPDATE/SHARE, and to do EvalPlanQual
- * rechecking. See comments for PlanRowMark in plannodes.h.
+ * rechecking. See comments for PlanRowMark in plannodes.h.
*/
foreach(lc, root->rowMarks)
{
* The Vars are always generated with varno 0.
*/
static List *
-generate_append_tlist(List *colTypes, List*colCollations, bool flag,
+generate_append_tlist(List *colTypes, List *colCollations, bool flag,
List *input_plans,
List *refnames_tlist)
{
*
* Whenever a function is eliminated from the expression by means of
* constant-expression evaluation or inlining, we add the function to
- * root->glob->invalItems. This ensures the plan is known to depend on
+ * root->glob->invalItems. This ensures the plan is known to depend on
* such functions, even though they aren't referenced anymore.
*
* We assume that the tree has already been type-checked and contains
context);
/*
- * Use negate_clause() to see if we can simplify away
- * the NOT.
+ * Use negate_clause() to see if we can simplify away the
+ * NOT.
*/
return negate_clause(arg);
}
makeConst(OIDOID, -1, InvalidOid, sizeof(Oid),
ObjectIdGetDatum(intypioparam),
false, true),
- makeConst(INT4OID, -1, InvalidOid, sizeof(int32),
- Int32GetDatum(-1),
- false, true));
+ makeConst(INT4OID, -1, InvalidOid, sizeof(int32),
+ Int32GetDatum(-1),
+ false, true));
simple = simplify_function(infunc,
expr->resulttype, -1,
/*
* If we can simplify the input to a constant, then we don't need the
* CollateExpr node at all: just change the constcollid field of the
- * Const node. Otherwise, replace the CollateExpr with a RelabelType.
- * (We do that so as to improve uniformity of expression representation
- * and thus simplify comparison of expressions.)
+ * Const node. Otherwise, replace the CollateExpr with a RelabelType.
+ * (We do that so as to improve uniformity of expression
+ * representation and thus simplify comparison of expressions.)
*/
CollateExpr *collate = (CollateExpr *) node;
Node *arg;
* placeholder nodes, so that we have the opportunity to reduce
* constant test conditions. For example this allows
* CASE 0 WHEN 0 THEN 1 ELSE 1/0 END
- * to reduce to 1 rather than drawing a divide-by-0 error. Note
+ * to reduce to 1 rather than drawing a divide-by-0 error. Note
* that when the test expression is constant, we don't have to
* include it in the resulting CASE; for example
* CASE 0 WHEN x THEN y ELSE z END
/*
* We can remove null constants from the list. For a non-null
* constant, if it has not been preceded by any other
- * non-null-constant expressions then it is the result. Otherwise,
- * it's the next argument, but we can drop following arguments
- * since they will never be reached.
+ * non-null-constant expressions then it is the result.
+ * Otherwise, it's the next argument, but we can drop following
+ * arguments since they will never be reached.
*/
if (IsA(e, Const))
{
if (DatumGetBool(((Const *) leftop)->constvalue))
return rightop; /* true = foo */
else
- return negate_clause(rightop); /* false = foo */
+ return negate_clause(rightop); /* false = foo */
}
else
{
if (DatumGetBool(((Const *) leftop)->constvalue))
- return negate_clause(rightop); /* true <> foo */
+ return negate_clause(rightop); /* true <> foo */
else
return rightop; /* false <> foo */
}
fexpr->funcresulttype = result_type;
fexpr->funcretset = false;
fexpr->funcformat = COERCE_DONTCARE; /* doesn't matter */
- fexpr->funccollid = result_collid; /* doesn't matter */
+ fexpr->funccollid = result_collid; /* doesn't matter */
fexpr->inputcollid = input_collid;
fexpr->args = args;
fexpr->location = -1;
MemoryContextDelete(mycxt);
/*
- * If the result is of a collatable type, force the result to expose
- * the correct collation. In most cases this does not matter, but
- * it's possible that the function result is used directly as a sort key
- * or in other places where we expect exprCollation() to tell the truth.
+ * If the result is of a collatable type, force the result to expose the
+ * correct collation. In most cases this does not matter, but it's
+ * possible that the function result is used directly as a sort key or in
+ * other places where we expect exprCollation() to tell the truth.
*/
if (OidIsValid(result_collid))
{
- Oid exprcoll = exprCollation(newexpr);
+ Oid exprcoll = exprCollation(newexpr);
if (OidIsValid(exprcoll) && exprcoll != result_collid)
{
- CollateExpr *newnode = makeNode(CollateExpr);
+ CollateExpr *newnode = makeNode(CollateExpr);
newnode->arg = (Expr *) newexpr;
newnode->collOid = result_collid;
oldcxt = MemoryContextSwitchTo(mycxt);
/*
- * When we call eval_const_expressions below, it might try to add items
- * to root->glob->invalItems. Since it is running in the temp context,
- * those items will be in that context, and will need to be copied out
- * if we're successful. Temporarily reset the list so that we can keep
- * those items separate from the pre-existing list contents.
+ * When we call eval_const_expressions below, it might try to add items to
+ * root->glob->invalItems. Since it is running in the temp context, those
+ * items will be in that context, and will need to be copied out if we're
+ * successful. Temporarily reset the list so that we can keep those items
+ * separate from the pre-existing list contents.
*/
saveInvalItems = root->glob->invalItems;
root->glob->invalItems = NIL;
goto fail;
/*
- * Set up to handle parameters while parsing the function body. We
- * can use the FuncExpr just created as the input for
+ * Set up to handle parameters while parsing the function body. We can
+ * use the FuncExpr just created as the input for
* prepare_sql_fn_parse_info.
*/
pinfo = prepare_sql_fn_parse_info(func_tuple,
querytree_list = pg_analyze_and_rewrite_params(linitial(raw_parsetree_list),
src,
- (ParserSetupHook) sql_fn_parser_setup,
+ (ParserSetupHook) sql_fn_parser_setup,
pinfo);
if (list_length(querytree_list) != 1)
goto fail;
ReleaseSysCache(func_tuple);
/*
- * We don't have to fix collations here because the upper query is
- * already parsed, ie, the collations in the RTE are what count.
+ * We don't have to fix collations here because the upper query is already
+ * parsed, ie, the collations in the RTE are what count.
*/
/*
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,
ForeignPath *pathnode = makeNode(ForeignPath);
RangeTblEntry *rte;
FdwRoutine *fdwroutine;
- FdwPlan *fdwplan;
+ FdwPlan *fdwplan;
pathnode->path.pathtype = T_ForeignScan;
pathnode->path.parent = rel;
- pathnode->path.pathkeys = NIL; /* result is always unordered */
+ pathnode->path.pathkeys = NIL; /* result is always unordered */
/* Get FDW's callback info */
rte = planner_rt_fetch(rel->relid, root);
/* Local functions */
static Relids find_placeholders_recurse(PlannerInfo *root, Node *jtnode);
static void find_placeholders_in_qual(PlannerInfo *root, Node *qual,
- Relids relids);
+ Relids relids);
/*
{
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(jtnode));
- jtrelids = NULL; /* keep compiler quiet */
+ jtrelids = NULL; /* keep compiler quiet */
}
return jtrelids;
}
else if (OidIsValid(clause_op_negator))
{
clause_tuple = SearchSysCache3(AMOPOPID,
- ObjectIdGetDatum(clause_op_negator),
+ ObjectIdGetDatum(clause_op_negator),
CharGetDatum(AMOP_SEARCH),
ObjectIdGetDatum(opfamily_id));
if (HeapTupleIsValid(clause_tuple))
* entries might now be arbitrary expressions, not just Vars. This affects
* this function in one important way: we might find ourselves inserting
* SubLink expressions into subqueries, and we must make sure that their
- * Query.hasSubLinks fields get set to TRUE if so. If there are any
+ * Query.hasSubLinks fields get set to TRUE if so. If there are any
* SubLinks in the join alias lists, the outer Query should already have
* hasSubLinks = TRUE, so this is only relevant to un-flattened subqueries.
*
* columns. Add a suitable hint if that seems to be the problem,
* because the main error message is quite misleading for this case.
* (If there's no stmtcols, you'll get something about data type
- * mismatch, which is less misleading so we don't worry about giving
- * a hint in that case.)
+ * mismatch, which is less misleading so we don't worry about giving a
+ * hint in that case.)
*/
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
* return -1 if expression isn't a RowExpr or a Var referencing one.
*
* This is currently used only for hint purposes, so we aren't terribly
- * tense about recognizing all possible cases. The Var case is interesting
+ * tense about recognizing all possible cases. The Var case is interesting
* because that's what we'll get in the INSERT ... SELECT (...) case.
*/
static int
/*
* We must assign collations now because assign_query_collations
* doesn't process rangetable entries. We just assign all the
- * collations independently in each row, and don't worry about
- * whether they are consistent vertically either.
+ * collations independently in each row, and don't worry about whether
+ * they are consistent vertically either.
*/
assign_list_collations(pstate, newsublist);
* Recursively transform leaves and internal nodes of a set-op tree
*
* In addition to returning the transformed node, if targetlist isn't NULL
- * then we return a list of its non-resjunk TargetEntry nodes. For a leaf
+ * then we return a list of its non-resjunk TargetEntry nodes. For a leaf
* set-op node these are the actual targetlist entries; otherwise they are
* dummy entries created to carry the type, typmod, collation, and location
* (for error messages) of each output column of the set-op node. This info
* child query's semantics.
*
* If a child expression is an UNKNOWN-type Const or Param, we
- * want to replace it with the coerced expression. This can only
+ * want to replace it with the coerced expression. This can only
* happen when the child is a leaf set-op node. It's safe to
* replace the expression because if the child query's semantics
* depended on the type of this output column, it'd have already
* collation.)
*/
rescolcoll = select_common_collation(pstate,
- list_make2(lcolnode, rcolnode),
- (op->op == SETOP_UNION && op->all));
+ list_make2(lcolnode, rcolnode),
+ (op->op == SETOP_UNION && op->all));
/* emit results */
op->colTypes = lappend_oid(op->colTypes, rescoltype);
rescolnode->collation = rescolcoll;
rescolnode->location = bestlocation;
restle = makeTargetEntry((Expr *) rescolnode,
- 0, /* no need to set resno */
+ 0, /* no need to set resno */
NULL,
false);
*targetlist = lappend(*targetlist, restle);
case RTE_RELATION:
if (rte->relkind == RELKIND_FOREIGN_TABLE)
ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("SELECT FOR UPDATE/SHARE cannot be used with foreign table \"%s\"",
- rte->eref->aliasname),
- parser_errposition(pstate, thisrel->location)));
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("SELECT FOR UPDATE/SHARE cannot be used with foreign table \"%s\"",
+ rte->eref->aliasname),
+ parser_errposition(pstate, thisrel->location)));
applyLockingClause(qry, i,
lc->forUpdate, lc->noWait,
pushedDown);
/*
* Check whether the Var is known functionally dependent on the GROUP
- * BY columns. If so, we can allow the Var to be used, because the
+ * BY columns. If so, we can allow the Var to be used, because the
* grouping is really a no-op for this table. However, this deduction
* depends on one or more constraints of the table, so we have to add
* those constraints to the query's constraintDeps list, because it's
* Because this is a pretty expensive check, and will have the same
* outcome for all columns of a table, we remember which RTEs we've
* already proven functional dependency for in the func_grouped_rels
- * list. This test also prevents us from adding duplicate entries
- * to the constraintDeps list.
+ * list. This test also prevents us from adding duplicate entries to
+ * the constraintDeps list.
*/
if (list_member_int(*context->func_grouped_rels, var->varno))
- return false; /* previously proven acceptable */
+ return false; /* previously proven acceptable */
Assert(var->varno > 0 &&
(int) var->varno <= list_length(context->pstate->p_rtable));
{
*context->func_grouped_rels =
lappend_int(*context->func_grouped_rels, var->varno);
- return false; /* acceptable */
+ return false; /* acceptable */
}
}
else if (l_colvar->vartypmod != outcoltypmod)
l_node = (Node *) makeRelabelType((Expr *) l_colvar,
outcoltype, outcoltypmod,
- InvalidOid, /* fixed below */
+ InvalidOid, /* fixed below */
COERCE_IMPLICIT_CAST);
else
l_node = (Node *) l_colvar;
else if (r_colvar->vartypmod != outcoltypmod)
r_node = (Node *) makeRelabelType((Expr *) r_colvar,
outcoltype, outcoltypmod,
- InvalidOid, /* fixed below */
+ InvalidOid, /* fixed below */
COERCE_IMPLICIT_CAST);
else
r_node = (Node *) r_colvar;
/*
* Apply assign_expr_collations to fix up the collation info in the
- * coercion and CoalesceExpr nodes, if we made any. This must be done
- * now so that the join node's alias vars show correct collation info.
+ * coercion and CoalesceExpr nodes, if we made any. This must be done now
+ * so that the join node's alias vars show correct collation info.
*/
assign_expr_collations(pstate, res_node);
{
/*
* If we have a COLLATE clause, we have to push the coercion
- * underneath the COLLATE. This is really ugly, but there is little
+ * underneath the COLLATE. This is really ugly, but there is little
* choice because the above hacks on Consts and Params wouldn't happen
* otherwise.
*/
Oid sourceElem;
if ((targetElem = get_element_type(targetTypeId)) != InvalidOid &&
- (sourceElem = get_base_element_type(sourceTypeId)) != InvalidOid)
+ (sourceElem = get_base_element_type(sourceTypeId)) != InvalidOid)
{
CoercionPathType elempathtype;
Oid elemfuncid;
static bool
typeIsOfTypedTable(Oid reltypeId, Oid reloftypeId)
{
- Oid relid = typeidTypeRelid(reltypeId);
- bool result = false;
+ Oid relid = typeidTypeRelid(reltypeId);
+ bool result = false;
if (relid)
{
* 1. The output collation of each expression node, or InvalidOid if it
* returns a noncollatable data type. This can also be InvalidOid if the
* result type is collatable but the collation is indeterminate.
- * 2. The collation to be used in executing each function. InvalidOid means
+ * 2. The collation to be used in executing each function. InvalidOid means
* that there are no collatable inputs or their collation is indeterminate.
* This value is only stored in node types that might call collation-using
* functions.
*
* You might think we could get away with storing only one collation per
- * node, but the two concepts really need to be kept distinct. Otherwise
+ * node, but the two concepts really need to be kept distinct. Otherwise
* it's too confusing when a function produces a collatable output type but
* has no collatable inputs or produces noncollatable output from collatable
* inputs.
*
* Cases with indeterminate collation might result in an error being thrown
- * at runtime. If we knew exactly which functions require collation
+ * at runtime. If we knew exactly which functions require collation
* information, we could throw those errors at parse time instead.
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
static bool assign_query_collations_walker(Node *node, ParseState *pstate);
static bool assign_collations_walker(Node *node,
- assign_collations_context *context);
+ assign_collations_context *context);
/*
return false;
/*
- * We don't want to recurse into a set-operations tree; it's already
- * been fully processed in transformSetOperationStmt.
+ * We don't want to recurse into a set-operations tree; it's already been
+ * fully processed in transformSetOperationStmt.
*/
if (IsA(node, SetOperationStmt))
return false;
foreach(lc, exprs)
{
- Node *node = (Node *) lfirst(lc);
+ Node *node = (Node *) lfirst(lc);
assign_expr_collations(pstate, node);
}
* Recursive guts of collation processing.
*
* Nodes with no children (eg, Vars, Consts, Params) must have been marked
- * when built. All upper-level nodes are marked here.
+ * when built. All upper-level nodes are marked here.
*
* Note: if this is invoked directly on a List, it will attempt to infer a
* common collation for all the list members. In particular, it will throw
return false;
/*
- * Prepare for recursion. For most node types, though not all, the
- * first thing we do is recurse to process all nodes below this one.
- * Each level of the tree has its own local context.
+ * Prepare for recursion. For most node types, though not all, the first
+ * thing we do is recurse to process all nodes below this one. Each level
+ * of the tree has its own local context.
*/
loccontext.pstate = context->pstate;
loccontext.collation = InvalidOid;
{
/*
* CaseExpr is a special case because we do not want to
- * recurse into the test expression (if any). It was
- * already marked with collations during transformCaseExpr,
- * and furthermore its collation is not relevant to the
- * result of the CASE --- only the output expressions are.
- * So we can't use expression_tree_walker here.
+ * recurse into the test expression (if any). It was already
+ * marked with collations during transformCaseExpr, and
+ * furthermore its collation is not relevant to the result of
+ * the CASE --- only the output expressions are. So we can't
+ * use expression_tree_walker here.
*/
CaseExpr *expr = (CaseExpr *) node;
Oid typcollation;
CaseWhen *when = (CaseWhen *) lfirst(lc);
Assert(IsA(when, CaseWhen));
+
/*
* The condition expressions mustn't affect the CASE's
* result collation either; but since they are known to
case T_RowExpr:
{
/*
- * RowExpr is a special case because the subexpressions
- * are independent: we don't want to complain if some of
- * them have incompatible explicit collations.
+ * RowExpr is a special case because the subexpressions are
+ * independent: we don't want to complain if some of them have
+ * incompatible explicit collations.
*/
- RowExpr *expr = (RowExpr *) node;
+ RowExpr *expr = (RowExpr *) node;
assign_list_collations(context->pstate, expr->args);
* has a collation, we can just stop here: this node has no
* impact on the collation of its parent.
*/
- return false; /* done */
+ return false; /* done */
}
case T_RowCompareExpr:
{
forboth(l, expr->largs, r, expr->rargs)
{
- Node *le = (Node *) lfirst(l);
- Node *re = (Node *) lfirst(r);
- Oid coll;
+ Node *le = (Node *) lfirst(l);
+ Node *re = (Node *) lfirst(r);
+ Oid coll;
coll = select_common_collation(context->pstate,
list_make2(le, re),
expr->inputcollids = colls;
/*
- * Since the result is always boolean and therefore never
- * has a collation, we can just stop here: this node has no
- * impact on the collation of its parent.
+ * Since the result is always boolean and therefore never has
+ * a collation, we can just stop here: this node has no impact
+ * on the collation of its parent.
*/
- return false; /* done */
+ return false; /* done */
}
case T_CoerceToDomain:
{
* If the domain declaration included a non-default COLLATE
* spec, then use that collation as the output collation of
* the coercion. Otherwise allow the input collation to
- * bubble up. (The input should be of the domain's base
- * type, therefore we don't need to worry about it not being
+ * bubble up. (The input should be of the domain's base type,
+ * therefore we don't need to worry about it not being
* collatable when the domain is.)
*/
CoerceToDomain *expr = (CoerceToDomain *) node;
- Oid typcollation = get_typcollation(expr->resulttype);
+ Oid typcollation = get_typcollation(expr->resulttype);
/* ... but first, recurse */
(void) expression_tree_walker(node,
/*
* TargetEntry can have only one child, and should bubble that
- * state up to its parent. We can't use the general-case code
+ * state up to its parent. We can't use the general-case code
* below because exprType and friends don't work on TargetEntry.
*/
collation = loccontext.collation;
* There are some cases where there might not be a failure, for
* example if the planner chooses to use hash aggregation instead
* of sorting for grouping; but it seems better to predictably
- * throw an error. (Compare transformSetOperationTree, which will
- * throw error for indeterminate collation of set-op columns,
- * even though the planner might be able to implement the set-op
+ * throw an error. (Compare transformSetOperationTree, which will
+ * throw error for indeterminate collation of set-op columns, even
+ * though the planner might be able to implement the set-op
* without sorting.)
*/
if (strength == COLLATE_CONFLICT &&
(void) expression_tree_walker(node,
assign_collations_walker,
(void *) &loccontext);
+
/*
* When we're invoked on a query's jointree, we don't need to do
* anything with join nodes except recurse through them to process
case T_CaseTestExpr:
case T_SetToDefault:
case T_CurrentOfExpr:
+
/*
* General case for childless expression nodes. These should
* already have a collation assigned; it is not this function's
/*
* Note: in most cases, there will be an assigned collation
* whenever type_is_collatable(exprType(node)); but an exception
- * occurs for a Var referencing a subquery output column for
- * which a unique collation was not determinable. That may lead
- * to a runtime failure if a collation-sensitive function is
- * applied to the Var.
+ * occurs for a Var referencing a subquery output column for which
+ * a unique collation was not determinable. That may lead to a
+ * runtime failure if a collation-sensitive function is applied to
+ * the Var.
*/
if (OidIsValid(collation))
default:
{
/*
- * General case for most expression nodes with children.
- * First recurse, then figure out what to assign here.
+ * General case for most expression nodes with children. First
+ * recurse, then figure out what to assign here.
*/
- Oid typcollation;
+ Oid typcollation;
(void) expression_tree_walker(node,
assign_collations_walker,
}
/*
- * Save the result collation into the expression node.
- * If the state is COLLATE_CONFLICT, we'll set the collation
- * to InvalidOid, which might result in an error at runtime.
+ * Save the result collation into the expression node. If the
+ * state is COLLATE_CONFLICT, we'll set the collation to
+ * InvalidOid, which might result in an error at runtime.
*/
if (strength == COLLATE_CONFLICT)
exprSetCollation(node, InvalidOid);
cte->ctequery = (Node *) query;
/*
- * Check that we got something reasonable. These first two cases should
+ * Check that we got something reasonable. These first two cases should
* be prevented by the grammar.
*/
if (!IsA(query, Query))
continue;
varattno++;
Assert(varattno == te->resno);
- if (lctyp == NULL || lctypmod == NULL || lccoll == NULL) /* shouldn't happen */
+ if (lctyp == NULL || lctypmod == NULL || lccoll == NULL) /* shouldn't happen */
elog(ERROR, "wrong number of output columns in WITH");
texpr = (Node *) te->expr;
if (exprType(texpr) != lfirst_oid(lctyp) ||
lctypmod = lnext(lctypmod);
lccoll = lnext(lccoll);
}
- if (lctyp != NULL || lctypmod != NULL || lccoll != NULL) /* shouldn't happen */
+ if (lctyp != NULL || lctypmod != NULL || lccoll != NULL) /* shouldn't happen */
elog(ERROR, "wrong number of output columns in WITH");
}
}
CommonTableExpr *cte = cstate->items[i].cte;
SelectStmt *stmt = (SelectStmt *) cte->ctequery;
- Assert(!IsA(stmt, Query)); /* not analyzed yet */
+ Assert(!IsA(stmt, Query)); /* not analyzed yet */
/* Ignore items that weren't found to be recursive */
if (!cte->cterecursive)
typenameTypeIdAndMod(pstate, tc->typeName,
&targetType, &targetTypmod);
+
/*
* If target is a domain over array, work with the base
* array type here. transformTypeCast below will cast the
/*
* Run collation assignment on the test expression so that we know
- * what collation to mark the placeholder with. In principle we
- * could leave it to parse_collate.c to do that later, but propagating
- * the result to the CaseTestExpr would be unnecessarily complicated.
+ * what collation to mark the placeholder with. In principle we could
+ * leave it to parse_collate.c to do that later, but propagating the
+ * result to the CaseTestExpr would be unnecessarily complicated.
*/
assign_expr_collations(pstate, arg);
transformCollateClause(ParseState *pstate, CollateClause *c)
{
CollateExpr *newc;
- Oid argtype;
+ Oid argtype;
newc = makeNode(CollateExpr);
newc->arg = (Expr *) transformExpr(pstate, c->arg);
argtype = exprType((Node *) newc->arg);
+
/*
- * The unknown type is not collatable, but coerce_type() takes
- * care of it separately, so we'll let it go here.
+ * The unknown type is not collatable, but coerce_type() takes care of it
+ * separately, so we'll let it go here.
*/
if (!type_is_collatable(argtype) && argtype != UNKNOWNOID)
ereport(ERROR,
rcexpr->rctype = rctype;
rcexpr->opnos = opnos;
rcexpr->opfamilies = opfamilies;
- rcexpr->inputcollids = NIL; /* assign_expr_collations will fix this */
+ rcexpr->inputcollids = NIL; /* assign_expr_collations will fix this */
rcexpr->largs = largs;
rcexpr->rargs = rargs;
errmsg("function %s does not exist",
func_signature_string(funcname, nargs, argnames,
actual_arg_types)),
- errhint("No aggregate function matches the given name and argument types. "
- "Perhaps you misplaced ORDER BY; ORDER BY must appear "
- "after all regular arguments of the aggregate."),
+ errhint("No aggregate function matches the given name and argument types. "
+ "Perhaps you misplaced ORDER BY; ORDER BY must appear "
+ "after all regular arguments of the aggregate."),
parser_errposition(pstate, location)));
}
else
case COERCION_PATH_COERCEVIAIO:
if ((sourceType == RECORDOID ||
ISCOMPLEX(sourceType)) &&
- TypeCategory(targetType) == TYPCATEGORY_STRING)
+ TypeCategory(targetType) == TYPCATEGORY_STRING)
iscoercion = false;
else
iscoercion = true;
* If the input is a domain, smash to base type, and extract the actual
* typmod to be applied to the base type. Subscripting a domain is an
* operation that necessarily works on the base array type, not the domain
- * itself. (Note that we provide no method whereby the creator of a
+ * itself. (Note that we provide no method whereby the creator of a
* domain over an array type could hide its ability to be subscripted.)
*/
*arrayType = getBaseTypeAndTypmod(*arrayType, arrayTypmod);
/*
* Caller may or may not have bothered to determine elementType. Note
- * that if the caller did do so, arrayType/arrayTypMod must be as
- * modified by transformArrayType, ie, smash domain to base type.
+ * that if the caller did do so, arrayType/arrayTypMod must be as modified
+ * by transformArrayType, ie, smash domain to base type.
*/
if (!OidIsValid(elementType))
elementType = transformArrayType(&arrayType, &arrayTypMod);
con = makeConst(typeid,
-1, /* typmod -1 is OK for all cases */
- InvalidOid, /* all cases are uncollatable types */
+ InvalidOid, /* all cases are uncollatable types */
typelen,
val,
false,
/*
* If the datatype is an array, then we can use array_lt and friends ...
* but only if there are suitable operators for the element type.
- * Likewise, array types are only hashable if the element type is.
- * Testing all three operator IDs here should be redundant, but let's do
- * it anyway.
+ * Likewise, array types are only hashable if the element type is. Testing
+ * all three operator IDs here should be redundant, but let's do it
+ * anyway.
*/
if (lt_opr == ARRAY_LT_OP ||
eq_opr == ARRAY_EQ_OP ||
/*
* This module always sets a Param's collation to be the default for
- * its datatype. If that's not what you want, you should be using
- * the more general parser substitution hooks.
+ * its datatype. If that's not what you want, you should be using the
+ * more general parser substitution hooks.
*/
param->paramcollid = get_typcollation(param->paramtype);
*/
if (IsA(cte->ctequery, Query))
{
- Query *ctequery = (Query *) cte->ctequery;
+ Query *ctequery = (Query *) cte->ctequery;
if (ctequery->commandType != CMD_SELECT &&
ctequery->returningList == NIL)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("WITH query \"%s\" does not have a RETURNING clause",
- cte->ctename),
+ errmsg("WITH query \"%s\" does not have a RETURNING clause",
+ cte->ctename),
parser_errposition(pstate, rv->location)));
}
* what type the Const claims to be.
*/
*colvars = lappend(*colvars,
- makeNullConst(INT4OID, -1, InvalidOid));
+ makeNullConst(INT4OID, -1, InvalidOid));
}
}
continue;
Var *varnode;
varnode = makeVar(rtindex, attr->attnum,
- attr->atttypid, attr->atttypmod, attr->attcollation,
+ attr->atttypid, attr->atttypmod, attr->attcollation,
sublevels_up);
varnode->location = location;
parser_errposition(pstate, location)));
get_atttypetypmodcoll(typrelid, attnum,
- &fieldTypeId, &fieldTypMod, &fieldCollation);
+ &fieldTypeId, &fieldTypMod, &fieldCollation);
/* recurse to create appropriate RHS for field assign */
rhs = transformAssignmentIndirection(pstate,
/*
* Array normally has same collation as elements, but there's an
- * exception: we might be subscripting a domain over an array type.
- * In that case use collation of the base type.
+ * exception: we might be subscripting a domain over an array type. In
+ * that case use collation of the base type.
*/
if (arrayType == targetTypeId)
collationNeeded = targetCollation;
bool skipValidation,
bool isAddConstraint);
static void transformConstraintAttrs(CreateStmtContext *cxt,
- List *constraintList);
+ List *constraintList);
static void transformColumnType(CreateStmtContext *cxt, ColumnDef *column);
static void setSchemaName(char *context_schema, char **stmt_schema_name);
* 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.
+ * 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;
/* Copy comment on constraint */
if ((inhRelation->options & CREATE_TABLE_LIKE_COMMENTS) &&
(comment = GetComment(get_constraint_oid(RelationGetRelid(relation),
- n->conname, false),
+ n->conname, false),
ConstraintRelationId,
0)) != NULL)
{
/*
* If it's ALTER TABLE ADD CONSTRAINT USING INDEX, look up the index and
* verify it's usable, then extract the implied column name list. (We
- * will not actually need the column name list at runtime, but we need
- * it now to check for duplicate column entries below.)
+ * will not actually need the column name list at runtime, but we need it
+ * now to check for duplicate column entries below.)
*/
if (constraint->indexname != NULL)
{
if (OidIsValid(get_index_constraint(index_oid)))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("index \"%s\" is already associated with a constraint",
- index_name),
+ errmsg("index \"%s\" is already associated with a constraint",
+ index_name),
parser_errposition(cxt->pstate, constraint->location)));
/* Perform validity checks on the index */
parser_errposition(cxt->pstate, constraint->location)));
/*
- * It's probably unsafe to change a deferred index to non-deferred.
- * (A non-constraint index couldn't be deferred anyway, so this case
+ * It's probably unsafe to change a deferred index to non-deferred. (A
+ * non-constraint index couldn't be deferred anyway, so this case
* should never occur; no need to sweat, but let's check it.)
*/
if (!index_form->indimmediate && !constraint->deferrable)
parser_errposition(cxt->pstate, constraint->location)));
/*
- * Insist on it being a btree. That's the only kind that supports
+ * Insist on it being a btree. That's the only kind that supports
* uniqueness at the moment anyway; but we must have an index that
* exactly matches what you'd get from plain ADD CONSTRAINT syntax,
* else dump and reload will produce a different index (breaking
for (i = 0; i < index_form->indnatts; i++)
{
- int2 attnum = index_form->indkey.values[i];
+ int2 attnum = index_form->indkey.values[i];
Form_pg_attribute attform;
- char *attname;
- Oid defopclass;
+ char *attname;
+ Oid defopclass;
/*
* We shouldn't see attnum == 0 here, since we already rejected
- * expression indexes. If we do, SystemAttributeDefinition
- * will throw an error.
+ * expression indexes. If we do, SystemAttributeDefinition will
+ * throw an error.
*/
if (attnum > 0)
{
}
else
attform = SystemAttributeDefinition(attnum,
- heap_rel->rd_rel->relhasoids);
+ heap_rel->rd_rel->relhasoids);
attname = pstrdup(NameStr(attform->attname));
/*
- * Insist on default opclass and sort options. While the index
+ * Insist on default opclass and sort options. While the index
* would still work as a constraint with non-default settings, it
* might not provide exactly the same uniqueness semantics as
* you'd get from a normally-created constraint; and there's also
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("index \"%s\" does not have default sorting behavior", index_name),
errdetail("Cannot create a PRIMARY KEY or UNIQUE constraint using such an index."),
- parser_errposition(cxt->pstate, constraint->location)));
+ parser_errposition(cxt->pstate, constraint->location)));
constraint->keys = lappend(constraint->keys, makeString(attname));
}
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" appears twice in primary key constraint",
key),
- parser_errposition(cxt->pstate, constraint->location)));
+ parser_errposition(cxt->pstate, constraint->location)));
else
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" appears twice in unique constraint",
key),
- parser_errposition(cxt->pstate, constraint->location)));
+ parser_errposition(cxt->pstate, constraint->location)));
}
}
Constraint *constraint = (Constraint *) lfirst(fkclist);
constraint->skip_validation = true;
- constraint->initially_valid = true;
+ constraint->initially_valid = true;
}
}
* However, they were already in the outer rangetable when we
* analyzed the query, so we have to check.
*
- * Note that in the INSERT...SELECT case, we need to examine
- * the CTE lists of both top_subqry and sub_qry.
+ * Note that in the INSERT...SELECT case, we need to examine the
+ * CTE lists of both top_subqry and sub_qry.
*
- * Note that we aren't digging into the body of the query
- * looking for WITHs in nested sub-SELECTs. A WITH down there
- * can legitimately refer to OLD/NEW, because it'd be an
+ * Note that we aren't digging into the body of the query looking
+ * for WITHs in nested sub-SELECTs. A WITH down there can
+ * legitimately refer to OLD/NEW, because it'd be an
* indirect-correlated outer reference.
*/
if (rangeTableEntry_used((Node *) top_subqry->cteList,
PRS2_OLD_VARNO, 0) ||
rangeTableEntry_used((Node *) sub_qry->cteList,
- PRS2_OLD_VARNO, 0))
+ PRS2_OLD_VARNO, 0))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot refer to OLD within WITH query")));
lockmode = AlterTableGetLockLevel(stmt->cmds);
/*
- * Acquire appropriate lock on the target relation, which will be held until
- * end of transaction. This ensures any decisions we make here based on
- * the state of the relation will still be good at execution. We must get
- * lock now because execution will later require it; taking a lower grade lock
- * now and trying to upgrade later risks deadlock. Any new commands we add
- * after this must not upgrade the lock level requested here.
+ * Acquire appropriate lock on the target relation, which will be held
+ * until end of transaction. This ensures any decisions we make here
+ * based on the state of the relation will still be good at execution. We
+ * must get lock now because execution will later require it; taking a
+ * lower grade lock now and trying to upgrade later risks deadlock. Any
+ * new commands we add after this must not upgrade the lock level
+ * requested here.
*/
rel = relation_openrv(stmt->relation, lockmode);
if (column->collClause)
{
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(ctype);
- Oid collOid;
+ Oid collOid;
collOid = LookupCollation(cxt->pstate,
column->collClause->collname,
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
-#endif /* !__ELF__ */
+#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
-#endif /* !__ELF__ */
+#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
-#endif /* !__ELF__ */
+#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(0);
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
+ if (bind(s, (SOCKADDR *) &serv_addr, len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to bind: %ui", WSAGetLastError())));
closesocket(s);
closesocket(s);
return -1;
}
- if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
+ if (getsockname(s, (SOCKADDR *) &serv_addr, &len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to getsockname: %ui", WSAGetLastError())));
closesocket(s);
return -1;
}
- if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
+ if (connect(handles[1], (SOCKADDR *) &serv_addr, len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to connect socket: %ui", WSAGetLastError())));
closesocket(s);
return -1;
}
- if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
+ if ((handles[0] = accept(s, (SOCKADDR *) &serv_addr, &len)) == INVALID_SOCKET)
{
ereport(LOG, (errmsg_internal("pgpipe failed to accept socket: %ui", WSAGetLastError())));
closesocket(handles[1]);
"segment exceeded your kernel's SHMMAX parameter. You can either "
"reduce the request size or reconfigure the kernel with larger SHMMAX. "
"To reduce the request size (currently %lu bytes), reduce "
- "PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
+ "PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"or max_connections.\n"
"If the request size is already small, it's possible that it is less than "
"your kernel's SHMMIN parameter, in which case raising the request size or "
(errno == ENOMEM) ?
errhint("This error usually means that PostgreSQL's request for a shared "
"memory segment exceeded available memory or swap space, "
- "or exceeded your kernel's SHMALL parameter. You can either "
+ "or exceeded your kernel's SHMALL parameter. You can either "
"reduce the request size or reconfigure the kernel with larger SHMALL. "
"To reduce the request size (currently %lu bytes), reduce "
- "PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
+ "PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"or max_connections.\n"
"The PostgreSQL documentation contains more information about shared "
"memory configuration.",
* hurt, but might confuse humans).
*/
{
- char line[64];
+ char line[64];
sprintf(line, "%9lu %9lu",
(unsigned long) memKey, (unsigned long) shmid);
*
* for (;;)
* {
- * ResetLatch();
- * if (work to do)
- * Do Stuff();
+ * ResetLatch();
+ * if (work to do)
+ * Do Stuff();
*
- * WaitLatch();
+ * WaitLatch();
* }
*
* It's important to reset the latch *before* checking if there's work to
static volatile sig_atomic_t waiting = false;
/* Read and write end of the self-pipe */
-static int selfpipe_readfd = -1;
-static int selfpipe_writefd = -1;
+static int selfpipe_readfd = -1;
+static int selfpipe_writefd = -1;
/* private function prototypes */
static void initSelfPipe(void);
WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
bool forWrite, long timeout)
{
- struct timeval tv, *tvp = NULL;
+ struct timeval tv,
+ *tvp = NULL;
fd_set input_mask;
fd_set output_mask;
int rc;
waiting = true;
for (;;)
{
- int hifd;
+ int hifd;
/*
* Clear the pipe, and check if the latch is set already. If someone
- * sets the latch between this and the select() below, the setter
- * will write a byte to the pipe (or signal us and the signal handler
- * will do that), and the select() will return immediately.
+ * sets the latch between this and the select() below, the setter will
+ * write a byte to the pipe (or signal us and the signal handler will
+ * do that), and the select() will return immediately.
*/
drainSelfPipe();
if (latch->is_set)
(forWrite && FD_ISSET(sock, &output_mask))))
{
result = 2;
- break; /* data available in socket */
+ break; /* data available in socket */
}
}
waiting = false;
void
SetLatch(volatile Latch *latch)
{
- pid_t owner_pid;
+ pid_t owner_pid;
/* Quick exit if already set */
if (latch->is_set)
latch->is_set = true;
/*
- * See if anyone's waiting for the latch. It can be the current process
- * if we're in a signal handler. We use the self-pipe to wake up the
- * select() in that case. If it's another process, send a signal.
+ * See if anyone's waiting for the latch. It can be the current process if
+ * we're in a signal handler. We use the self-pipe to wake up the select()
+ * in that case. If it's another process, send a signal.
*
- * Fetch owner_pid only once, in case the owner simultaneously disowns
- * the latch and clears owner_pid. XXX: This assumes that pid_t is
- * atomic, which isn't guaranteed to be true! In practice, the effective
- * range of pid_t fits in a 32 bit integer, and so should be atomic. In
- * the worst case, we might end up signaling wrong process if the right
- * one disowns the latch just as we fetch owner_pid. Even then, you're
- * very unlucky if a process with that bogus pid exists.
+ * Fetch owner_pid only once, in case the owner simultaneously disowns the
+ * latch and clears owner_pid. XXX: This assumes that pid_t is atomic,
+ * which isn't guaranteed to be true! In practice, the effective range of
+ * pid_t fits in a 32 bit integer, and so should be atomic. In the worst
+ * case, we might end up signaling wrong process if the right one disowns
+ * the latch just as we fetch owner_pid. Even then, you're very unlucky if
+ * a process with that bogus pid exists.
*/
owner_pid = latch->owner_pid;
if (owner_pid == 0)
static void
initSelfPipe(void)
{
- int pipefd[2];
+ int pipefd[2];
/*
* Set up the self-pipe that allows a signal handler to wake up the
* select() in WaitLatch. Make the write-end non-blocking, so that
* SetLatch won't block if the event has already been set many times
- * filling the kernel buffer. Make the read-end non-blocking too, so
- * that we can easily clear the pipe by reading until EAGAIN or
- * EWOULDBLOCK.
+ * filling the kernel buffer. Make the read-end non-blocking too, so that
+ * we can easily clear the pipe by reading until EAGAIN or EWOULDBLOCK.
*/
if (pipe(pipefd) < 0)
elog(FATAL, "pipe() failed: %m");
static void
sendSelfPipeByte(void)
{
- int rc;
- char dummy = 0;
+ int rc;
+ char dummy = 0;
retry:
rc = write(selfpipe_writefd, &dummy, 1);
goto retry;
/*
- * If the pipe is full, we don't need to retry, the data that's
- * there already is enough to wake up WaitLatch.
+ * If the pipe is full, we don't need to retry, the data that's there
+ * already is enough to wake up WaitLatch.
*/
if (errno == EAGAIN || errno == EWOULDBLOCK)
return;
/*
- * Oops, the write() failed for some other reason. We might be in
- * a signal handler, so it's not safe to elog(). We have no choice
- * but silently ignore the error.
+ * Oops, the write() failed for some other reason. We might be in a
+ * signal handler, so it's not safe to elog(). We have no choice but
+ * silently ignore the error.
*/
return;
}
drainSelfPipe(void)
{
/*
- * There shouldn't normally be more than one byte in the pipe, or maybe
- * a few more if multiple processes run SetLatch at the same instant.
+ * There shouldn't normally be more than one byte in the pipe, or maybe a
+ * few more if multiple processes run SetLatch at the same instant.
*/
- char buf[16];
- int rc;
+ char buf[16];
+ int rc;
for (;;)
{
if (rc < 0)
{
if (errno == EAGAIN || errno == EWOULDBLOCK)
- break; /* the pipe is empty */
+ break; /* the pipe is empty */
else if (errno == EINTR)
- continue; /* retry */
+ continue; /* retry */
else
elog(ERROR, "read() on self-pipe failed: %m");
}
/*-------------------------------------------------------------------------
*
* win32_crashdump.c
- * Automatic crash dump creation for PostgreSQL on Windows
+ * Automatic crash dump creation for PostgreSQL on Windows
*
* The crashdump feature traps unhandled win32 exceptions produced by the
* backend, and tries to produce a Windows MiniDump crash
* http://www.debuginfo.com/articles/effminidumps.html
*/
-typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
- CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
- CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
- );
+typedef BOOL (WINAPI * MINIDUMPWRITEDUMP) (HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
+ CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
+ CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
+ CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
+);
/*
* any PostgreSQL functions.
*/
static LONG WINAPI
-crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
+crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
{
/*
- * We only write crash dumps if the "crashdumps" directory within
- * the postgres data directory exists.
+ * We only write crash dumps if the "crashdumps" directory within the
+ * postgres data directory exists.
*/
- DWORD attribs = GetFileAttributesA("crashdumps");
- if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY) )
+ DWORD attribs = GetFileAttributesA("crashdumps");
+
+ if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY))
{
/* 'crashdumps' exists and is a directory. Try to write a dump' */
- HMODULE hDll = NULL;
+ HMODULE hDll = NULL;
MINIDUMPWRITEDUMP pDump = NULL;
MINIDUMP_TYPE dumpType;
- char dumpPath[_MAX_PATH];
- HANDLE selfProcHandle = GetCurrentProcess();
- DWORD selfPid = GetProcessId(selfProcHandle);
- HANDLE dumpFile;
- DWORD systemTicks;
+ char dumpPath[_MAX_PATH];
+ HANDLE selfProcHandle = GetCurrentProcess();
+ DWORD selfPid = GetProcessId(selfProcHandle);
+ HANDLE dumpFile;
+ DWORD systemTicks;
struct _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = GetCurrentThreadId();
return EXCEPTION_CONTINUE_SEARCH;
}
- pDump = (MINIDUMPWRITEDUMP)GetProcAddress(hDll, "MiniDumpWriteDump");
+ pDump = (MINIDUMPWRITEDUMP) GetProcAddress(hDll, "MiniDumpWriteDump");
- if (pDump==NULL)
+ if (pDump == NULL)
{
write_stderr("could not load required functions in dbghelp.dll, cannot write crashdump\n");
return EXCEPTION_CONTINUE_SEARCH;
}
/*
- * Dump as much as we can, except shared memory, code segments,
- * and memory mapped files.
- * Exactly what we can dump depends on the version of dbghelp.dll,
- * see:
+ * Dump as much as we can, except shared memory, code segments, and
+ * memory mapped files. Exactly what we can dump depends on the
+ * version of dbghelp.dll, see:
* http://msdn.microsoft.com/en-us/library/ms680519(v=VS.85).aspx
*/
dumpType = MiniDumpNormal | MiniDumpWithHandleData |
systemTicks = GetTickCount();
snprintf(dumpPath, _MAX_PATH,
- "crashdumps\\postgres-pid%0i-%0i.mdmp", selfPid, systemTicks);
- dumpPath[_MAX_PATH-1] = '\0';
+ "crashdumps\\postgres-pid%0i-%0i.mdmp", selfPid, systemTicks);
+ dumpPath[_MAX_PATH - 1] = '\0';
dumpFile = CreateFile(dumpPath, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL);
- if (dumpFile==INVALID_HANDLE_VALUE)
+ if (dumpFile == INVALID_HANDLE_VALUE)
{
write_stderr("could not open crash dump file %s for writing: error code %d\n",
- dumpPath, GetLastError());
+ dumpPath, GetLastError());
return EXCEPTION_CONTINUE_SEARCH;
}
- if ((*pDump)(selfProcHandle, selfPid, dumpFile, dumpType, &ExInfo,
- NULL, NULL))
+ if ((*pDump) (selfProcHandle, selfPid, dumpFile, dumpType, &ExInfo,
+ NULL, NULL))
write_stderr("wrote crash dump to %s\n", dumpPath);
else
write_stderr("could not write crash dump to %s: error code %08x\n",
- dumpPath, GetLastError());
+ dumpPath, GetLastError());
CloseHandle(dumpFile);
}
struct itimerval value;
HANDLE event;
CRITICAL_SECTION crit_sec;
-} timerCA;
+} timerCA;
static timerCA timerCommArea;
static HANDLE timerThreadHandle = INVALID_HANDLE_VALUE;
latch->is_shared = true;
/*
- * Set up security attributes to specify that the events are
- * inherited.
+ * Set up security attributes to specify that the events are inherited.
*/
ZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
numevents = 2;
if (sock != PGINVALID_SOCKET && (forRead || forWrite))
{
- int flags = 0;
+ int flags = 0;
if (forRead)
flags |= FD_READ;
}
rc = WaitForMultipleObjects(numevents, events, FALSE,
- (timeout >= 0) ? (timeout / 1000) : INFINITE);
+ (timeout >= 0) ? (timeout / 1000) : INFINITE);
if (rc == WAIT_FAILED)
elog(ERROR, "WaitForMultipleObjects() failed: error code %d", (int) GetLastError());
else if (rc == WAIT_TIMEOUT)
void
SetLatch(volatile Latch *latch)
{
- HANDLE handle;
+ HANDLE handle;
/* Quick exit if already set */
if (latch->is_set)
latch->is_set = true;
/*
- * See if anyone's waiting for the latch. It can be the current process
- * if we're in a signal handler. Use a local variable here in case the
- * latch is just disowned between the test and the SetEvent call, and
- * event field set to NULL.
+ * See if anyone's waiting for the latch. It can be the current process if
+ * we're in a signal handler. Use a local variable here in case the latch
+ * is just disowned between the test and the SetEvent call, and event
+ * field set to NULL.
*
- * Fetch handle field only once, in case the owner simultaneously
- * disowns the latch and clears handle. This assumes that HANDLE is
- * atomic, which isn't guaranteed to be true! In practice, it should be,
- * and in the worst case we end up calling SetEvent with a bogus handle,
- * and SetEvent will return an error with no harm done.
+ * Fetch handle field only once, in case the owner simultaneously disowns
+ * the latch and clears handle. This assumes that HANDLE is atomic, which
+ * isn't guaranteed to be true! In practice, it should be, and in the
+ * worst case we end up calling SetEvent with a bogus handle, and SetEvent
+ * will return an error with no harm done.
*/
handle = latch->event;
if (handle)
{
SetEvent(handle);
+
/*
* Note that we silently ignore any errors. We might be in a signal
* handler or other critical path where it's not safe to call elog().
int wi_cost_delay;
int wi_cost_limit;
int wi_cost_limit_base;
-} WorkerInfoData;
+} WorkerInfoData;
typedef struct WorkerInfoData *WorkerInfo;
AutoVacForkFailed, /* failed trying to start a worker */
AutoVacRebalance, /* rebalance the cost limits */
AutoVacNumSignals /* must be last */
-} AutoVacuumSignal;
+} AutoVacuumSignal;
/*-------------
* The main autovacuum shmem struct. On shared memory we store this main
SetConfigOption("statement_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE);
/*
- * Force synchronous replication off to allow regular maintenance even
- * if we are waiting for standbys to connect. This is important to
- * ensure we aren't blocked from performing anti-wraparound tasks.
+ * Force synchronous replication off to allow regular maintenance even if
+ * we are waiting for standbys to connect. This is important to ensure we
+ * aren't blocked from performing anti-wraparound tasks.
*/
if (synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
SetConfigOption("synchronous_commit", "local", PGC_SUSET, PGC_S_OVERRIDE);
{
/*
* The idea here is that we ration out I/O equally. The amount of I/O
- * that a worker can consume is determined by cost_limit/cost_delay, so
- * we try to equalize those ratios rather than the raw limit settings.
+ * that a worker can consume is determined by cost_limit/cost_delay, so we
+ * try to equalize those ratios rather than the raw limit settings.
*
* note: in cost_limit, zero also means use value from elsewhere, because
* zero is not a valid value.
/*
* We put a lower bound of 1 on the cost_limit, to avoid division-
- * by-zero in the vacuum code. Also, in case of roundoff trouble
+ * by-zero in the vacuum code. Also, in case of roundoff trouble
* in these calculations, let's be sure we don't ever set
* cost_limit to more than the base value.
*/
Relation rel;
HeapScanDesc scan;
HeapTuple tup;
- MemoryContext resultcxt;
+ MemoryContext resultcxt;
/* This is the context that we will allocate our output data in */
resultcxt = CurrentMemoryContext;
{
Form_pg_database pgdatabase = (Form_pg_database) GETSTRUCT(tup);
avw_dbase *avdb;
- MemoryContext oldcxt;
+ MemoryContext oldcxt;
/*
- * Allocate our results in the caller's context, not the transaction's.
- * We do this inside the loop, and restore the original context at the
- * end, so that leaky things like heap_getnext() are not called in a
- * potentially long-lived context.
+ * Allocate our results in the caller's context, not the
+ * transaction's. We do this inside the loop, and restore the original
+ * context at the end, so that leaky things like heap_getnext() are
+ * not called in a potentially long-lived context.
*/
oldcxt = MemoryContextSwitchTo(resultcxt);
LWLockRelease(AutovacuumScheduleLock);
/*
- * Remember the prevailing values of the vacuum cost GUCs. We have
- * to restore these at the bottom of the loop, else we'll compute
- * wrong values in the next iteration of autovac_balance_cost().
+ * Remember the prevailing values of the vacuum cost GUCs. We have to
+ * restore these at the bottom of the loop, else we'll compute wrong
+ * values in the next iteration of autovac_balance_cost().
*/
stdVacuumCostDelay = VacuumCostDelay;
stdVacuumCostLimit = VacuumCostLimit;
* to the requests[] queue without checking for duplicates. The bgwriter
* will have to eliminate dups internally anyway. However, if we discover
* that the queue is full, we make a pass over the entire queue to compact
- * it. This is somewhat expensive, but the alternative is for the backend
+ * it. This is somewhat expensive, but the alternative is for the backend
* to perform its own fsync, which is far more expensive in practice. It
* is theoretically possible a backend fsync might still be necessary, if
* the queue is full and contains no duplicate entries. In that case, we
/*
* If the background writer isn't running or the request queue is full,
- * the backend will have to perform its own fsync request. But before
+ * the backend will have to perform its own fsync request. But before
* forcing that to happen, we can try to compact the background writer
* request queue.
*/
if (BgWriterShmem->bgwriter_pid == 0 ||
(BgWriterShmem->num_requests >= BgWriterShmem->max_requests
- && !CompactBgwriterRequestQueue()))
+ && !CompactBgwriterRequestQueue()))
{
/*
* Count the subset of writes where backends have to do their own
/*
* CompactBgwriterRequestQueue
- * Remove duplicates from the request queue to avoid backend fsyncs.
+ * Remove duplicates from the request queue to avoid backend fsyncs.
*
* Although a full fsync request queue is not common, it can lead to severe
* performance problems when it does happen. So far, this situation has
* only been observed to occur when the system is under heavy write load,
- * and especially during the "sync" phase of a checkpoint. Without this
+ * and especially during the "sync" phase of a checkpoint. Without this
* logic, each backend begins doing an fsync for every block written, which
* gets very expensive and can slow down the whole system.
*
static bool
CompactBgwriterRequestQueue()
{
- struct BgWriterSlotMapping {
- BgWriterRequest request;
- int slot;
+ struct BgWriterSlotMapping
+ {
+ BgWriterRequest request;
+ int slot;
};
int n,
/* Initialize skip_slot array */
skip_slot = palloc0(sizeof(bool) * BgWriterShmem->num_requests);
- /*
+ /*
* The basic idea here is that a request can be skipped if it's followed
* by a later, identical request. It might seem more sensible to work
* backwards from the end of the queue and check whether a request is
{
BgWriterRequest *request;
struct BgWriterSlotMapping *slotmap;
- bool found;
+ bool found;
request = &BgWriterShmem->requests[n];
slotmap = hash_search(htab, request, HASH_ENTER, &found);
BgWriterShmem->requests[preserve_count++] = BgWriterShmem->requests[n];
}
ereport(DEBUG1,
- (errmsg("compacted fsync request queue from %d entries to %d entries",
- BgWriterShmem->num_requests, preserve_count)));
+ (errmsg("compacted fsync request queue from %d entries to %d entries",
+ BgWriterShmem->num_requests, preserve_count)));
BgWriterShmem->num_requests = preserve_count;
/* Cleanup. */
/* --------
* pgstat_report_recovery_conflict() -
*
- * Tell the collector about a Hot Standby recovery conflict.
+ * Tell the collector about a Hot Standby recovery conflict.
* --------
*/
void
dbentry->functions = NULL;
/*
- * Reset database-level stats too. This should match the initialization
+ * Reset database-level stats too. This should match the initialization
* code in pgstat_get_db_entry().
*/
dbentry->n_xact_commit = 0;
/* ----------
* pgstat_recv_recoveryconflict() -
*
- * Process as RECOVERYCONFLICT message.
+ * Process as RECOVERYCONFLICT message.
* ----------
*/
static void
pgstat_recv_recoveryconflict(PgStat_MsgRecoveryConflict *msg, int len)
{
PgStat_StatDBEntry *dbentry;
+
dbentry = pgstat_get_db_entry(msg->m_databaseid, true);
switch (msg->m_reason)
{
case PROCSIG_RECOVERY_CONFLICT_DATABASE:
+
/*
- * Since we drop the information about the database as soon
- * as it replicates, there is no point in counting these
- * conflicts.
+ * Since we drop the information about the database as soon as it
+ * replicates, there is no point in counting these conflicts.
*/
break;
case PROCSIG_RECOVERY_CONFLICT_TABLESPACE:
HANDLE waitHandle;
HANDLE procHandle;
DWORD procId;
-} win32_deadchild_waitinfo;
+} win32_deadchild_waitinfo;
HANDLE PostmasterHandle;
#endif
SOCKET origsocket; /* Original socket value, or PGINVALID_SOCKET
* if not a socket */
WSAPROTOCOL_INFO wsainfo;
-} InheritableSocket;
+} InheritableSocket;
#else
typedef int InheritableSocket;
#endif
char my_exec_path[MAXPGPATH];
char pkglib_path[MAXPGPATH];
char ExtraOptions[MAXPGPATH];
-} BackendParameters;
+} BackendParameters;
static void read_backend_variables(char *id, Port *port);
-static void restore_backend_variables(BackendParameters * param, Port *port);
+static void restore_backend_variables(BackendParameters *param, Port *port);
#ifndef WIN32
-static bool save_backend_variables(BackendParameters * param, Port *port);
+static bool save_backend_variables(BackendParameters *param, Port *port);
#else
-static bool save_backend_variables(BackendParameters * param, Port *port,
+static bool save_backend_variables(BackendParameters *param, Port *port,
HANDLE childProcess, pid_t childPid);
#endif
*
* In state PM_WAIT_BACKUP only superusers can connect (this must be
* allowed so that a superuser can end online backup mode); we return
- * CAC_WAITBACKUP code to indicate that this must be checked later.
- * Note that neither CAC_OK nor CAC_WAITBACKUP can safely be returned
- * until we have checked for too many children.
+ * CAC_WAITBACKUP code to indicate that this must be checked later. Note
+ * that neither CAC_OK nor CAC_WAITBACKUP can safely be returned until we
+ * have checked for too many children.
*/
if (pmState != PM_RUN)
{
else if (!FatalError &&
(pmState == PM_STARTUP ||
pmState == PM_RECOVERY))
- return CAC_STARTUP; /* normal startup */
+ return CAC_STARTUP; /* normal startup */
else if (!FatalError &&
pmState == PM_HOT_STANDBY)
- result = CAC_OK; /* connection OK during hot standby */
+ result = CAC_OK; /* connection OK during hot standby */
else
return CAC_RECOVERY; /* else must be crash recovery */
}
/*
* Precompute password salt values to use for this connection. It's
- * slightly annoying to do this long in advance of knowing whether
- * we'll need 'em or not, but we must do the random() calls before we
- * fork, not after. Else the postmaster's random sequence won't get
- * advanced, and all backends would end up using the same salt...
+ * slightly annoying to do this long in advance of knowing whether we'll
+ * need 'em or not, but we must do the random() calls before we fork, not
+ * after. Else the postmaster's random sequence won't get advanced, and
+ * all backends would end up using the same salt...
*/
RandomSalt(port->md5Salt);
* the active backend list.
*/
#ifdef WIN32
+
/*
- * On win32, also treat ERROR_WAIT_NO_CHILDREN (128) as nonfatal
- * case, since that sometimes happens under load when the process fails
- * to start properly (long before it starts using shared memory).
- * Microsoft reports it is related to mutex failure:
- * http://archives.postgresql.org/pgsql-hackers/2010-09/msg00790.php
+ * On win32, also treat ERROR_WAIT_NO_CHILDREN (128) as nonfatal case,
+ * since that sometimes happens under load when the process fails to start
+ * properly (long before it starts using shared memory). Microsoft reports
+ * it is related to mutex failure:
+ * http://archives.postgresql.org/pgsql-hackers/2010-09/msg00790.php
*/
if (exitstatus == ERROR_WAIT_NO_CHILDREN)
{
}
/*
- * If recovery failed, or the user does not want an automatic restart after
- * backend crashes, wait for all non-syslogger children to exit, and then
- * exit postmaster. We don't try to reinitialize when recovery fails,
- * because more than likely it will just fail again and we will keep trying
- * forever.
+ * If recovery failed, or the user does not want an automatic restart
+ * after backend crashes, wait for all non-syslogger children to exit, and
+ * then exit postmaster. We don't try to reinitialize when recovery fails,
+ * because more than likely it will just fail again and we will keep
+ * trying forever.
*/
if (pmState == PM_NO_CHILDREN && (RecoveryError || !restart_after_crash))
ExitPostmaster(1);
continue;
/*
- * Since target == BACKEND_TYPE_ALL is the most common case,
- * we test it first and avoid touching shared memory for
- * every child.
+ * Since target == BACKEND_TYPE_ALL is the most common case, we test
+ * it first and avoid touching shared memory for every child.
*/
if (target != BACKEND_TYPE_ALL)
{
continue;
/*
- * Since target == BACKEND_TYPE_ALL is the most common case,
- * we test it first and avoid touching shared memory for
- * every child.
+ * Since target == BACKEND_TYPE_ALL is the most common case, we test
+ * it first and avoid touching shared memory for every child.
*/
if (target != BACKEND_TYPE_ALL)
{
#define read_inheritable_socket(dest, src) (*(dest) = *(src))
#else
static bool write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child);
-static bool write_inheritable_socket(InheritableSocket * dest, SOCKET src,
+static bool write_inheritable_socket(InheritableSocket *dest, SOCKET src,
pid_t childPid);
-static void read_inheritable_socket(SOCKET * dest, InheritableSocket * src);
+static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src);
#endif
/* Save critical backend variables into the BackendParameters struct */
#ifndef WIN32
static bool
-save_backend_variables(BackendParameters * param, Port *port)
+save_backend_variables(BackendParameters *param, Port *port)
#else
static bool
-save_backend_variables(BackendParameters * param, Port *port,
+save_backend_variables(BackendParameters *param, Port *port,
HANDLE childProcess, pid_t childPid)
#endif
{
* straight socket inheritance.
*/
static bool
-write_inheritable_socket(InheritableSocket * dest, SOCKET src, pid_t childpid)
+write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid)
{
dest->origsocket = src;
if (src != 0 && src != PGINVALID_SOCKET)
* Read a duplicate socket structure back, and get the socket descriptor.
*/
static void
-read_inheritable_socket(SOCKET * dest, InheritableSocket * src)
+read_inheritable_socket(SOCKET *dest, InheritableSocket *src)
{
SOCKET s;
/* Restore critical backend variables from the BackendParameters struct */
static void
-restore_backend_variables(BackendParameters * param, Port *port)
+restore_backend_variables(BackendParameters *param, Port *port)
{
memcpy(port, ¶m->port, sizeof(Port));
read_inheritable_socket(&port->sock, ¶m->portsocket);
static void flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
static void open_csvlogfile(void);
static FILE *logfile_open(const char *filename, const char *mode,
- bool allow_errors);
+ bool allow_errors);
#ifdef WIN32
static unsigned int __stdcall pipeThread(void *arg);
mode_t oumask;
/*
- * Note we do not let Log_file_mode disable IWUSR, since we certainly
- * want to be able to write the files ourselves.
+ * Note we do not let Log_file_mode disable IWUSR, since we certainly want
+ * to be able to write the files ourselves.
*/
oumask = umask((mode_t) ((~(Log_file_mode | S_IWUSR)) & (S_IRWXU | S_IRWXG | S_IRWXO)));
fh = fopen(filename, mode);
}
else
{
- int save_errno = errno;
+ int save_errno = errno;
ereport(allow_errors ? LOG : FATAL,
(errcode_for_file_access(),
#define NOERR() {if (ISERR()) return;} /* if error seen, return */
#define NOERRN() {if (ISERR()) return NULL;} /* NOERR with retval */
#define NOERRZ() {if (ISERR()) return 0;} /* NOERR with retval */
-#define INSIST(c, e) do { if (!(c)) ERR(e); } while (0) /* error if c false */
+#define INSIST(c, e) do { if (!(c)) ERR(e); } while (0) /* error if c false */
#define NOTE(b) (v->re->re_info |= (b)) /* note visible condition */
#define EMPTYARC(x, y) newarc(v->nfa, EMPTY, 0, x, y)
bool fastcheckpoint;
bool nowait;
bool includewal;
-} basebackup_options;
+} basebackup_options;
static int64 sendDir(char *path, int basepathlen, bool sizeonly);
char *oid;
char *path;
int64 size;
-} tablespaceinfo;
+} tablespaceinfo;
/*
if (readlink(fullpath, linkpath, sizeof(linkpath) - 1) == -1)
{
ereport(WARNING,
- (errmsg("unable to read symbolic link %s: %m", fullpath)));
+ (errmsg("unable to read symbolic link %s: %m", fullpath)));
continue;
}
ptr.xrecoff = logseg * XLogSegSize + TAR_SEND_SIZE * i;
/*
- * Some old compilers, e.g. gcc 2.95.3/x86, think that passing
- * a struct in the same function as a longjump might clobber
- * a variable. bjm 2011-02-04
- * http://lists.apple.com/archives/xcode-users/2003/Dec//msg00051.html
+ * Some old compilers, e.g. gcc 2.95.3/x86, think that passing
+ * a struct in the same function as a longjump might clobber a
+ * variable. bjm 2011-02-04
+ * http://lists.apple.com/archives/xcode-users/2003/Dec//msg000
+ * 51.html
*/
XLogRead(buf, ptr, TAR_SEND_SIZE);
if (pq_putmessage('d', buf, TAR_SEND_SIZE))
sendFileWithContent(const char *filename, const char *content)
{
struct stat statbuf;
- int pad, len;
+ int pad,
+ len;
len = strlen(content);
/*
- * Construct a stat struct for the backup_label file we're injecting
- * in the tar.
+ * Construct a stat struct for the backup_label file we're injecting in
+ * the tar.
*/
/* Windows doesn't have the concept of uid and gid */
#ifdef WIN32
pad = ((len + 511) & ~511) - len;
if (pad > 0)
{
- char buf[512];
+ char buf[512];
+
MemSet(buf, 0, pad);
pq_putmessage('d', buf, pad);
}
continue;
/*
- * Check if the postmaster has signaled us to exit, and abort
- * with an error in that case. The error handler further up
- * will call do_pg_abort_backup() for us.
+ * Check if the postmaster has signaled us to exit, and abort with an
+ * error in that case. The error handler further up will call
+ * do_pg_abort_backup() for us.
*/
if (walsender_shutdown_requested || walsender_ready_to_stop)
ereport(ERROR,
- (errmsg("shutdown requested, aborting active base backup")));
+ (errmsg("shutdown requested, aborting active base backup")));
snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
/* Given the member, write the TAR header & send the file */
static void
-sendFile(char *readfilename, char *tarfilename, struct stat *statbuf)
+sendFile(char *readfilename, char *tarfilename, struct stat * statbuf)
{
FILE *fp;
char buf[TAR_SEND_SIZE];
/* Send the chunk as a CopyData message */
if (pq_putmessage('d', buf, cnt))
ereport(ERROR,
- (errmsg("base backup could not send data, aborting backup")));
+ (errmsg("base backup could not send data, aborting backup")));
len += cnt;
#include "utils/ps_status.h"
/* User-settable parameters for sync rep */
-char *SyncRepStandbyNames;
+char *SyncRepStandbyNames;
#define SyncStandbysDefined() \
(SyncRepStandbyNames != NULL && SyncRepStandbyNames[0] != '\0')
static void SyncRepQueueInsert(void);
static void SyncRepCancelWait(void);
-static int SyncRepGetStandbyPriority(void);
+static int SyncRepGetStandbyPriority(void);
+
#ifdef USE_ASSERT_CHECKING
static bool SyncRepQueueIsOrderedByLSN(void);
#endif
void
SyncRepWaitForLSN(XLogRecPtr XactCommitLSN)
{
- char *new_status = NULL;
+ char *new_status = NULL;
const char *old_status;
/*
- * Fast exit if user has not requested sync replication, or
- * there are no sync replication standby names defined.
- * Note that those standbys don't need to be connected.
+ * Fast exit if user has not requested sync replication, or there are no
+ * sync replication standby names defined. Note that those standbys don't
+ * need to be connected.
*/
if (!SyncRepRequested() || !SyncStandbysDefined())
return;
Assert(MyProc->syncRepState == SYNC_REP_NOT_WAITING);
/*
- * We don't wait for sync rep if WalSndCtl->sync_standbys_defined is
- * not set. See SyncRepUpdateSyncStandbysDefined.
+ * We don't wait for sync rep if WalSndCtl->sync_standbys_defined is not
+ * set. See SyncRepUpdateSyncStandbysDefined.
*
- * Also check that the standby hasn't already replied. Unlikely
- * race condition but we'll be fetching that cache line anyway
- * so its likely to be a low cost check.
+ * Also check that the standby hasn't already replied. Unlikely race
+ * condition but we'll be fetching that cache line anyway so its likely to
+ * be a low cost check.
*/
if (!WalSndCtl->sync_standbys_defined ||
XLByteLE(XactCommitLSN, WalSndCtl->lsn))
*/
for (;;)
{
- int syncRepState;
+ int syncRepState;
/*
- * Wait on latch for up to 60 seconds. This allows us to
- * check for postmaster death regularly while waiting.
- * Note that timeout here does not necessarily release from loop.
+ * Wait on latch for up to 60 seconds. This allows us to check for
+ * postmaster death regularly while waiting. Note that timeout here
+ * does not necessarily release from loop.
*/
WaitLatch(&MyProc->waitLatch, 60000000L);
ResetLatch(&MyProc->waitLatch);
/*
- * Try checking the state without the lock first. There's no guarantee
- * that we'll read the most up-to-date value, so if it looks like we're
- * still waiting, recheck while holding the lock. But if it looks like
- * we're done, we must really be done, because once walsender changes
- * the state to SYNC_REP_WAIT_COMPLETE, it will never update it again,
- * so we can't be seeing a stale value in that case.
+ * Try checking the state without the lock first. There's no
+ * guarantee that we'll read the most up-to-date value, so if it looks
+ * like we're still waiting, recheck while holding the lock. But if
+ * it looks like we're done, we must really be done, because once
+ * walsender changes the state to SYNC_REP_WAIT_COMPLETE, it will
+ * never update it again, so we can't be seeing a stale value in that
+ * case.
*/
syncRepState = MyProc->syncRepState;
if (syncRepState == SYNC_REP_WAITING)
/*
* If a wait for synchronous replication is pending, we can neither
- * acknowledge the commit nor raise ERROR or FATAL. The latter
- * would lead the client to believe that that the transaction
- * aborted, which is not true: it's already committed locally.
- * The former is no good either: the client has requested
- * synchronous replication, and is entitled to assume that an
- * acknowledged commit is also replicated, which may not be true.
- * So in this case we issue a WARNING (which some clients may
- * be able to interpret) and shut off further output. We do NOT
- * reset ProcDiePending, so that the process will die after the
- * commit is cleaned up.
+ * acknowledge the commit nor raise ERROR or FATAL. The latter would
+ * lead the client to believe that that the transaction aborted, which
+ * is not true: it's already committed locally. The former is no good
+ * either: the client has requested synchronous replication, and is
+ * entitled to assume that an acknowledged commit is also replicated,
+ * which may not be true. So in this case we issue a WARNING (which
+ * some clients may be able to interpret) and shut off further output.
+ * We do NOT reset ProcDiePending, so that the process will die after
+ * the commit is cleaned up.
*/
if (ProcDiePending)
{
/*
* It's unclear what to do if a query cancel interrupt arrives. We
* can't actually abort at this point, but ignoring the interrupt
- * altogether is not helpful, so we just terminate the wait with
- * a suitable warning.
+ * altogether is not helpful, so we just terminate the wait with a
+ * suitable warning.
*/
if (QueryCancelPending)
{
}
/*
- * If the postmaster dies, we'll probably never get an acknowledgement,
- * because all the wal sender processes will exit. So just bail out.
+ * If the postmaster dies, we'll probably never get an
+ * acknowledgement, because all the wal sender processes will exit.
+ * So just bail out.
*/
if (!PostmasterIsAlive(true))
{
static void
SyncRepQueueInsert(void)
{
- PGPROC *proc;
+ PGPROC *proc;
proc = (PGPROC *) SHMQueuePrev(&(WalSndCtl->SyncRepQueue),
&(WalSndCtl->SyncRepQueue),
while (proc)
{
/*
- * Stop at the queue element that we should after to
- * ensure the queue is ordered by LSN.
+ * Stop at the queue element that we should after to ensure the queue
+ * is ordered by LSN.
*/
if (XLByteLT(proc->waitLSN, MyProc->waitLSN))
break;
void
SyncRepInitConfig(void)
{
- int priority;
+ int priority;
/*
* Determine if we are a potential sync standby and remember the result
MyWalSnd->sync_standby_priority = priority;
LWLockRelease(SyncRepLock);
ereport(DEBUG1,
- (errmsg("standby \"%s\" now has synchronous standby priority %u",
- application_name, priority)));
+ (errmsg("standby \"%s\" now has synchronous standby priority %u",
+ application_name, priority)));
}
}
{
volatile WalSndCtlData *walsndctl = WalSndCtl;
volatile WalSnd *syncWalSnd = NULL;
- int numprocs = 0;
+ int numprocs = 0;
int priority = 0;
int i;
/*
* If this WALSender is serving a standby that is not on the list of
- * potential standbys then we have nothing to do. If we are still
- * starting up or still running base backup, then leave quickly also.
+ * potential standbys then we have nothing to do. If we are still starting
+ * up or still running base backup, then leave quickly also.
*/
if (MyWalSnd->sync_standby_priority == 0 ||
MyWalSnd->state < WALSNDSTATE_STREAMING)
return;
/*
- * We're a potential sync standby. Release waiters if we are the
- * highest priority standby. If there are multiple standbys with
- * same priorities then we use the first mentioned standby.
- * If you change this, also change pg_stat_get_wal_senders().
+ * We're a potential sync standby. Release waiters if we are the highest
+ * priority standby. If there are multiple standbys with same priorities
+ * then we use the first mentioned standby. If you change this, also
+ * change pg_stat_get_wal_senders().
*/
LWLockAcquire(SyncRepLock, LW_EXCLUSIVE);
(priority == 0 ||
priority > walsnd->sync_standby_priority))
{
- priority = walsnd->sync_standby_priority;
- syncWalSnd = walsnd;
+ priority = walsnd->sync_standby_priority;
+ syncWalSnd = walsnd;
}
}
if (XLByteLT(walsndctl->lsn, MyWalSnd->flush))
{
/*
- * Set the lsn first so that when we wake backends they will
- * release up to this location.
+ * Set the lsn first so that when we wake backends they will release
+ * up to this location.
*/
walsndctl->lsn = MyWalSnd->flush;
numprocs = SyncRepWakeQueue(false);
LWLockRelease(SyncRepLock);
elog(DEBUG3, "released %d procs up to %X/%X",
- numprocs,
- MyWalSnd->flush.xlogid,
- MyWalSnd->flush.xrecoff);
+ numprocs,
+ MyWalSnd->flush.xlogid,
+ MyWalSnd->flush.xrecoff);
/*
* If we are managing the highest priority standby, though we weren't
/*
* Walk queue from head. Set the state of any backends that need to be woken,
- * remove them from the queue, and then wake them. Pass all = true to wake
+ * remove them from the queue, and then wake them. Pass all = true to wake
* whole queue; otherwise, just wake up to the walsender's LSN.
*
* Must hold SyncRepLock.
SyncRepWakeQueue(bool all)
{
volatile WalSndCtlData *walsndctl = WalSndCtl;
- PGPROC *proc = NULL;
- PGPROC *thisproc = NULL;
- int numprocs = 0;
+ PGPROC *proc = NULL;
+ PGPROC *thisproc = NULL;
+ int numprocs = 0;
Assert(SyncRepQueueIsOrderedByLSN());
offsetof(PGPROC, syncRepLinks));
/*
- * Set state to complete; see SyncRepWaitForLSN() for discussion
- * of the various states.
+ * Set state to complete; see SyncRepWaitForLSN() for discussion of
+ * the various states.
*/
thisproc->syncRepState = SYNC_REP_WAIT_COMPLETE;
static bool
SyncRepQueueIsOrderedByLSN(void)
{
- PGPROC *proc = NULL;
- XLogRecPtr lastLSN;
+ PGPROC *proc = NULL;
+ XLogRecPtr lastLSN;
lastLSN.xlogid = 0;
lastLSN.xrecoff = 0;
while (proc)
{
/*
- * Check the queue is ordered by LSN and that multiple
- * procs don't have matching LSNs
+ * Check the queue is ordered by LSN and that multiple procs don't
+ * have matching LSNs
*/
if (XLByteLE(proc->waitLSN, lastLSN))
return false;
* Any additional validation of standby names should go here.
*
* Don't attempt to set WALSender priority because this is executed by
- * postmaster at startup, not WALSender, so the application_name is
- * not yet correctly set.
+ * postmaster at startup, not WALSender, so the application_name is not
+ * yet correctly set.
*/
pfree(rawstring);
XLogRecPtr Flush; /* last byte + 1 flushed in the standby */
} LogstreamResult;
-static StandbyReplyMessage reply_message;
-static StandbyHSFeedbackMessage feedback_message;
+static StandbyReplyMessage reply_message;
+static StandbyHSFeedbackMessage feedback_message;
/*
* About SIGTERM handling:
else
{
/*
- * We didn't receive anything new, but send a status update to
- * the master anyway, to report any progress in applying WAL.
+ * We didn't receive anything new, but send a status update to the
+ * master anyway, to report any progress in applying WAL.
*/
XLogWalRcvSendReply();
XLogWalRcvSendHSFeedback();
XLogWalRcvSendReply(void)
{
char buf[sizeof(StandbyReplyMessage) + 1];
- TimestampTz now;
+ TimestampTz now;
/*
* If the user doesn't want status to be reported to the master, be sure
if (XLByteEQ(reply_message.write, LogstreamResult.Write)
&& XLByteEQ(reply_message.flush, LogstreamResult.Flush)
&& !TimestampDifferenceExceeds(reply_message.sendTime, now,
- wal_receiver_status_interval * 1000))
+ wal_receiver_status_interval * 1000))
return;
/* Construct a new message */
reply_message.sendTime = now;
elog(DEBUG2, "sending write %X/%X flush %X/%X apply %X/%X",
- reply_message.write.xlogid, reply_message.write.xrecoff,
- reply_message.flush.xlogid, reply_message.flush.xrecoff,
- reply_message.apply.xlogid, reply_message.apply.xrecoff);
+ reply_message.write.xlogid, reply_message.write.xrecoff,
+ reply_message.flush.xlogid, reply_message.flush.xrecoff,
+ reply_message.apply.xlogid, reply_message.apply.xrecoff);
/* Prepend with the message type and send it. */
buf[0] = 'r';
static void
XLogWalRcvSendHSFeedback(void)
{
- char buf[sizeof(StandbyHSFeedbackMessage) + 1];
- TimestampTz now;
- TransactionId nextXid;
- uint32 nextEpoch;
- TransactionId xmin;
+ char buf[sizeof(StandbyHSFeedbackMessage) + 1];
+ TimestampTz now;
+ TransactionId nextXid;
+ uint32 nextEpoch;
+ TransactionId xmin;
/*
* If the user doesn't want status to be reported to the master, be sure
* Send feedback at most once per wal_receiver_status_interval.
*/
if (!TimestampDifferenceExceeds(feedback_message.sendTime, now,
- wal_receiver_status_interval * 1000))
+ wal_receiver_status_interval * 1000))
return;
/*
- * If Hot Standby is not yet active there is nothing to send.
- * Check this after the interval has expired to reduce number of
- * calls.
+ * If Hot Standby is not yet active there is nothing to send. Check this
+ * after the interval has expired to reduce number of calls.
*/
if (!HotStandbyActive())
return;
/*
- * Make the expensive call to get the oldest xmin once we are
- * certain everything else has been checked.
+ * Make the expensive call to get the oldest xmin once we are certain
+ * everything else has been checked.
*/
xmin = GetOldestXmin(true, false);
/*
- * Get epoch and adjust if nextXid and oldestXmin are different
- * sides of the epoch boundary.
+ * Get epoch and adjust if nextXid and oldestXmin are different sides of
+ * the epoch boundary.
*/
GetNextXidAndEpoch(&nextXid, &nextEpoch);
if (nextXid < xmin)
feedback_message.epoch = nextEpoch;
elog(DEBUG2, "sending hot standby feedback xmin %u epoch %u",
- feedback_message.xmin,
- feedback_message.epoch);
+ feedback_message.xmin,
+ feedback_message.epoch);
/* Prepend with the message type and send it. */
buf[0] = 'h';
walrcv->startTime = now;
/*
- * If this is the first startup of walreceiver, we initialize
- * receivedUpto and latestChunkStart to receiveStart.
+ * If this is the first startup of walreceiver, we initialize receivedUpto
+ * and latestChunkStart to receiveStart.
*/
if (walrcv->receiveStart.xlogid == 0 &&
walrcv->receiveStart.xrecoff == 0)
WalSndCtlData *WalSndCtl = NULL;
/* My slot in the shared memory array */
-WalSnd *MyWalSnd = NULL;
+WalSnd *MyWalSnd = NULL;
/* Global state */
bool am_walsender = false; /* Am I a walsender process ? */
/* User-settable parameters for walsender */
int max_wal_senders = 0; /* the maximum number of concurrent walsenders */
-int WalSndDelay = 1000; /* max sleep time between some actions */
-int replication_timeout = 60 * 1000; /* maximum time to send one WAL data message */
+int WalSndDelay = 1000; /* max sleep time between some actions */
+int replication_timeout = 60 * 1000; /* maximum time to send one
+ * WAL data message */
/*
* These variables are used similarly to openLogFile/Id/Seg/Off,
static void WalSndKill(int code, Datum arg);
static void XLogSend(char *msgbuf, bool *caughtup);
static void IdentifySystem(void);
-static void StartReplication(StartReplicationCmd * cmd);
+static void StartReplication(StartReplicationCmd *cmd);
static void ProcessStandbyMessage(void);
static void ProcessStandbyReplyMessage(void);
static void ProcessStandbyHSFeedbackMessage(void);
XLogRecPtr logptr;
/*
- * Reply with a result set with one row, three columns. First col is system
- * ID, second is timeline ID, and third is current xlog location.
+ * Reply with a result set with one row, three columns. First col is
+ * system ID, second is timeline ID, and third is current xlog location.
*/
snprintf(sysid, sizeof(sysid), UINT64_FORMAT,
* START_REPLICATION
*/
static void
-StartReplication(StartReplicationCmd * cmd)
+StartReplication(StartReplicationCmd *cmd)
{
StringInfoData buf;
/*
- * Let postmaster know that we're streaming. Once we've declared us as
- * a WAL sender process, postmaster will let us outlive the bgwriter and
- * kill us last in the shutdown sequence, so we get a chance to stream
- * all remaining WAL at shutdown, including the shutdown checkpoint.
- * Note that there's no going back, and we mustn't write any WAL records
- * after this.
+ * Let postmaster know that we're streaming. Once we've declared us as a
+ * WAL sender process, postmaster will let us outlive the bgwriter and
+ * kill us last in the shutdown sequence, so we get a chance to stream all
+ * remaining WAL at shutdown, including the shutdown checkpoint. Note that
+ * there's no going back, and we mustn't write any WAL records after this.
*/
MarkPostmasterChildWalSender();
SendPostmasterSignal(PMSIGNAL_ADVANCE_STATE_MACHINE);
* For some applications, for example, synchronous replication, it is
* important to have a clear state for this initial catchup mode, so we
* can trigger actions when we change streaming state later. We may stay
- * in this state for a long time, which is exactly why we want to be
- * able to monitor whether or not we are still here.
+ * in this state for a long time, which is exactly why we want to be able
+ * to monitor whether or not we are still here.
*/
WalSndSetState(WALSNDSTATE_CATCHUP);
{
unsigned char firstchar;
int r;
- int received = false;
+ int received = false;
for (;;)
{
firstchar)));
}
}
+
/*
- * Save the last reply timestamp if we've received at least
- * one reply.
+ * Save the last reply timestamp if we've received at least one reply.
*/
if (received)
last_reply_timestamp = GetCurrentTimestamp();
static void
ProcessStandbyMessage(void)
{
- char msgtype;
+ char msgtype;
resetStringInfo(&reply_message);
static void
ProcessStandbyReplyMessage(void)
{
- StandbyReplyMessage reply;
+ StandbyReplyMessage reply;
pq_copymsgbytes(&reply_message, (char *) &reply, sizeof(StandbyReplyMessage));
reply.apply.xlogid, reply.apply.xrecoff);
/*
- * Update shared state for this WalSender process
- * based on reply data from standby.
+ * Update shared state for this WalSender process based on reply data from
+ * standby.
*/
{
/* use volatile pointer to prevent code rearrangement */
static void
ProcessStandbyHSFeedbackMessage(void)
{
- StandbyHSFeedbackMessage reply;
+ StandbyHSFeedbackMessage reply;
TransactionId newxmin = InvalidTransactionId;
pq_copymsgbytes(&reply_message, (char *) &reply, sizeof(StandbyHSFeedbackMessage));
reply.epoch);
/*
- * Update the WalSender's proc xmin to allow it to be visible
- * to snapshots. This will hold back the removal of dead rows
- * and thereby prevent the generation of cleanup conflicts
- * on the standby server.
+ * Update the WalSender's proc xmin to allow it to be visible to
+ * snapshots. This will hold back the removal of dead rows and thereby
+ * prevent the generation of cleanup conflicts on the standby server.
*/
if (TransactionIdIsValid(reply.xmin))
{
- TransactionId nextXid;
- uint32 nextEpoch;
- bool epochOK = false;
+ TransactionId nextXid;
+ uint32 nextEpoch;
+ bool epochOK = false;
GetNextXidAndEpoch(&nextXid, &nextEpoch);
/*
- * Epoch of oldestXmin should be same as standby or
- * if the counter has wrapped, then one less than reply.
+ * Epoch of oldestXmin should be same as standby or if the counter has
+ * wrapped, then one less than reply.
*/
if (reply.xmin <= nextXid)
{
if (!TransactionIdIsValid(MyProc->xmin))
{
TransactionId oldestXmin = GetOldestXmin(true, true);
+
if (TransactionIdPrecedes(oldestXmin, reply.xmin))
newxmin = reply.xmin;
else
if (TransactionIdPrecedes(MyProc->xmin, reply.xmin))
newxmin = reply.xmin;
else
- newxmin = MyProc->xmin; /* stay the same */
+ newxmin = MyProc->xmin; /* stay the same */
}
}
}
}
/*
- * If we don't have any pending data in the output buffer, try to
- * send some more.
+ * If we don't have any pending data in the output buffer, try to send
+ * some more.
*/
if (!pq_is_send_pending())
{
* Even if we wrote all the WAL that was available when we started
* sending, more might have arrived while we were sending this
* batch. We had the latch set while sending, so we have not
- * received any signals from that time. Let's arm the latch
- * again, and after that check that we're still up-to-date.
+ * received any signals from that time. Let's arm the latch again,
+ * and after that check that we're still up-to-date.
*/
if (caughtup && !pq_is_send_pending())
{
!got_SIGHUP &&
!walsender_shutdown_requested)
{
- TimestampTz finish_time = 0;
+ TimestampTz finish_time = 0;
long sleeptime;
/* Reschedule replication timeout */
if (replication_timeout > 0)
{
long secs;
- int usecs;
+ int usecs;
finish_time = TimestampTzPlusMilliseconds(last_reply_timestamp,
- replication_timeout);
+ replication_timeout);
TimestampDifference(GetCurrentTimestamp(),
finish_time, &secs, &usecs);
sleeptime = secs * 1000 + usecs / 1000;
{
/*
* Since typically expiration of replication timeout means
- * communication problem, we don't send the error message
- * to the standby.
+ * communication problem, we don't send the error message to
+ * the standby.
*/
ereport(COMMERROR,
(errmsg("terminating walsender process due to replication timeout")));
* This is an important state change for users, since before this
* point data loss might occur if the primary dies and we need to
* failover to the standby. The state change is also important for
- * synchronous replication, since commits that started to wait at
- * that point might wait for some time.
+ * synchronous replication, since commits that started to wait at that
+ * point might wait for some time.
*/
if (MyWalSnd->state == WALSNDSTATE_CATCHUP && caughtup)
{
ereport(DEBUG1,
(errmsg("standby \"%s\" has now caught up with primary",
- application_name)));
+ application_name)));
WalSndSetState(WALSNDSTATE_STREAMING);
}
void
WalSndWakeup(void)
{
- int i;
+ int i;
for (i = 0; i < max_wal_senders; i++)
SetLatch(&WalSndCtl->walsnds[i].latch);
Datum
pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
{
-#define PG_STAT_GET_WAL_SENDERS_COLS 8
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
- int *sync_priority;
- int priority = 0;
- int sync_standby = -1;
- int i;
+#define PG_STAT_GET_WAL_SENDERS_COLS 8
+ ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
+ TupleDesc tupdesc;
+ Tuplestorestate *tupstore;
+ MemoryContext per_query_ctx;
+ MemoryContext oldcontext;
+ int *sync_priority;
+ int priority = 0;
+ int sync_standby = -1;
+ int i;
/* check to see if caller supports us returning a tuplestore */
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
MemoryContextSwitchTo(oldcontext);
/*
- * Get the priorities of sync standbys all in one go, to minimise
- * lock acquisitions and to allow us to evaluate who is the current
- * sync standby. This code must match the code in SyncRepReleaseWaiters().
+ * Get the priorities of sync standbys all in one go, to minimise lock
+ * acquisitions and to allow us to evaluate who is the current sync
+ * standby. This code must match the code in SyncRepReleaseWaiters().
*/
sync_priority = palloc(sizeof(int) * max_wal_senders);
LWLockAcquire(SyncRepLock, LW_SHARED);
XLogRecPtr write;
XLogRecPtr flush;
XLogRecPtr apply;
- WalSndState state;
+ WalSndState state;
Datum values[PG_STAT_GET_WAL_SENDERS_COLS];
bool nulls[PG_STAT_GET_WAL_SENDERS_COLS];
if (!superuser())
{
/*
- * Only superusers can see details. Other users only get
- * the pid value to know it's a walsender, but no details.
+ * Only superusers can see details. Other users only get the pid
+ * value to know it's a walsender, but no details.
*/
MemSet(&nulls[1], true, PG_STAT_GET_WAL_SENDERS_COLS - 1);
}
if (flush.xlogid == 0 && flush.xrecoff == 0)
nulls[4] = true;
snprintf(location, sizeof(location), "%X/%X",
- flush.xlogid, flush.xrecoff);
+ flush.xlogid, flush.xrecoff);
values[4] = CStringGetTextDatum(location);
if (apply.xlogid == 0 && apply.xrecoff == 0)
values[6] = Int32GetDatum(sync_priority[i]);
/*
- * More easily understood version of standby state.
- * This is purely informational, not different from priority.
+ * More easily understood version of standby state. This is purely
+ * informational, not different from priority.
*/
if (sync_priority[i] == 0)
values[7] = CStringGetTextDatum("ASYNC");
/*
* If we are installing an ON SELECT rule, we had better grab
* AccessExclusiveLock to ensure no SELECTs are currently running on the
- * event relation. For other types of rules, it is sufficient to
- * grab ShareRowExclusiveLock to lock out insert/update/delete actions
- * and to ensure that we lock out current CREATE RULE statements.
+ * event relation. For other types of rules, it is sufficient to grab
+ * ShareRowExclusiveLock to lock out insert/update/delete actions and to
+ * ensure that we lock out current CREATE RULE statements.
*/
if (event_type == CMD_SELECT)
event_relation = heap_open(event_relid, AccessExclusiveLock);
static void rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation,
List *attrnos);
static void rewriteTargetListUD(Query *parsetree, RangeTblEntry *target_rte,
- Relation target_relation);
+ Relation target_relation);
static void markQueryForLocking(Query *qry, Node *jtnode,
bool forUpdate, bool noWait, bool pushedDown);
static List *matchLocks(CmdType event, RuleLock *rulelocks,
}
/*
- * For an UPDATE on a view, provide a dummy entry whenever there is
- * no explicit assignment.
+ * For an UPDATE on a view, provide a dummy entry whenever there is no
+ * explicit assignment.
*/
if (new_tle == NULL && commandType == CMD_UPDATE &&
target_relation->rd_rel->relkind == RELKIND_VIEW)
* rewriteTargetListUD - rewrite UPDATE/DELETE targetlist as needed
*
* This function adds a "junk" TLE that is needed to allow the executor to
- * find the original row for the update or delete. When the target relation
+ * find the original row for the update or delete. When the target relation
* is a regular table, the junk TLE emits the ctid attribute of the original
* row. When the target relation is a view, there is no ctid, so we instead
* emit a whole-row Var that will contain the "old" values of the view row.
else
{
/*
- * Emit whole-row Var so that executor will have the "old" view row
- * to pass to the INSTEAD OF trigger.
+ * Emit whole-row Var so that executor will have the "old" view row to
+ * pass to the INSTEAD OF trigger.
*/
var = makeWholeRowVar(target_rte,
parsetree->resultRelation,
* fine as the result relation.
*
* For UPDATE/DELETE, we need to expand the view so as to have source
- * data for the operation. But we also need an unmodified RTE to
+ * data for the operation. But we also need an unmodified RTE to
* serve as the target. So, copy the RTE and add the copy to the
- * rangetable. Note that the copy does not get added to the jointree.
- * Also note that there's a hack in fireRIRrules to avoid calling
- * this function again when it arrives at the copied RTE.
+ * rangetable. Note that the copy does not get added to the jointree.
+ * Also note that there's a hack in fireRIRrules to avoid calling this
+ * function again when it arrives at the copied RTE.
*/
if (parsetree->commandType == CMD_INSERT)
return parsetree;
parsetree->resultRelation = list_length(parsetree->rtable);
/*
- * There's no need to do permissions checks twice, so wipe out
- * the permissions info for the original RTE (we prefer to keep
- * the bits set on the result RTE).
+ * There's no need to do permissions checks twice, so wipe out the
+ * permissions info for the original RTE (we prefer to keep the
+ * bits set on the result RTE).
*/
rte->requiredPerms = 0;
rte->checkAsUser = InvalidOid;
*/
foreach(lc1, parsetree->cteList)
{
- CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc1);
- Query *ctequery = (Query *) cte->ctequery;
- List *newstuff;
+ CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc1);
+ Query *ctequery = (Query *) cte->ctequery;
+ List *newstuff;
Assert(IsA(ctequery, Query));
}
else
{
- ListCell *lc2;
+ ListCell *lc2;
/* examine queries to determine which error message to issue */
foreach(lc2, newstuff)
{
- Query *q = (Query *) lfirst(lc2);
+ Query *q = (Query *) lfirst(lc2);
if (q->querySource == QSRC_QUAL_INSTEAD_RULE)
ereport(ERROR,
* Find rule oid, given only a rule name but no rel OID.
*
* If there's more than one, it's an error. If there aren't any, that's an
- * error, too. In general, this should be avoided - it is provided to support
+ * error, too. In general, this should be avoided - it is provided to support
* syntax that is compatible with pre-7.3 versions of PG, where rule names
* were unique across the entire database.
*/
/* OK, do the I/O */
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_START(forkNum, blockNum,
- smgr->smgr_rnode.node.spcNode,
- smgr->smgr_rnode.node.dbNode,
- smgr->smgr_rnode.node.relNode);
+ smgr->smgr_rnode.node.spcNode,
+ smgr->smgr_rnode.node.dbNode,
+ smgr->smgr_rnode.node.relNode);
FlushBuffer(buf, NULL);
LWLockRelease(buf->content_lock);
TRACE_POSTGRESQL_BUFFER_WRITE_DIRTY_DONE(forkNum, blockNum,
- smgr->smgr_rnode.node.spcNode,
- smgr->smgr_rnode.node.dbNode,
- smgr->smgr_rnode.node.relNode);
+ smgr->smgr_rnode.node.spcNode,
+ smgr->smgr_rnode.node.dbNode,
+ smgr->smgr_rnode.node.relNode);
}
else
{
"[%02d] (freeNext=%d, rel=%s, "
"blockNum=%u, flags=0x%x, refcount=%u %d)",
i, buf->freeNext,
- relpathbackend(buf->tag.rnode, InvalidBackendId, buf->tag.forkNum),
+ relpathbackend(buf->tag.rnode, InvalidBackendId, buf->tag.forkNum),
buf->tag.blockNum, buf->flags,
buf->refcount, PrivateRefCount[i]);
}
if (bufHdr != NULL)
{
char *path = relpathbackend(bufHdr->tag.rnode, MyBackendId,
- bufHdr->tag.forkNum);
+ bufHdr->tag.forkNum);
errcontext("writing block %u of relation %s",
bufHdr->tag.blockNum, path);
* struct.
*/
Buffer buffers[1]; /* VARIABLE SIZE ARRAY */
-} BufferAccessStrategyData;
+} BufferAccessStrategyData;
/* Prototypes for internal functions */
#ifdef LBDEBUG
fprintf(stderr, "LB ALLOC (%u,%d,%d) %d\n",
- smgr->smgr_rnode.node.relNode, forkNum, blockNum,
- -nextFreeLocalBuf - 1);
+ smgr->smgr_rnode.node.relNode, forkNum, blockNum,
+ -nextFreeLocalBuf - 1);
#endif
/*
elog(ERROR, "block %u of %s is still referenced (local %u)",
bufHdr->tag.blockNum,
relpathbackend(bufHdr->tag.rnode, MyBackendId,
- bufHdr->tag.forkNum),
+ bufHdr->tag.forkNum),
LocalRefCount[i]);
/* Remove entry from hashtable */
hresult = (LocalBufferLookupEnt *)
/*
* We allocate local buffers in a context of their own, so that the
* space eaten for them is easily recognizable in MemoryContextStats
- * output. Create the context on first use.
+ * output. Create the context on first use.
*/
if (LocalBufferContext == NULL)
LocalBufferContext =
* If we get an error, as could happen within the ereport/elog calls,
* we'll come right back here during transaction abort. Reset the
* flag to ensure that we can't get into an infinite loop. This code
- * is arranged to ensure that the worst-case consequence is failing
- * to emit log message(s), not failing to attempt the unlink.
+ * is arranged to ensure that the worst-case consequence is failing to
+ * emit log message(s), not failing to attempt the unlink.
*/
vfdP->fdstate &= ~FD_TEMPORARY;
if (log_temp_files >= 0)
{
struct stat filestats;
- int stat_errno;
+ int stat_errno;
/* first try the stat() */
if (stat(vfdP->fileName, &filestats))
RemovePgTempFilesInDir(temp_path);
snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
- spc_de->d_name, TABLESPACE_VERSION_DIRECTORY);
+ spc_de->d_name, TABLESPACE_VERSION_DIRECTORY);
RemovePgTempRelationFiles(temp_path);
}
while ((de = ReadDir(ts_dir, tsdirname)) != NULL)
{
- int i = 0;
+ int i = 0;
/*
* We're only interested in the per-database directories, which have
snprintf(rm_path, sizeof(rm_path), "%s/%s",
dbspacedirname, de->d_name);
- unlink(rm_path); /* note we ignore any error */
+ unlink(rm_path); /* note we ignore any error */
}
FreeDir(dbspace_dir);
/* We might have _forkname or .segment or both. */
if (name[pos] == '_')
{
- int forkchar = forkname_chars(&name[pos+1], NULL);
+ int forkchar = forkname_chars(&name[pos + 1], NULL);
+
if (forkchar <= 0)
return false;
pos += forkchar + 1;
}
if (name[pos] == '.')
{
- int segchar;
- for (segchar = 1; isdigit((unsigned char) name[pos+segchar]); ++segchar)
+ int segchar;
+
+ for (segchar = 1; isdigit((unsigned char) name[pos + segchar]); ++segchar)
;
if (segchar <= 1)
return false;
#include "utils/memutils.h"
static void ResetUnloggedRelationsInTablespaceDir(const char *tsdirname,
- int op);
+ int op);
static void ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname,
int op);
static bool parse_filename_for_nontemp_relation(const char *name,
int *oidchars, ForkNumber *fork);
-typedef struct {
- char oid[OIDCHARS+1];
+typedef struct
+{
+ char oid[OIDCHARS + 1];
} unlogged_relation_entry;
/*
char temp_path[MAXPGPATH];
DIR *spc_dir;
struct dirent *spc_de;
- MemoryContext tmpctx, oldctx;
+ MemoryContext tmpctx,
+ oldctx;
/* Log it. */
ereport(DEBUG1,
(errmsg("resetting unlogged relations: cleanup %d init %d",
- (op & UNLOGGED_RELATION_CLEANUP) != 0,
- (op & UNLOGGED_RELATION_INIT) != 0)));
+ (op & UNLOGGED_RELATION_CLEANUP) != 0,
+ (op & UNLOGGED_RELATION_INIT) != 0)));
/*
* Just to be sure we don't leak any memory, let's create a temporary
continue;
snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
- spc_de->d_name, TABLESPACE_VERSION_DIRECTORY);
+ spc_de->d_name, TABLESPACE_VERSION_DIRECTORY);
ResetUnloggedRelationsInTablespaceDir(temp_path, op);
}
while ((de = ReadDir(ts_dir, tsdirname)) != NULL)
{
- int i = 0;
+ int i = 0;
/*
* We're only interested in the per-database directories, which have
/* Scan the directory. */
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
{
- ForkNumber forkNum;
- int oidchars;
+ ForkNumber forkNum;
+ int oidchars;
unlogged_relation_entry ent;
/* Skip anything that doesn't look like a relation data file. */
continue;
/*
- * Put the OID portion of the name into the hash table, if it isn't
- * already.
+ * Put the OID portion of the name into the hash table, if it
+ * isn't already.
*/
memset(ent.oid, 0, sizeof(ent.oid));
memcpy(ent.oid, de->d_name, oidchars);
/* Scan the directory. */
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
{
- ForkNumber forkNum;
- int oidchars;
- bool found;
+ ForkNumber forkNum;
+ int oidchars;
+ bool found;
unlogged_relation_entry ent;
/* Skip anything that doesn't look like a relation data file. */
if (found)
{
snprintf(rm_path, sizeof(rm_path), "%s/%s",
- dbspacedirname, de->d_name);
+ dbspacedirname, de->d_name);
+
/*
* It's tempting to actually throw an error here, but since
* this code gets run during database startup, that could
/*
* Initialization happens after cleanup is complete: we copy each init
* fork file to the corresponding main fork file. Note that if we are
- * asked to do both cleanup and init, we may never get here: if the cleanup
- * code determines that there are no init forks in this dbspace, it will
- * return before we get to this point.
+ * asked to do both cleanup and init, we may never get here: if the
+ * cleanup code determines that there are no init forks in this dbspace,
+ * it will return before we get to this point.
*/
if ((op & UNLOGGED_RELATION_INIT) != 0)
{
/* Scan the directory. */
while ((de = ReadDir(dbspace_dir, dbspacedirname)) != NULL)
{
- ForkNumber forkNum;
- int oidchars;
- char oidbuf[OIDCHARS+1];
- char srcpath[MAXPGPATH];
- char dstpath[MAXPGPATH];
+ ForkNumber forkNum;
+ int oidchars;
+ char oidbuf[OIDCHARS + 1];
+ char srcpath[MAXPGPATH];
+ char dstpath[MAXPGPATH];
/* Skip anything that doesn't look like a relation data file. */
if (!parse_filename_for_nontemp_relation(de->d_name, &oidchars,
*fork = MAIN_FORKNUM;
else
{
- int forkchar;
+ int forkchar;
- forkchar = forkname_chars(&name[pos+1], fork);
+ forkchar = forkname_chars(&name[pos + 1], fork);
if (forkchar <= 0)
return false;
pos += forkchar + 1;
/* Check for a segment number. */
if (name[pos] == '.')
{
- int segchar;
- for (segchar = 1; isdigit((unsigned char) name[pos+segchar]); ++segchar)
+ int segchar;
+
+ for (segchar = 1; isdigit((unsigned char) name[pos + segchar]); ++segchar)
;
if (segchar <= 1)
return false;
#ifndef WIN32
if (amDirectChild)
{
- pid_t ppid = getppid();
+ pid_t ppid = getppid();
/* If the postmaster is still our parent, it must be alive. */
if (ppid == PostmasterPid)
}
/*
- * Use kill() to see if the postmaster is still alive. This can
- * sometimes give a false positive result, since the postmaster's PID
- * may get recycled, but it is good enough for existing uses by
- * indirect children and in debugging environments.
+ * Use kill() to see if the postmaster is still alive. This can sometimes
+ * give a false positive result, since the postmaster's PID may get
+ * recycled, but it is good enough for existing uses by indirect children
+ * and in debugging environments.
*/
return (kill(PostmasterPid, 0) == 0);
#else /* WIN32 */
return;
/*
- * If our initial RunningTransactionsData had an overflowed snapshot then we knew
- * we were missing some subxids from our snapshot. We can use this data as
- * an initial snapshot, but we cannot yet mark it valid. We know that the
- * missing subxids are equal to or earlier than nextXid. After we
+ * If our initial RunningTransactionsData had an overflowed snapshot then
+ * we knew we were missing some subxids from our snapshot. We can use this
+ * data as an initial snapshot, but we cannot yet mark it valid. We know
+ * that the missing subxids are equal to or earlier than nextXid. After we
* initialise we continue to apply changes during recovery, so once the
* oldestRunningXid is later than the nextXid from the initial snapshot we
* know that we no longer have missing information and can mark the
*/
/*
- * Release any locks belonging to old transactions that are not
- * running according to the running-xacts record.
+ * Release any locks belonging to old transactions that are not running
+ * according to the running-xacts record.
*/
StandbyReleaseOldLocks(running->nextXid);
* Now we've got the running xids we need to set the global values that
* are used to track snapshots as they evolve further.
*
- * - latestCompletedXid which will be the xmax for snapshots
- * - lastOverflowedXid which shows whether snapshots overflow
- * - nextXid
+ * - latestCompletedXid which will be the xmax for snapshots -
+ * lastOverflowedXid which shows whether snapshots overflow - nextXid
*
* If the snapshot overflowed, then we still initialise with what we know,
* but the recovery snapshot isn't fully valid yet because we know there
/*
* If a transaction wrote a commit record in the gap between taking and
- * logging the snapshot then latestCompletedXid may already be higher
- * than the value from the snapshot, so check before we use the incoming
- * value.
+ * logging the snapshot then latestCompletedXid may already be higher than
+ * the value from the snapshot, so check before we use the incoming value.
*/
if (TransactionIdPrecedes(ShmemVariableCache->latestCompletedXid,
running->latestCompletedXid))
if (allDbs ||
proc->databaseId == MyDatabaseId ||
- proc->databaseId == 0) /* include WalSender */
+ proc->databaseId == 0) /* include WalSender */
{
/* Fetch xid just once - see GetNewTransactionId */
TransactionId xid = proc->xid;
if (RecoveryInProgress())
{
/*
- * Check to see whether KnownAssignedXids contains an xid value
- * older than the main procarray.
+ * Check to see whether KnownAssignedXids contains an xid value older
+ * than the main procarray.
*/
TransactionId kaxmin = KnownAssignedXidsGetOldestXmin();
if (TransactionIdIsNormal(kaxmin) &&
TransactionIdPrecedes(kaxmin, result))
- result = kaxmin;
+ result = kaxmin;
}
else
{
* vacuum_defer_cleanup_age provides some additional "slop" for the
* benefit of hot standby queries on slave servers. This is quick and
* dirty, and perhaps not all that useful unless the master has a
- * predictable transaction rate, but it's what we've got. Note that we
- * are assuming vacuum_defer_cleanup_age isn't large enough to cause
- * wraparound --- so guc.c should limit it to no more than the
+ * predictable transaction rate, but it's what we've got. Note that
+ * we are assuming vacuum_defer_cleanup_age isn't large enough to
+ * cause wraparound --- so guc.c should limit it to no more than the
* xidStopLimit threshold in varsup.c.
*/
result -= vacuum_defer_cleanup_age;
suboverflowed = true;
/*
- * Top-level XID of a transaction is always less than any of
- * its subxids, so we don't need to check if any of the subxids
- * are smaller than oldestRunningXid
+ * Top-level XID of a transaction is always less than any of its
+ * subxids, so we don't need to check if any of the subxids are
+ * smaller than oldestRunningXid
*/
}
}
return;
waitStart = GetCurrentTimestamp();
- new_status = NULL; /* we haven't changed the ps display */
+ new_status = NULL; /* we haven't changed the ps display */
while (VirtualTransactionIdIsValid(*waitlist))
{
LogAccessExclusiveLockPrepare(void)
{
/*
- * Ensure that a TransactionId has been assigned to this transaction,
- * for two reasons, both related to lock release on the standby.
- * First, we must assign an xid so that RecordTransactionCommit() and
+ * Ensure that a TransactionId has been assigned to this transaction, for
+ * two reasons, both related to lock release on the standby. First, we
+ * must assign an xid so that RecordTransactionCommit() and
* RecordTransactionAbort() do not optimise away the transaction
- * completion record which recovery relies upon to release locks. It's
- * a hack, but for a corner case not worth adding code for into the
- * main commit path. Second, must must assign an xid before the lock
- * is recorded in shared memory, otherwise a concurrently executing
+ * completion record which recovery relies upon to release locks. It's a
+ * hack, but for a corner case not worth adding code for into the main
+ * commit path. Second, must must assign an xid before the lock is
+ * recorded in shared memory, otherwise a concurrently executing
* GetRunningTransactionLocks() might see a lock associated with an
* InvalidTransactionId which we later assert cannot happen.
*/
{
/*
* If the first page we found was after the truncation point, we're in
- * a hole that we'll fill, but we need to delete the later page because
- * the loop below won't visit it again.
+ * a hole that we'll fill, but we need to delete the later page
+ * because the loop below won't visit it again.
*/
if (olddata != NULL)
{
* standby server. Only AccessExclusiveLocks can conflict with lock types
* that read-only transactions can acquire in a standby server.
*
- * Make sure this definition matches the one in GetRunningTransactionLocks().
+ * Make sure this definition matches the one in
+ * GetRunningTransactionLocks().
*
* First we prepare to log, then after lock acquired we issue log record.
*/
TransactionId headXid; /* newest valid Xid in the SLRU */
TransactionId tailXid; /* oldest xmin we might be interested in */
bool warningIssued;
-} OldSerXidControlData;
+} OldSerXidControlData;
typedef struct OldSerXidControlData *OldSerXidControl;
ptle = (PredXactListElement)
(((char *) sxact)
- offsetof(PredXactListElementData, sxact)
- +offsetof(PredXactListElementData, link));
+ + offsetof(PredXactListElementData, link));
SHMQueueDelete(&ptle->link);
SHMQueueInsertBefore(&PredXact->availableList, &ptle->link);
}
ptle = (PredXactListElement)
(((char *) sxact)
- offsetof(PredXactListElementData, sxact)
- +offsetof(PredXactListElementData, link));
+ + offsetof(PredXactListElementData, link));
ptle = (PredXactListElement)
SHMQueueNext(&PredXact->activeList,
&ptle->link,
Assert(TransactionIdIsValid(tailXid));
/*
- * If the SLRU is currently unused, zero out the whole active region
- * from tailXid to headXid before taking it into use. Otherwise zero
- * out only any new pages that enter the tailXid-headXid range as we
- * advance headXid.
+ * If the SLRU is currently unused, zero out the whole active region from
+ * tailXid to headXid before taking it into use. Otherwise zero out only
+ * any new pages that enter the tailXid-headXid range as we advance
+ * headXid.
*/
if (oldSerXidControl->headPage < 0)
{
/*
* When no sxacts are active, nothing overlaps, set the xid values to
* invalid to show that there are no valid entries. Don't clear headPage,
- * though. A new xmin might still land on that page, and we don't want
- * to repeatedly zero out the same page.
+ * though. A new xmin might still land on that page, and we don't want to
+ * repeatedly zero out the same page.
*/
if (!TransactionIdIsValid(xid))
{
void
CheckPointPredicate(void)
{
- int tailPage;
+ int tailPage;
LWLockAcquire(OldSerXidLock, LW_EXCLUSIVE);
{
/*
* The SLRU is no longer needed. Truncate everything. If we try to
- * leave the head page around to avoid re-zeroing it, we might not
- * use the SLRU again until we're past the wrap-around point, which
- * makes SLRU unhappy.
+ * leave the head page around to avoid re-zeroing it, we might not use
+ * the SLRU again until we're past the wrap-around point, which makes
+ * SLRU unhappy.
*
* While the API asks you to specify truncation by page, it silently
- * ignores the request unless the specified page is in a segment
- * past some allocated portion of the SLRU. We don't care which
- * page in a later segment we hit, so just add the number of pages
- * per segment to the head page to land us *somewhere* in the next
- * segment.
+ * ignores the request unless the specified page is in a segment past
+ * some allocated portion of the SLRU. We don't care which page in a
+ * later segment we hit, so just add the number of pages per segment
+ * to the head page to land us *somewhere* in the next segment.
*/
tailPage = oldSerXidControl->headPage + SLRU_PAGES_PER_SEGMENT;
oldSerXidControl->headPage = -1;
/*
* This function is only called if there are no sxact slots available.
* Some of them must belong to old, already-finished transactions, so
- * there should be something in FinishedSerializableTransactions list
- * that we can summarize. However, there's a race condition: while we
- * were not holding any locks, a transaction might have ended and cleaned
- * up all the finished sxact entries already, freeing up their sxact
- * slots. In that case, we have nothing to do here. The caller will find
- * one of the slots released by the other backend when it retries.
+ * there should be something in FinishedSerializableTransactions list that
+ * we can summarize. However, there's a race condition: while we were not
+ * holding any locks, a transaction might have ended and cleaned up all
+ * the finished sxact entries already, freeing up their sxact slots. In
+ * that case, we have nothing to do here. The caller will find one of the
+ * slots released by the other backend when it retries.
*/
if (SHMQueueEmpty(FinishedSerializableTransactions))
{
*/
if (relation->rd_index == NULL)
{
- TransactionId myxid;
+ TransactionId myxid;
targetxmin = HeapTupleHeaderGetXmin(tuple->t_data);
if (TransactionIdFollowsOrEquals(targetxmin, TransactionXmin))
{
TransactionId xid = SubTransGetTopmostTransaction(targetxmin);
+
if (TransactionIdEquals(xid, myxid))
{
/* We wrote it; we already have a write lock. */
PREDICATELOCKTARGETTAG oldtupletag;
PREDICATELOCKTARGETTAG oldpagetag;
PREDICATELOCKTARGETTAG newtupletag;
- BlockNumber oldblk,
+ BlockNumber oldblk,
newblk;
OffsetNumber oldoff,
newoff;
/*
* A page-level lock on the page containing the old tuple counts too.
- * Anyone holding a lock on the page is logically holding a lock on
- * the old tuple, so we need to acquire a lock on his behalf on the
- * new tuple too. However, if the new tuple is on the same page as the
- * old one, the old page-level lock already covers the new tuple.
+ * Anyone holding a lock on the page is logically holding a lock on the
+ * old tuple, so we need to acquire a lock on his behalf on the new tuple
+ * too. However, if the new tuple is on the same page as the old one, the
+ * old page-level lock already covers the new tuple.
*
* A relation-level lock always covers both tuple versions, so we don't
* need to worry about those here.
/*
* Move the locks to the parent. This shouldn't fail.
*
- * Note that here we are removing locks held by other
- * backends, leading to a possible inconsistency in their
- * local lock hash table. This is OK because we're replacing
- * it with a lock that covers the old one.
+ * Note that here we are removing locks held by other backends,
+ * leading to a possible inconsistency in their local lock hash table.
+ * This is OK because we're replacing it with a lock that covers the
+ * old one.
*/
success = TransferPredicateLocksToNewTarget(oldtargettag,
newtargettag,
const BlockNumber newblkno)
{
/*
- * Page combines differ from page splits in that we ought to be
- * able to remove the locks on the old page after transferring
- * them to the new page, instead of duplicating them. However,
- * because we can't edit other backends' local lock tables,
- * removing the old lock would leave them with an entry in their
- * LocalPredicateLockHash for a lock they're not holding, which
- * isn't acceptable. So we wind up having to do the same work as a
- * page split, acquiring a lock on the new page and keeping the old
- * page locked too. That can lead to some false positives, but
- * should be rare in practice.
+ * Page combines differ from page splits in that we ought to be able to
+ * remove the locks on the old page after transferring them to the new
+ * page, instead of duplicating them. However, because we can't edit other
+ * backends' local lock tables, removing the old lock would leave them
+ * with an entry in their LocalPredicateLockHash for a lock they're not
+ * holding, which isn't acceptable. So we wind up having to do the same
+ * work as a page split, acquiring a lock on the new page and keeping the
+ * old page locked too. That can lead to some false positives, but should
+ * be rare in practice.
*/
PredicateLockPageSplit(relation, oldblkno, newblkno);
}
/*
* If we're getting a write lock on the tuple and we're not in a
* subtransaction, we don't need a predicate (SIREAD) lock. We
- * can't use this optimization within a subtransaction because
- * the subtransaction could be rolled back, and we would be left
+ * can't use this optimization within a subtransaction because the
+ * subtransaction could be rolled back, and we would be left
* without any lock at the top level.
- *
+ *
* At this point our transaction already has an ExclusiveRowLock
- * on the relation, so we are OK to drop the predicate lock on
- * the tuple, if found, without fearing that another write
- * against the tuple will occur before the MVCC information
- * makes it to the buffer.
+ * on the relation, so we are OK to drop the predicate lock on the
+ * tuple, if found, without fearing that another write against the
+ * tuple will occur before the MVCC information makes it to the
+ * buffer.
*/
if (!IsSubTransaction()
&& GET_PREDICATELOCKTARGETTAG_OFFSET(*targettag))
/*
* Remove entry in local lock table if it exists and has
* no children. It's OK if it doesn't exist; that means
- * the lock was transferred to a new target by a
- * different backend.
+ * the lock was transferred to a new target by a different
+ * backend.
*/
if (locallock != NULL)
{
{
rmlocallock = (LOCALPREDICATELOCK *)
hash_search_with_hash_value(LocalPredicateLockHash,
- targettag, targettaghash,
- HASH_REMOVE, NULL);
+ targettag, targettaghash,
+ HASH_REMOVE, NULL);
Assert(rmlocallock == locallock);
}
}
LWLockAcquire(partitionLock, LW_SHARED);
/*
- * The list may have been altered by another process
- * while we weren't holding the partition lock. Start
- * over at the front.
+ * The list may have been altered by another process while
+ * we weren't holding the partition lock. Start over at
+ * the front.
*/
nextpredlock = (PREDICATELOCK *)
SHMQueueNext(&(target->predicateLocks),
relation->rd_node.dbNode,
relation->rd_id,
ItemPointerGetBlockNumber(&(tuple->t_data->t_ctid)),
- ItemPointerGetOffsetNumber(&(tuple->t_data->t_ctid)),
- HeapTupleHeaderGetXmin(tuple->t_data));
+ ItemPointerGetOffsetNumber(&(tuple->t_data->t_ctid)),
+ HeapTupleHeaderGetXmin(tuple->t_data));
CheckTargetForConflictsIn(&targettag);
}
int processed = 0;
instr_time sync_start,
sync_end,
- sync_diff;
+ sync_diff;
uint64 elapsed;
uint64 longest = 0;
uint64 total_elapsed = 0;
if (seg != NULL &&
FileSync(seg->mdfd_vfd) >= 0)
{
- if (log_checkpoints && (! INSTR_TIME_IS_ZERO(sync_start)))
+ if (log_checkpoints && (!INSTR_TIME_IS_ZERO(sync_start)))
{
INSTR_TIME_SET_CURRENT(sync_end);
sync_diff = sync_end;
longest = elapsed;
total_elapsed += elapsed;
processed++;
- elog(DEBUG1, "checkpoint sync: number=%d file=%s time=%.3f msec",
- processed, FilePathName(seg->mdfd_vfd), (double) elapsed / 1000);
+ elog(DEBUG1, "checkpoint sync: number=%d file=%s time=%.3f msec",
+ processed, FilePathName(seg->mdfd_vfd), (double) elapsed / 1000);
}
break; /* success; break out of retry loop */
return; /* passed it off successfully */
ereport(DEBUG1,
- (errmsg("could not forward fsync request because request queue is full")));
+ (errmsg("could not forward fsync request because request queue is full")));
if (FileSync(seg->mdfd_vfd) < 0)
ereport(ERROR,
void (*smgr_unlink) (RelFileNodeBackend rnode, ForkNumber forknum,
bool isRedo);
void (*smgr_extend) (SMgrRelation reln, ForkNumber forknum,
- BlockNumber blocknum, char *buffer, bool skipFsync);
+ BlockNumber blocknum, char *buffer, bool skipFsync);
void (*smgr_prefetch) (SMgrRelation reln, ForkNumber forknum,
BlockNumber blocknum);
void (*smgr_read) (SMgrRelation reln, ForkNumber forknum,
BlockNumber blocknum, char *buffer);
void (*smgr_write) (SMgrRelation reln, ForkNumber forknum,
- BlockNumber blocknum, char *buffer, bool skipFsync);
+ BlockNumber blocknum, char *buffer, bool skipFsync);
BlockNumber (*smgr_nblocks) (SMgrRelation reln, ForkNumber forknum);
void (*smgr_truncate) (SMgrRelation reln, ForkNumber forknum,
- BlockNumber nblocks);
+ BlockNumber nblocks);
void (*smgr_immedsync) (SMgrRelation reln, ForkNumber forknum);
void (*smgr_pre_ckpt) (void); /* may be NULL */
void (*smgr_sync) (void); /* may be NULL */
/* sizeof(ParamListInfoData) includes the first array element */
params = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
- (numParams - 1) *sizeof(ParamExternData));
+ (numParams - 1) * sizeof(ParamExternData));
/* we have static list of params, so no hooks needed */
params->paramFetch = NULL;
params->paramFetchArg = NULL;
#ifndef __INTEL_COMPILER
/* the ;; is a "stop", seems to be required before fetching BSP */
- __asm__ __volatile__(
- ";;\n"
- " mov %0=ar.bsp \n"
-: "=r"(ret));
+ __asm__ __volatile__(
+ ";;\n"
+ " mov %0=ar.bsp \n"
+ : "=r"(ret));
#else
- ret = (char *) __getReg(_IA64_REG_AR_BSP);
+ ret = (char *) __getReg(_IA64_REG_AR_BSP);
#endif
- return ret;
+ return ret;
}
-
-#endif /* IA64 */
+#endif /* IA64 */
/*
(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
errmsg("stack depth limit exceeded"),
errhint("Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
- "after ensuring the platform's stack depth limit is adequate.",
+ "after ensuring the platform's stack depth limit is adequate.",
max_stack_depth)));
}
(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
errmsg("stack depth limit exceeded"),
errhint("Increase the configuration parameter \"max_stack_depth\" (currently %dkB), "
- "after ensuring the platform's stack depth limit is adequate.",
+ "after ensuring the platform's stack depth limit is adequate.",
max_stack_depth)));
}
-#endif /* IA64 */
+#endif /* IA64 */
}
/* GUC check hook for max_stack_depth */
/*
* PORTAL_ONE_SELECT and PORTAL_UTIL_SELECT need only consider the
* single-statement case, since there are no rewrite rules that can add
- * auxiliary queries to a SELECT or a utility command.
- * PORTAL_ONE_MOD_WITH likewise allows only one top-level statement.
+ * auxiliary queries to a SELECT or a utility command. PORTAL_ONE_MOD_WITH
+ * likewise allows only one top-level statement.
*/
if (list_length(stmts) == 1)
{
* list. Transaction control, LOCK, and SET must *not* set a snapshot
* since they need to be executable at the start of a transaction-snapshot
* mode transaction without freezing a snapshot. By extension we allow
- * SHOW not to set a snapshot. The other stmts listed are just efficiency
+ * SHOW not to set a snapshot. The other stmts listed are just efficiency
* hacks. Beware of listing anything that can modify the database --- if,
* say, it has to update an index with expressions that invoke
* user-defined functions, then it had better have a snapshot.
/*
* Unless "IF NOT EXISTS" was specified and the
- * relation already exists, create the pg_foreign_table
- * entry.
+ * relation already exists, create the
+ * pg_foreign_table entry.
*/
if (relOid != InvalidOid)
CreateForeignTable((CreateForeignTableStmt *) stmt,
- relOid);
+ relOid);
}
else
{
break;
case T_AlterEnumStmt: /* ALTER TYPE (enum) */
+
/*
* We disallow this in transaction blocks, because we can't cope
* with enum OID values getting into indexes and then having their
* doesn't need that. The cpalloc and cpalloc0 macros are just documentation
* to indicate which allocations actually require zeroing.
*/
-#define COMPACT_ALLOC_CHUNK 8192 /* must be > aset.c's allocChunkLimit */
+#define COMPACT_ALLOC_CHUNK 8192 /* must be > aset.c's allocChunkLimit */
#define COMPACT_MAX_REQ 1024 /* must be < COMPACT_ALLOC_CHUNK */
static void *
{
int clen = pg_mblen(ptr);
wchar_t character[2];
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
if (clen == 1 || lc_ctype_is_c(collation))
return isdigit(TOUCHAR(ptr));
{
int clen = pg_mblen(ptr);
wchar_t character[2];
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
if (clen == 1 || lc_ctype_is_c(collation))
return isspace(TOUCHAR(ptr));
{
int clen = pg_mblen(ptr);
wchar_t character[2];
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
if (clen == 1 || lc_ctype_is_c(collation))
return isalpha(TOUCHAR(ptr));
{
int clen = pg_mblen(ptr);
wchar_t character[2];
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
if (clen == 1 || lc_ctype_is_c(collation))
return isprint(TOUCHAR(ptr));
lowerstr_with_len(const char *str, int len)
{
char *out;
+
#ifdef USE_WIDE_UPPER_LOWER
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
#endif
if (len == 0)
/*
* Our strategy is to scan through the MCV list and add up the
- * frequencies of the ones that match the prefix, thereby
- * assuming that the MCVs are representative of the whole lexeme
- * population in this respect. Compare histogram_selectivity().
+ * frequencies of the ones that match the prefix, thereby assuming
+ * that the MCVs are representative of the whole lexeme population
+ * in this respect. Compare histogram_selectivity().
*
* This is only a good plan if we have a pretty fair number of
* MCVs available; we set the threshold at 100. If no stats or
default:
elog(ERROR, "unrecognized operator: %d", item->qoperator.oper);
- selec = 0; /* keep compiler quiet */
+ selec = 0; /* keep compiler quiet */
break;
}
}
*/
if (prs->charmaxlen > 1)
{
- Oid collation = DEFAULT_COLLATION_OID; /*TODO*/
-
+ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
+
prs->usewide = true;
- if ( lc_ctype_is_c(collation) )
+ if (lc_ctype_is_c(collation))
{
/*
- * char2wchar doesn't work for C-locale and
- * sizeof(pg_wchar) could be not equal to sizeof(wchar_t)
+ * char2wchar doesn't work for C-locale and sizeof(pg_wchar) could
+ * be not equal to sizeof(wchar_t)
*/
- prs->pgwstr = (pg_wchar*) palloc(sizeof(pg_wchar) * (prs->lenstr + 1));
+ prs->pgwstr = (pg_wchar *) palloc(sizeof(pg_wchar) * (prs->lenstr + 1));
pg_mb2wchar_with_len(prs->str, prs->pgwstr, prs->lenstr);
}
else
prs->state->state = TPS_Base;
#ifdef WPARSER_TRACE
+
/*
- * Use of %.*s here is a bit risky since it can misbehave if the data
- * is not in what libc thinks is the prevailing encoding. However,
- * since this is just a debugging aid, we choose to live with that.
+ * Use of %.*s here is a bit risky since it can misbehave if the data is
+ * not in what libc thinks is the prevailing encoding. However, since
+ * this is just a debugging aid, we choose to live with that.
*/
fprintf(stderr, "parsing \"%.*s\"\n", len, str);
#endif
/*
* Character-type support functions, equivalent to is* macros, but
* working with any possible encodings and locales. Notes:
- * - with multibyte encoding and C-locale isw* function may fail
- * or give wrong result.
- * - multibyte encoding and C-locale often are used for
- * Asian languages.
- * - if locale is C the we use pgwstr instead of wstr
+ * - with multibyte encoding and C-locale isw* function may fail
+ * or give wrong result.
+ * - multibyte encoding and C-locale often are used for
+ * Asian languages.
+ * - if locale is C the we use pgwstr instead of wstr
*/
#ifdef USE_WIDE_UPPER_LOWER
} \
\
return is##type( *(unsigned char*)( prs->str + prs->state->posbyte ) ); \
-} \
+} \
\
static int \
p_isnot##type(TParser *prs) { \
static int
p_ishost(TParser *prs)
{
- TParser *tmpprs = TParserCopyInit(prs);
+ TParser *tmpprs = TParserCopyInit(prs);
int res = 0;
tmpprs->wanthost = true;
static int
p_isURLPath(TParser *prs)
{
- TParser *tmpprs = TParserCopyInit(prs);
+ TParser *tmpprs = TParserCopyInit(prs);
int res = 0;
tmpprs->state = newTParserPosition(tmpprs->state);
/*
* pg_dsplen could return -1 which means error or control character
*/
- if ( pg_dsplen(prs->str + prs->state->posbyte) == 0 )
+ if (pg_dsplen(prs->str + prs->state->posbyte) == 0)
return 1;
#ifdef USE_WIDE_UPPER_LOWER
+
/*
- * Unicode Characters in the 'Mark, Spacing Combining' Category
- * That characters are not alpha although they are not breakers
- * of word too.
- * Check that only in utf encoding, because other encodings
- * aren't supported by postgres or even exists.
+ * Unicode Characters in the 'Mark, Spacing Combining' Category That
+ * characters are not alpha although they are not breakers of word too.
+ * Check that only in utf encoding, because other encodings aren't
+ * supported by postgres or even exists.
*/
- if ( GetDatabaseEncoding() == PG_UTF8 && prs->usewide )
+ if (GetDatabaseEncoding() == PG_UTF8 && prs->usewide)
{
- static pg_wchar strange_letter[] = {
- /*
- * use binary search, so elements
- * should be ordered
- */
- 0x0903, /* DEVANAGARI SIGN VISARGA */
- 0x093E, /* DEVANAGARI VOWEL SIGN AA */
- 0x093F, /* DEVANAGARI VOWEL SIGN I */
- 0x0940, /* DEVANAGARI VOWEL SIGN II */
- 0x0949, /* DEVANAGARI VOWEL SIGN CANDRA O */
- 0x094A, /* DEVANAGARI VOWEL SIGN SHORT O */
- 0x094B, /* DEVANAGARI VOWEL SIGN O */
- 0x094C, /* DEVANAGARI VOWEL SIGN AU */
- 0x0982, /* BENGALI SIGN ANUSVARA */
- 0x0983, /* BENGALI SIGN VISARGA */
- 0x09BE, /* BENGALI VOWEL SIGN AA */
- 0x09BF, /* BENGALI VOWEL SIGN I */
- 0x09C0, /* BENGALI VOWEL SIGN II */
- 0x09C7, /* BENGALI VOWEL SIGN E */
- 0x09C8, /* BENGALI VOWEL SIGN AI */
- 0x09CB, /* BENGALI VOWEL SIGN O */
- 0x09CC, /* BENGALI VOWEL SIGN AU */
- 0x09D7, /* BENGALI AU LENGTH MARK */
- 0x0A03, /* GURMUKHI SIGN VISARGA */
- 0x0A3E, /* GURMUKHI VOWEL SIGN AA */
- 0x0A3F, /* GURMUKHI VOWEL SIGN I */
- 0x0A40, /* GURMUKHI VOWEL SIGN II */
- 0x0A83, /* GUJARATI SIGN VISARGA */
- 0x0ABE, /* GUJARATI VOWEL SIGN AA */
- 0x0ABF, /* GUJARATI VOWEL SIGN I */
- 0x0AC0, /* GUJARATI VOWEL SIGN II */
- 0x0AC9, /* GUJARATI VOWEL SIGN CANDRA O */
- 0x0ACB, /* GUJARATI VOWEL SIGN O */
- 0x0ACC, /* GUJARATI VOWEL SIGN AU */
- 0x0B02, /* ORIYA SIGN ANUSVARA */
- 0x0B03, /* ORIYA SIGN VISARGA */
- 0x0B3E, /* ORIYA VOWEL SIGN AA */
- 0x0B40, /* ORIYA VOWEL SIGN II */
- 0x0B47, /* ORIYA VOWEL SIGN E */
- 0x0B48, /* ORIYA VOWEL SIGN AI */
- 0x0B4B, /* ORIYA VOWEL SIGN O */
- 0x0B4C, /* ORIYA VOWEL SIGN AU */
- 0x0B57, /* ORIYA AU LENGTH MARK */
- 0x0BBE, /* TAMIL VOWEL SIGN AA */
- 0x0BBF, /* TAMIL VOWEL SIGN I */
- 0x0BC1, /* TAMIL VOWEL SIGN U */
- 0x0BC2, /* TAMIL VOWEL SIGN UU */
- 0x0BC6, /* TAMIL VOWEL SIGN E */
- 0x0BC7, /* TAMIL VOWEL SIGN EE */
- 0x0BC8, /* TAMIL VOWEL SIGN AI */
- 0x0BCA, /* TAMIL VOWEL SIGN O */
- 0x0BCB, /* TAMIL VOWEL SIGN OO */
- 0x0BCC, /* TAMIL VOWEL SIGN AU */
- 0x0BD7, /* TAMIL AU LENGTH MARK */
- 0x0C01, /* TELUGU SIGN CANDRABINDU */
- 0x0C02, /* TELUGU SIGN ANUSVARA */
- 0x0C03, /* TELUGU SIGN VISARGA */
- 0x0C41, /* TELUGU VOWEL SIGN U */
- 0x0C42, /* TELUGU VOWEL SIGN UU */
- 0x0C43, /* TELUGU VOWEL SIGN VOCALIC R */
- 0x0C44, /* TELUGU VOWEL SIGN VOCALIC RR */
- 0x0C82, /* KANNADA SIGN ANUSVARA */
- 0x0C83, /* KANNADA SIGN VISARGA */
- 0x0CBE, /* KANNADA VOWEL SIGN AA */
- 0x0CC0, /* KANNADA VOWEL SIGN II */
- 0x0CC1, /* KANNADA VOWEL SIGN U */
- 0x0CC2, /* KANNADA VOWEL SIGN UU */
- 0x0CC3, /* KANNADA VOWEL SIGN VOCALIC R */
- 0x0CC4, /* KANNADA VOWEL SIGN VOCALIC RR */
- 0x0CC7, /* KANNADA VOWEL SIGN EE */
- 0x0CC8, /* KANNADA VOWEL SIGN AI */
- 0x0CCA, /* KANNADA VOWEL SIGN O */
- 0x0CCB, /* KANNADA VOWEL SIGN OO */
- 0x0CD5, /* KANNADA LENGTH MARK */
- 0x0CD6, /* KANNADA AI LENGTH MARK */
- 0x0D02, /* MALAYALAM SIGN ANUSVARA */
- 0x0D03, /* MALAYALAM SIGN VISARGA */
- 0x0D3E, /* MALAYALAM VOWEL SIGN AA */
- 0x0D3F, /* MALAYALAM VOWEL SIGN I */
- 0x0D40, /* MALAYALAM VOWEL SIGN II */
- 0x0D46, /* MALAYALAM VOWEL SIGN E */
- 0x0D47, /* MALAYALAM VOWEL SIGN EE */
- 0x0D48, /* MALAYALAM VOWEL SIGN AI */
- 0x0D4A, /* MALAYALAM VOWEL SIGN O */
- 0x0D4B, /* MALAYALAM VOWEL SIGN OO */
- 0x0D4C, /* MALAYALAM VOWEL SIGN AU */
- 0x0D57, /* MALAYALAM AU LENGTH MARK */
- 0x0D82, /* SINHALA SIGN ANUSVARAYA */
- 0x0D83, /* SINHALA SIGN VISARGAYA */
- 0x0DCF, /* SINHALA VOWEL SIGN AELA-PILLA */
- 0x0DD0, /* SINHALA VOWEL SIGN KETTI AEDA-PILLA */
- 0x0DD1, /* SINHALA VOWEL SIGN DIGA AEDA-PILLA */
- 0x0DD8, /* SINHALA VOWEL SIGN GAETTA-PILLA */
- 0x0DD9, /* SINHALA VOWEL SIGN KOMBUVA */
- 0x0DDA, /* SINHALA VOWEL SIGN DIGA KOMBUVA */
- 0x0DDB, /* SINHALA VOWEL SIGN KOMBU DEKA */
- 0x0DDC, /* SINHALA VOWEL SIGN KOMBUVA HAA AELA-PILLA */
- 0x0DDD, /* SINHALA VOWEL SIGN KOMBUVA HAA DIGA AELA-PILLA */
- 0x0DDE, /* SINHALA VOWEL SIGN KOMBUVA HAA GAYANUKITTA */
- 0x0DDF, /* SINHALA VOWEL SIGN GAYANUKITTA */
- 0x0DF2, /* SINHALA VOWEL SIGN DIGA GAETTA-PILLA */
- 0x0DF3, /* SINHALA VOWEL SIGN DIGA GAYANUKITTA */
- 0x0F3E, /* TIBETAN SIGN YAR TSHES */
- 0x0F3F, /* TIBETAN SIGN MAR TSHES */
- 0x0F7F, /* TIBETAN SIGN RNAM BCAD */
- 0x102B, /* MYANMAR VOWEL SIGN TALL AA */
- 0x102C, /* MYANMAR VOWEL SIGN AA */
- 0x1031, /* MYANMAR VOWEL SIGN E */
- 0x1038, /* MYANMAR SIGN VISARGA */
- 0x103B, /* MYANMAR CONSONANT SIGN MEDIAL YA */
- 0x103C, /* MYANMAR CONSONANT SIGN MEDIAL RA */
- 0x1056, /* MYANMAR VOWEL SIGN VOCALIC R */
- 0x1057, /* MYANMAR VOWEL SIGN VOCALIC RR */
- 0x1062, /* MYANMAR VOWEL SIGN SGAW KAREN EU */
- 0x1063, /* MYANMAR TONE MARK SGAW KAREN HATHI */
- 0x1064, /* MYANMAR TONE MARK SGAW KAREN KE PHO */
- 0x1067, /* MYANMAR VOWEL SIGN WESTERN PWO KAREN EU */
- 0x1068, /* MYANMAR VOWEL SIGN WESTERN PWO KAREN UE */
- 0x1069, /* MYANMAR SIGN WESTERN PWO KAREN TONE-1 */
- 0x106A, /* MYANMAR SIGN WESTERN PWO KAREN TONE-2 */
- 0x106B, /* MYANMAR SIGN WESTERN PWO KAREN TONE-3 */
- 0x106C, /* MYANMAR SIGN WESTERN PWO KAREN TONE-4 */
- 0x106D, /* MYANMAR SIGN WESTERN PWO KAREN TONE-5 */
- 0x1083, /* MYANMAR VOWEL SIGN SHAN AA */
- 0x1084, /* MYANMAR VOWEL SIGN SHAN E */
- 0x1087, /* MYANMAR SIGN SHAN TONE-2 */
- 0x1088, /* MYANMAR SIGN SHAN TONE-3 */
- 0x1089, /* MYANMAR SIGN SHAN TONE-5 */
- 0x108A, /* MYANMAR SIGN SHAN TONE-6 */
- 0x108B, /* MYANMAR SIGN SHAN COUNCIL TONE-2 */
- 0x108C, /* MYANMAR SIGN SHAN COUNCIL TONE-3 */
- 0x108F, /* MYANMAR SIGN RUMAI PALAUNG TONE-5 */
- 0x17B6, /* KHMER VOWEL SIGN AA */
- 0x17BE, /* KHMER VOWEL SIGN OE */
- 0x17BF, /* KHMER VOWEL SIGN YA */
- 0x17C0, /* KHMER VOWEL SIGN IE */
- 0x17C1, /* KHMER VOWEL SIGN E */
- 0x17C2, /* KHMER VOWEL SIGN AE */
- 0x17C3, /* KHMER VOWEL SIGN AI */
- 0x17C4, /* KHMER VOWEL SIGN OO */
- 0x17C5, /* KHMER VOWEL SIGN AU */
- 0x17C7, /* KHMER SIGN REAHMUK */
- 0x17C8, /* KHMER SIGN YUUKALEAPINTU */
- 0x1923, /* LIMBU VOWEL SIGN EE */
- 0x1924, /* LIMBU VOWEL SIGN AI */
- 0x1925, /* LIMBU VOWEL SIGN OO */
- 0x1926, /* LIMBU VOWEL SIGN AU */
- 0x1929, /* LIMBU SUBJOINED LETTER YA */
- 0x192A, /* LIMBU SUBJOINED LETTER RA */
- 0x192B, /* LIMBU SUBJOINED LETTER WA */
- 0x1930, /* LIMBU SMALL LETTER KA */
- 0x1931, /* LIMBU SMALL LETTER NGA */
- 0x1933, /* LIMBU SMALL LETTER TA */
- 0x1934, /* LIMBU SMALL LETTER NA */
- 0x1935, /* LIMBU SMALL LETTER PA */
- 0x1936, /* LIMBU SMALL LETTER MA */
- 0x1937, /* LIMBU SMALL LETTER RA */
- 0x1938, /* LIMBU SMALL LETTER LA */
- 0x19B0, /* NEW TAI LUE VOWEL SIGN VOWEL SHORTENER */
- 0x19B1, /* NEW TAI LUE VOWEL SIGN AA */
- 0x19B2, /* NEW TAI LUE VOWEL SIGN II */
- 0x19B3, /* NEW TAI LUE VOWEL SIGN U */
- 0x19B4, /* NEW TAI LUE VOWEL SIGN UU */
- 0x19B5, /* NEW TAI LUE VOWEL SIGN E */
- 0x19B6, /* NEW TAI LUE VOWEL SIGN AE */
- 0x19B7, /* NEW TAI LUE VOWEL SIGN O */
- 0x19B8, /* NEW TAI LUE VOWEL SIGN OA */
- 0x19B9, /* NEW TAI LUE VOWEL SIGN UE */
- 0x19BA, /* NEW TAI LUE VOWEL SIGN AY */
- 0x19BB, /* NEW TAI LUE VOWEL SIGN AAY */
- 0x19BC, /* NEW TAI LUE VOWEL SIGN UY */
- 0x19BD, /* NEW TAI LUE VOWEL SIGN OY */
- 0x19BE, /* NEW TAI LUE VOWEL SIGN OAY */
- 0x19BF, /* NEW TAI LUE VOWEL SIGN UEY */
- 0x19C0, /* NEW TAI LUE VOWEL SIGN IY */
- 0x19C8, /* NEW TAI LUE TONE MARK-1 */
- 0x19C9, /* NEW TAI LUE TONE MARK-2 */
- 0x1A19, /* BUGINESE VOWEL SIGN E */
- 0x1A1A, /* BUGINESE VOWEL SIGN O */
- 0x1A1B, /* BUGINESE VOWEL SIGN AE */
- 0x1B04, /* BALINESE SIGN BISAH */
- 0x1B35, /* BALINESE VOWEL SIGN TEDUNG */
- 0x1B3B, /* BALINESE VOWEL SIGN RA REPA TEDUNG */
- 0x1B3D, /* BALINESE VOWEL SIGN LA LENGA TEDUNG */
- 0x1B3E, /* BALINESE VOWEL SIGN TALING */
- 0x1B3F, /* BALINESE VOWEL SIGN TALING REPA */
- 0x1B40, /* BALINESE VOWEL SIGN TALING TEDUNG */
- 0x1B41, /* BALINESE VOWEL SIGN TALING REPA TEDUNG */
- 0x1B43, /* BALINESE VOWEL SIGN PEPET TEDUNG */
- 0x1B44, /* BALINESE ADEG ADEG */
- 0x1B82, /* SUNDANESE SIGN PANGWISAD */
- 0x1BA1, /* SUNDANESE CONSONANT SIGN PAMINGKAL */
- 0x1BA6, /* SUNDANESE VOWEL SIGN PANAELAENG */
- 0x1BA7, /* SUNDANESE VOWEL SIGN PANOLONG */
- 0x1BAA, /* SUNDANESE SIGN PAMAAEH */
- 0x1C24, /* LEPCHA SUBJOINED LETTER YA */
- 0x1C25, /* LEPCHA SUBJOINED LETTER RA */
- 0x1C26, /* LEPCHA VOWEL SIGN AA */
- 0x1C27, /* LEPCHA VOWEL SIGN I */
- 0x1C28, /* LEPCHA VOWEL SIGN O */
- 0x1C29, /* LEPCHA VOWEL SIGN OO */
- 0x1C2A, /* LEPCHA VOWEL SIGN U */
- 0x1C2B, /* LEPCHA VOWEL SIGN UU */
- 0x1C34, /* LEPCHA CONSONANT SIGN NYIN-DO */
- 0x1C35, /* LEPCHA CONSONANT SIGN KANG */
- 0xA823, /* SYLOTI NAGRI VOWEL SIGN A */
- 0xA824, /* SYLOTI NAGRI VOWEL SIGN I */
- 0xA827, /* SYLOTI NAGRI VOWEL SIGN OO */
- 0xA880, /* SAURASHTRA SIGN ANUSVARA */
- 0xA881, /* SAURASHTRA SIGN VISARGA */
- 0xA8B4, /* SAURASHTRA CONSONANT SIGN HAARU */
- 0xA8B5, /* SAURASHTRA VOWEL SIGN AA */
- 0xA8B6, /* SAURASHTRA VOWEL SIGN I */
- 0xA8B7, /* SAURASHTRA VOWEL SIGN II */
- 0xA8B8, /* SAURASHTRA VOWEL SIGN U */
- 0xA8B9, /* SAURASHTRA VOWEL SIGN UU */
- 0xA8BA, /* SAURASHTRA VOWEL SIGN VOCALIC R */
- 0xA8BB, /* SAURASHTRA VOWEL SIGN VOCALIC RR */
- 0xA8BC, /* SAURASHTRA VOWEL SIGN VOCALIC L */
- 0xA8BD, /* SAURASHTRA VOWEL SIGN VOCALIC LL */
- 0xA8BE, /* SAURASHTRA VOWEL SIGN E */
- 0xA8BF, /* SAURASHTRA VOWEL SIGN EE */
- 0xA8C0, /* SAURASHTRA VOWEL SIGN AI */
- 0xA8C1, /* SAURASHTRA VOWEL SIGN O */
- 0xA8C2, /* SAURASHTRA VOWEL SIGN OO */
- 0xA8C3, /* SAURASHTRA VOWEL SIGN AU */
- 0xA952, /* REJANG CONSONANT SIGN H */
- 0xA953, /* REJANG VIRAMA */
- 0xAA2F, /* CHAM VOWEL SIGN O */
- 0xAA30, /* CHAM VOWEL SIGN AI */
- 0xAA33, /* CHAM CONSONANT SIGN YA */
- 0xAA34, /* CHAM CONSONANT SIGN RA */
- 0xAA4D /* CHAM CONSONANT SIGN FINAL H */
- };
- pg_wchar *StopLow = strange_letter,
- *StopHigh = strange_letter + lengthof(strange_letter),
- *StopMiddle;
+ static pg_wchar strange_letter[] = {
+ /*
+ * use binary search, so elements should be ordered
+ */
+ 0x0903, /* DEVANAGARI SIGN VISARGA */
+ 0x093E, /* DEVANAGARI VOWEL SIGN AA */
+ 0x093F, /* DEVANAGARI VOWEL SIGN I */
+ 0x0940, /* DEVANAGARI VOWEL SIGN II */
+ 0x0949, /* DEVANAGARI VOWEL SIGN CANDRA O */
+ 0x094A, /* DEVANAGARI VOWEL SIGN SHORT O */
+ 0x094B, /* DEVANAGARI VOWEL SIGN O */
+ 0x094C, /* DEVANAGARI VOWEL SIGN AU */
+ 0x0982, /* BENGALI SIGN ANUSVARA */
+ 0x0983, /* BENGALI SIGN VISARGA */
+ 0x09BE, /* BENGALI VOWEL SIGN AA */
+ 0x09BF, /* BENGALI VOWEL SIGN I */
+ 0x09C0, /* BENGALI VOWEL SIGN II */
+ 0x09C7, /* BENGALI VOWEL SIGN E */
+ 0x09C8, /* BENGALI VOWEL SIGN AI */
+ 0x09CB, /* BENGALI VOWEL SIGN O */
+ 0x09CC, /* BENGALI VOWEL SIGN AU */
+ 0x09D7, /* BENGALI AU LENGTH MARK */
+ 0x0A03, /* GURMUKHI SIGN VISARGA */
+ 0x0A3E, /* GURMUKHI VOWEL SIGN AA */
+ 0x0A3F, /* GURMUKHI VOWEL SIGN I */
+ 0x0A40, /* GURMUKHI VOWEL SIGN II */
+ 0x0A83, /* GUJARATI SIGN VISARGA */
+ 0x0ABE, /* GUJARATI VOWEL SIGN AA */
+ 0x0ABF, /* GUJARATI VOWEL SIGN I */
+ 0x0AC0, /* GUJARATI VOWEL SIGN II */
+ 0x0AC9, /* GUJARATI VOWEL SIGN CANDRA O */
+ 0x0ACB, /* GUJARATI VOWEL SIGN O */
+ 0x0ACC, /* GUJARATI VOWEL SIGN AU */
+ 0x0B02, /* ORIYA SIGN ANUSVARA */
+ 0x0B03, /* ORIYA SIGN VISARGA */
+ 0x0B3E, /* ORIYA VOWEL SIGN AA */
+ 0x0B40, /* ORIYA VOWEL SIGN II */
+ 0x0B47, /* ORIYA VOWEL SIGN E */
+ 0x0B48, /* ORIYA VOWEL SIGN AI */
+ 0x0B4B, /* ORIYA VOWEL SIGN O */
+ 0x0B4C, /* ORIYA VOWEL SIGN AU */
+ 0x0B57, /* ORIYA AU LENGTH MARK */
+ 0x0BBE, /* TAMIL VOWEL SIGN AA */
+ 0x0BBF, /* TAMIL VOWEL SIGN I */
+ 0x0BC1, /* TAMIL VOWEL SIGN U */
+ 0x0BC2, /* TAMIL VOWEL SIGN UU */
+ 0x0BC6, /* TAMIL VOWEL SIGN E */
+ 0x0BC7, /* TAMIL VOWEL SIGN EE */
+ 0x0BC8, /* TAMIL VOWEL SIGN AI */
+ 0x0BCA, /* TAMIL VOWEL SIGN O */
+ 0x0BCB, /* TAMIL VOWEL SIGN OO */
+ 0x0BCC, /* TAMIL VOWEL SIGN AU */
+ 0x0BD7, /* TAMIL AU LENGTH MARK */
+ 0x0C01, /* TELUGU SIGN CANDRABINDU */
+ 0x0C02, /* TELUGU SIGN ANUSVARA */
+ 0x0C03, /* TELUGU SIGN VISARGA */
+ 0x0C41, /* TELUGU VOWEL SIGN U */
+ 0x0C42, /* TELUGU VOWEL SIGN UU */
+ 0x0C43, /* TELUGU VOWEL SIGN VOCALIC R */
+ 0x0C44, /* TELUGU VOWEL SIGN VOCALIC RR */
+ 0x0C82, /* KANNADA SIGN ANUSVARA */
+ 0x0C83, /* KANNADA SIGN VISARGA */
+ 0x0CBE, /* KANNADA VOWEL SIGN AA */
+ 0x0CC0, /* KANNADA VOWEL SIGN II */
+ 0x0CC1, /* KANNADA VOWEL SIGN U */
+ 0x0CC2, /* KANNADA VOWEL SIGN UU */
+ 0x0CC3, /* KANNADA VOWEL SIGN VOCALIC R */
+ 0x0CC4, /* KANNADA VOWEL SIGN VOCALIC RR */
+ 0x0CC7, /* KANNADA VOWEL SIGN EE */
+ 0x0CC8, /* KANNADA VOWEL SIGN AI */
+ 0x0CCA, /* KANNADA VOWEL SIGN O */
+ 0x0CCB, /* KANNADA VOWEL SIGN OO */
+ 0x0CD5, /* KANNADA LENGTH MARK */
+ 0x0CD6, /* KANNADA AI LENGTH MARK */
+ 0x0D02, /* MALAYALAM SIGN ANUSVARA */
+ 0x0D03, /* MALAYALAM SIGN VISARGA */
+ 0x0D3E, /* MALAYALAM VOWEL SIGN AA */
+ 0x0D3F, /* MALAYALAM VOWEL SIGN I */
+ 0x0D40, /* MALAYALAM VOWEL SIGN II */
+ 0x0D46, /* MALAYALAM VOWEL SIGN E */
+ 0x0D47, /* MALAYALAM VOWEL SIGN EE */
+ 0x0D48, /* MALAYALAM VOWEL SIGN AI */
+ 0x0D4A, /* MALAYALAM VOWEL SIGN O */
+ 0x0D4B, /* MALAYALAM VOWEL SIGN OO */
+ 0x0D4C, /* MALAYALAM VOWEL SIGN AU */
+ 0x0D57, /* MALAYALAM AU LENGTH MARK */
+ 0x0D82, /* SINHALA SIGN ANUSVARAYA */
+ 0x0D83, /* SINHALA SIGN VISARGAYA */
+ 0x0DCF, /* SINHALA VOWEL SIGN AELA-PILLA */
+ 0x0DD0, /* SINHALA VOWEL SIGN KETTI AEDA-PILLA */
+ 0x0DD1, /* SINHALA VOWEL SIGN DIGA AEDA-PILLA */
+ 0x0DD8, /* SINHALA VOWEL SIGN GAETTA-PILLA */
+ 0x0DD9, /* SINHALA VOWEL SIGN KOMBUVA */
+ 0x0DDA, /* SINHALA VOWEL SIGN DIGA KOMBUVA */
+ 0x0DDB, /* SINHALA VOWEL SIGN KOMBU DEKA */
+ 0x0DDC, /* SINHALA VOWEL SIGN KOMBUVA HAA AELA-PILLA */
+ 0x0DDD, /* SINHALA VOWEL SIGN KOMBUVA HAA DIGA
+ * AELA-PILLA */
+ 0x0DDE, /* SINHALA VOWEL SIGN KOMBUVA HAA GAYANUKITTA */
+ 0x0DDF, /* SINHALA VOWEL SIGN GAYANUKITTA */
+ 0x0DF2, /* SINHALA VOWEL SIGN DIGA GAETTA-PILLA */
+ 0x0DF3, /* SINHALA VOWEL SIGN DIGA GAYANUKITTA */
+ 0x0F3E, /* TIBETAN SIGN YAR TSHES */
+ 0x0F3F, /* TIBETAN SIGN MAR TSHES */
+ 0x0F7F, /* TIBETAN SIGN RNAM BCAD */
+ 0x102B, /* MYANMAR VOWEL SIGN TALL AA */
+ 0x102C, /* MYANMAR VOWEL SIGN AA */
+ 0x1031, /* MYANMAR VOWEL SIGN E */
+ 0x1038, /* MYANMAR SIGN VISARGA */
+ 0x103B, /* MYANMAR CONSONANT SIGN MEDIAL YA */
+ 0x103C, /* MYANMAR CONSONANT SIGN MEDIAL RA */
+ 0x1056, /* MYANMAR VOWEL SIGN VOCALIC R */
+ 0x1057, /* MYANMAR VOWEL SIGN VOCALIC RR */
+ 0x1062, /* MYANMAR VOWEL SIGN SGAW KAREN EU */
+ 0x1063, /* MYANMAR TONE MARK SGAW KAREN HATHI */
+ 0x1064, /* MYANMAR TONE MARK SGAW KAREN KE PHO */
+ 0x1067, /* MYANMAR VOWEL SIGN WESTERN PWO KAREN EU */
+ 0x1068, /* MYANMAR VOWEL SIGN WESTERN PWO KAREN UE */
+ 0x1069, /* MYANMAR SIGN WESTERN PWO KAREN TONE-1 */
+ 0x106A, /* MYANMAR SIGN WESTERN PWO KAREN TONE-2 */
+ 0x106B, /* MYANMAR SIGN WESTERN PWO KAREN TONE-3 */
+ 0x106C, /* MYANMAR SIGN WESTERN PWO KAREN TONE-4 */
+ 0x106D, /* MYANMAR SIGN WESTERN PWO KAREN TONE-5 */
+ 0x1083, /* MYANMAR VOWEL SIGN SHAN AA */
+ 0x1084, /* MYANMAR VOWEL SIGN SHAN E */
+ 0x1087, /* MYANMAR SIGN SHAN TONE-2 */
+ 0x1088, /* MYANMAR SIGN SHAN TONE-3 */
+ 0x1089, /* MYANMAR SIGN SHAN TONE-5 */
+ 0x108A, /* MYANMAR SIGN SHAN TONE-6 */
+ 0x108B, /* MYANMAR SIGN SHAN COUNCIL TONE-2 */
+ 0x108C, /* MYANMAR SIGN SHAN COUNCIL TONE-3 */
+ 0x108F, /* MYANMAR SIGN RUMAI PALAUNG TONE-5 */
+ 0x17B6, /* KHMER VOWEL SIGN AA */
+ 0x17BE, /* KHMER VOWEL SIGN OE */
+ 0x17BF, /* KHMER VOWEL SIGN YA */
+ 0x17C0, /* KHMER VOWEL SIGN IE */
+ 0x17C1, /* KHMER VOWEL SIGN E */
+ 0x17C2, /* KHMER VOWEL SIGN AE */
+ 0x17C3, /* KHMER VOWEL SIGN AI */
+ 0x17C4, /* KHMER VOWEL SIGN OO */
+ 0x17C5, /* KHMER VOWEL SIGN AU */
+ 0x17C7, /* KHMER SIGN REAHMUK */
+ 0x17C8, /* KHMER SIGN YUUKALEAPINTU */
+ 0x1923, /* LIMBU VOWEL SIGN EE */
+ 0x1924, /* LIMBU VOWEL SIGN AI */
+ 0x1925, /* LIMBU VOWEL SIGN OO */
+ 0x1926, /* LIMBU VOWEL SIGN AU */
+ 0x1929, /* LIMBU SUBJOINED LETTER YA */
+ 0x192A, /* LIMBU SUBJOINED LETTER RA */
+ 0x192B, /* LIMBU SUBJOINED LETTER WA */
+ 0x1930, /* LIMBU SMALL LETTER KA */
+ 0x1931, /* LIMBU SMALL LETTER NGA */
+ 0x1933, /* LIMBU SMALL LETTER TA */
+ 0x1934, /* LIMBU SMALL LETTER NA */
+ 0x1935, /* LIMBU SMALL LETTER PA */
+ 0x1936, /* LIMBU SMALL LETTER MA */
+ 0x1937, /* LIMBU SMALL LETTER RA */
+ 0x1938, /* LIMBU SMALL LETTER LA */
+ 0x19B0, /* NEW TAI LUE VOWEL SIGN VOWEL SHORTENER */
+ 0x19B1, /* NEW TAI LUE VOWEL SIGN AA */
+ 0x19B2, /* NEW TAI LUE VOWEL SIGN II */
+ 0x19B3, /* NEW TAI LUE VOWEL SIGN U */
+ 0x19B4, /* NEW TAI LUE VOWEL SIGN UU */
+ 0x19B5, /* NEW TAI LUE VOWEL SIGN E */
+ 0x19B6, /* NEW TAI LUE VOWEL SIGN AE */
+ 0x19B7, /* NEW TAI LUE VOWEL SIGN O */
+ 0x19B8, /* NEW TAI LUE VOWEL SIGN OA */
+ 0x19B9, /* NEW TAI LUE VOWEL SIGN UE */
+ 0x19BA, /* NEW TAI LUE VOWEL SIGN AY */
+ 0x19BB, /* NEW TAI LUE VOWEL SIGN AAY */
+ 0x19BC, /* NEW TAI LUE VOWEL SIGN UY */
+ 0x19BD, /* NEW TAI LUE VOWEL SIGN OY */
+ 0x19BE, /* NEW TAI LUE VOWEL SIGN OAY */
+ 0x19BF, /* NEW TAI LUE VOWEL SIGN UEY */
+ 0x19C0, /* NEW TAI LUE VOWEL SIGN IY */
+ 0x19C8, /* NEW TAI LUE TONE MARK-1 */
+ 0x19C9, /* NEW TAI LUE TONE MARK-2 */
+ 0x1A19, /* BUGINESE VOWEL SIGN E */
+ 0x1A1A, /* BUGINESE VOWEL SIGN O */
+ 0x1A1B, /* BUGINESE VOWEL SIGN AE */
+ 0x1B04, /* BALINESE SIGN BISAH */
+ 0x1B35, /* BALINESE VOWEL SIGN TEDUNG */
+ 0x1B3B, /* BALINESE VOWEL SIGN RA REPA TEDUNG */
+ 0x1B3D, /* BALINESE VOWEL SIGN LA LENGA TEDUNG */
+ 0x1B3E, /* BALINESE VOWEL SIGN TALING */
+ 0x1B3F, /* BALINESE VOWEL SIGN TALING REPA */
+ 0x1B40, /* BALINESE VOWEL SIGN TALING TEDUNG */
+ 0x1B41, /* BALINESE VOWEL SIGN TALING REPA TEDUNG */
+ 0x1B43, /* BALINESE VOWEL SIGN PEPET TEDUNG */
+ 0x1B44, /* BALINESE ADEG ADEG */
+ 0x1B82, /* SUNDANESE SIGN PANGWISAD */
+ 0x1BA1, /* SUNDANESE CONSONANT SIGN PAMINGKAL */
+ 0x1BA6, /* SUNDANESE VOWEL SIGN PANAELAENG */
+ 0x1BA7, /* SUNDANESE VOWEL SIGN PANOLONG */
+ 0x1BAA, /* SUNDANESE SIGN PAMAAEH */
+ 0x1C24, /* LEPCHA SUBJOINED LETTER YA */
+ 0x1C25, /* LEPCHA SUBJOINED LETTER RA */
+ 0x1C26, /* LEPCHA VOWEL SIGN AA */
+ 0x1C27, /* LEPCHA VOWEL SIGN I */
+ 0x1C28, /* LEPCHA VOWEL SIGN O */
+ 0x1C29, /* LEPCHA VOWEL SIGN OO */
+ 0x1C2A, /* LEPCHA VOWEL SIGN U */
+ 0x1C2B, /* LEPCHA VOWEL SIGN UU */
+ 0x1C34, /* LEPCHA CONSONANT SIGN NYIN-DO */
+ 0x1C35, /* LEPCHA CONSONANT SIGN KANG */
+ 0xA823, /* SYLOTI NAGRI VOWEL SIGN A */
+ 0xA824, /* SYLOTI NAGRI VOWEL SIGN I */
+ 0xA827, /* SYLOTI NAGRI VOWEL SIGN OO */
+ 0xA880, /* SAURASHTRA SIGN ANUSVARA */
+ 0xA881, /* SAURASHTRA SIGN VISARGA */
+ 0xA8B4, /* SAURASHTRA CONSONANT SIGN HAARU */
+ 0xA8B5, /* SAURASHTRA VOWEL SIGN AA */
+ 0xA8B6, /* SAURASHTRA VOWEL SIGN I */
+ 0xA8B7, /* SAURASHTRA VOWEL SIGN II */
+ 0xA8B8, /* SAURASHTRA VOWEL SIGN U */
+ 0xA8B9, /* SAURASHTRA VOWEL SIGN UU */
+ 0xA8BA, /* SAURASHTRA VOWEL SIGN VOCALIC R */
+ 0xA8BB, /* SAURASHTRA VOWEL SIGN VOCALIC RR */
+ 0xA8BC, /* SAURASHTRA VOWEL SIGN VOCALIC L */
+ 0xA8BD, /* SAURASHTRA VOWEL SIGN VOCALIC LL */
+ 0xA8BE, /* SAURASHTRA VOWEL SIGN E */
+ 0xA8BF, /* SAURASHTRA VOWEL SIGN EE */
+ 0xA8C0, /* SAURASHTRA VOWEL SIGN AI */
+ 0xA8C1, /* SAURASHTRA VOWEL SIGN O */
+ 0xA8C2, /* SAURASHTRA VOWEL SIGN OO */
+ 0xA8C3, /* SAURASHTRA VOWEL SIGN AU */
+ 0xA952, /* REJANG CONSONANT SIGN H */
+ 0xA953, /* REJANG VIRAMA */
+ 0xAA2F, /* CHAM VOWEL SIGN O */
+ 0xAA30, /* CHAM VOWEL SIGN AI */
+ 0xAA33, /* CHAM CONSONANT SIGN YA */
+ 0xAA34, /* CHAM CONSONANT SIGN RA */
+ 0xAA4D /* CHAM CONSONANT SIGN FINAL H */
+ };
+ pg_wchar *StopLow = strange_letter,
+ *StopHigh = strange_letter + lengthof(strange_letter),
+ *StopMiddle;
pg_wchar c;
- if ( prs->pgwstr )
+ if (prs->pgwstr)
c = *(prs->pgwstr + prs->state->poschar);
else
c = (pg_wchar) *(prs->wstr + prs->state->poschar);
- while( StopLow < StopHigh )
+ while (StopLow < StopHigh)
{
StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
- if ( *StopMiddle == c )
+ if (*StopMiddle == c)
return 1;
- else if ( *StopMiddle < c )
+ else if (*StopMiddle < c)
StopLow = StopMiddle + 1;
else
StopHigh = StopMiddle;
static const TParserStateActionItem actionTPS_InXMLBegin[] = {
{p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
/* <?xml ... */
- /* XXX do we wants states for the m and l ? Right now this accepts <?xZ */
+ /* XXX do we wants states for the m and l ? Right now this accepts <?xZ */
{p_iseqC, 'x', A_NEXT, TPS_InTag, 0, NULL},
{NULL, 0, A_POP, TPS_Null, 0, NULL}
};
#define COMPLEXTOKEN(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
#define ENDPUNCTOKEN(x) ( (x)==SPACE )
-#define TS_IDIGNORE(x) ( (x)==TAG_T || (x)==PROTOCOL || (x)==SPACE || (x)==XMLENTITY )
-#define HLIDREPLACE(x) ( (x)==TAG_T )
-#define HLIDSKIP(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
-#define XMLHLIDSKIP(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
+#define TS_IDIGNORE(x) ( (x)==TAG_T || (x)==PROTOCOL || (x)==SPACE || (x)==XMLENTITY )
+#define HLIDREPLACE(x) ( (x)==TAG_T )
+#define HLIDSKIP(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
+#define XMLHLIDSKIP(x) ( (x)==URL_T || (x)==NUMHWORD || (x)==ASCIIHWORD || (x)==HWORD )
#define NONWORDTOKEN(x) ( (x)==SPACE || HLIDREPLACE(x) || HLIDSKIP(x) )
#define NOENDTOKEN(x) ( NONWORDTOKEN(x) || (x)==SCIENTIFIC || (x)==VERSIONNUMBER || (x)==DECIMAL_T || (x)==SIGNEDINT || (x)==UNSIGNEDINT || TS_IDIGNORE(x) )
static void
mark_fragment(HeadlineParsedText *prs, int highlight, int startpos, int endpos)
{
- int i;
+ int i;
for (i = startpos; i <= endpos; i++)
{
{
if (HLIDREPLACE(prs->words[i].type))
prs->words[i].replace = 1;
- else if ( HLIDSKIP(prs->words[i].type) )
+ else if (HLIDSKIP(prs->words[i].type))
prs->words[i].skip = 1;
}
else
typedef struct
{
- int4 startpos;
- int4 endpos;
- int4 poslen;
- int4 curlen;
- int2 in;
- int2 excluded;
+ int4 startpos;
+ int4 endpos;
+ int4 poslen;
+ int4 curlen;
+ int2 in;
+ int2 excluded;
} CoverPos;
static void
get_next_fragment(HeadlineParsedText *prs, int *startpos, int *endpos,
- int *curlen, int *poslen, int max_words)
+ int *curlen, int *poslen, int max_words)
{
- int i;
- /* Objective: Generate a fragment of words between startpos and endpos
- * such that it has at most max_words and both ends has query words.
- * If the startpos and endpos are the endpoints of the cover and the
- * cover has fewer words than max_words, then this function should
- * just return the cover
+ int i;
+
+ /*
+ * Objective: Generate a fragment of words between startpos and endpos
+ * such that it has at most max_words and both ends has query words. If
+ * the startpos and endpos are the endpoints of the cover and the cover
+ * has fewer words than max_words, then this function should just return
+ * the cover
*/
/* first move startpos to an item */
- for(i = *startpos; i <= *endpos; i++)
+ for (i = *startpos; i <= *endpos; i++)
{
*startpos = i;
if (prs->words[i].item && !prs->words[i].repeated)
/* cut endpos to have only max_words */
*curlen = 0;
*poslen = 0;
- for(i = *startpos; i <= *endpos && *curlen < max_words; i++)
+ for (i = *startpos; i <= *endpos && *curlen < max_words; i++)
{
if (!NONWORDTOKEN(prs->words[i].type))
*curlen += 1;
if (*endpos > i)
{
*endpos = i;
- for(i = *endpos; i >= *startpos; i --)
+ for (i = *endpos; i >= *startpos; i--)
{
*endpos = i;
if (prs->words[i].item && !prs->words[i].repeated)
static void
mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight,
- int shortword, int min_words,
- int max_words, int max_fragments)
+ int shortword, int min_words,
+ int max_words, int max_fragments)
{
- int4 poslen, curlen, i, f, num_f = 0;
- int4 stretch, maxstretch, posmarker;
-
- int4 startpos = 0,
- endpos = 0,
- p = 0,
- q = 0;
+ int4 poslen,
+ curlen,
+ i,
+ f,
+ num_f = 0;
+ int4 stretch,
+ maxstretch,
+ posmarker;
+
+ int4 startpos = 0,
+ endpos = 0,
+ p = 0,
+ q = 0;
int4 numcovers = 0,
- maxcovers = 32;
+ maxcovers = 32;
- int4 minI, minwords, maxitems;
- CoverPos *covers;
+ int4 minI,
+ minwords,
+ maxitems;
+ CoverPos *covers;
covers = palloc(maxcovers * sizeof(CoverPos));
while (hlCover(prs, query, &p, &q))
{
startpos = p;
- endpos = q;
+ endpos = q;
- /* Break the cover into smaller fragments such that each fragment
- * has at most max_words. Also ensure that each end of the fragment
- * is a query word. This will allow us to stretch the fragment in
- * either direction
+ /*
+ * Break the cover into smaller fragments such that each fragment has
+ * at most max_words. Also ensure that each end of the fragment is a
+ * query word. This will allow us to stretch the fragment in either
+ * direction
*/
while (startpos <= endpos)
if (numcovers >= maxcovers)
{
maxcovers *= 2;
- covers = repalloc(covers, sizeof(CoverPos) * maxcovers);
+ covers = repalloc(covers, sizeof(CoverPos) * maxcovers);
}
covers[numcovers].startpos = startpos;
- covers[numcovers].endpos = endpos;
- covers[numcovers].curlen = curlen;
- covers[numcovers].poslen = poslen;
- covers[numcovers].in = 0;
+ covers[numcovers].endpos = endpos;
+ covers[numcovers].curlen = curlen;
+ covers[numcovers].poslen = poslen;
+ covers[numcovers].in = 0;
covers[numcovers].excluded = 0;
- numcovers ++;
+ numcovers++;
startpos = endpos + 1;
- endpos = q;
+ endpos = q;
}
/* move p to generate the next cover */
p++;
maxitems = 0;
minwords = 0x7fffffff;
minI = -1;
- /* Choose the cover that contains max items.
- * In case of tie choose the one with smaller
- * number of words.
+
+ /*
+ * Choose the cover that contains max items. In case of tie choose the
+ * one with smaller number of words.
*/
- for (i = 0; i < numcovers; i ++)
+ for (i = 0; i < numcovers; i++)
{
- if (!covers[i].in && !covers[i].excluded &&
+ if (!covers[i].in && !covers[i].excluded &&
(maxitems < covers[i].poslen || (maxitems == covers[i].poslen
- && minwords > covers[i].curlen)))
+ && minwords > covers[i].curlen)))
{
maxitems = covers[i].poslen;
minwords = covers[i].curlen;
- minI = i;
+ minI = i;
}
}
/* if a cover was found mark it */
covers[minI].in = 1;
/* adjust the size of cover */
startpos = covers[minI].startpos;
- endpos = covers[minI].endpos;
- curlen = covers[minI].curlen;
+ endpos = covers[minI].endpos;
+ curlen = covers[minI].curlen;
/* stretch the cover if cover size is lower than max_words */
if (curlen < max_words)
{
/* divide the stretch on both sides of cover */
- maxstretch = (max_words - curlen)/2;
- /* first stretch the startpos
- * stop stretching if
- * 1. we hit the beginning of document
- * 2. exceed maxstretch
- * 3. we hit an already marked fragment
+ maxstretch = (max_words - curlen) / 2;
+
+ /*
+ * first stretch the startpos stop stretching if 1. we hit the
+ * beginning of document 2. exceed maxstretch 3. we hit an
+ * already marked fragment
*/
- stretch = 0;
+ stretch = 0;
posmarker = startpos;
for (i = startpos - 1; i >= 0 && stretch < maxstretch && !prs->words[i].in; i--)
{
if (!NONWORDTOKEN(prs->words[i].type))
{
- curlen ++;
- stretch ++;
+ curlen++;
+ stretch++;
}
posmarker = i;
}
for (i = posmarker; i < startpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i++)
{
if (!NONWORDTOKEN(prs->words[i].type))
- curlen --;
+ curlen--;
}
startpos = i;
- /* now stretch the endpos as much as possible*/
+ /* now stretch the endpos as much as possible */
posmarker = endpos;
for (i = endpos + 1; i < prs->curwords && curlen < max_words && !prs->words[i].in; i++)
{
if (!NONWORDTOKEN(prs->words[i].type))
- curlen ++;
+ curlen++;
posmarker = i;
}
/* cut back endpos till we find a non-short token */
- for ( i = posmarker; i > endpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i--)
+ for (i = posmarker; i > endpos && (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword); i--)
{
if (!NONWORDTOKEN(prs->words[i].type))
- curlen --;
+ curlen--;
}
endpos = i;
}
covers[minI].startpos = startpos;
- covers[minI].endpos = endpos;
- covers[minI].curlen = curlen;
+ covers[minI].endpos = endpos;
+ covers[minI].curlen = curlen;
/* Mark the chosen fragments (covers) */
mark_fragment(prs, highlight, startpos, endpos);
- num_f ++;
+ num_f++;
/* exclude overlapping covers */
- for (i = 0; i < numcovers; i ++)
+ for (i = 0; i < numcovers; i++)
{
- if (i != minI && ( (covers[i].startpos >= covers[minI].startpos && covers[i].startpos <= covers[minI].endpos) || (covers[i].endpos >= covers[minI].startpos && covers[i].endpos <= covers[minI].endpos)))
+ if (i != minI && ((covers[i].startpos >= covers[minI].startpos && covers[i].startpos <= covers[minI].endpos) || (covers[i].endpos >= covers[minI].startpos && covers[i].endpos <= covers[minI].endpos)))
covers[i].excluded = 1;
}
}
break;
}
- /* show at least min_words we have not marked anything*/
+ /* show at least min_words we have not marked anything */
if (num_f <= 0)
{
startpos = endpos = curlen = 0;
static void
mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
- int shortword, int min_words, int max_words)
+ int shortword, int min_words, int max_words)
{
int p = 0,
q = 0;
curlen++;
if (prs->words[i].item && !prs->words[i].repeated)
poslen++;
- if ( curlen >= max_words )
+ if (curlen >= max_words)
break;
if (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword)
continue;
{
if (HLIDREPLACE(prs->words[i].type))
prs->words[i].replace = 1;
- else if ( HLIDSKIP(prs->words[i].type) )
+ else if (HLIDSKIP(prs->words[i].type))
prs->words[i].skip = 1;
}
else
TSQuery query = PG_GETARG_TSQUERY(2);
/* from opt + start and and tag */
- int min_words = 15;
- int max_words = 35;
- int shortword = 3;
+ int min_words = 15;
+ int max_words = 35;
+ int shortword = 3;
int max_fragments = 0;
- int highlight = 0;
+ int highlight = 0;
ListCell *l;
/* config */
static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode);
static void RoleMembershipCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr);
-static Oid get_role_oid_or_public(const char *rolname);
+static Oid get_role_oid_or_public(const char *rolname);
/*
/*
* get_role_oid_or_public - As above, but return ACL_ID_PUBLIC if the
- * role name is "public".
+ * role name is "public".
*/
static Oid
get_role_oid_or_public(const char *rolname)
/* current position information, updated on each iteration */
char *data_ptr; /* our current position in the array */
int current_item; /* the item # we're at in the array */
-} ArrayIteratorData;
+} ArrayIteratorData;
static bool array_isspace(char ch);
static int ArrayCount(const char *str, int *dim, char typdelim);
*/
if (dim[i] != 0)
{
- int ub = lBound[i] + dim[i] - 1;
+ int ub = lBound[i] + dim[i] - 1;
+
if (lBound[i] > ub)
ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
Datum
int4_cash(PG_FUNCTION_ARGS)
{
- int32 amount = PG_GETARG_INT32(0);
- Cash result;
- int fpoint;
- int64 scale;
- int i;
+ int32 amount = PG_GETARG_INT32(0);
+ Cash result;
+ int fpoint;
+ int64 scale;
+ int i;
struct lconv *lconvert = PGLC_localeconv();
/* see comments about frac_digits in cash_in() */
/* compute amount * scale, checking for overflow */
result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount),
- Int64GetDatum(scale)));
+ Int64GetDatum(scale)));
PG_RETURN_CASH(result);
}
Datum
int8_cash(PG_FUNCTION_ARGS)
{
- int64 amount = PG_GETARG_INT64(0);
- Cash result;
- int fpoint;
- int64 scale;
- int i;
+ int64 amount = PG_GETARG_INT64(0);
+ Cash result;
+ int fpoint;
+ int64 scale;
+ int i;
struct lconv *lconvert = PGLC_localeconv();
/* see comments about frac_digits in cash_in() */
/* compute amount * scale, checking for overflow */
result = DatumGetInt64(DirectFunctionCall2(int8mul, Int64GetDatum(amount),
- Int64GetDatum(scale)));
+ Int64GetDatum(scale)));
PG_RETURN_CASH(result);
}
double
date2timestamp_no_overflow(DateADT dateVal)
{
- double result;
+ double result;
if (DATE_IS_NOBEGIN(dateVal))
result = -DBL_MAX;
/* do a sanity check */
#ifdef HAVE_INT64_TIMESTAMP
- if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR -1 ||
+ if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR - 1 ||
tm->tm_sec < 0 || tm->tm_sec > SECS_PER_MINUTE ||
*fsec < INT64CONST(0) ||
*fsec > USECS_PER_SEC)
break;
default:
elog(ERROR, "invalid relpersistence: %c", relform->relpersistence);
- backend = InvalidBackendId; /* placate compiler */
+ backend = InvalidBackendId; /* placate compiler */
break;
}
Datum *elems;
int max,
cnt;
- bool left_found;
+ bool left_found;
/*
* Scan the enum members in order using pg_enum_typid_sortorder_index.
while (HeapTupleIsValid(enum_tuple = systable_getnext_ordered(enum_scan, ForwardScanDirection)))
{
- Oid enum_oid = HeapTupleGetOid(enum_tuple);
+ Oid enum_oid = HeapTupleGetOid(enum_tuple);
if (!left_found && lower == enum_oid)
left_found = true;
/* last */
_DCH_last_
-} DCH_poz;
+} DCH_poz;
typedef enum
{
/* last */
_NUM_last_
-} NUM_poz;
+} NUM_poz;
/* ----------
* KeyWords for DATE-TIME version
#ifdef USE_WIDE_UPPER_LOWER
else if (pg_database_encoding_max_length() > 1)
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
wchar_t *workspace;
size_t curr_char;
size_t result_size;
#endif /* USE_WIDE_UPPER_LOWER */
else
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
char *p;
if (collid != DEFAULT_COLLATION_OID)
#ifdef USE_WIDE_UPPER_LOWER
else if (pg_database_encoding_max_length() > 1)
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
wchar_t *workspace;
size_t curr_char;
size_t result_size;
#endif /* USE_WIDE_UPPER_LOWER */
else
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
char *p;
if (collid != DEFAULT_COLLATION_OID)
for (p = result; *p; p++)
{
- char c;
+ char c;
if (wasalnum)
*p = c = pg_ascii_tolower((unsigned char) *p);
#ifdef USE_WIDE_UPPER_LOWER
else if (pg_database_encoding_max_length() > 1)
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
wchar_t *workspace;
size_t curr_char;
size_t result_size;
#endif /* USE_WIDE_UPPER_LOWER */
else
{
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
char *p;
if (collid != DEFAULT_COLLATION_OID)
/*
* 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
+ * 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.
* intervals
*/
sprintf(s, "%0*d", S_FM(n->suffix) ? 0 : 2,
- tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? HOURS_PER_DAY / 2 :
+ tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? HOURS_PER_DAY / 2 :
tm->tm_hour % (HOURS_PER_DAY / 2));
if (S_THth(n->suffix))
str_numth(s, s, S_TH_TYPE(n->suffix));
strcpy(s, str_toupper_z(localized_full_months[tm->tm_mon - 1], collid));
else
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
- str_toupper_z(months_full[tm->tm_mon - 1], collid));
+ str_toupper_z(months_full[tm->tm_mon - 1], collid));
s += strlen(s);
break;
case DCH_Month:
/* Disallow '/a/b/data/..' */
if (path_contains_parent_reference(filename))
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("reference to parent directory (\"..\") not allowed"))));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("reference to parent directory (\"..\") not allowed"))));
+
/*
- * Allow absolute paths if within DataDir or Log_directory, even
- * though Log_directory might be outside DataDir.
+ * Allow absolute paths if within DataDir or Log_directory, even
+ * though Log_directory might be outside DataDir.
*/
if (!path_is_prefix_of_path(DataDir, filename) &&
(!is_absolute_path(Log_directory) ||
!path_is_prefix_of_path(Log_directory, filename)))
ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- (errmsg("absolute path not allowed"))));
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ (errmsg("absolute path not allowed"))));
}
else if (!path_is_relative_and_below_cwd(filename))
ereport(ERROR,
#define LIKE_ABORT (-1)
-static int SB_MatchText(char *t, int tlen, char *p, int plen,
- pg_locale_t locale, bool locale_is_c);
+static int SB_MatchText(char *t, int tlen, char *p, int plen,
+ pg_locale_t locale, bool locale_is_c);
static text *SB_do_like_escape(text *, text *);
-static int MB_MatchText(char *t, int tlen, char *p, int plen,
- pg_locale_t locale, bool locale_is_c);
+static int MB_MatchText(char *t, int tlen, char *p, int plen,
+ pg_locale_t locale, bool locale_is_c);
static text *MB_do_like_escape(text *, text *);
-static int UTF8_MatchText(char *t, int tlen, char *p, int plen,
- pg_locale_t locale, bool locale_is_c);
+static int UTF8_MatchText(char *t, int tlen, char *p, int plen,
+ pg_locale_t locale, bool locale_is_c);
-static int SB_IMatchText(char *t, int tlen, char *p, int plen,
- pg_locale_t locale, bool locale_is_c);
+static int SB_IMatchText(char *t, int tlen, char *p, int plen,
+ pg_locale_t locale, bool locale_is_c);
static int GenericMatchText(char *s, int slen, char *p, int plen);
static int Generic_Text_IC_like(text *str, text *pat, Oid collation);
else
{
/*
- * Here we need to prepare locale information for SB_lower_char.
- * This should match the methods used in str_tolower().
+ * Here we need to prepare locale information for SB_lower_char. This
+ * should match the methods used in str_tolower().
*/
- pg_locale_t locale = 0;
- bool locale_is_c = false;
+ pg_locale_t locale = 0;
+ bool locale_is_c = false;
if (lc_ctype_is_c(collation))
locale_is_c = true;
tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR ||
tm->tm_mday < 1 || tm->tm_mday > 31 ||
tm->tm_hour < 0 ||
- tm->tm_hour > HOURS_PER_DAY || /* test for > 24:00:00 */
- (tm->tm_hour == HOURS_PER_DAY && (tm->tm_min > 0 || tm->tm_sec > 0)) ||
+ tm->tm_hour > HOURS_PER_DAY || /* test for > 24:00:00 */
+ (tm->tm_hour == HOURS_PER_DAY && (tm->tm_min > 0 || tm->tm_sec > 0)) ||
tm->tm_min < 0 || tm->tm_min > MINS_PER_HOUR - 1 ||
tm->tm_sec < 0 || tm->tm_sec > SECS_PER_MINUTE)
return INVALID_ABSTIME;
* 1. The interval length computations overflow at 2^31 seconds, causing
* intervals longer than that to sort oddly compared to those shorter.
* 2. infinity and minus infinity (NOEND_ABSTIME and NOSTART_ABSTIME) are
- * just ordinary integers. Since this code doesn't handle them specially,
+ * just ordinary integers. Since this code doesn't handle them specially,
* it's possible for [a b] to be considered longer than [c infinity] for
* finite abstimes a, b, c. In combination with the previous point, the
* interval [-infinity infinity] is treated as being shorter than many finite
inet *src = PG_GETARG_INET_P(0);
inet *dst;
int bits;
- int byte;
+ int byte;
int nbits;
int maxbytes;
/* clear the first byte, this might be a partial byte */
if (nbits != 0)
{
- ip_addr(dst)[byte] &=~(0xFF >> nbits);
- byte ++;
+ ip_addr(dst)[byte] &= ~(0xFF >> nbits);
+ byte++;
}
/* clear remaining bytes */
maxbytes = ip_addrsize(dst);
- while (byte <maxbytes)
+ while (byte < maxbytes)
{
ip_addr(dst)[byte] = 0;
- byte ++;
+ byte++;
}
PG_RETURN_INET_P(dst);
inet *src = PG_GETARG_INET_P(0);
int bits = PG_GETARG_INT32(1);
inet *dst;
- int byte;
+ int byte;
int nbits;
int maxbytes;
/* clear the first byte, this might be a partial byte */
if (nbits != 0)
{
- ip_addr(dst)[byte] &=~(0xFF >> nbits);
- byte ++;
+ ip_addr(dst)[byte] &= ~(0xFF >> nbits);
+ byte++;
}
/* clear remaining bytes */
maxbytes = ip_addrsize(dst);
- while (byte <maxbytes)
+ while (byte < maxbytes)
{
ip_addr(dst)[byte] = 0;
- byte ++;
+ byte++;
}
PG_RETURN_INET_P(dst);
{
inet *ip = PG_GETARG_INET_P(0);
inet *dst;
- int byte;
+ int byte;
int bits;
int maxbytes;
unsigned char mask;
a = ip_addr(ip);
b = ip_addr(dst);
- for (byte = 0; byte <maxbytes; byte ++)
+ for (byte = 0; byte < maxbytes; byte++)
{
if (bits >= 8)
{
bits = 0;
}
- b[byte] = a[byte] |mask;
+ b[byte] = a[byte] | mask;
}
ip_family(dst) = ip_family(ip);
{
inet *ip = PG_GETARG_INET_P(0);
inet *dst;
- int byte;
+ int byte;
int bits;
unsigned char mask;
unsigned char *a,
bits = 0;
}
- b[byte] = a[byte] &mask;
- byte ++;
+ b[byte] = a[byte] & mask;
+ byte++;
}
ip_family(dst) = ip_family(ip);
{
inet *ip = PG_GETARG_INET_P(0);
inet *dst;
- int byte;
+ int byte;
int bits;
unsigned char mask;
unsigned char *b;
}
b[byte] = mask;
- byte ++;
+ byte++;
}
ip_family(dst) = ip_family(ip);
{
inet *ip = PG_GETARG_INET_P(0);
inet *dst;
- int byte;
+ int byte;
int bits;
int maxbytes;
unsigned char mask;
}
b[byte] = mask;
- byte --;
+ byte--;
}
ip_family(dst) = ip_family(ip);
static bool
addressOK(unsigned char *a, int bits, int family)
{
- int byte;
+ int byte;
int nbits;
int maxbits;
int maxbytes;
if (bits != 0)
mask >>= nbits;
- while (byte <maxbytes)
+ while (byte < maxbytes)
{
- if ((a[byte] &mask) != 0)
+ if ((a[byte] & mask) != 0)
return false;
mask = 0xff;
- byte ++;
+ byte++;
}
return true;
* two's complement, too bad.
*/
int nb = ip_addrsize(ip);
- int byte = 0;
+ int byte = 0;
unsigned char *pip = ip_addr(ip);
unsigned char *pip2 = ip_addr(ip2);
int carry = 1;
carry = pip[nb] + (~pip2[nb] & 0xFF) + carry;
lobyte = carry & 0xFF;
- if (byte <sizeof(int64))
+ if (byte < sizeof(int64))
{
- res |= ((int64) lobyte) << (byte *8);
+ res |= ((int64) lobyte) << (byte * 8);
}
else
{
errmsg("result is out of range")));
}
carry >>= 8;
- byte ++;
+ byte++;
}
/*
* If input is narrower than int64, overflow is not possible, but we
* have to do proper sign extension.
*/
- if (carry == 0 && byte <sizeof(int64))
- res |= ((int64) -1) << (byte *8);
+ if (carry == 0 && byte < sizeof(int64))
+ res |= ((int64) -1) << (byte * 8);
}
PG_RETURN_INT64(res);
* If the high bits of the first word of a NumericChoice (n_header, or
* n_short.n_header, or n_long.n_sign_dscale) are NUMERIC_SHORT, then the
* numeric follows the NumericShort format; if they are NUMERIC_POS or
- * NUMERIC_NEG, it follows the NumericLong format. If they are NUMERIC_NAN,
+ * NUMERIC_NEG, it follows the NumericLong format. If they are NUMERIC_NAN,
* it is a NaN. We currently always store a NaN using just two bytes (i.e.
* only n_header), but previous releases used only the NumericLong format,
* so we might find 4-byte NaNs on disk if a database has been migrated using
- * pg_upgrade. In either case, when the high bits indicate a NaN, the
+ * pg_upgrade. In either case, when the high bits indicate a NaN, the
* remaining bits are never examined. Currently, we always initialize these
* to zero, but it might be possible to use them for some other purpose in
* the future.
union NumericChoice
{
uint16 n_header; /* Header word */
- struct NumericLong n_long; /* Long form (4-byte header) */
- struct NumericShort n_short; /* Short form (2-byte header) */
+ struct NumericLong n_long; /* Long form (4-byte header) */
+ struct NumericShort n_short; /* Short form (2-byte header) */
};
struct NumericData
{
int32 vl_len_; /* varlena header (do not touch directly!) */
- union NumericChoice choice; /* choice of format */
+ union NumericChoice choice; /* choice of format */
};
#define NUMERIC_IS_SHORT(n) (NUMERIC_FLAGBITS(n) == NUMERIC_SHORT)
#define NUMERIC_HDRSZ (VARHDRSZ + sizeof(uint16) + sizeof(int16))
-#define NUMERIC_HDRSZ_SHORT (VARHDRSZ + sizeof(uint16))
+#define NUMERIC_HDRSZ_SHORT (VARHDRSZ + sizeof(uint16))
/*
* If the flag bits are NUMERIC_SHORT or NUMERIC_NAN, we want the short header;
* Extract sign, display scale, weight.
*/
-#define NUMERIC_DSCALE_MASK 0x3FFF
+#define NUMERIC_DSCALE_MASK 0x3FFF
#define NUMERIC_SIGN(n) \
(NUMERIC_IS_SHORT(n) ? \
/*
* numeric_is_nan() -
*
- * Is Numeric value a NaN?
+ * Is Numeric value a NaN?
*/
bool
numeric_is_nan(Numeric num)
/*
* numeric_maximum_size() -
*
- * Maximum size of a numeric with given typmod, or -1 if unlimited/unknown.
+ * Maximum size of a numeric with given typmod, or -1 if unlimited/unknown.
*/
int32
numeric_maximum_size(int32 typmod)
{
- int precision;
- int numeric_digits;
+ int precision;
+ int numeric_digits;
if (typmod < (int32) (VARHDRSZ))
return -1;
precision = ((typmod - VARHDRSZ) >> 16) & 0xffff;
/*
- * This formula computes the maximum number of NumericDigits we could
- * need in order to store the specified number of decimal digits.
- * Because the weight is stored as a number of NumericDigits rather
- * than a number of decimal digits, it's possible that the first
- * NumericDigit will contain only a single decimal digit. Thus, the
- * first two decimal digits can require two NumericDigits to store,
- * but it isn't until we reach DEC_DIGITS + 2 decimal digits that we
- * potentially need a third NumericDigit.
+ * This formula computes the maximum number of NumericDigits we could need
+ * in order to store the specified number of decimal digits. Because the
+ * weight is stored as a number of NumericDigits rather than a number of
+ * decimal digits, it's possible that the first NumericDigit will contain
+ * only a single decimal digit. Thus, the first two decimal digits can
+ * require two NumericDigits to store, but it isn't until we reach
+ * DEC_DIGITS + 2 decimal digits that we potentially need a third
+ * NumericDigit.
*/
numeric_digits = (precision + 2 * (DEC_DIGITS - 1)) / DEC_DIGITS;
/*
* In most cases, the size of a numeric will be smaller than the value
* computed below, because the varlena header will typically get toasted
- * down to a single byte before being stored on disk, and it may also
- * be possible to use a short numeric header. But our job here is to
- * compute the worst case.
+ * down to a single byte before being stored on disk, and it may also be
+ * possible to use a short numeric header. But our job here is to compute
+ * the worst case.
*/
return NUMERIC_HDRSZ + (numeric_digits * sizeof(NumericDigit));
}
* If the number is certainly in bounds and due to the target scale no
* rounding could be necessary, just make a copy of the input and modify
* its scale fields, unless the larger scale forces us to abandon the
- * short representation. (Note we assume the existing dscale is honest...)
+ * short representation. (Note we assume the existing dscale is
+ * honest...)
*/
ddigits = (NUMERIC_WEIGHT(num) + 1) * DEC_DIGITS;
if (ddigits <= maxdigits && scale >= NUMERIC_DSCALE(num)
&& (NUMERIC_CAN_BE_SHORT(scale, NUMERIC_WEIGHT(num))
- || !NUMERIC_IS_SHORT(num)))
+ || !NUMERIC_IS_SHORT(num)))
{
new = (Numeric) palloc(VARSIZE(num));
memcpy(new, num, VARSIZE(num));
int end_offset;
int i;
int hash_len;
- NumericDigit *digits;
+ NumericDigit *digits;
/* If it's NaN, don't try to hash the rest of the fields */
if (NUMERIC_IS_NAN(key))
SET_VARSIZE(result, len);
result->choice.n_short.n_header =
(sign == NUMERIC_NEG ? (NUMERIC_SHORT | NUMERIC_SHORT_SIGN_MASK)
- : NUMERIC_SHORT)
+ : NUMERIC_SHORT)
| (var->dscale << NUMERIC_SHORT_DSCALE_SHIFT)
| (weight < 0 ? NUMERIC_SHORT_WEIGHT_SIGN_MASK : 0)
| (weight & NUMERIC_SHORT_WEIGHT_MASK);
* Avoid problems with the most negative integer not being representable
* as a positive integer.
*/
- if (value == (-2147483647-1))
+ if (value == (-2147483647 - 1))
{
memcpy(a, "-2147483648", 12);
return;
/* Compute the result string backwards. */
do
{
- int32 remainder;
- int32 oldval = value;
+ int32 remainder;
+ int32 oldval = value;
value /= 10;
remainder = oldval - value * 10;
/* Reverse string. */
while (start < a)
{
- char swap = *start;
+ char swap = *start;
*start++ = *a;
*a-- = swap;
* Avoid problems with the most negative integer not being representable
* as a positive integer.
*/
- if (value == (-INT64CONST(0x7FFFFFFFFFFFFFFF)-1))
+ if (value == (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1))
{
memcpy(a, "-9223372036854775808", 21);
return;
/* Compute the result string backwards. */
do
{
- int64 remainder;
- int64 oldval = value;
+ int64 remainder;
+ int64 oldval = value;
value /= 10;
remainder = oldval - value * 10;
/* Reverse string. */
while (start < a)
{
- char swap = *start;
+ char swap = *start;
*start++ = *a;
*a-- = swap;
bool collate_is_c; /* is collation's LC_COLLATE C? */
bool ctype_is_c; /* is collation's LC_CTYPE C? */
bool flags_valid; /* true if above flags are valid */
- pg_locale_t locale; /* locale_t struct, or 0 if not valid */
+ pg_locale_t locale; /* locale_t struct, or 0 if not valid */
} collation_cache_entry;
static HTAB *collation_cache = NULL;
*
* For most locale categories, the assign hook doesn't actually set the locale
* permanently, just reset flags so that the next use will cache the
- * appropriate values. (See explanation at the top of this file.)
+ * appropriate values. (See explanation at the top of this file.)
*
* Note: we accept value = "" as selecting the postmaster's environment
* value, whatever it was (so long as the environment setting is legal).
return NULL; /* Not supported on this version of msvc/mingw */
#endif /* _MSC_VER >= 1400 */
}
-
#endif /* WIN32 && LC_MESSAGES */
* could fail if the locale is C, so str_tolower() shouldn't call it
* in that case.
*
- * Note that we currently lack any way to flush the cache. Since we don't
+ * Note that we currently lack any way to flush the cache. Since we don't
* support ALTER COLLATION, this is OK. The worst case is that someone
* drops a collation, and a useless cache entry hangs around in existing
* backends.
lc_collate_is_c(Oid collation)
{
/*
- * If we're asked about "collation 0", return false, so that the code
- * will go into the non-C path and report that the collation is bogus.
+ * If we're asked about "collation 0", return false, so that the code will
+ * go into the non-C path and report that the collation is bogus.
*/
if (!OidIsValid(collation))
return false;
/*
- * If we're asked about the default collation, we have to inquire of
- * the C library. Cache the result so we only have to compute it once.
+ * If we're asked about the default collation, we have to inquire of the C
+ * library. Cache the result so we only have to compute it once.
*/
if (collation == DEFAULT_COLLATION_OID)
{
lc_ctype_is_c(Oid collation)
{
/*
- * If we're asked about "collation 0", return false, so that the code
- * will go into the non-C path and report that the collation is bogus.
+ * If we're asked about "collation 0", return false, so that the code will
+ * go into the non-C path and report that the collation is bogus.
*/
if (!OidIsValid(collation))
return false;
/*
- * If we're asked about the default collation, we have to inquire of
- * the C library. Cache the result so we only have to compute it once.
+ * If we're asked about the default collation, we have to inquire of the C
+ * library. Cache the result so we only have to compute it once.
*/
if (collation == DEFAULT_COLLATION_OID)
{
/*
- * Create a locale_t from a collation OID. Results are cached for the
+ * Create a locale_t from a collation OID. Results are cached for the
* lifetime of the backend. Thus, do not free the result with freelocale().
*
* As a special optimization, the default/database collation returns 0.
{
#ifndef WIN32
/* We need two newlocale() steps */
- locale_t loc1;
+ locale_t loc1;
loc1 = newlocale(LC_COLLATE_MASK, collcollate, NULL);
if (!loc1)
errmsg("could not create locale \"%s\": %m",
collctype)));
#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),
cache_entry->locale = result;
ReleaseSysCache(tp);
-
-#else /* not HAVE_LOCALE_T */
+#else /* not HAVE_LOCALE_T */
/*
* For platforms that don't support locale_t, we can't do anything
*/
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("nondefault collations are not supported on this platform")));
-#endif /* not HAVE_LOCALE_T */
+ errmsg("nondefault collations are not supported on this platform")));
+#endif /* not HAVE_LOCALE_T */
}
return cache_entry->locale;
{
Oid relid = PG_GETARG_OID(0);
int64 result;
- PgStat_StatTabEntry *tabentry;
+ PgStat_StatTabEntry *tabentry;
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
{
Oid relid = PG_GETARG_OID(0);
int64 result;
- PgStat_StatTabEntry *tabentry;
+ PgStat_StatTabEntry *tabentry;
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
{
Oid relid = PG_GETARG_OID(0);
int64 result;
- PgStat_StatTabEntry *tabentry;
+ PgStat_StatTabEntry *tabentry;
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
{
Oid relid = PG_GETARG_OID(0);
int64 result;
- PgStat_StatTabEntry *tabentry;
+ PgStat_StatTabEntry *tabentry;
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
result = 0;
else
result = (int64) (
- dbentry->n_conflict_tablespace +
- dbentry->n_conflict_lock +
- dbentry->n_conflict_snapshot +
- dbentry->n_conflict_bufferpin +
- dbentry->n_conflict_startup_deadlock);
+ dbentry->n_conflict_tablespace +
+ dbentry->n_conflict_lock +
+ dbentry->n_conflict_snapshot +
+ dbentry->n_conflict_bufferpin +
+ dbentry->n_conflict_startup_deadlock);
PG_RETURN_INT64(result);
}
* This is not a trigger procedure, but is called during ALTER TABLE
* ADD FOREIGN KEY to validate the initial table contents.
*
- * We expect that the caller has made provision to prevent any problems
+ * We expect that the caller has made provision to prevent any problems
* caused by concurrent actions. This could be either by locking rel and
* pkrel at ShareRowExclusiveLock or higher, or by otherwise ensuring
* that triggers implementing the checks are already active.
char fkrelname[MAX_QUOTED_REL_NAME_LEN];
char pkattname[MAX_QUOTED_NAME_LEN + 3];
char fkattname[MAX_QUOTED_NAME_LEN + 3];
- RangeTblEntry *pkrte;
- RangeTblEntry *fkrte;
+ RangeTblEntry *pkrte;
+ RangeTblEntry *fkrte;
const char *sep;
int i;
int old_work_mem;
for (i = 0; i < riinfo.nkeys; i++)
{
- int attno;
+ int attno;
attno = riinfo.pk_attnums[i] - FirstLowInvalidHeapAttributeNumber;
pkrte->selectedCols = bms_add_member(pkrte->selectedCols, attno);
/*
* Run the plan. For safety we force a current snapshot to be used. (In
- * transaction-snapshot mode, this arguably violates transaction
- * isolation rules, but we really haven't got much choice.)
- * We don't need to register the snapshot, because SPI_execute_snapshot
- * will see to it. We need at most one tuple returned, so pass limit = 1.
+ * transaction-snapshot mode, this arguably violates transaction isolation
+ * rules, but we really haven't got much choice.) We don't need to
+ * register the snapshot, because SPI_execute_snapshot will see to it. We
+ * need at most one tuple returned, so pass limit = 1.
*/
spi_result = SPI_execute_snapshot(qplan,
NULL, NULL,
/*
* In READ COMMITTED mode, we just need to use an up-to-date regular
* snapshot, and we will see all rows that could be interesting. But in
- * transaction-snapshot mode, we can't change the transaction snapshot.
- * If the caller passes detectNewRows == false then it's okay to do the query
+ * transaction-snapshot mode, we can't change the transaction snapshot. If
+ * the caller passes detectNewRows == false then it's okay to do the query
* with the transaction snapshot; otherwise we use a current snapshot, and
* tell the executor to error out if it finds any rows under the current
* snapshot that wouldn't be visible per the transaction snapshot. Note
static void push_child_plan(deparse_namespace *dpns, PlanState *ps,
deparse_namespace *save_dpns);
static void pop_child_plan(deparse_namespace *dpns,
- deparse_namespace *save_dpns);
+ deparse_namespace *save_dpns);
static void push_ancestor_plan(deparse_namespace *dpns, ListCell *ancestor_cell,
deparse_namespace *save_dpns);
static void pop_ancestor_plan(deparse_namespace *dpns,
- deparse_namespace *save_dpns);
+ deparse_namespace *save_dpns);
static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
int prettyFlags);
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
if (!attrsOnly && (!colno || colno == keyno + 1))
{
- Oid indcoll;
+ Oid indcoll;
/* Add collation, if not default for column */
indcoll = indcollation->values[keyno];
* We special-case Append and MergeAppend to pretend that the first child
* plan is the OUTER referent; we have to interpret OUTER Vars in their
* tlists according to one of the children, and the first one is the most
- * natural choice. Likewise special-case ModifyTable to pretend that the
+ * natural choice. Likewise special-case ModifyTable to pretend that the
* first child plan is the OUTER referent; this is to support RETURNING
* lists containing references to non-target relations.
*/
/*
* Currently we don't bother to adjust the ancestors list, because an
- * OUTER or INNER reference really shouldn't contain any Params that
- * would be set by the parent node itself. If we did want to adjust it,
+ * OUTER or INNER reference really shouldn't contain any Params that would
+ * be set by the parent node itself. If we did want to adjust it,
* lcons'ing dpns->planstate onto dpns->ancestors would be the appropriate
* thing --- and pop_child_plan would need to undo the change to the list.
*/
* subquery's alias, that's not possible for resjunk items since they have
* no alias. So in that case, drill down to the subplan and print the
* contents of the referenced tlist item. This works because in a plan
- * tree, such Vars can only occur in a SubqueryScan or CteScan node,
- * and we'll have set dpns->inner_plan to reference the child plan node.
+ * tree, such Vars can only occur in a SubqueryScan or CteScan node, and
+ * we'll have set dpns->inner_plan to reference the child plan node.
*/
if ((rte->rtekind == RTE_SUBQUERY || rte->rtekind == RTE_CTE) &&
attnum > list_length(rte->eref->colnames) &&
if (lc != NULL)
{
Query *ctequery = (Query *) cte->ctequery;
- TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte),
+ TargetEntry *ste = get_tle_by_resno(GetCTETargetList(cte),
attnum);
if (ste == NULL || ste->resjunk)
get_parameter(Param *param, deparse_context *context)
{
/*
- * If it's a PARAM_EXEC parameter, try to locate the expression from
- * which the parameter was computed. This will necessarily be in some
- * ancestor of the current expression's PlanState. Note that failing
- * to find a referent isn't an error, since the Param might well be a
- * subplan output rather than an input.
+ * If it's a PARAM_EXEC parameter, try to locate the expression from which
+ * the parameter was computed. This will necessarily be in some ancestor
+ * of the current expression's PlanState. Note that failing to find a
+ * referent isn't an error, since the Param might well be a subplan output
+ * rather than an input.
*/
if (param->paramkind == PARAM_EXEC)
{
ListCell *lc2;
/*
- * NestLoops transmit params to their inner child only; also,
- * once we've crawled up out of a subplan, this couldn't
- * possibly be the right match.
+ * NestLoops transmit params to their inner child only; also, once
+ * we've crawled up out of a subplan, this couldn't possibly be
+ * the right match.
*/
if (IsA(ps, NestLoopState) &&
child_ps == innerPlanState(ps) &&
foreach(lc2, nl->nestParams)
{
- NestLoopParam *nlp = (NestLoopParam *) lfirst(lc2);
+ NestLoopParam *nlp = (NestLoopParam *) lfirst(lc2);
if (nlp->paramno == param->paramid)
{
/* Matched subplan, so check its arguments */
forboth(lc3, subplan->parParam, lc4, subplan->args)
{
- int paramid = lfirst_int(lc3);
- Node *arg = (Node *) lfirst(lc4);
+ int paramid = lfirst_int(lc3);
+ Node *arg = (Node *) lfirst(lc4);
if (paramid == param->paramid)
{
appendStringInfo(buf, " %s %s (",
generate_operator_name(expr->opno,
exprType(arg1),
- get_base_element_type(exprType(arg2))),
+ get_base_element_type(exprType(arg2))),
expr->useOr ? "ANY" : "ALL");
get_rule_expr_paren(arg2, context, true, node);
appendStringInfoChar(buf, ')');
if (OidIsValid(constval->constcollid))
{
- Oid typcollation = get_typcollation(constval->consttype);
+ Oid typcollation = get_typcollation(constval->consttype);
if (constval->constcollid != typcollation)
{
gavealias = true;
}
else if (rte->rtekind == RTE_RELATION &&
- strcmp(rte->eref->aliasname, get_relation_name(rte->relid)) != 0)
+ strcmp(rte->eref->aliasname, get_relation_name(rte->relid)) != 0)
{
/*
* Apparently the rel has been renamed since the rule was made.
Cost *indexTotalCost = (Cost *) PG_GETARG_POINTER(6);
Selectivity *indexSelectivity = (Selectivity *) PG_GETARG_POINTER(7);
double *indexCorrelation = (double *) PG_GETARG_POINTER(8);
- ListCell *l;
- List *selectivityQuals;
- double numPages = index->pages,
- numTuples = index->tuples;
- double numEntryPages,
- numDataPages,
- numPendingPages,
- numEntries;
- bool haveFullScan = false;
- double partialEntriesInQuals = 0.0;
- double searchEntriesInQuals = 0.0;
- double exactEntriesInQuals = 0.0;
- double entryPagesFetched,
- dataPagesFetched,
- dataPagesFetchedBySel;
- double qual_op_cost,
- qual_arg_cost,
- spc_random_page_cost,
- num_scans;
- QualCost index_qual_cost;
- Relation indexRel;
- GinStatsData ginStats;
+ ListCell *l;
+ List *selectivityQuals;
+ double numPages = index->pages,
+ numTuples = index->tuples;
+ double numEntryPages,
+ numDataPages,
+ numPendingPages,
+ numEntries;
+ bool haveFullScan = false;
+ double partialEntriesInQuals = 0.0;
+ double searchEntriesInQuals = 0.0;
+ double exactEntriesInQuals = 0.0;
+ double entryPagesFetched,
+ dataPagesFetched,
+ dataPagesFetchedBySel;
+ double qual_op_cost,
+ qual_arg_cost,
+ spc_random_page_cost,
+ num_scans;
+ QualCost index_qual_cost;
+ Relation indexRel;
+ GinStatsData ginStats;
/*
* Obtain statistic information from the meta page
/*
* nPendingPages can be trusted, but the other fields are as of the last
- * VACUUM. Scale them by the ratio numPages / nTotalPages to account for
+ * VACUUM. Scale them by the ratio numPages / nTotalPages to account for
* growth since then. If the fields are zero (implying no VACUUM at all,
* and an index created pre-9.1), assume all pages are entry pages.
*/
{
numEntryPages = numPages;
numDataPages = 0;
- numEntries = numTuples; /* bogus, but no other info available */
+ numEntries = numTuples; /* bogus, but no other info available */
}
else
{
- double scale = numPages / ginStats.nTotalPages;
+ double scale = numPages / ginStats.nTotalPages;
numEntryPages = ceil(numEntryPages * scale);
numDataPages = ceil(numDataPages * scale);
}
/*
- * Include predicate in selectivityQuals (should match genericcostestimate)
+ * Include predicate in selectivityQuals (should match
+ * genericcostestimate)
*/
if (index->indpred != NIL)
{
/* Estimate the fraction of main-table tuples that will be visited */
*indexSelectivity = clauselist_selectivity(root, selectivityQuals,
- index->rel->relid,
- JOIN_INNER,
- NULL);
+ index->rel->relid,
+ JOIN_INNER,
+ NULL);
/* fetch estimated page cost for schema containing index */
- get_tablespace_page_costs(index->reltablespace,
+ get_tablespace_page_costs(index->reltablespace,
&spc_random_page_cost,
NULL);
*/
foreach(l, indexQuals)
{
- RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
- Expr *clause;
- Node *leftop,
- *rightop,
- *operand;
- Oid extractProcOid;
- Oid clause_op;
- int strategy_op;
- Oid lefttype,
- righttype;
- int32 nentries = 0;
- bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
- bool *nullFlags = NULL;
- int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
- int indexcol;
+ RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
+ Expr *clause;
+ Node *leftop,
+ *rightop,
+ *operand;
+ Oid extractProcOid;
+ Oid clause_op;
+ int strategy_op;
+ Oid lefttype,
+ righttype;
+ int32 nentries = 0;
+ bool *partial_matches = NULL;
+ Pointer *extra_data = NULL;
+ bool *nullFlags = NULL;
+ int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
+ int indexcol;
Assert(IsA(rinfo, RestrictInfo));
clause = rinfo->clause;
else
{
elog(ERROR, "could not match index to operand");
- operand = NULL; /* keep compiler quiet */
+ operand = NULL; /* keep compiler quiet */
}
if (IsA(operand, RelabelType))
operand = (Node *) ((RelabelType *) operand)->arg;
/*
- * It's impossible to call extractQuery method for unknown operand.
- * So unless operand is a Const we can't do much; just assume there
- * will be one ordinary search entry from the operand at runtime.
+ * It's impossible to call extractQuery method for unknown operand. So
+ * unless operand is a Const we can't do much; just assume there will
+ * be one ordinary search entry from the operand at runtime.
*/
if (!IsA(operand, Const))
{
}
/* If Const is null, there can be no matches */
- if (((Const*) operand)->constisnull)
+ if (((Const *) operand)->constisnull)
{
*indexStartupCost = 0;
*indexTotalCost = 0;
/*
* Get the operator's strategy number and declared input data types
- * within the index opfamily. (We don't need the latter, but we
- * use get_op_opfamily_properties because it will throw error if
- * it fails to find a matching pg_amop entry.)
+ * within the index opfamily. (We don't need the latter, but we use
+ * get_op_opfamily_properties because it will throw error if it fails
+ * to find a matching pg_amop entry.)
*/
get_op_opfamily_properties(clause_op, index->opfamily[indexcol], false,
&strategy_op, &lefttype, &righttype);
{
/* should not happen; throw same error as index_getprocinfo */
elog(ERROR, "missing support function %d for attribute %d of index \"%s\"",
- GIN_EXTRACTQUERY_PROC, indexcol+1,
+ GIN_EXTRACTQUERY_PROC, indexcol + 1,
get_rel_name(index->indexoid));
}
OidFunctionCall7(extractProcOid,
- ((Const*) operand)->constvalue,
+ ((Const *) operand)->constvalue,
PointerGetDatum(&nentries),
UInt16GetDatum(strategy_op),
PointerGetDatum(&partial_matches),
}
else
{
- int32 i;
+ int32 i;
- for (i=0; i<nentries; i++)
+ for (i = 0; i < nentries; i++)
{
/*
* For partial match we haven't any information to estimate
num_scans = 1;
/*
- * cost to begin scan, first of all, pay attention to
- * pending list.
+ * cost to begin scan, first of all, pay attention to pending list.
*/
entryPagesFetched = numPendingPages;
/*
* Estimate number of entry pages read. We need to do
* searchEntriesInQuals searches. Use a power function as it should be,
- * but tuples on leaf pages usually is much greater.
- * Here we include all searches in entry tree, including
- * search of first entry in partial match algorithm
+ * but tuples on leaf pages usually is much greater. Here we include all
+ * searches in entry tree, including search of first entry in partial
+ * match algorithm
*/
entryPagesFetched += ceil(searchEntriesInQuals * rint(pow(numEntryPages, 0.15)));
/*
- * Add an estimate of entry pages read by partial match algorithm.
- * It's a scan over leaf pages in entry tree. We haven't any useful stats
- * here, so estimate it as proportion.
+ * Add an estimate of entry pages read by partial match algorithm. It's a
+ * scan over leaf pages in entry tree. We haven't any useful stats here,
+ * so estimate it as proportion.
*/
entryPagesFetched += ceil(numEntryPages * partialEntriesInQuals / numEntries);
/*
- * Partial match algorithm reads all data pages before
- * doing actual scan, so it's a startup cost. Again,
- * we havn't any useful stats here, so, estimate it as
- * proportion
+ * Partial match algorithm reads all data pages before doing actual scan,
+ * so it's a startup cost. Again, we havn't any useful stats here, so,
+ * estimate it as proportion
*/
dataPagesFetched = ceil(numDataPages * partialEntriesInQuals / numEntries);
}
/*
- * Here we use random page cost because logically-close pages could be
- * far apart on disk.
+ * Here we use random page cost because logically-close pages could be far
+ * apart on disk.
*/
*indexStartupCost = (entryPagesFetched + dataPagesFetched) * spc_random_page_cost;
* capacity of data page.
*/
dataPagesFetchedBySel = ceil(*indexSelectivity *
- (numTuples / (BLCKSZ/SizeOfIptrData)));
+ (numTuples / (BLCKSZ / SizeOfIptrData)));
if (dataPagesFetchedBySel > dataPagesFetched)
{
/*
- * At least one of entries is very frequent and, unfortunately,
- * we couldn't get statistic about entries (only tsvector has
- * such statistics). So, we obviously have too small estimation of
- * pages fetched from data tree. Re-estimate it from known
- * capacity of data pages
+ * At least one of entries is very frequent and, unfortunately, we
+ * couldn't get statistic about entries (only tsvector has such
+ * statistics). So, we obviously have too small estimation of pages
+ * fetched from data tree. Re-estimate it from known capacity of data
+ * pages
*/
dataPagesFetched = dataPagesFetchedBySel;
}
qual_op_cost = cpu_operator_cost *
(list_length(indexQuals) + list_length(indexOrderBys));
qual_arg_cost -= qual_op_cost;
- if (qual_arg_cost < 0) /* just in case... */
+ if (qual_arg_cost < 0) /* just in case... */
qual_arg_cost = 0;
*indexStartupCost += qual_arg_cost;
{
TSQuery query = PG_GETARG_TSQUERY(0);
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
+
/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3);
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
- /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
+
+ /* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
Datum *entries = NULL;
/*
* If the query doesn't have any required positive matches (for
- * instance, it's something like '! foo'), we have to do a full
- * index scan.
+ * instance, it's something like '! foo'), we have to do a full index
+ * scan.
*/
if (tsquery_requires_match(item))
*searchMode = GIN_SEARCH_MODE_DEFAULT;
* Formerly, gin_extract_tsvector had only two arguments. Now it has three,
* but we still need a pg_proc entry with two args to support reloading
* pre-9.1 contrib/tsearch2 opclass declarations. This compatibility
- * function should go away eventually. (Note: you might say "hey, but the
+ * function should go away eventually. (Note: you might say "hey, but the
* code above is only *using* two args, so let's just declare it that way".
* If you try that you'll find the opr_sanity regression test complains.)
*/
switch (curitem->qoperator.oper)
{
case OP_NOT:
+
/*
* Assume there are no required matches underneath a NOT. For
* some cases with nested NOTs, we could prove there's a required
/* same as varbit output */
return varbit_out(fcinfo);
#else
+
/*
* This is how one would print a hex string, in case someone wants to
* write a formatting function.
static Datum text_to_array_internal(PG_FUNCTION_ARGS);
static text *array_to_text_internal(FunctionCallInfo fcinfo, ArrayType *v,
- char *fldsep, char *null_string);
+ char *fldsep, char *null_string);
/*****************************************************************************
char a2buf[STACKBUFLEN];
char *a1p,
*a2p;
- pg_locale_t mylocale = 0;
+ pg_locale_t mylocale = 0;
if (collid != DEFAULT_COLLATION_OID)
{
result = wcscoll_l((LPWSTR) a1p, (LPWSTR) a2p, mylocale);
else
#endif
- result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p);
+ result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p);
if (result == 2147483647) /* _NLSCMPERROR; missing from mingw
* headers */
ereport(ERROR,
result = strcoll_l(a1p, a2p, mylocale);
else
#endif
- result = strcoll(a1p, a2p);
+ result = strcoll(a1p, a2p);
/*
* In some locales strcoll() can claim that nonidentical strings are
/*
* Since we only care about equality or not-equality, we can avoid all the
- * expense of strcoll() here, and just do bitwise comparison. In fact,
- * we don't even have to do a bitwise comparison if we can show the
- * lengths of the strings are unequal; which might save us from having
- * to detoast one or both values.
+ * expense of strcoll() here, and just do bitwise comparison. In fact, we
+ * don't even have to do a bitwise comparison if we can show the lengths
+ * of the strings are unequal; which might save us from having to detoast
+ * one or both values.
*/
len1 = toast_raw_datum_size(arg1);
len2 = toast_raw_datum_size(arg2);
bytea *v = PG_GETARG_BYTEA_PP(0);
int32 n = PG_GETARG_INT32(1);
int len;
- int byte;
+ int byte;
len = VARSIZE_ANY_EXHDR(v);
int byteNo,
bitNo;
int len;
- int byte;
+ int byte;
len = VARSIZE_ANY_EXHDR(v);
byte = ((unsigned char *) VARDATA_ANY(v))[byteNo];
- if (byte &(1 << bitNo))
+ if (byte & (1 << bitNo))
PG_RETURN_INT32(1);
else
PG_RETURN_INT32(0);
/* single element can be a NULL too */
is_null = null_string ? text_isequal(inputstring, null_string) : false;
PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID,
- PointerGetDatum(inputstring),
+ PointerGetDatum(inputstring),
is_null, 1));
}
/* start_ptr points to the start_posn'th character of inputstring */
start_ptr = VARDATA_ANY(inputstring);
- for (fldnum = 1;; fldnum++) /* field number is 1 based */
+ for (fldnum = 1;; fldnum++) /* field number is 1 based */
{
CHECK_FOR_INTERRUPTS();
{
/*
* When fldsep is NULL, each character in the inputstring becomes an
- * element in the result array. The separator is effectively the space
- * between characters.
+ * element in the result array. The separator is effectively the
+ * space between characters.
*/
inputstring_len = VARSIZE_ANY_EXHDR(inputstring);
while (inputstring_len > 0)
{
- int chunk_len = pg_mblen(start_ptr);
+ int chunk_len = pg_mblen(start_ptr);
CHECK_FOR_INTERRUPTS();
static text *
concat_internal(const char *sepstr, int seplen, int argidx, FunctionCallInfo fcinfo)
{
- StringInfoData str;
- text *result;
- int i;
+ StringInfoData str;
+ text *result;
+ int i;
initStringInfo(&str);
{
if (!PG_ARGISNULL(i))
{
- Oid valtype;
- Datum value;
- Oid typOutput;
- bool typIsVarlena;
+ Oid valtype;
+ Datum value;
+ Oid typOutput;
+ bool typIsVarlena;
if (i > argidx)
appendBinaryStringInfo(&str, sepstr, seplen);
valtype = get_fn_expr_argtype(fcinfo->flinfo, i);
getTypeOutputInfo(valtype, &typOutput, &typIsVarlena);
appendStringInfoString(&str,
- OidOutputFunctionCall(typOutput, value));
+ OidOutputFunctionCall(typOutput, value));
}
}
Datum
text_concat_ws(PG_FUNCTION_ARGS)
{
- text *sep;
+ text *sep;
/* return NULL when separator is NULL */
if (PG_ARGISNULL(0))
sep = PG_GETARG_TEXT_PP(0);
PG_RETURN_TEXT_P(concat_internal(
- VARDATA_ANY(sep), VARSIZE_ANY_EXHDR(sep), 1, fcinfo));
+ VARDATA_ANY(sep), VARSIZE_ANY_EXHDR(sep), 1, fcinfo));
}
/*
Datum
text_reverse(PG_FUNCTION_ARGS)
{
- text *str = PG_GETARG_TEXT_PP(0);
- const char *p = VARDATA_ANY(str);
- int len = VARSIZE_ANY_EXHDR(str);
- const char *endp = p + len;
- text *result;
- char *dst;
+ text *str = PG_GETARG_TEXT_PP(0);
+ const char *p = VARDATA_ANY(str);
+ int len = VARSIZE_ANY_EXHDR(str);
+ const char *endp = p + len;
+ text *result;
+ char *dst;
result = palloc(len + VARHDRSZ);
- dst = (char*) VARDATA(result) + len;
+ dst = (char *) VARDATA(result) + len;
SET_VARSIZE(result, len + VARHDRSZ);
if (pg_database_encoding_max_length() > 1)
/* multibyte version */
while (p < endp)
{
- int sz;
+ int sz;
sz = pg_mblen(p);
dst -= sz;
text_format(PG_FUNCTION_ARGS)
{
text *fmt;
- StringInfoData str;
+ StringInfoData str;
const char *cp;
const char *start_ptr;
const char *end_ptr;
/* Scan format string, looking for conversion specifiers. */
for (cp = start_ptr; cp < end_ptr; cp++)
{
- Datum value;
- bool isNull;
- Oid typid;
+ Datum value;
+ bool isNull;
+ Oid typid;
/*
* If it's not the start of a conversion specifier, just copy it to
++arg;
else
{
- bool unterminated = false;
+ bool unterminated = false;
/* Parse digit string. */
arg = 0;
- do {
+ do
+ {
/* Treat overflowing arg position as unterminated. */
if (arg > INT_MAX / 10)
break;
/* There's no argument 0. */
if (arg == 0)
ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("conversion specifies argument 0, but arguments are numbered from 1")));
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("conversion specifies argument 0, but arguments are numbered from 1")));
}
/* Not enough arguments? Deduct 1 to avoid counting format string. */
errmsg("too few arguments for format conversion")));
/*
- * At this point, we should see the main conversion specifier.
- * Whether or not an argument position was present, it's known
- * that at least one character remains in the string at this point.
+ * At this point, we should see the main conversion specifier. Whether
+ * or not an argument position was present, it's known that at least
+ * one character remains in the string at this point.
*/
value = PG_GETARG_DATUM(arg);
isNull = PG_ARGISNULL(arg);
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("unrecognized conversion specifier: %c",
- *cp)));
+ *cp)));
}
}
/* Format a %s, %I, or %L conversion. */
void
text_format_string_conversion(StringInfo buf, char conversion,
- Oid typid, Datum value, bool isNull)
+ Oid typid, Datum value, bool isNull)
{
- Oid typOutput;
- bool typIsVarlena;
- char *str;
+ Oid typOutput;
+ bool typIsVarlena;
+ char *str;
/* Handle NULL arguments before trying to stringify the value. */
if (isNull)
if (conversion == 'L')
appendStringInfoString(buf, "NULL");
else if (conversion == 'I')
- ereport(ERROR,
+ ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("NULL cannot be escaped as an SQL identifier")));
return;
}
else if (conversion == 'L')
{
- char *qstr = quote_literal_cstr(str);
+ char *qstr = quote_literal_cstr(str);
+
appendStringInfoString(buf, qstr);
/* quote_literal_cstr() always allocates a new string */
pfree(qstr);
/*
* text_format_nv - nonvariadic wrapper for text_format function.
- *
+ *
* note: this wrapper is necessary to be sanity_checks test ok
*/
Datum
{
/*
* Note, that here we try to apply DTD defaults
- * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d: 'Default
- * values defined by internal DTD are applied'. As for external
- * DTDs, we try to support them too, (see SQL/XML:2008 GR 10.16.7.e)
+ * (XML_PARSE_DTDATTR) according to SQL/XML:2008 GR 10.16.7.d:
+ * 'Default values defined by internal DTD are applied'. As for
+ * external DTDs, we try to support them too, (see SQL/XML:2008 GR
+ * 10.16.7.e)
*/
doc = xmlCtxtReadDoc(ctxt, utf8string,
NULL,
/*
* Version 2.6.27 introduces a function named
- * xmlXPathCompiledEvalToBoolean, which would be enough for
- * xmlexists, but we can derive the existence by whether any
- * nodes are returned, thereby preventing a library version
- * upgrade and keeping the code the same.
+ * xmlXPathCompiledEvalToBoolean, which would be enough for xmlexists,
+ * but we can derive the existence by whether any nodes are returned,
+ * thereby preventing a library version upgrade and keeping the code
+ * the same.
*/
xpathobj = xmlXPathCompiledEval(xpathcomp, xpathctx);
if (xpathobj == NULL) /* TODO: reason? */
xmlFreeDoc(doc);
xmlFreeParserCtxt(ctxt);
}
-#endif /* USE_LIBXML */
+#endif /* USE_LIBXML */
/*
* Evaluate XPath expression and return array of XML values.
* Determines if the node specified by the supplied XPath exists
* in a given XML document, returning a boolean.
*/
-Datum xmlexists(PG_FUNCTION_ARGS)
+Datum
+xmlexists(PG_FUNCTION_ARGS)
{
#ifdef USE_LIBXML
text *xpath_expr_text = PG_GETARG_TEXT_P(0);
* We could have smgr entries for relations of other databases, so no
* short-circuit test is possible here.
*/
- RelFileNodeBackend rnode;
+ RelFileNodeBackend rnode;
+
rnode.node = msg->sm.rnode;
rnode.backend = (msg->sm.backend_hi << 16) | (int) msg->sm.backend_lo;
smgrclosenode(rnode);
*
* In some cases (currently only array_eq), mergejoinability depends on the
* specific input data type the operator is invoked for, so that must be
- * passed as well. We currently assume that only one input's type is needed
+ * passed as well. We currently assume that only one input's type is needed
* to check this --- by convention, pass the left input's data type.
*/
bool
*
* In some cases (currently only array_eq), hashjoinability depends on the
* specific input data type the operator is invoked for, so that must be
- * passed as well. We currently assume that only one input's type is needed
+ * passed as well. We currently assume that only one input's type is needed
* to check this --- by convention, pass the left input's data type.
*/
bool
/*
* Need to get info about the array element type. We look at the
* actual element type embedded in the array, which might be only
- * binary-compatible with the passed-in atttype. The info we
- * extract here should be the same either way, but deconstruct_array
- * is picky about having an exact type OID match.
+ * binary-compatible with the passed-in atttype. The info we extract
+ * here should be the same either way, but deconstruct_array is picky
+ * about having an exact type OID match.
*/
arrayelemtype = ARR_ELEMTYPE(statarray);
typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
TupleDesc resultDesc;
/*
- * Restore the search_path that was in use when the plan was made.
- * See comments for PushOverrideSearchPath about limitations of this.
+ * Restore the search_path that was in use when the plan was made. See
+ * comments for PushOverrideSearchPath about limitations of this.
*
* (XXX is there anything else we really need to restore?)
*/
MemoryContextAllocZero(indexcxt, natts * sizeof(int16));
/*
- * indcollation cannot be referenced directly through the C struct, because it
- * comes after the variable-width indkey field. Must extract the datum
- * the hard way...
+ * indcollation cannot be referenced directly through the C struct,
+ * because it comes after the variable-width indkey field. Must extract
+ * the datum the hard way...
*/
indcollDatum = fastgetattr(relation->rd_indextuple,
Anum_pg_index_indcollation,
/*
* Fill the support procedure OID array, as well as the info about
- * opfamilies and opclass input types. (aminfo and supportinfo are left
+ * opfamilies and opclass input types. (aminfo and supportinfo are left
* as zeroes, and are filled on-the-fly when used)
*/
IndexSupportInitialize(indclass, relation->rd_support,
},
32
},
- {ForeignTableRelationId, /* FOREIGNTABLEREL */
+ {ForeignTableRelationId, /* FOREIGNTABLEREL */
ForeignTableRelidIndexId,
1,
{
/* Look up the config */
TSCurrentConfigCache =
get_ts_config_oid(stringToQualifiedNameList(TSCurrentConfig),
- !emitError);
+ !emitError);
return TSCurrentConfigCache;
}
Oid bitmap_base; /* OID corresponding to bit 0 of bitmapset */
Bitmapset *sorted_values; /* Set of OIDs known to be in order */
int num_values; /* total number of values in enum */
- EnumItem enum_values[1]; /* VARIABLE LENGTH ARRAY */
+ EnumItem enum_values[1]; /* VARIABLE LENGTH ARRAY */
} TypeCacheEnumData;
/*
{
/*
* In case we find a btree opclass where previously we only found
- * a hash opclass, reset eq_opr and derived information so that
- * we can fetch the btree equality operator instead of the hash
- * equality operator. (They're probably the same operator, but
- * we don't assume that here.)
+ * a hash opclass, reset eq_opr and derived information so that we
+ * can fetch the btree equality operator instead of the hash
+ * equality operator. (They're probably the same operator, but we
+ * don't assume that here.)
*/
typentry->eq_opr = InvalidOid;
typentry->eq_opr_finfo.fn_oid = InvalidOid;
while ((typentry = (TypeCacheEntry *) hash_seq_search(&status)) != NULL)
{
if (typentry->tupDesc == NULL)
- continue; /* not composite, or tupdesc hasn't been requested */
+ continue; /* not composite, or tupdesc hasn't been
+ * requested */
/* Delete if match, or if we're zapping all composite types */
if (relid == typentry->typrelid || relid == InvalidOid)
EnumItem *item2;
/*
- * Equal OIDs are certainly equal --- this case was probably handled
- * by our caller, but we may as well check.
+ * Equal OIDs are certainly equal --- this case was probably handled by
+ * our caller, but we may as well check.
*/
if (arg1 == arg2)
return 0;
{
/*
* We couldn't find one or both values. That means the enum has
- * changed under us, so re-initialize the cache and try again.
- * We don't bother retrying the known-sorted case in this path.
+ * changed under us, so re-initialize the cache and try again. We
+ * don't bother retrying the known-sorted case in this path.
*/
load_enum_cache_data(tcache);
enumdata = tcache->enumData;
item2 = find_enumitem(enumdata, arg2);
/*
- * If we still can't find the values, complain: we must have
- * corrupt data.
+ * If we still can't find the values, complain: we must have corrupt
+ * data.
*/
if (item1 == NULL)
elog(ERROR, "enum value %u not found in cache for enum %s",
format_type_be(tcache->type_id))));
/*
- * Read all the information for members of the enum type. We collect
- * the info in working memory in the caller's context, and then transfer
- * it to permanent memory in CacheMemoryContext. This minimizes the risk
- * of leaking memory from CacheMemoryContext in the event of an error
- * partway through.
+ * Read all the information for members of the enum type. We collect the
+ * info in working memory in the caller's context, and then transfer it to
+ * permanent memory in CacheMemoryContext. This minimizes the risk of
+ * leaking memory from CacheMemoryContext in the event of an error partway
+ * through.
*/
maxitems = 64;
items = (EnumItem *) palloc(sizeof(EnumItem) * maxitems);
numitems = 0;
/*
- * Scan pg_enum for the members of the target enum type. We use a
- * current MVCC snapshot, *not* SnapshotNow, so that we see a consistent
- * set of rows even if someone commits a renumbering of the enum meanwhile.
- * See comments for RenumberEnumType in catalog/pg_enum.c for more info.
+ * Scan pg_enum for the members of the target enum type. We use a current
+ * MVCC snapshot, *not* SnapshotNow, so that we see a consistent set of
+ * rows even if someone commits a renumbering of the enum meanwhile. See
+ * comments for RenumberEnumType in catalog/pg_enum.c for more info.
*/
ScanKeyInit(&skey,
Anum_pg_enum_enumtypid,
* and we'd rather not do binary searches unnecessarily.
*
* This is somewhat heuristic, and might identify a subset of OIDs that
- * isn't exactly what the type started with. That's okay as long as
- * the subset is correctly sorted.
+ * isn't exactly what the type started with. That's okay as long as the
+ * subset is correctly sorted.
*/
bitmap_base = InvalidOid;
bitmap = NULL;
/*
* Identify longest sorted subsequence starting at start_pos
*/
- Bitmapset *this_bitmap = bms_make_singleton(0);
- int this_bm_size = 1;
- Oid start_oid = items[start_pos].enum_oid;
- float4 prev_order = items[start_pos].sort_order;
- int i;
+ Bitmapset *this_bitmap = bms_make_singleton(0);
+ int this_bm_size = 1;
+ Oid start_oid = items[start_pos].enum_oid;
+ float4 prev_order = items[start_pos].sort_order;
+ int i;
for (i = start_pos + 1; i < numitems; i++)
{
- Oid offset;
+ Oid offset;
offset = items[i].enum_oid - start_oid;
/* quit if bitmap would be too large; cutoff is arbitrary */
bms_free(this_bitmap);
/*
- * Done if it's not possible to find a longer sequence in the rest
- * of the list. In typical cases this will happen on the first
- * iteration, which is why we create the bitmaps on the fly instead
- * of doing a second pass over the list.
+ * Done if it's not possible to find a longer sequence in the rest of
+ * the list. In typical cases this will happen on the first
+ * iteration, which is why we create the bitmaps on the fly instead of
+ * doing a second pass over the list.
*/
if (bm_size >= (numitems - start_pos - 1))
break;
*
* Because of the extremely high rate at which log messages can be generated,
* we need to be mindful of the performance cost of obtaining any information
- * that may be logged. Also, it's important to keep in mind that this code may
+ * that may be logged. Also, it's important to keep in mind that this code may
* get called from within an aborted transaction, in which case operations
* such as syscache lookups are unsafe.
*
* The result of format_elog_string() is stored in ErrorContext, and will
* therefore survive until FlushErrorState() is called.
*/
-static int save_format_errnumber;
+static int save_format_errnumber;
static const char *save_format_domain;
void
}
char *
-format_elog_string(const char *fmt, ...)
+format_elog_string(const char *fmt,...)
{
ErrorData errdata;
ErrorData *edata;
* WriteConsoleW() will fail of stdout is redirected, so just fall through
* to writing unconverted to the logfile in this case.
*
- * Since we palloc the structure required for conversion, also fall through
- * to writing unconverted if we have not yet set up CurrentMemoryContext.
+ * Since we palloc the structure required for conversion, also fall
+ * through to writing unconverted if we have not yet set up
+ * CurrentMemoryContext.
*/
if (GetDatabaseEncoding() != GetPlatformEncoding() &&
!in_error_recursion_trouble() &&
* Hooks for function calls
*/
PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook = NULL;
-PGDLLIMPORT fmgr_hook_type fmgr_hook = NULL;
+PGDLLIMPORT fmgr_hook_type fmgr_hook = NULL;
/*
* Declaration for old-style function pointer type. This is now used only
* elogs.
*/
finfo->fn_oid = InvalidOid;
- finfo->fn_collation = InvalidOid; /* caller may set this later */
+ finfo->fn_collation = InvalidOid; /* caller may set this later */
finfo->fn_extra = NULL;
finfo->fn_mcxt = mcxt;
finfo->fn_expr = NULL; /* caller may set this later */
/* function manager hook */
if (fmgr_hook)
- (*fmgr_hook)(FHET_START, &fcache->flinfo, &fcache->arg);
+ (*fmgr_hook) (FHET_START, &fcache->flinfo, &fcache->arg);
/*
* We don't need to restore GUC or userid settings on error, because the
{
fcinfo->flinfo = save_flinfo;
if (fmgr_hook)
- (*fmgr_hook)(FHET_ABORT, &fcache->flinfo, &fcache->arg);
+ (*fmgr_hook) (FHET_ABORT, &fcache->flinfo, &fcache->arg);
PG_RE_THROW();
}
PG_END_TRY();
if (OidIsValid(fcache->userid))
SetUserIdAndSecContext(save_userid, save_sec_context);
if (fmgr_hook)
- (*fmgr_hook)(FHET_END, &fcache->flinfo, &fcache->arg);
+ (*fmgr_hook) (FHET_END, &fcache->flinfo, &fcache->arg);
return result;
}
/*
* These are the same as DirectFunctionCallN except that a nonzero
- * collation can be specified. No other fields of FmgrInfo are made valid.
+ * collation can be specified. No other fields of FmgrInfo are made valid.
*/
Datum
DirectFunctionCall1WithCollation(PGFunction func, Oid collation, Datum arg1)
return false;
/*
- * Identify the collation to use for polymorphic OUT parameters.
- * (It'll necessarily be the same for both anyelement and anyarray.)
+ * Identify the collation to use for polymorphic OUT parameters. (It'll
+ * necessarily be the same for both anyelement and anyarray.)
*/
anycollation = get_typcollation(OidIsValid(anyelement_type) ? anyelement_type : anyarray_type);
if (OidIsValid(anycollation))
* collation. We do so if we can identify the input collation used
* for the function.
*/
- Oid inputcollation = exprInputCollation(call_expr);
+ Oid inputcollation = exprInputCollation(call_expr);
if (OidIsValid(inputcollation))
anycollation = inputcollation;
bool
is_authenticated_user_replication_role(void)
{
- bool result = false;
- HeapTuple utup;
+ bool result = false;
+ HeapTuple utup;
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(AuthenticatedUserId));
if (HeapTupleIsValid(utup))
"(key %lu, ID %lu) is still in use",
id1, id2),
errhint("If you're sure there are no old "
- "server processes still running, remove "
+ "server processes still running, remove "
"the shared memory block "
"or just delete the file \"%s\".",
filename)));
}
/*
- * Successfully created the file, now fill it. See comment in miscadmin.h
- * about the contents. Note that we write the same info into both datadir
+ * Successfully created the file, now fill it. See comment in miscadmin.h
+ * about the contents. Note that we write the same info into both datadir
* and socket lockfiles; although more stuff may get added to the datadir
* lockfile later.
*/
#else
""
#endif
- );
+ );
errno = 0;
if (write(fd, buffer, strlen(buffer)) != strlen(buffer))
{
if (am_walsender)
ereport(LOG,
- (errmsg("replication connection authorized: user=%s",
- port->user_name)));
+ (errmsg("replication connection authorized: user=%s",
+ port->user_name)));
else
ereport(LOG,
(errmsg("connection authorized: user=%s database=%s",
errmsg("remaining connection slots are reserved for non-replication superuser connections")));
/*
- * If walsender, we don't want to connect to any particular database.
- * Just finish the backend startup by processing any options from the
- * startup packet, and we're done.
+ * If walsender, we don't want to connect to any particular database. Just
+ * finish the backend startup by processing any options from the startup
+ * packet, and we're done.
*/
if (am_walsender)
{
/*
- * Prepare for a future call to SetClientEncoding. Success should mean
+ * Prepare for a future call to SetClientEncoding. Success should mean
* that SetClientEncoding is guaranteed to succeed for this encoding request.
*
* (But note that success before backend_startup_complete does not guarantee
/*
* We cannot yet remove any older entry for the same encoding pair,
- * since it could still be in use. SetClientEncoding will clean up.
+ * since it could still be in use. SetClientEncoding will clean up.
*/
return 0; /* success */
/*
* Search the cache for the entry previously prepared by
* PrepareClientEncoding; if there isn't one, we lose. While at it,
- * release any duplicate entries so that repeated Prepare/Set cycles
- * don't leak memory.
+ * release any duplicate entries so that repeated Prepare/Set cycles don't
+ * leak memory.
*/
found = false;
foreach(lc, ConvProcList)
return perform_default_encoding_conversion(s, len, true);
else
return (char *) pg_do_encoding_conversion(
- (unsigned char *) s, len, encoding, DatabaseEncoding->encoding);
+ (unsigned char *) s, len, encoding, DatabaseEncoding->encoding);
}
/*
return perform_default_encoding_conversion(s, len, false);
else
return (char *) pg_do_encoding_conversion(
- (unsigned char *) s, len, DatabaseEncoding->encoding, encoding);
+ (unsigned char *) s, len, DatabaseEncoding->encoding, encoding);
}
/*
static int GUC_check_errcode_value;
/* global variables for check hook support */
-char *GUC_check_errmsg_string;
-char *GUC_check_errdetail_string;
-char *GUC_check_errhint_string;
+char *GUC_check_errmsg_string;
+char *GUC_check_errdetail_string;
+char *GUC_check_errhint_string;
static void set_config_sourcefile(const char *name, char *sourcefile,
int sourceline);
-static bool call_bool_check_hook(struct config_bool *conf, bool *newval,
- void **extra, GucSource source, int elevel);
-static bool call_int_check_hook(struct config_int *conf, int *newval,
- void **extra, GucSource source, int elevel);
-static bool call_real_check_hook(struct config_real *conf, double *newval,
- void **extra, GucSource source, int elevel);
-static bool call_string_check_hook(struct config_string *conf, char **newval,
- void **extra, GucSource source, int elevel);
-static bool call_enum_check_hook(struct config_enum *conf, int *newval,
- void **extra, GucSource source, int elevel);
+static bool call_bool_check_hook(struct config_bool * conf, bool *newval,
+ void **extra, GucSource source, int elevel);
+static bool call_int_check_hook(struct config_int * conf, int *newval,
+ void **extra, GucSource source, int elevel);
+static bool call_real_check_hook(struct config_real * conf, double *newval,
+ void **extra, GucSource source, int elevel);
+static bool call_string_check_hook(struct config_string * conf, char **newval,
+ void **extra, GucSource source, int elevel);
+static bool call_enum_check_hook(struct config_enum * conf, int *newval,
+ void **extra, GucSource source, int elevel);
static bool check_log_destination(char **newval, void **extra, GucSource source);
static void assign_log_destination(const char *newval, void *extra);
GUC_UNIT_S
},
&wal_receiver_status_interval,
- 10, 0, INT_MAX/1000,
+ 10, 0, INT_MAX / 1000,
NULL, NULL, NULL
},
{"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
gettext_noop("Sets the maximum number of predicate locks per transaction."),
gettext_noop("The shared predicate lock table is sized on the assumption that "
- "at most max_pred_locks_per_transaction * max_connections distinct "
+ "at most max_pred_locks_per_transaction * max_connections distinct "
"objects will need to be locked at any one time.")
},
&max_predicate_locks_per_xact,
" the level, the fewer messages are sent.")
},
&trace_recovery_messages,
+
/*
- * client_message_level_options allows too many values, really,
- * but it's not worth having a separate options array for this.
+ * client_message_level_options allows too many values, really, but
+ * it's not worth having a separate options array for this.
*/
LOG, client_message_level_options,
NULL, NULL, NULL
{
/*
* Historically we've just silently ignored attempts to set
- * PGC_INTERNAL variables from the config file. Maybe it'd
- * be better to use the prohibitValueChange logic for this?
+ * PGC_INTERNAL variables from the config file. Maybe it'd be
+ * better to use the prohibitValueChange logic for this?
*/
return true;
}
if (value)
{
/*
- * The value passed by the caller could be transient,
- * so we always strdup it.
+ * The value passed by the caller could be transient, so
+ * we always strdup it.
*/
newval = guc_strdup(elevel, value);
if (newval == NULL)
* ERRCODE_INVALID_PARAMETER_VALUE SQLSTATE for check hook failures.
*
* Note that GUC_check_errmsg() etc are just macros that result in a direct
- * assignment to the associated variables. That is ugly, but forced by the
+ * assignment to the associated variables. That is ugly, but forced by the
* limitations of C's macro mechanisms.
*/
void
*/
static bool
-call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra,
+call_bool_check_hook(struct config_bool * conf, bool *newval, void **extra,
GucSource source, int elevel)
{
/* Quick success if no hook */
}
static bool
-call_int_check_hook(struct config_int *conf, int *newval, void **extra,
+call_int_check_hook(struct config_int * conf, int *newval, void **extra,
GucSource source, int elevel)
{
/* Quick success if no hook */
}
static bool
-call_real_check_hook(struct config_real *conf, double *newval, void **extra,
+call_real_check_hook(struct config_real * conf, double *newval, void **extra,
GucSource source, int elevel)
{
/* Quick success if no hook */
}
static bool
-call_string_check_hook(struct config_string *conf, char **newval, void **extra,
+call_string_check_hook(struct config_string * conf, char **newval, void **extra,
GucSource source, int elevel)
{
/* Quick success if no hook */
}
static bool
-call_enum_check_hook(struct config_enum *conf, int *newval, void **extra,
+call_enum_check_hook(struct config_enum * conf, int *newval, void **extra,
GucSource source, int elevel)
{
/* Quick success if no hook */
check_canonical_path(char **newval, void **extra, GucSource source)
{
/*
- * Since canonicalize_path never enlarges the string, we can just
- * modify newval in-place. But watch out for NULL, which is the
- * default value for external_pid_file.
+ * Since canonicalize_path never enlarges the string, we can just modify
+ * newval in-place. But watch out for NULL, which is the default value
+ * for external_pid_file.
*/
if (*newval)
canonicalize_path(*newval);
check_timezone_abbreviations(char **newval, void **extra, GucSource source)
{
/*
- * The boot_val given above for timezone_abbreviations is NULL.
- * When we see this we just do nothing. If this value isn't overridden
- * from the config file then pg_timezone_abbrev_initialize() will
- * eventually replace it with "Default". This hack has two purposes: to
- * avoid wasting cycles loading values that might soon be overridden from
- * the config file, and to avoid trying to read the timezone abbrev files
+ * The boot_val given above for timezone_abbreviations is NULL. When we
+ * see this we just do nothing. If this value isn't overridden from the
+ * config file then pg_timezone_abbrev_initialize() will eventually
+ * replace it with "Default". This hack has two purposes: to avoid
+ * wasting cycles loading values that might soon be overridden from the
+ * config file, and to avoid trying to read the timezone abbrev files
* during InitializeGUCOptions(). The latter doesn't work in an
* EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
* we can't locate PGSHAREDIR.
assign_tcp_keepalives_idle(int newval, void *extra)
{
/*
- * The kernel API provides no way to test a value without setting it;
- * and once we set it we might fail to unset it. So there seems little
- * point in fully implementing the check-then-assign GUC API for these
+ * The kernel API provides no way to test a value without setting it; and
+ * once we set it we might fail to unset it. So there seems little point
+ * in fully implementing the check-then-assign GUC API for these
* variables. Instead we just do the assignment on demand. pqcomm.c
* reports any problems via elog(LOG).
*
- * This approach means that the GUC value might have little to do with
- * the actual kernel value, so we use a show_hook that retrieves the
- * kernel value rather than trusting GUC's copy.
+ * This approach means that the GUC value might have little to do with the
+ * actual kernel value, so we use a show_hook that retrieves the kernel
+ * value rather than trusting GUC's copy.
*/
(void) pq_setkeepalivesidle(newval, MyProcPort);
}
/* This range check shouldn't fail, but let's be paranoid */
if (new_prefetch_pages >= 0.0 && new_prefetch_pages < (double) INT_MAX)
{
- int *myextra = (int *) guc_malloc(ERROR, sizeof(int));
+ int *myextra = (int *) guc_malloc(ERROR, sizeof(int));
*myextra = (int) rint(new_prefetch_pages);
*extra = (void *) myextra;
*/
#define RBNIL (&sentinel)
-static RBNode sentinel = {InitialState, RBBLACK, RBNIL, RBNIL, NULL};
+static RBNode sentinel = {InitialState, RBBLACK, RBNIL, RBNIL, NULL};
/*
*
* The freefunc should just be pfree or equivalent; it should NOT attempt
* to free any subsidiary data, because the node passed to it may not contain
- * valid data! freefunc can be NULL if caller doesn't require retail
+ * valid data! freefunc can be NULL if caller doesn't require retail
* space reclamation.
*
- * The RBTree node is palloc'd in the caller's memory context. Note that
+ * The RBTree node is palloc'd in the caller's memory context. Note that
* all contents of the tree are actually allocated by the caller, not here.
*
* Since tree contents are managed by the caller, there is currently not
tree->combiner = combiner;
tree->allocfunc = allocfunc;
tree->freefunc = freefunc;
+
tree->arg = arg;
return tree;
while (node != RBNIL)
{
- int cmp = rb->comparator(data, node, rb->arg);
+ int cmp = rb->comparator(data, node, rb->arg);
if (cmp == 0)
return node;
*/
*isNew = true;
- x = rb->allocfunc(rb->arg);
+ x = rb->allocfunc (rb->arg);
x->iteratorState = InitialState;
x->color = RBRED;
+
x->left = RBNIL;
x->right = RBNIL;
x->parent = parent;
/* Now we can recycle the y node */
if (rb->freefunc)
- rb->freefunc(y, rb->arg);
+ rb->freefunc (y, rb->arg);
}
/*
* Functions for parsing timezone offset files
*
* Note: this code is invoked from the check_hook for the GUC variable
- * timezone_abbreviations. Therefore, it should report problems using
+ * timezone_abbreviations. Therefore, it should report problems using
* GUC_check_errmsg() and related functions, and try to avoid throwing
* elog(ERROR). This is not completely bulletproof at present --- in
* particular out-of-memory will throw an error. Could probably fix with
AllocBlock next; /* next block in aset's blocks list */
char *freeptr; /* start of free space in this block */
char *endptr; /* end of space in this block */
-} AllocBlockData;
+} AllocBlockData;
/*
* AllocChunk
/* this is zero in a free chunk */
Size requested_size;
#endif
-} AllocChunkData;
+} AllocChunkData;
/*
* AllocPointerIsValid
portal->status = PORTAL_DONE;
/*
- * Allow portalcmds.c to clean up the state it knows about. We might
- * as well do that now, since the portal can't be executed any more.
+ * Allow portalcmds.c to clean up the state it knows about. We might as
+ * well do that now, since the portal can't be executed any more.
*
* In some cases involving execution of a ROLLBACK command in an already
* aborted transaction, this prevents an assertion failure from reaching
/*
* Allow portalcmds.c to clean up the state it knows about, in particular
- * shutting down the executor if still active. This step potentially runs
+ * shutting down the executor if still active. This step potentially runs
* user-defined code so failure has to be expected. It's the cleanup
* hook's responsibility to not try to do that more than once, in the case
* that failure occurs and then we come back to drop the portal again
* Holdable cursors created in this transaction need to be converted to
* materialized form, since we are going to close down the executor and
* release locks. Non-holdable portals created in this transaction are
- * simply removed. Portals remaining from prior transactions should be
+ * simply removed. Portals remaining from prior transactions should be
* left untouched.
*
* Returns TRUE if any portals changed state (possibly causing user-defined
}
/*
- * After either freezing or dropping a portal, we have to restart
- * the iteration, because we could have invoked user-defined code
- * that caused a drop of the next portal in the hash chain.
+ * After either freezing or dropping a portal, we have to restart the
+ * iteration, because we could have invoked user-defined code that
+ * caused a drop of the next portal in the hash chain.
*/
hash_seq_term(&status);
hash_seq_init(&status, PortalHashTable);
int nfiles; /* number of owned temporary files */
File *files; /* dynamically allocated array */
int maxfiles; /* currently allocated array size */
-} ResourceOwnerData;
+} ResourceOwnerData;
/*****************************************************************************
* indexScanKey.
*/
IndexInfo *indexInfo; /* info about index being used for reference */
- EState *estate; /* for evaluating index expressions */
+ EState *estate; /* for evaluating index expressions */
/*
* These variables are specific to the IndexTuple case; they are set by
int tapenum, unsigned int len);
static void reversedirection_heap(Tuplesortstate *state);
static int comparetup_cluster(const SortTuple *a, const SortTuple *b,
- Tuplesortstate *state);
+ Tuplesortstate *state);
static void copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup);
static void writetup_cluster(Tuplesortstate *state, int tapenum,
- SortTuple *stup);
+ SortTuple *stup);
static void readtup_cluster(Tuplesortstate *state, SortTuple *stup,
- int tapenum, unsigned int len);
+ int tapenum, unsigned int len);
static int comparetup_index_btree(const SortTuple *a, const SortTuple *b,
Tuplesortstate *state);
static int comparetup_index_hash(const SortTuple *a, const SortTuple *b,
Tuplesortstate *
tuplesort_begin_heap(TupleDesc tupDesc,
int nkeys, AttrNumber *attNums,
- Oid *sortOperators, Oid *collations, bool *nullsFirstFlags,
+ Oid *sortOperators, Oid *collations, bool *nullsFirstFlags,
int workMem, bool randomAccess)
{
Tuplesortstate *state = tuplesort_begin_common(workMem, randomAccess);
if (state->indexInfo->ii_Expressions != NULL)
{
TupleTableSlot *slot;
- ExprContext *econtext;
+ ExprContext *econtext;
/*
* We will need to use FormIndexDatum to evaluate the index
Tuplesortstate *
tuplesort_begin_datum(Oid datumType,
- Oid sortOperator, Oid sortCollation, bool nullsFirstFlag,
+ Oid sortOperator, Oid sortCollation, bool nullsFirstFlag,
int workMem, bool randomAccess)
{
Tuplesortstate *state = tuplesort_begin_common(workMem, randomAccess);
/* Free any execution state created for CLUSTER case */
if (state->estate != NULL)
{
- ExprContext *econtext = GetPerTupleExprContext(state->estate);
+ ExprContext *econtext = GetPerTupleExprContext(state->estate);
ExecDropSingleTupleTableSlot(econtext->ecxt_scantuple);
FreeExecutorState(state->estate);
/*
* Fetch the next tuple in either forward or back direction.
- * Returns NULL if no more tuples. If *should_free is set, the
+ * Returns NULL if no more tuples. If *should_free is set, the
* caller must pfree the returned tuple when done with it.
*/
HeapTuple
* CurrentSnapshot points to the only snapshot taken in transaction-snapshot
* mode, and to the latest one taken in a read-committed transaction.
* SecondarySnapshot is a snapshot that's always up-to-date as of the current
- * instant, even in transaction-snapshot mode. It should only be used for
+ * instant, even in transaction-snapshot mode. It should only be used for
* special-purpose code (say, RI checking.)
*
* These SnapshotData structs are static to simplify memory allocation
AtEarlyCommit_Snapshot(void)
{
/*
- * In transaction-snapshot mode we must unregister our private refcount
- * to the transaction-snapshot.
+ * In transaction-snapshot mode we must unregister our private refcount to
+ * the transaction-snapshot.
*/
if (registered_xact_snapshot)
UnregisterSnapshotFromOwner(CurrentSnapshot,
#define PG_CMD_PRINTF3(fmt, arg1, arg2, arg3) \
do { \
- if (fprintf(cmdfd, fmt, arg1, arg2, arg3) < 0 || fflush(cmdfd) < 0) \
+ if (fprintf(cmdfd, fmt, arg1, arg2, arg3) < 0 || fflush(cmdfd) < 0) \
output_failed = true, output_errno = errno; \
} while (0)
/* Create default descriptions for operator implementation functions */
PG_CMD_PUTS("WITH funcdescs AS ( "
"SELECT p.oid as p_oid, oprname, "
- "coalesce(obj_description(o.oid, 'pg_operator'),'') as opdesc "
+ "coalesce(obj_description(o.oid, 'pg_operator'),'') as opdesc "
"FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid ) "
"INSERT INTO pg_description "
" SELECT p_oid, 'pg_proc'::regclass, 0, "
" FROM funcdescs "
" WHERE opdesc NOT LIKE 'deprecated%' AND "
" NOT EXISTS (SELECT 1 FROM pg_description "
- " WHERE objoid = p_oid AND classoid = 'pg_proc'::regclass);\n");
+ " WHERE objoid = p_oid AND classoid = 'pg_proc'::regclass);\n");
PG_CMD_CLOSE;
static bool
normalize_locale_name(char *new, const char *old)
{
- char *n = new;
+ char *n = new;
const char *o = old;
- bool changed = false;
+ bool changed = false;
while (*o)
{
return changed;
}
-#endif /* HAVE_LOCALE_T */
+#endif /* HAVE_LOCALE_T */
/*
* populate pg_collation
setup_collation(void)
{
#ifdef HAVE_LOCALE_T
- int i;
- FILE *locale_a_handle;
- char localebuf[NAMEDATALEN];
- int count = 0;
+ int i;
+ FILE *locale_a_handle;
+ char localebuf[NAMEDATALEN];
+ int count = 0;
+
PG_CMD_DECL;
#endif
while (fgets(localebuf, sizeof(localebuf), locale_a_handle))
{
- size_t len;
- int enc;
- bool skip;
- char alias[NAMEDATALEN];
+ size_t len;
+ int enc;
+ bool skip;
+ char alias[NAMEDATALEN];
len = strlen(localebuf);
localebuf[len - 1] = '\0';
/*
- * Some systems have locale names that don't consist entirely
- * of ASCII letters (such as "bokmål" or
- * "français"). This is pretty silly, since we need
- * the locale itself to interpret the non-ASCII characters.
- * We can't do much with those, so we filter them out.
+ * Some systems have locale names that don't consist entirely of ASCII
+ * letters (such as "bokmål" or "français"). This is
+ * pretty silly, since we need the locale itself to interpret the
+ * non-ASCII characters. We can't do much with those, so we filter
+ * them out.
*/
skip = false;
for (i = 0; i < len; i++)
escape_quotes(localebuf), enc);
/*
- * Generate aliases such as "en_US" in addition to
- * "en_US.utf8" for ease of use. Note that collation names
- * are unique per encoding only, so this doesn't clash with
- * "en_US" for LATIN1, say.
+ * Generate aliases such as "en_US" in addition to "en_US.utf8" for
+ * ease of use. Note that collation names are unique per encoding
+ * only, so this doesn't clash with "en_US" for LATIN1, say.
*/
if (normalize_locale_name(alias, localebuf))
PG_CMD_PRINTF3("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('%s', '%s', %d);\n",
- escape_quotes(alias), escape_quotes(localebuf), enc);
+ escape_quotes(alias), escape_quotes(localebuf), enc);
}
/* Add an SQL-standard name */
PG_CMD_PRINTF1("INSERT INTO tmp_pg_collation (collname, locale, encoding) VALUES ('ucs_basic', 'C', %d);\n", PG_UTF8);
/*
- * When copying collations to the final location, eliminate
- * aliases that conflict with an existing locale name for the same
- * encoding. For example, "br_FR.iso88591" is normalized to
- * "br_FR", both for encoding LATIN1. But the unnormalized locale
- * "br_FR" already exists for LATIN1. Prefer the collation that
- * matches the OS locale name, else the first name by sort order
- * (arbitrary choice to be deterministic).
+ * When copying collations to the final location, eliminate aliases that
+ * conflict with an existing locale name for the same encoding. For
+ * example, "br_FR.iso88591" is normalized to "br_FR", both for encoding
+ * LATIN1. But the unnormalized locale "br_FR" already exists for LATIN1.
+ * Prefer the collation that matches the OS locale name, else the first
+ * name by sort order (arbitrary choice to be deterministic).
*/
PG_CMD_PUTS("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) "
- " SELECT DISTINCT ON (final_collname, collnamespace, encoding)"
+ " SELECT DISTINCT ON (final_collname, collnamespace, encoding)"
" COALESCE(collname, locale) AS final_collname, "
" (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog') AS collnamespace, "
" (SELECT relowner FROM pg_class WHERE relname = 'pg_collation') AS collowner, "
printf(_("No usable system locales were found.\n"));
printf(_("Use the option \"--debug\" to see details.\n"));
}
-#else /* not HAVE_LOCALE_T */
+#else /* not HAVE_LOCALE_T */
printf(_("not supported on this platform\n"));
fflush(stdout);
-#endif /* not HAVE_LOCALE_T */
+#endif /* not HAVE_LOCALE_T */
}
/*
printf(_(" -Z, --compress=0-9 compress tar output\n"));
printf(_("\nGeneral options:\n"));
printf(_(" -c, --checkpoint=fast|spread\n"
- " set fast or spread checkpointing\n"));
+ " set fast or spread checkpointing\n"));
printf(_(" -l, --label=label set backup label\n"));
printf(_(" -P, --progress show progress information\n"));
printf(_(" -v, --verbose output verbose messages\n"));
static void
progress_report(int tablespacenum, char *fn)
{
- int percent = (int) ((totaldone / 1024) * 100 / totalsize);
+ int percent = (int) ((totaldone / 1024) * 100 / totalsize);
+
if (percent > 100)
percent = 100;
if (file == NULL)
{
- int filemode;
+ int filemode;
/*
* No current file, so this must be the header for a new file
showprogress ? "PROGRESS" : "",
includewal ? "WAL" : "",
fastcheckpoint ? "FAST" : "",
- includewal ? "NOWAIT" : "");
+ includewal ? "NOWAIT" : "");
if (PQsendQuery(conn, current_path) == 0)
{
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
fprintf(stderr, _("%s: could not get end xlog position from server.\n"),
- progname);
+ progname);
disconnect_and_exit(1);
}
if (PQntuples(res) != 1)
int i;
connstr[0] = '\0';
-
+
for (i = 0; i < wait_seconds; i++)
{
/* Do we need a connection string? */
* 6 9.1+ server, shared memory not created
* 7 9.1+ server, shared memory created
*
- * This code does not support pre-9.1 servers. On Unix machines
+ * This code does not support pre-9.1 servers. On Unix machines
* we could consider extracting the port number from the shmem
* key, but that (a) is not robust, and (b) doesn't help with
* finding out the socket directory. And it wouldn't work anyway
optlines[5] != NULL)
{
/* File is complete enough for us, parse it */
- time_t pmstart;
- int portnum;
- char *sockdir;
- char *hostaddr;
- char host_str[MAXPGPATH];
+ time_t pmstart;
+ int portnum;
+ char *sockdir;
+ char *hostaddr;
+ char host_str[MAXPGPATH];
/*
* Easy cross-check that we are looking at the right data
}
/*
- * OK, extract port number and host string to use.
- * Prefer using Unix socket if available.
+ * OK, extract port number and host string to use. Prefer
+ * using Unix socket if available.
*/
portnum = atoi(optlines[LOCK_FILE_LINE_PORT - 1]);
* first.
*/
snprintf(connstr, sizeof(connstr),
- "dbname=postgres port=%d host='%s' connect_timeout=5",
+ "dbname=postgres port=%d host='%s' connect_timeout=5",
portnum, host_str);
}
}
if (do_checkpoint)
{
/*
- * Increment the wait hint by 6 secs (connection timeout +
- * sleep) We must do this to indicate to the SCM that our
- * startup time is changing, otherwise it'll usually send a
- * stop signal after 20 seconds, despite incrementing the
- * checkpoint counter.
+ * Increment the wait hint by 6 secs (connection timeout + sleep)
+ * We must do this to indicate to the SCM that our startup time is
+ * changing, otherwise it'll usually send a stop signal after 20
+ * seconds, despite incrementing the checkpoint counter.
*/
status.dwWaitHint += 6000;
status.dwCheckPoint++;
#endif
print_msg(".");
- pg_usleep(1000000); /* 1 sec */
+ pg_usleep(1000000); /* 1 sec */
}
/* return result of last call to PQping */
else
{
/*
- * If backup_label exists, an online backup is running. Warn the
- * user that smart shutdown will wait for it to finish. However, if
+ * If backup_label exists, an online backup is running. Warn the user
+ * that smart shutdown will wait for it to finish. However, if
* recovery.conf is also present, we're recovering from an online
* backup instead of performing one.
*/
write_stderr(_("%s: server does not shut down\n"), progname);
if (shutdown_mode == SMART_MODE)
write_stderr(_("HINT: The \"-m fast\" option immediately disconnects sessions rather than\n"
- "waiting for session-initiated disconnection.\n"));
+ "waiting for session-initiated disconnection.\n"));
exit(1);
}
print_msg(_(" done\n"));
}
/*
- * If backup_label exists, an online backup is running. Warn the
- * user that smart shutdown will wait for it to finish. However, if
+ * If backup_label exists, an online backup is running. Warn the user
+ * that smart shutdown will wait for it to finish. However, if
* recovery.conf is also present, we're recovering from an online
* backup instead of performing one.
*/
write_stderr(_("%s: server does not shut down\n"), progname);
if (shutdown_mode == SMART_MODE)
write_stderr(_("HINT: The \"-m fast\" option immediately disconnects sessions rather than\n"
- "waiting for session-initiated disconnection.\n"));
+ "waiting for session-initiated disconnection.\n"));
exit(1);
}
}
if ((hService = CreateService(hSCM, register_servicename, register_servicename,
- SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
pgctl_start_type, SERVICE_ERROR_NORMAL,
pgwin32_CommandLine(true),
NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
printf(_(" %s kill SIGNALNAME PID\n"), progname);
#if defined(WIN32) || defined(__CYGWIN__)
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
- " [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
+ " [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s unregister [-N SERVICENAME]\n"), progname);
#endif
/*-------------------------------------------------------------------------
*
* compress_io.c
- * Routines for archivers to write an uncompressed or compressed data
- * stream.
+ * Routines for archivers to write an uncompressed or compressed data
+ * stream.
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Compressor API
* --------------
*
- * The interface for writing to an archive consists of three functions:
- * AllocateCompressor, WriteDataToArchive and EndCompressor. First you call
- * AllocateCompressor, then write all the data by calling WriteDataToArchive
- * as many times as needed, and finally EndCompressor. WriteDataToArchive
- * and EndCompressor will call the WriteFunc that was provided to
- * AllocateCompressor for each chunk of compressed data.
+ * The interface for writing to an archive consists of three functions:
+ * AllocateCompressor, WriteDataToArchive and EndCompressor. First you call
+ * AllocateCompressor, then write all the data by calling WriteDataToArchive
+ * as many times as needed, and finally EndCompressor. WriteDataToArchive
+ * and EndCompressor will call the WriteFunc that was provided to
+ * AllocateCompressor for each chunk of compressed data.
*
- * The interface for reading an archive consists of just one function:
- * ReadDataFromArchive. ReadDataFromArchive reads the whole compressed input
- * stream, by repeatedly calling the given ReadFunc. ReadFunc returns the
- * compressed data chunk at a time, and ReadDataFromArchive decompresses it
- * and passes the decompressed data to ahwrite(), until ReadFunc returns 0
- * to signal EOF.
+ * The interface for reading an archive consists of just one function:
+ * ReadDataFromArchive. ReadDataFromArchive reads the whole compressed input
+ * stream, by repeatedly calling the given ReadFunc. ReadFunc returns the
+ * compressed data chunk at a time, and ReadDataFromArchive decompresses it
+ * and passes the decompressed data to ahwrite(), until ReadFunc returns 0
+ * to signal EOF.
*
- * The interface is the same for compressed and uncompressed streams.
+ * The interface is the same for compressed and uncompressed streams.
*
* Compressed stream API
* ----------------------
*
- * The compressed stream API is a wrapper around the C standard fopen() and
- * libz's gzopen() APIs. It allows you to use the same functions for
- * compressed and uncompressed streams. cfopen_read() first tries to open
- * the file with given name, and if it fails, it tries to open the same
- * file with the .gz suffix. cfopen_write() opens a file for writing, an
- * extra argument specifies if the file should be compressed, and adds the
- * .gz suffix to the filename if so. This allows you to easily handle both
- * compressed and uncompressed files.
+ * The compressed stream API is a wrapper around the C standard fopen() and
+ * libz's gzopen() APIs. It allows you to use the same functions for
+ * compressed and uncompressed streams. cfopen_read() first tries to open
+ * the file with given name, and if it fails, it tries to open the same
+ * file with the .gz suffix. cfopen_write() opens a file for writing, an
+ * extra argument specifies if the file should be compressed, and adds the
+ * .gz suffix to the filename if so. This allows you to easily handle both
+ * compressed and uncompressed files.
*
* IDENTIFICATION
- * src/bin/pg_dump/compress_io.c
+ * src/bin/pg_dump/compress_io.c
*
*-------------------------------------------------------------------------
*/
struct CompressorState
{
CompressionAlgorithm comprAlg;
- WriteFunc writeF;
+ WriteFunc writeF;
#ifdef HAVE_LIBZ
- z_streamp zp;
- char *zlibOut;
- size_t zlibOutSize;
+ z_streamp zp;
+ char *zlibOut;
+ size_t zlibOutSize;
#endif
};
static const char *modulename = gettext_noop("compress_io");
static void ParseCompressionOption(int compression, CompressionAlgorithm *alg,
- int *level);
+ int *level);
/* Routines that support zlib compressed data I/O */
#ifdef HAVE_LIBZ
static void InitCompressorZlib(CompressorState *cs, int level);
static void DeflateCompressorZlib(ArchiveHandle *AH, CompressorState *cs,
- bool flush);
+ bool flush);
static void ReadDataFromArchiveZlib(ArchiveHandle *AH, ReadFunc readF);
static size_t WriteDataToArchiveZlib(ArchiveHandle *AH, CompressorState *cs,
- const char *data, size_t dLen);
+ const char *data, size_t dLen);
static void EndCompressorZlib(ArchiveHandle *AH, CompressorState *cs);
-
#endif
/* Routines that support uncompressed data I/O */
static void ReadDataFromArchiveNone(ArchiveHandle *AH, ReadFunc readF);
static size_t WriteDataToArchiveNone(ArchiveHandle *AH, CompressorState *cs,
- const char *data, size_t dLen);
+ const char *data, size_t dLen);
/*
* Interprets a numeric 'compression' value. The algorithm implied by the
{
CompressorState *cs;
CompressionAlgorithm alg;
- int level;
+ int level;
ParseCompressionOption(compression, &alg, &level);
WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs,
const void *data, size_t dLen)
{
- switch(cs->comprAlg)
+ switch (cs->comprAlg)
{
case COMPR_ALG_LIBZ:
#ifdef HAVE_LIBZ
case COMPR_ALG_NONE:
return WriteDataToArchiveNone(AH, cs, data, dLen);
}
- return 0; /* keep compiler quiet */
+ return 0; /* keep compiler quiet */
}
/*
static void
InitCompressorZlib(CompressorState *cs, int level)
{
- z_streamp zp;
+ z_streamp zp;
zp = cs->zp = (z_streamp) malloc(sizeof(z_stream));
if (cs->zp == NULL)
zp->opaque = Z_NULL;
/*
- * zlibOutSize is the buffer size we tell zlib it can output
- * to. We actually allocate one extra byte because some routines
- * want to append a trailing zero byte to the zlib output.
+ * zlibOutSize is the buffer size we tell zlib it can output to. We
+ * actually allocate one extra byte because some routines want to append a
+ * trailing zero byte to the zlib output.
*/
cs->zlibOut = (char *) malloc(ZLIB_OUT_SIZE + 1);
cs->zlibOutSize = ZLIB_OUT_SIZE;
static void
EndCompressorZlib(ArchiveHandle *AH, CompressorState *cs)
{
- z_streamp zp = cs->zp;
+ z_streamp zp = cs->zp;
zp->next_in = NULL;
zp->avail_in = 0;
if (zp->avail_out < cs->zlibOutSize)
{
/*
- * Any write function shoud do its own error checking but
- * to make sure we do a check here as well...
+ * Any write function shoud do its own error checking but to
+ * make sure we do a check here as well...
*/
- size_t len = cs->zlibOutSize - zp->avail_out;
+ size_t len = cs->zlibOutSize - zp->avail_out;
+
if (cs->writeF(AH, out, len) != len)
die_horribly(AH, modulename,
"could not write to output file: %s\n",
cs->zp->next_in = (void *) data;
cs->zp->avail_in = dLen;
DeflateCompressorZlib(AH, cs, false);
- /* we have either succeeded in writing dLen bytes or we have called
- * die_horribly() */
+
+ /*
+ * we have either succeeded in writing dLen bytes or we have called
+ * die_horribly()
+ */
return dLen;
}
free(out);
free(zp);
}
-
-#endif /* HAVE_LIBZ */
+#endif /* HAVE_LIBZ */
/*
const char *data, size_t dLen)
{
/*
- * Any write function should do its own error checking but to make
- * sure we do a check here as well...
+ * Any write function should do its own error checking but to make sure we
+ * do a check here as well...
*/
if (cs->writeF(AH, data, dLen) != dLen)
die_horribly(AH, modulename,
*/
struct cfp
{
- FILE *uncompressedfp;
+ FILE *uncompressedfp;
#ifdef HAVE_LIBZ
- gzFile compressedfp;
+ gzFile compressedfp;
#endif
};
cfp *
cfopen_read(const char *path, const char *mode)
{
- cfp *fp;
+ cfp *fp;
#ifdef HAVE_LIBZ
if (hasSuffix(path, ".gz"))
#ifdef HAVE_LIBZ
if (fp == NULL)
{
- int fnamelen = strlen(path) + 4;
- char *fname = malloc(fnamelen);
+ int fnamelen = strlen(path) + 4;
+ char *fname = malloc(fnamelen);
+
if (fname == NULL)
die_horribly(NULL, modulename, "Out of memory\n");
cfp *
cfopen_write(const char *path, const char *mode, int compression)
{
- cfp *fp;
+ cfp *fp;
if (compression == 0)
fp = cfopen(path, mode, 0);
else
{
#ifdef HAVE_LIBZ
- int fnamelen = strlen(path) + 4;
- char *fname = malloc(fnamelen);
+ int fnamelen = strlen(path) + 4;
+ char *fname = malloc(fnamelen);
+
if (fname == NULL)
die_horribly(NULL, modulename, "Out of memory\n");
cfp *
cfopen(const char *path, const char *mode, int compression)
{
- cfp *fp = malloc(sizeof(cfp));
+ cfp *fp = malloc(sizeof(cfp));
+
if (fp == NULL)
die_horribly(NULL, modulename, "Out of memory\n");
int
cfclose(cfp *fp)
{
- int result;
+ int result;
if (fp == NULL)
{
static int
hasSuffix(const char *filename, const char *suffix)
{
- int filenamelen = strlen(filename);
- int suffixlen = strlen(suffix);
+ int filenamelen = strlen(filename);
+ int suffixlen = strlen(suffix);
if (filenamelen < suffixlen)
return 0;
return memcmp(&filename[filenamelen - suffixlen],
- suffix,
- suffixlen) == 0;
+ suffix,
+ suffixlen) == 0;
}
+
#endif
/*-------------------------------------------------------------------------
*
* compress_io.h
- * Interface to compress_io.c routines
+ * Interface to compress_io.c routines
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * src/bin/pg_dump/compress_io.h
+ * src/bin/pg_dump/compress_io.h
*
*-------------------------------------------------------------------------
*/
} CompressionAlgorithm;
/* Prototype for callback function to WriteDataToArchive() */
-typedef size_t (*WriteFunc)(ArchiveHandle *AH, const char *buf, size_t len);
+typedef size_t (*WriteFunc) (ArchiveHandle *AH, const char *buf, size_t len);
/*
* Prototype for callback function to ReadDataFromArchive()
*
* Returns the number of bytes read into *buf, or 0 on EOF.
*/
-typedef size_t (*ReadFunc)(ArchiveHandle *AH, char **buf, size_t *buflen);
+typedef size_t (*ReadFunc) (ArchiveHandle *AH, char **buf, size_t *buflen);
/* struct definition appears in compress_io.c */
typedef struct CompressorState CompressorState;
extern CompressorState *AllocateCompressor(int compression, WriteFunc writeF);
extern void ReadDataFromArchive(ArchiveHandle *AH, int compression,
- ReadFunc readF);
+ ReadFunc readF);
extern size_t WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs,
- const void *data, size_t dLen);
+ const void *data, size_t dLen);
extern void EndCompressor(ArchiveHandle *AH, CompressorState *cs);
extern cfp *cfopen(const char *path, const char *mode, int compression);
extern cfp *cfopen_read(const char *path, const char *mode);
extern cfp *cfopen_write(const char *path, const char *mode, int compression);
-extern int cfread(void *ptr, int size, cfp *fp);
-extern int cfwrite(const void *ptr, int size, cfp *fp);
-extern int cfgetc(cfp *fp);
+extern int cfread(void *ptr, int size, cfp *fp);
+extern int cfwrite(const void *ptr, int size, cfp *fp);
+extern int cfgetc(cfp *fp);
extern char *cfgets(cfp *fp, char *buf, int len);
-extern int cfclose(cfp *fp);
-extern int cfeof(cfp *fp);
+extern int cfclose(cfp *fp);
+extern int cfeof(cfp *fp);
#endif
#include "parser/keywords.h"
-int quote_all_identifiers = 0;
+int quote_all_identifiers = 0;
#define supports_grant_options(version) ((version) >= 70400)
#include "libpq-fe.h"
#include "pqexpbuffer.h"
-extern int quote_all_identifiers;
+extern int quote_all_identifiers;
extern void init_parallel_dump_utils(void);
extern const char *fmtId(const char *identifier);
static const char *modulename = gettext_noop("archiver");
/* index array created by fix_dependencies -- only used in parallel restore */
-static TocEntry **tocsByDumpId; /* index by dumpId - 1 */
-static DumpId maxDumpId; /* length of above array */
+static TocEntry **tocsByDumpId; /* index by dumpId - 1 */
+static DumpId maxDumpId; /* length of above array */
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
pos->next->prev = te;
pos->next = te;
}
-
#endif
static void
if (AH->fSpec)
{
- struct stat st;
+ struct stat st;
wantClose = 1;
if (stat(AH->fSpec, &st) == 0 && S_ISDIR(st.st_mode))
{
char buf[MAXPGPATH];
+
if (snprintf(buf, MAXPGPATH, "%s/toc.dat", AH->fSpec) >= MAXPGPATH)
die_horribly(AH, modulename, "directory name too long: \"%s\"\n",
AH->fSpec);
#endif
die_horribly(AH, modulename, "directory \"%s\" does not appear to be a valid archive (\"toc.dat\" does not exist)\n",
AH->fSpec);
- fh = NULL; /* keep compiler quiet */
+ fh = NULL; /* keep compiler quiet */
}
else
{
*
* Work is done in three phases.
* First we process all SECTION_PRE_DATA tocEntries, in a single connection,
- * just as for a standard restore. Second we process the remaining non-ACL
+ * just as for a standard restore. Second we process the remaining non-ACL
* steps in parallel worker children (threads on Windows, processes on Unix),
* each of which connects separately to the database. Finally we process all
* the ACL entries in a single connection (that happens back in
* Do all the early stuff in a single connection in the parent. There's no
* great point in running it in parallel, in fact it will actually run
* faster in a single connection because we avoid all the connection and
- * setup overhead. Also, pg_dump is not currently very good about
- * showing all the dependencies of SECTION_PRE_DATA items, so we do not
- * risk trying to process them out-of-order.
+ * setup overhead. Also, pg_dump is not currently very good about showing
+ * all the dependencies of SECTION_PRE_DATA items, so we do not risk
+ * trying to process them out-of-order.
*/
skipped_some = false;
for (next_work_item = AH->toc->next; next_work_item != AH->toc; next_work_item = next_work_item->next)
/*
* Count the incoming dependencies for each item. Also, it is possible
- * that the dependencies list items that are not in the archive at
- * all. Subtract such items from the depCounts.
+ * that the dependencies list items that are not in the archive at all.
+ * Subtract such items from the depCounts.
*/
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
}
/*
- * Allocate space for revDeps[] arrays, and reset nRevDeps so we can
- * use it as a counter below.
+ * Allocate space for revDeps[] arrays, and reset nRevDeps so we can use
+ * it as a counter below.
*/
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
}
/*
- * Build the revDeps[] arrays of incoming-dependency dumpIds. This
- * had better agree with the loops above.
+ * Build the revDeps[] arrays of incoming-dependency dumpIds. This had
+ * better agree with the loops above.
*/
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
DumpId maxDumpId; /* largest DumpId among all TOC entries */
struct _tocEntry *currToc; /* Used when dumping data */
- int compression; /* Compression requested on open
- * Possible values for compression:
- * -1 Z_DEFAULT_COMPRESSION
- * 0 COMPRESSION_NONE
- * 1-9 levels for gzip compression */
+ int compression; /* Compression requested on open Possible
+ * values for compression: -1
+ * Z_DEFAULT_COMPRESSION 0 COMPRESSION_NONE
+ * 1-9 levels for gzip compression */
ArchiveMode mode; /* File mode - r or w */
void *formatData; /* Header data specific to file format */
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{
lclContext *ctx = (lclContext *) AH->formatData;
- CompressorState *cs = ctx->cs;
+ CompressorState *cs = ctx->cs;
if (dLen == 0)
return 0;
_DeClone(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
+
free(ctx);
}
"could not read from input file: end of file\n");
else
die_horribly(AH, modulename,
- "could not read from input file: %s\n", strerror(errno));
+ "could not read from input file: %s\n", strerror(errno));
}
return cnt;
}
* Our archive location. This is basically what the user specified as his
* backup file but of course here it is a directory.
*/
- char *directory;
+ char *directory;
- cfp *dataFH; /* currently open data file */
+ cfp *dataFH; /* currently open data file */
- cfp *blobsTocFH; /* file handle for blobs.toc */
+ cfp *blobsTocFH; /* file handle for blobs.toc */
} lclContext;
typedef struct
fname, strerror(errno));
ctx->dataFH = tocFH;
+
/*
- * The TOC of a directory format dump shares the format code of
- * the tar format.
+ * The TOC of a directory format dump shares the format code of the
+ * tar format.
*/
AH->format = archTar;
ReadHead(AH);
static void
_ArchiveEntry(ArchiveHandle *AH, TocEntry *te)
{
- lclTocEntry *tctx;
- char fn[MAXPGPATH];
+ lclTocEntry *tctx;
+ char fn[MAXPGPATH];
tctx = (lclTocEntry *) calloc(1, sizeof(lclTocEntry));
if (!tctx)
static void
_StartData(ArchiveHandle *AH, TocEntry *te)
{
- lclTocEntry *tctx = (lclTocEntry *) te->formatData;
- lclContext *ctx = (lclContext *) AH->formatData;
- char *fname;
+ lclTocEntry *tctx = (lclTocEntry *) te->formatData;
+ lclContext *ctx = (lclContext *) AH->formatData;
+ char *fname;
fname = prependDirectory(AH, tctx->filename);
static size_t
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{
- lclContext *ctx = (lclContext *) AH->formatData;
+ lclContext *ctx = (lclContext *) AH->formatData;
if (dLen == 0)
return 0;
static void
_EndData(ArchiveHandle *AH, TocEntry *te)
{
- lclContext *ctx = (lclContext *) AH->formatData;
+ lclContext *ctx = (lclContext *) AH->formatData;
/* Close the file */
cfclose(ctx->dataFH);
if (!filename)
return;
- cfp = cfopen_read(filename, PG_BINARY_R);
+ cfp = cfopen_read(filename, PG_BINARY_R);
+
if (!cfp)
die_horribly(AH, modulename, "could not open input file \"%s\": %s\n",
filename, strerror(errno));
_LoadBlobs(AH, ropt);
else
{
- char *fname = prependDirectory(AH, tctx->filename);
+ char *fname = prependDirectory(AH, tctx->filename);
+
_PrintFileData(AH, fname, ropt);
}
}
static void
_LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
{
- Oid oid;
- lclContext *ctx = (lclContext *) AH->formatData;
- char *fname;
- char line[MAXPGPATH];
+ Oid oid;
+ lclContext *ctx = (lclContext *) AH->formatData;
+ char *fname;
+ char line[MAXPGPATH];
StartRestoreBlobs(AH);
_CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
+
if (AH->mode == archModeWrite)
{
- cfp *tocFH;
- char *fname = prependDirectory(AH, "toc.dat");
+ cfp *tocFH;
+ char *fname = prependDirectory(AH, "toc.dat");
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
die_horribly(AH, modulename, "could not open output file \"%s\": %s\n",
fname, strerror(errno));
ctx->dataFH = tocFH;
+
/*
* Write 'tar' in the format field of the toc.dat file. The directory
* is compatible with 'tar', so there's no point having a different
* Called by the archiver when starting to save all BLOB DATA (not schema).
* It is called just prior to the dumper's DataDumper routine.
*
- * We open the large object TOC file here, so that we can append a line to
+ * We open the large object TOC file here, so that we can append a line to
* it for each blob.
*/
static void
_StartBlobs(ArchiveHandle *AH, TocEntry *te)
{
- lclContext *ctx = (lclContext *) AH->formatData;
- char *fname;
+ lclContext *ctx = (lclContext *) AH->formatData;
+ char *fname;
fname = prependDirectory(AH, "blobs.toc");
static void
_StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
{
- lclContext *ctx = (lclContext *) AH->formatData;
- char fname[MAXPGPATH];
+ lclContext *ctx = (lclContext *) AH->formatData;
+ char fname[MAXPGPATH];
snprintf(fname, MAXPGPATH, "%s/blob_%u.dat", ctx->directory, oid);
static void
_EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
{
- lclContext *ctx = (lclContext *) AH->formatData;
- char buf[50];
- int len;
+ lclContext *ctx = (lclContext *) AH->formatData;
+ char buf[50];
+ int len;
/* Close the BLOB data file itself */
cfclose(ctx->dataFH);
/* register the blob in blobs.toc */
len = snprintf(buf, sizeof(buf), "%u blob_%u.dat\n", oid, oid);
if (cfwrite(buf, len, ctx->blobsTocFH) != len)
- die_horribly(AH, modulename, "could not write to blobs TOC file\n");
+ die_horribly(AH, modulename, "could not write to blobs TOC file\n");
}
/*
static void
createDirectory(const char *dir)
{
- struct stat st;
+ struct stat st;
/* the directory must not exist yet. */
if (stat(dir, &st) == 0)
static char *
prependDirectory(ArchiveHandle *AH, const char *relativeFilename)
{
- lclContext *ctx = (lclContext *) AH->formatData;
- static char buf[MAXPGPATH];
- char *dname;
+ lclContext *ctx = (lclContext *) AH->formatData;
+ static char buf[MAXPGPATH];
+ char *dname;
dname = ctx->directory;
if (strlen(dname) + 1 + strlen(relativeFilename) + 1 > MAXPGPATH)
- die_horribly(AH, modulename, "path name too long: %s", dname);
+ die_horribly(AH, modulename, "path name too long: %s", dname);
strcpy(buf, dname);
strcat(buf, "/");
*
* This file is copied from the 'files' format file, but dumps data into
* one temp file then sends it to the output TAR archive.
- *
+ *
* NOTE: If you untar the created 'tar' file, the resulting files are
* compatible with the 'directory' format. Please keep the two formats in
* sync.
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
-static void dumpSecLabel(Archive *fout, const char *target,
- const char *namespace, const char *owner,
- CatalogId catalogId, int subid, DumpId dumpId);
-static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
- SecLabelItem **items);
+static void dumpSecLabel(Archive *fout, const char *target,
+ const char *namespace, const char *owner,
+ CatalogId catalogId, int subid, DumpId dumpId);
+static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
+ SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
static bool binary_upgrade_set_type_oids_by_rel_oid(
PQExpBuffer upgrade_buffer, Oid pg_rel_oid);
static void binary_upgrade_set_pg_class_oids(PQExpBuffer upgrade_buffer,
- Oid pg_class_oid, bool is_index);
+ Oid pg_class_oid, bool is_index);
static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer,
- DumpableObject *dobj,
- const char *objlabel);
+ DumpableObject *dobj,
+ const char *objlabel);
static const char *getAttrName(int attrnum, TableInfo *tblInfo);
static const char *fmtCopyColumnList(const TableInfo *ti);
static void do_sql_command(PGconn *conn, const char *query);
int optindex;
RestoreOptions *ropt;
ArchiveFormat archiveFormat = archUnknown;
- ArchiveMode archiveMode;
+ ArchiveMode archiveMode;
static int disable_triggers = 0;
static int outputNoTablespaces = 0;
else if (pg_strcasecmp(format, "directory") == 0)
archiveFormat = archDirectory;
else if (pg_strcasecmp(format, "f") == 0 || pg_strcasecmp(format, "file") == 0)
+
/*
* Dump files into the current directory; for demonstration only, not
* documented.
tdinfo->dobj.namespace = tbinfo->dobj.namespace;
tdinfo->tdtable = tbinfo;
tdinfo->oids = oids;
- tdinfo->filtercond = NULL; /* might get set later */
+ tdinfo->filtercond = NULL; /* might get set later */
addObjectDependency(&tdinfo->dobj, tbinfo->dobj.dumpId);
tbinfo->dataObj = tdinfo;
int i_relfrozenxid;
/*
- * pg_largeobject
+ * pg_largeobject
*/
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
"FROM pg_catalog.pg_class\n"
PQclear(lo_res);
/*
- * pg_largeobject_metadata
+ * pg_largeobject_metadata
*/
if (g_fout->remoteVersion >= 90000)
{
resetPQExpBuffer(loFrozenQry);
resetPQExpBuffer(loOutQry);
-
+
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
"FROM pg_catalog.pg_class\n"
"WHERE oid = %u;\n",
LargeObjectMetadataRelationId);
-
+
lo_res = PQexec(g_conn, loFrozenQry->data);
check_sql_result(lo_res, g_conn, loFrozenQry->data, PGRES_TUPLES_OK);
-
+
if (PQntuples(lo_res) != 1)
{
write_msg(NULL, "dumpDatabase(): could not find pg_largeobject_metadata.relfrozenxid\n");
exit_nicely();
}
-
+
i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
-
+
appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject_metadata.relfrozenxid\n");
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
"SET relfrozenxid = '%u'\n"
loOutQry->data, "", NULL,
NULL, 0,
NULL, NULL);
-
+
PQclear(lo_res);
}
static void
binary_upgrade_set_pg_class_oids(PQExpBuffer upgrade_buffer, Oid pg_class_oid,
- bool is_index)
+ bool is_index)
{
PQExpBuffer upgrade_query = createPQExpBuffer();
int ntups;
Oid pg_class_reltoastidxid;
appendPQExpBuffer(upgrade_query,
- "SELECT c.reltoastrelid, t.reltoastidxid "
+ "SELECT c.reltoastrelid, t.reltoastidxid "
"FROM pg_catalog.pg_class c LEFT JOIN "
"pg_catalog.pg_class t ON (c.reltoastrelid = t.oid) "
"WHERE c.oid = '%u'::pg_catalog.oid;",
pg_class_reltoastidxid = atooid(PQgetvalue(upgrade_res, 0, PQfnumber(upgrade_res, "reltoastidxid")));
appendPQExpBuffer(upgrade_buffer,
- "\n-- For binary upgrade, must preserve pg_class oids\n");
+ "\n-- For binary upgrade, must preserve pg_class oids\n");
if (!is_index)
{
* the creation of a TOAST table, and the TOAST table might have
* been created long after table creation, when the table was
* loaded with wide data. By setting the TOAST oid we force
- * creation of the TOAST heap and TOAST index by the backend
- * so we can cleanly copy the files during binary upgrade.
+ * creation of the TOAST heap and TOAST index by the backend so we
+ * can cleanly copy the files during binary upgrade.
*/
-
+
appendPQExpBuffer(upgrade_buffer,
"SELECT binary_upgrade.set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
pg_class_reltoastrelid);
-
+
/* every toast table has an index */
appendPQExpBuffer(upgrade_buffer,
"SELECT binary_upgrade.set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
return;
/*
- * Find the parent extension. We could avoid this search if we wanted
- * to add a link field to DumpableObject, but the space costs of that
- * would be considerable. We assume that member objects could only have
- * a direct dependency on their own extension, not any others.
+ * Find the parent extension. We could avoid this search if we wanted to
+ * add a link field to DumpableObject, but the space costs of that would
+ * be considerable. We assume that member objects could only have a
+ * direct dependency on their own extension, not any others.
*/
for (i = 0; i < dobj->nDeps; i++)
{
}
appendPQExpBuffer(upgrade_buffer,
- "\n-- For binary upgrade, handle extension membership the hard way\n");
+ "\n-- For binary upgrade, handle extension membership the hard way\n");
appendPQExpBuffer(upgrade_buffer, "ALTER EXTENSION %s ADD %s;\n",
fmtId(extobj->name),
objlabel);
selectSourceSchema("pg_catalog");
/*
- * Find all user-defined functions. Normally we can exclude functions
- * in pg_catalog, which is worth doing since there are several thousand
- * of 'em. However, there are some extensions that create functions in
- * pg_catalog. In normal dumps we can still ignore those --- but in
+ * Find all user-defined functions. Normally we can exclude functions in
+ * pg_catalog, which is worth doing since there are several thousand of
+ * 'em. However, there are some extensions that create functions in
+ * pg_catalog. In normal dumps we can still ignore those --- but in
* binary-upgrade mode, we must dump the member objects of the extension,
* so be sure to fetch any such functions.
*/
if (g_fout->remoteVersion >= 90100)
{
/*
- * attcollation is new in 9.1. Since we only want to dump
- * COLLATE clauses for attributes whose collation is different
- * from their type's default, we use a CASE here to suppress
- * uninteresting attcollations cheaply.
+ * attcollation is new in 9.1. Since we only want to dump COLLATE
+ * clauses for attributes whose collation is different from their
+ * type's default, we use a CASE here to suppress uninteresting
+ * attcollations cheaply.
*/
appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, "
"a.attstattarget, a.attstorage, t.typstorage, "
"a.attnotnull, a.atthasdef, a.attisdropped, "
"a.attlen, a.attalign, a.attislocal, "
"pg_catalog.format_type(t.oid,a.atttypmod) AS atttypname, "
- "array_to_string(a.attoptions, ', ') AS attoptions, "
+ "array_to_string(a.attoptions, ', ') AS attoptions, "
"CASE WHEN a.attcollation <> t.typcollation "
- "THEN a.attcollation ELSE 0 END AS attcollation "
+ "THEN a.attcollation ELSE 0 END AS attcollation "
"FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
"ON a.atttypid = t.oid "
"WHERE a.attrelid = '%u'::pg_catalog.oid "
"a.attnotnull, a.atthasdef, a.attisdropped, "
"a.attlen, a.attalign, a.attislocal, "
"pg_catalog.format_type(t.oid,a.atttypmod) AS atttypname, "
- "array_to_string(a.attoptions, ', ') AS attoptions, "
+ "array_to_string(a.attoptions, ', ') AS attoptions, "
"0 AS attcollation "
"FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
"ON a.atttypid = t.oid "
}
else
{
- int i;
- int n;
+ int i;
+ int n;
appendPQExpBuffer(q, "-- For binary upgrade, create an empty extension and insert objects into it\n");
appendPQExpBuffer(q,
appendPQExpBuffer(q, "%s, ", extinfo->relocatable ? "true" : "false");
appendStringLiteralAH(q, extinfo->extversion, fout);
appendPQExpBuffer(q, ", ");
+
/*
* Note that we're pushing extconfig (an OID array) back into
- * pg_extension exactly as-is. This is OK because pg_class OIDs
- * are preserved in binary upgrade.
+ * pg_extension exactly as-is. This is OK because pg_class OIDs are
+ * preserved in binary upgrade.
*/
if (strlen(extinfo->extconfig) > 2)
appendStringLiteralAH(q, extinfo->extconfig, fout);
{
/* typcollation is new in 9.1 */
appendPQExpBuffer(query, "SELECT t.typnotnull, "
- "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
+ "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
"pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
"t.typdefault, "
"CASE WHEN t.typcollation <> u.typcollation "
"THEN t.typcollation ELSE 0 END AS typcollation "
"FROM pg_catalog.pg_type t "
- "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
+ "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
"WHERE t.oid = '%u'::pg_catalog.oid",
tyinfo->dobj.catId.oid);
}
{
/* We assume here that remoteVersion must be at least 70300 */
appendPQExpBuffer(query, "SELECT typnotnull, "
- "pg_catalog.format_type(typbasetype, typtypmod) AS typdefn, "
+ "pg_catalog.format_type(typbasetype, typtypmod) AS typdefn, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
"typdefault, 0 AS typcollation "
"FROM pg_catalog.pg_type "
/* Print collation only if different from base type's collation */
if (OidIsValid(typcollation))
{
- CollInfo *coll;
+ CollInfo *coll;
coll = findCollationByOid(typcollation);
if (coll)
* Print only those opfamily members that are tied to the opclass by
* pg_depend entries.
*
- * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping
- * an older server's opclass in which it is used. This is to avoid
+ * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping an
+ * older server's opclass in which it is used. This is to avoid
* hard-to-detect breakage if a newer pg_dump is used to dump from an
- * older server and then reload into that old version. This can go
- * away once 8.3 is so old as to not be of interest to anyone.
+ * older server and then reload into that old version. This can go away
+ * once 8.3 is so old as to not be of interest to anyone.
*/
resetPQExpBuffer(query);
"amopopr::pg_catalog.regoperator, "
"opfname AS sortfamily, "
"nspname AS sortfamilynsp "
- "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
+ "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
"(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
- "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
- "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
+ "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
+ "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
"AND refobjid = '%u'::pg_catalog.oid "
"AND amopfamily = '%s'::pg_catalog.oid "
"ORDER BY amopstrategy",
else
{
/*
- * Here, we print all entries since there are no opfamilies and
- * hence no loose operators to worry about.
+ * Here, we print all entries since there are no opfamilies and hence
+ * no loose operators to worry about.
*/
appendPQExpBuffer(query, "SELECT amopstrategy, amopreqcheck, "
"amopopr::pg_catalog.regoperator, "
* Fetch only those opfamily members that are tied directly to the
* opfamily by pg_depend entries.
*
- * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping
- * an older server's opclass in which it is used. This is to avoid
+ * XXX RECHECK is gone as of 8.4, but we'll still print it if dumping an
+ * older server's opclass in which it is used. This is to avoid
* hard-to-detect breakage if a newer pg_dump is used to dump from an
- * older server and then reload into that old version. This can go
- * away once 8.3 is so old as to not be of interest to anyone.
+ * older server and then reload into that old version. This can go away
+ * once 8.3 is so old as to not be of interest to anyone.
*/
if (g_fout->remoteVersion >= 90100)
{
"amopopr::pg_catalog.regoperator, "
"opfname AS sortfamily, "
"nspname AS sortfamilynsp "
- "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
+ "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
"(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
- "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
- "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
+ "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
+ "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
"AND refobjid = '%u'::pg_catalog.oid "
"AND amopfamily = '%u'::pg_catalog.oid "
"ORDER BY amopstrategy",
* to fail if run by a non-superuser. Note that the view will show
* umoptions as null if the user hasn't got privileges for the associated
* server; this means that pg_dump will dump such a mapping, but with no
- * OPTIONS clause. A possible alternative is to skip such mappings
+ * OPTIONS clause. A possible alternative is to skip such mappings
* altogether, but it's not clear that that's an improvement.
*/
selectSourceSchema("pg_catalog");
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
- SecLabelItem *labels;
- int nlabels;
- int i;
- PQExpBuffer query;
+ SecLabelItem *labels;
+ int nlabels;
+ int i;
+ PQExpBuffer query;
/* do nothing, if --no-security-label is supplied */
if (no_security_label)
static void
dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
{
- SecLabelItem *labels;
- int nlabels;
- int i;
- PQExpBuffer query;
- PQExpBuffer target;
+ SecLabelItem *labels;
+ int nlabels;
+ int i;
+ PQExpBuffer query;
+ PQExpBuffer target;
/* do nothing, if --no-security-label is supplied */
if (no_security_label)
for (i = 0; i < nlabels; i++)
{
const char *colname;
- const char *provider = labels[i].provider;
- const char *label = labels[i].label;
- int objsubid = labels[i].objsubid;
+ const char *provider = labels[i].provider;
+ const char *label = labels[i].label;
+ int objsubid = labels[i].objsubid;
resetPQExpBuffer(target);
if (objsubid == 0)
{
/* static storage for table of security labels */
static SecLabelItem *labels = NULL;
- static int nlabels = -1;
+ static int nlabels = -1;
- SecLabelItem *middle = NULL;
- SecLabelItem *low;
- SecLabelItem *high;
- int nmatch;
+ SecLabelItem *middle = NULL;
+ SecLabelItem *low;
+ SecLabelItem *high;
+ int nmatch;
/* Get security labels if we didn't already */
if (nlabels < 0)
else if (objoid > middle->objoid)
low = middle + 1;
else
- break; /* found a match */
+ break; /* found a match */
}
- if (low > high) /* no matches */
+ if (low > high) /* no matches */
{
*items = NULL;
return 0;
static int
collectSecLabels(Archive *fout, SecLabelItem **items)
{
- PGresult *res;
- PQExpBuffer query;
- int i_label;
- int i_provider;
- int i_classoid;
- int i_objoid;
- int i_objsubid;
- int ntups;
- int i;
- SecLabelItem *labels;
+ PGresult *res;
+ PQExpBuffer query;
+ int i_label;
+ int i_provider;
+ int i_classoid;
+ int i_objoid;
+ int i_objsubid;
+ int ntups;
+ int i;
+ SecLabelItem *labels;
query = createPQExpBuffer();
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
/* Construct lookup table containing OIDs in numeric form */
- i_label = PQfnumber(res, "label");
- i_provider = PQfnumber(res, "provider");
- i_classoid = PQfnumber(res, "classoid");
- i_objoid = PQfnumber(res, "objoid");
- i_objsubid = PQfnumber(res, "objsubid");
+ i_label = PQfnumber(res, "label");
+ i_provider = PQfnumber(res, "provider");
+ i_classoid = PQfnumber(res, "classoid");
+ i_objoid = PQfnumber(res, "objoid");
+ i_objsubid = PQfnumber(res, "objsubid");
ntups = PQntuples(res);
for (i = 0; i < ntups; i++)
{
- labels[i].label = PQgetvalue(res, i, i_label);
- labels[i].provider = PQgetvalue(res, i, i_provider);
+ labels[i].label = PQgetvalue(res, i, i_label);
+ labels[i].provider = PQgetvalue(res, i, i_provider);
labels[i].classoid = atooid(PQgetvalue(res, i, i_classoid));
labels[i].objoid = atooid(PQgetvalue(res, i, i_objoid));
labels[i].objsubid = atoi(PQgetvalue(res, i, i_objsubid));
}
/* Do NOT free the PGresult since we are keeping pointers into it */
- destroyPQExpBuffer(query);
+ destroyPQExpBuffer(query);
*items = labels;
return ntups;
{
if (tbinfo->relkind == RELKIND_FOREIGN_TABLE)
{
- int i_srvname;
- int i_ftoptions;
+ int i_srvname;
+ int i_ftoptions;
reltypename = "FOREIGN TABLE";
- /* retrieve name of foreign server and generic options */
+ /* retrieve name of foreign server and generic options */
appendPQExpBuffer(query,
- "SELECT fs.srvname, array_to_string(ARRAY("
+ "SELECT fs.srvname, array_to_string(ARRAY("
" SELECT option_name || ' ' || quote_literal(option_value)"
- " FROM pg_options_to_table(ftoptions)), ', ') AS ftoptions "
- "FROM pg_foreign_table ft JOIN pg_foreign_server fs "
- " ON (fs.oid = ft.ftserver) "
- "WHERE ft.ftrelid = %u", tbinfo->dobj.catId.oid);
+ " FROM pg_options_to_table(ftoptions)), ', ') AS ftoptions "
+ "FROM pg_foreign_table ft JOIN pg_foreign_server fs "
+ " ON (fs.oid = ft.ftserver) "
+ "WHERE ft.ftrelid = %u", tbinfo->dobj.catId.oid);
res = PQexec(g_conn, query->data);
check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
i_srvname = PQfnumber(res, "srvname");
appendPQExpBuffer(q, "CREATE %s%s %s",
tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ?
- "UNLOGGED " : "",
+ "UNLOGGED " : "",
reltypename,
fmtId(tbinfo->dobj.name));
if (tbinfo->reloftype)
/* Add collation if not default for the type */
if (OidIsValid(tbinfo->attcollation[j]))
{
- CollInfo *coll;
+ CollInfo *coll;
coll = findCollationByOid(tbinfo->attcollation[j]);
if (coll)
{
/* always schema-qualify, don't try to be smart */
appendPQExpBuffer(q, " COLLATE %s.",
- fmtId(coll->dobj.namespace->dobj.name));
+ fmtId(coll->dobj.namespace->dobj.name));
appendPQExpBuffer(q, "%s",
fmtId(coll->dobj.name));
}
/*
* Normally, mark the member object as not to be dumped. But in
- * binary upgrades, we still dump the members individually, since
- * the idea is to exactly reproduce the database contents rather
- * than replace the extension contents with something different.
+ * binary upgrades, we still dump the members individually, since the
+ * idea is to exactly reproduce the database contents rather than
+ * replace the extension contents with something different.
*/
if (!binary_upgrade)
dobj->dump = false;
* objects for them, ensuring their data will be dumped even though the
* tables themselves won't be.
*
- * Note that we create TableDataInfo objects even in schemaOnly mode,
- * ie, user data in a configuration table is treated like schema data.
- * This seems appropriate since system data in a config table would
- * get reloaded by CREATE EXTENSION.
+ * Note that we create TableDataInfo objects even in schemaOnly mode, ie,
+ * user data in a configuration table is treated like schema data. This
+ * seems appropriate since system data in a config table would get
+ * reloaded by CREATE EXTENSION.
*/
for (i = 0; i < numExtensions; i++)
{
- char *extconfig = extinfo[i].extconfig;
- char *extcondition = extinfo[i].extcondition;
- char **extconfigarray = NULL;
- char **extconditionarray = NULL;
- int nconfigitems;
- int nconditionitems;
+ char *extconfig = extinfo[i].extconfig;
+ char *extcondition = extinfo[i].extcondition;
+ char **extconfigarray = NULL;
+ char **extconditionarray = NULL;
+ int nconfigitems;
+ int nconditionitems;
if (parsePGArray(extconfig, &extconfigarray, &nconfigitems) &&
- parsePGArray(extcondition, &extconditionarray, &nconditionitems) &&
+ parsePGArray(extcondition, &extconditionarray, &nconditionitems) &&
nconfigitems == nconditionitems)
{
- int j;
+ int j;
for (j = 0; j < nconfigitems; j++)
{
- TableInfo *configtbl;
+ TableInfo *configtbl;
configtbl = findTableByOid(atooid(extconfigarray[j]));
if (configtbl && configtbl->dataObj == NULL)
typedef struct _extensionInfo
{
DumpableObject dobj;
- char *namespace; /* schema containing extension's objects */
+ char *namespace; /* schema containing extension's objects */
bool relocatable;
char *extversion;
- char *extconfig; /* info about configuration tables */
- char *extcondition;
+ char *extconfig; /* info about configuration tables */
+ char *extcondition;
} ExtensionInfo;
typedef struct _typeInfo
char *rolname; /* name of owner, or empty string */
char *relacl;
char relkind;
- char relpersistence; /* relation persistence */
+ char relpersistence; /* relation persistence */
char *reltablespace; /* relation tablespace */
char *reloptions; /* options specified by WITH (...) */
char *toast_reloptions; /* ditto, for the TOAST table */
bool hasoids; /* does it have OIDs? */
uint32 frozenxid; /* for restore frozen xid */
Oid toast_oid; /* for restore toast frozen xid */
- uint32 toast_frozenxid;/* for restore toast frozen xid */
+ uint32 toast_frozenxid; /* for restore toast frozen xid */
int ncheck; /* # of CHECK expressions */
char *reloftype; /* underlying type for typed table */
/* these two are set only if table is a sequence owned by a column: */
appendPQExpBuffer(buf, "\n-- For binary upgrade, must preserve pg_authid.oid\n");
appendPQExpBuffer(buf,
- "SELECT binary_upgrade.set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
+ "SELECT binary_upgrade.set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
auth_oid);
}
break;
}
break;
- case 'x': /* Extensions */
+ case 'x': /* Extensions */
if (show_verbose)
success = listExtensionContents(pattern);
else
else if (strcmp(cmd, "sf") == 0 || strcmp(cmd, "sf+") == 0)
{
bool show_linenumbers = (strcmp(cmd, "sf+") == 0);
- PQExpBuffer func_buf;
+ PQExpBuffer func_buf;
char *func;
Oid foid = InvalidOid;
}
else
{
- FILE *output;
- bool is_pager;
+ FILE *output;
+ bool is_pager;
/* Select output stream: stdout, pager, or file */
if (pset.queryFout == stdout)
*/
while (*lines != '\0')
{
- char *eol;
+ char *eol;
if (in_header && strncmp(lines, "AS ", 3) == 0)
in_header = false;
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
param_is_newly_set(PQport(o_conn), PQport(pset.db)))
{
- char *host = PQhost(pset.db);
+ char *host = PQhost(pset.db);
if (host == NULL)
host = DEFAULT_PGSOCKET_DIR;
/* Allocate sufficient memory for command line. */
if (lineno > 0)
sys = pg_malloc(strlen(editorName)
- + strlen(editor_lineno_switch) + 10 /* for integer */
+ + strlen(editor_lineno_switch) + 10 /* for integer */
+ 1 + strlen(fname) + 10 + 1);
else
sys = pg_malloc(strlen(editorName) + strlen(fname) + 10 + 1);
* multibyte environment: there is no reason to believe that we are
* looking at the first byte of a character, nor are we necessarily
* working in a "safe" encoding. Fortunately the bitpatterns we are
- * looking for are unlikely to occur as non-first bytes, but beware
- * of trying to expand the set of cases that can be recognized. We must
+ * looking for are unlikely to occur as non-first bytes, but beware of
+ * trying to expand the set of cases that can be recognized. We must
* guard the <ctype.h> macros by using isascii() first, too.
*/
gettext_noop("Schema"),
gettext_noop("Name"),
gettext_noop("table"), gettext_noop("view"), gettext_noop("sequence"),
- gettext_noop("foreign table"),
+ gettext_noop("foreign table"),
gettext_noop("Type"));
printACLColumn(&buf, "c.relacl");
{
printfPQExpBuffer(&buf,
"SELECT conname,\n"
- " pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n");
+ " pg_catalog.pg_get_constraintdef(r.oid, true) as condef\n");
if (pset.sversion >= 90100)
appendPQExpBuffer(&buf, " ,convalidated\n");
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_constraint r\n"
*/
if (tableinfo.hastriggers)
{
- PGresult *result;
- int tuples;
+ PGresult *result;
+ int tuples;
- printfPQExpBuffer(&buf,
- "SELECT t.tgname, "
- "pg_catalog.pg_get_triggerdef(t.oid%s), "
- "t.tgenabled\n"
- "FROM pg_catalog.pg_trigger t\n"
- "WHERE t.tgrelid = '%s' AND ",
- (pset.sversion >= 90000 ? ", true" : ""),
- oid);
- if (pset.sversion >= 90000)
- appendPQExpBuffer(&buf, "NOT t.tgisinternal");
- else if (pset.sversion >= 80300)
- appendPQExpBuffer(&buf, "t.tgconstraint = 0");
- else
- appendPQExpBuffer(&buf,
- "(NOT tgisconstraint "
- " OR NOT EXISTS"
- " (SELECT 1 FROM pg_catalog.pg_depend d "
- " JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) "
- " WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))");
- appendPQExpBuffer(&buf, "\nORDER BY 1");
+ printfPQExpBuffer(&buf,
+ "SELECT t.tgname, "
+ "pg_catalog.pg_get_triggerdef(t.oid%s), "
+ "t.tgenabled\n"
+ "FROM pg_catalog.pg_trigger t\n"
+ "WHERE t.tgrelid = '%s' AND ",
+ (pset.sversion >= 90000 ? ", true" : ""),
+ oid);
+ if (pset.sversion >= 90000)
+ appendPQExpBuffer(&buf, "NOT t.tgisinternal");
+ else if (pset.sversion >= 80300)
+ appendPQExpBuffer(&buf, "t.tgconstraint = 0");
+ else
+ appendPQExpBuffer(&buf,
+ "(NOT tgisconstraint "
+ " OR NOT EXISTS"
+ " (SELECT 1 FROM pg_catalog.pg_depend d "
+ " JOIN pg_catalog.pg_constraint c ON (d.refclassid = c.tableoid AND d.refobjid = c.oid) "
+ " WHERE d.classid = t.tableoid AND d.objid = t.oid AND d.deptype = 'i' AND c.contype = 'f'))");
+ appendPQExpBuffer(&buf, "\nORDER BY 1");
- result = PSQLexec(buf.data, false);
- if (!result)
- goto error_return;
- else
- tuples = PQntuples(result);
+ result = PSQLexec(buf.data, false);
+ if (!result)
+ goto error_return;
+ else
+ tuples = PQntuples(result);
- if (tuples > 0)
+ if (tuples > 0)
+ {
+ bool have_heading;
+ int category;
+
+ /*
+ * split the output into 4 different categories. Enabled triggers,
+ * disabled triggers and the two special ALWAYS and REPLICA
+ * configurations.
+ */
+ for (category = 0; category < 4; category++)
{
- bool have_heading;
- int category;
-
- /*
- * split the output into 4 different categories. Enabled
- * triggers, disabled triggers and the two special ALWAYS and
- * REPLICA configurations.
- */
- for (category = 0; category < 4; category++)
+ have_heading = false;
+ for (i = 0; i < tuples; i++)
{
- have_heading = false;
- for (i = 0; i < tuples; i++)
+ bool list_trigger;
+ const char *tgdef;
+ const char *usingpos;
+ const char *tgenabled;
+
+ /*
+ * Check if this trigger falls into the current category
+ */
+ tgenabled = PQgetvalue(result, i, 2);
+ list_trigger = false;
+ switch (category)
+ {
+ case 0:
+ if (*tgenabled == 'O' || *tgenabled == 't')
+ list_trigger = true;
+ break;
+ case 1:
+ if (*tgenabled == 'D' || *tgenabled == 'f')
+ list_trigger = true;
+ break;
+ case 2:
+ if (*tgenabled == 'A')
+ list_trigger = true;
+ break;
+ case 3:
+ if (*tgenabled == 'R')
+ list_trigger = true;
+ break;
+ }
+ if (list_trigger == false)
+ continue;
+
+ /* Print the category heading once */
+ if (have_heading == false)
{
- bool list_trigger;
- const char *tgdef;
- const char *usingpos;
- const char *tgenabled;
-
- /*
- * Check if this trigger falls into the current
- * category
- */
- tgenabled = PQgetvalue(result, i, 2);
- list_trigger = false;
switch (category)
{
case 0:
- if (*tgenabled == 'O' || *tgenabled == 't')
- list_trigger = true;
+ printfPQExpBuffer(&buf, _("Triggers:"));
break;
case 1:
- if (*tgenabled == 'D' || *tgenabled == 'f')
- list_trigger = true;
+ printfPQExpBuffer(&buf, _("Disabled triggers:"));
break;
case 2:
- if (*tgenabled == 'A')
- list_trigger = true;
+ printfPQExpBuffer(&buf, _("Triggers firing always:"));
break;
case 3:
- if (*tgenabled == 'R')
- list_trigger = true;
+ printfPQExpBuffer(&buf, _("Triggers firing on replica only:"));
break;
- }
- if (list_trigger == false)
- continue;
-
- /* Print the category heading once */
- if (have_heading == false)
- {
- switch (category)
- {
- case 0:
- printfPQExpBuffer(&buf, _("Triggers:"));
- break;
- case 1:
- printfPQExpBuffer(&buf, _("Disabled triggers:"));
- break;
- case 2:
- printfPQExpBuffer(&buf, _("Triggers firing always:"));
- break;
- case 3:
- printfPQExpBuffer(&buf, _("Triggers firing on replica only:"));
- break;
- }
- printTableAddFooter(&cont, buf.data);
- have_heading = true;
}
-
- /* Everything after "TRIGGER" is echoed verbatim */
- tgdef = PQgetvalue(result, i, 1);
- usingpos = strstr(tgdef, " TRIGGER ");
- if (usingpos)
- tgdef = usingpos + 9;
-
- printfPQExpBuffer(&buf, " %s", tgdef);
printTableAddFooter(&cont, buf.data);
+ have_heading = true;
}
+
+ /* Everything after "TRIGGER" is echoed verbatim */
+ tgdef = PQgetvalue(result, i, 1);
+ usingpos = strstr(tgdef, " TRIGGER ");
+ if (usingpos)
+ tgdef = usingpos + 9;
+
+ printfPQExpBuffer(&buf, " %s", tgdef);
+ printTableAddFooter(&cont, buf.data);
}
}
- PQclear(result);
+ }
+ PQclear(result);
}
/*
}
printfPQExpBuffer(&buf, "Server: %s",
- PQgetvalue(result, 0, 0));
+ PQgetvalue(result, 0, 0));
printTableAddFooter(&cont, buf.data);
PQclear(result);
}
}
if (pset.sversion >= 90100)
{
- appendPQExpBufferStr(&buf,"\n, r.rolreplication");
+ appendPQExpBufferStr(&buf, "\n, r.rolreplication");
}
appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n");
if (verbose)
{
/*
- * As of PostgreSQL 9.0, use pg_table_size() to show a more acurate size
- * of a table, including FSM, VM and TOAST tables.
+ * As of PostgreSQL 9.0, use pg_table_size() to show a more acurate
+ * size of a table, including FSM, VM and TOAST tables.
*/
if (pset.sversion >= 90000)
appendPQExpBuffer(&buf,
listLanguages(const char *pattern, bool verbose, bool showSystem)
{
PQExpBufferData buf;
- PGresult *res;
+ PGresult *res;
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
"SELECT l.lanname AS \"%s\",\n",
gettext_noop("Name"));
if (pset.sversion >= 80300)
- appendPQExpBuffer(&buf,
- " pg_catalog.pg_get_userbyid(l.lanowner) as \"%s\",\n",
- gettext_noop("Owner"));
+ appendPQExpBuffer(&buf,
+ " pg_catalog.pg_get_userbyid(l.lanowner) as \"%s\",\n",
+ gettext_noop("Owner"));
appendPQExpBuffer(&buf,
" l.lanpltrusted AS \"%s\"",
if (verbose)
{
- appendPQExpBuffer(&buf,
- ",\n NOT l.lanispl AS \"%s\",\n"
- " l.lanplcallfoid::regprocedure AS \"%s\",\n"
- " l.lanvalidator::regprocedure AS \"%s\",\n ",
- gettext_noop("Internal Language"),
- gettext_noop("Call Handler"),
- gettext_noop("Validator"));
- if (pset.sversion >= 90000)
- appendPQExpBuffer(&buf, "l.laninline::regprocedure AS \"%s\",\n ",
- gettext_noop("Inline Handler"));
- printACLColumn(&buf, "l.lanacl");
+ appendPQExpBuffer(&buf,
+ ",\n NOT l.lanispl AS \"%s\",\n"
+ " l.lanplcallfoid::regprocedure AS \"%s\",\n"
+ " l.lanvalidator::regprocedure AS \"%s\",\n ",
+ gettext_noop("Internal Language"),
+ gettext_noop("Call Handler"),
+ gettext_noop("Validator"));
+ if (pset.sversion >= 90000)
+ appendPQExpBuffer(&buf, "l.laninline::regprocedure AS \"%s\",\n ",
+ gettext_noop("Inline Handler"));
+ printACLColumn(&buf, "l.lanacl");
}
appendPQExpBuffer(&buf,
if (verbose)
appendPQExpBuffer(&buf,
- ",\n pg_catalog.obj_description(c.oid, 'pg_collation') AS \"%s\"",
+ ",\n pg_catalog.obj_description(c.oid, 'pg_collation') AS \"%s\"",
gettext_noop("Description"));
appendPQExpBuffer(&buf,
- "\nFROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n\n"
+ "\nFROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n\n"
"WHERE n.oid = c.collnamespace\n");
if (!showSystem && !pattern)
if (!showSystem && !pattern)
appendPQExpBuffer(&buf,
- "WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'\n");
+ "WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'\n");
processSQLNamePattern(pset.db, &buf, pattern,
!showSystem && !pattern, false,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
"SELECT e.extname AS \"%s\", "
- "e.extversion AS \"%s\", n.nspname AS \"%s\", c.description AS \"%s\"\n"
+ "e.extversion AS \"%s\", n.nspname AS \"%s\", c.description AS \"%s\"\n"
"FROM pg_catalog.pg_extension e "
- "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace "
- "LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid "
- "AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass\n",
+ "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace "
+ "LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid "
+ "AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass\n",
gettext_noop("Name"),
gettext_noop("Version"),
gettext_noop("Schema"),
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
- "SELECT pg_catalog.pg_describe_object(classid, objid, 0) AS \"%s\"\n"
+ "SELECT pg_catalog.pg_describe_object(classid, objid, 0) AS \"%s\"\n"
"FROM pg_catalog.pg_depend\n"
"WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND refobjid = '%s' AND deptype = 'e'\n"
"ORDER BY 1;",
{"INDEX", NULL, &Query_for_list_of_indexes},
{"OPERATOR", NULL, NULL}, /* Querying for this is probably not such a
* good idea. */
- {"OWNED", NULL, NULL, THING_NO_CREATE}, /* for DROP OWNED BY ... */
+ {"OWNED", NULL, NULL, THING_NO_CREATE}, /* for DROP OWNED BY ... */
{"PARSER", Query_for_list_of_ts_parsers, NULL, THING_NO_SHOW},
{"ROLE", Query_for_list_of_roles},
{"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'"},
{"SERVER", Query_for_list_of_servers},
{"TABLE", NULL, &Query_for_list_of_tables},
{"TABLESPACE", Query_for_list_of_tablespaces},
- {"TEMP", NULL, NULL, THING_NO_DROP}, /* for CREATE TEMP TABLE ... */
+ {"TEMP", NULL, NULL, THING_NO_DROP}, /* for CREATE TEMP TABLE ... */
{"TEMPLATE", Query_for_list_of_ts_templates, NULL, THING_NO_SHOW},
{"TEXT SEARCH", NULL, NULL},
{"TRIGGER", "SELECT pg_catalog.quote_ident(tgname) FROM pg_catalog.pg_trigger WHERE substring(pg_catalog.quote_ident(tgname),1,%d)='%s'"},
{"TYPE", NULL, &Query_for_list_of_datatypes},
- {"UNIQUE", NULL, NULL, THING_NO_DROP}, /* for CREATE UNIQUE INDEX ... */
- {"UNLOGGED", NULL, NULL, THING_NO_DROP},/* for CREATE UNLOGGED TABLE ... */
+ {"UNIQUE", NULL, NULL, THING_NO_DROP}, /* for CREATE UNIQUE INDEX ... */
+ {"UNLOGGED", NULL, NULL, THING_NO_DROP}, /* for CREATE UNLOGGED TABLE
+ * ... */
{"USER", Query_for_list_of_roles},
{"USER MAPPING FOR", NULL, NULL},
{"VIEW", NULL, &Query_for_list_of_views},
- {NULL} /* end of list */
+ {NULL} /* end of list */
};
static char *complete_from_list(const char *text, int state);
static char *complete_from_const(const char *text, int state);
static char **complete_from_variables(char *text,
- const char *prefix, const char *suffix);
+ const char *prefix, const char *suffix);
static PGresult *exec_query(const char *query);
{
static const char *const list_ALTER[] =
{"AGGREGATE", "COLLATION", "CONVERSION", "DATABASE", "DEFAULT PRIVILEGES", "DOMAIN",
- "EXTENSION", "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "FUNCTION",
- "GROUP", "INDEX", "LANGUAGE", "LARGE OBJECT", "OPERATOR",
- "ROLE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE",
- "TABLESPACE", "TEXT SEARCH", "TRIGGER", "TYPE",
- "USER", "USER MAPPING FOR", "VIEW", NULL};
+ "EXTENSION", "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "FUNCTION",
+ "GROUP", "INDEX", "LANGUAGE", "LARGE OBJECT", "OPERATOR",
+ "ROLE", "SCHEMA", "SERVER", "SEQUENCE", "TABLE",
+ "TABLESPACE", "TEXT SEARCH", "TRIGGER", "TYPE",
+ "USER", "USER MAPPING FOR", "VIEW", NULL};
COMPLETE_WITH_LIST(list_ALTER);
}
{
static const char *const list_ALTER2[] =
{"ADD", "ALTER", "CLUSTER ON", "DISABLE", "DROP", "ENABLE", "INHERIT",
- "NO INHERIT", "RENAME", "RESET", "OWNER TO", "SET",
+ "NO INHERIT", "RENAME", "RESET", "OWNER TO", "SET",
"VALIDATE CONSTRAINT", NULL};
COMPLETE_WITH_LIST(list_ALTER2);
{
static const char *const list_ALTERTYPE[] =
{"ADD ATTRIBUTE", "ADD VALUE", "ALTER ATTRIBUTE", "DROP ATTRIBUTE",
- "OWNER TO", "RENAME", "SET SCHEMA", NULL};
+ "OWNER TO", "RENAME", "SET SCHEMA", NULL};
COMPLETE_WITH_LIST(list_ALTERTYPE);
}
COMPLETE_WITH_LIST(list_ALTERTYPE);
}
- /* ALTER TYPE <foo> RENAME */
+ /* ALTER TYPE <foo> RENAME */
else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
pg_strcasecmp(prev3_wd, "TYPE") == 0 &&
pg_strcasecmp(prev_wd, "RENAME") == 0)
pg_strcasecmp(prev2_wd, "ATTRIBUTE") == 0)
COMPLETE_WITH_CONST("TO");
- /* If we have TYPE <sth> ALTER/DROP/RENAME ATTRIBUTE, provide list of attributes */
+ /*
+ * If we have TYPE <sth> ALTER/DROP/RENAME ATTRIBUTE, provide list of
+ * attributes
+ */
else if (pg_strcasecmp(prev4_wd, "TYPE") == 0 &&
(pg_strcasecmp(prev2_wd, "ALTER") == 0 ||
pg_strcasecmp(prev2_wd, "DROP") == 0 ||
else if (pg_strcasecmp(prev3_wd, "CREATE") != 0 &&
pg_strcasecmp(prev2_wd, "FOREIGN") == 0 &&
pg_strcasecmp(prev_wd, "TABLE") == 0)
- COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_foreign_tables, NULL);
+ COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_foreign_tables, NULL);
/* GRANT && REVOKE */
/* Complete GRANT/REVOKE with a list of privileges */
pg_strcasecmp(prev_wd, "LABEL") == 0)
{
static const char *const list_SECURITY_LABEL_preposition[] =
- {"ON", "FOR"};
+ {"ON", "FOR"};
+
COMPLETE_WITH_LIST(list_SECURITY_LABEL_preposition);
}
else if (pg_strcasecmp(prev4_wd, "SECURITY") == 0 &&
else if ((pg_strcasecmp(prev3_wd, "SECURITY") == 0 &&
pg_strcasecmp(prev2_wd, "LABEL") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0) ||
- (pg_strcasecmp(prev5_wd, "SECURITY") == 0 &&
+ (pg_strcasecmp(prev5_wd, "SECURITY") == 0 &&
pg_strcasecmp(prev4_wd, "LABEL") == 0 &&
pg_strcasecmp(prev3_wd, "FOR") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0))
{
static const char *const list_SECURITY_LABEL[] =
{"LANGUAGE", "SCHEMA", "SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN",
- "AGGREGATE", "FUNCTION", "DOMAIN", "LARGE OBJECT",
+ "AGGREGATE", "FUNCTION", "DOMAIN", "LARGE OBJECT",
NULL};
COMPLETE_WITH_LIST(list_SECURITY_LABEL);
if (strcmp(prev_wd, "format") == 0)
{
static const char *const my_list[] =
- {"unaligned", "aligned", "wrapped", "html", "latex",
- "troff-ms", NULL};
+ {"unaligned", "aligned", "wrapped", "html", "latex",
+ "troff-ms", NULL};
COMPLETE_WITH_LIST(my_list);
}
else if (strcmp(prev_wd, "linestyle") == 0)
{
static const char *const my_list[] =
- {"ascii", "old-ascii", "unicode", NULL};
+ {"ascii", "old-ascii", "unicode", NULL};
COMPLETE_WITH_LIST(my_list);
}
for (ptr = pset.vars->next; ptr; ptr = ptr->next)
{
- char *buffer;
+ char *buffer;
if (nvars >= maxvars)
{
maxvars *= 2;
varnames = (const char **) realloc(varnames,
- (maxvars + 1) * sizeof(char *));
+ (maxvars + 1) * sizeof(char *));
if (!varnames)
{
psql_error("out of memory\n");
PQclear(result);
/*
- * Attempt to drop the language. We do not use CASCADE, so that
- * the drop will fail if there are any functions in the language.
+ * Attempt to drop the language. We do not use CASCADE, so that the drop
+ * will fail if there are any functions in the language.
*/
printfPQExpBuffer(&sql, "DROP EXTENSION \"%s\";\n", langname);
typedef struct GinStatsData
{
BlockNumber nPendingPages;
- BlockNumber nTotalPages;
- BlockNumber nEntryPages;
- BlockNumber nDataPages;
+ BlockNumber nTotalPages;
+ BlockNumber nEntryPages;
+ BlockNumber nDataPages;
int64 nEntries;
int32 ginVersion;
} GinStatsData;
/*
* Statistics for planner use (accurate as of last VACUUM)
*/
- BlockNumber nTotalPages;
- BlockNumber nEntryPages;
- BlockNumber nDataPages;
+ BlockNumber nTotalPages;
+ BlockNumber nEntryPages;
+ BlockNumber nDataPages;
int64 nEntries;
/*
- * GIN version number (ideally this should have been at the front, but
- * too late now. Don't move it!)
+ * GIN version number (ideally this should have been at the front, but too
+ * late now. Don't move it!)
*
* Currently 1 (for indexes initialized in 9.1 or later)
*
#define GinGetPostingTree(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
#define GinGetPostingOffset(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
-#define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,n)
+#define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,n)
#define GinGetPosting(itup) ((ItemPointer) ((char*)(itup) + GinGetPostingOffset(itup)))
#define GinMaxItemSize \
extern void GinInitBuffer(Buffer b, uint32 f);
extern void GinInitPage(Page page, uint32 f, Size pageSize);
extern void GinInitMetabuffer(Buffer b);
-extern int ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
- Datum a, GinNullCategory categorya,
- Datum b, GinNullCategory categoryb);
-extern int ginCompareAttEntries(GinState *ginstate,
+extern int ginCompareEntries(GinState *ginstate, OffsetNumber attnum,
+ Datum a, GinNullCategory categorya,
+ Datum b, GinNullCategory categoryb);
+extern int ginCompareAttEntries(GinState *ginstate,
OffsetNumber attnuma, Datum a, GinNullCategory categorya,
- OffsetNumber attnumb, Datum b, GinNullCategory categoryb);
+ OffsetNumber attnumb, Datum b, GinNullCategory categoryb);
extern Datum *ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
Datum value, bool isNull,
int32 *nentries, GinNullCategory **categories);
extern GinBtreeStack *ginFindLeafPage(GinBtree btree, GinBtreeStack *stack);
extern void freeGinBtreeStack(GinBtreeStack *stack);
extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
- GinStatsData *buildStats);
+ GinStatsData *buildStats);
extern void ginFindParents(GinBtree btree, GinBtreeStack *stack, BlockNumber rootBlkno);
/* ginentrypage.c */
/* gindatapage.c */
extern int ginCompareItemPointers(ItemPointer a, ItemPointer b);
extern uint32 ginMergeItemPointers(ItemPointerData *dst,
- ItemPointerData *a, uint32 na,
- ItemPointerData *b, uint32 nb);
+ ItemPointerData *a, uint32 na,
+ ItemPointerData *b, uint32 nb);
extern void GinDataPageAddItem(Page page, void *data, OffsetNumber offset);
extern void GinPageDeletePostingItem(Page page, OffsetNumber offset);
} GinPostingTreeScan;
extern GinPostingTreeScan *ginPrepareScanPostingTree(Relation index,
- BlockNumber rootBlkno, bool searchMode);
+ BlockNumber rootBlkno, bool searchMode);
extern void ginInsertItemPointers(GinPostingTreeScan *gdi,
- ItemPointerData *items, uint32 nitem,
- GinStatsData *buildStats);
+ ItemPointerData *items, uint32 nitem,
+ GinStatsData *buildStats);
extern Buffer ginScanBeginPostingTree(GinPostingTreeScan *gdi);
extern void ginDataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
extern void ginPrepareDataScan(GinBtree btree, Relation index);
*
* In each GinScanKeyData, nentries is the true number of entries, while
* nuserentries is the number that extractQueryFn returned (which is what
- * we report to consistentFn). The "user" entries must come first.
+ * we report to consistentFn). The "user" entries must come first.
*/
typedef struct GinScanKeyData *GinScanKey;
OffsetNumber attnum;
/*
- * Match status data. curItem is the TID most recently tested (could be
- * a lossy-page pointer). curItemMatches is TRUE if it passes the
+ * Match status data. curItem is the TID most recently tested (could be a
+ * lossy-page pointer). curItemMatches is TRUE if it passes the
* consistentFn test; if so, recheckCurItem is the recheck flag.
- * isFinished means that all the input entry streams are finished, so
- * this key cannot succeed for any later TIDs.
+ * isFinished means that all the input entry streams are finished, so this
+ * key cannot succeed for any later TIDs.
*/
ItemPointerData curItem;
bool curItemMatches;
bool recheckCurItem;
bool isFinished;
-} GinScanKeyData;
+} GinScanKeyData;
typedef struct GinScanEntryData
{
bool isFinished;
bool reduceResult;
uint32 predictNumberResult;
-} GinScanEntryData;
+} GinScanEntryData;
typedef struct GinScanOpaqueData
{
#define RTOverAboveStrategyNumber 12
#define RTOldContainsStrategyNumber 13 /* for old spelling of @> */
#define RTOldContainedByStrategyNumber 14 /* for old spelling of <@ */
-#define RTKNNSearchStrategyNumber 15
+#define RTKNNSearchStrategyNumber 15
/*
* Page opaque data in a GiST index page.
BlockNumber blkno; /* index page number, or InvalidBlockNumber */
union
{
- GistNSN parentlsn; /* parent page's LSN, if index page */
+ GistNSN parentlsn; /* parent page's LSN, if index page */
/* we must store parentlsn to detect whether a split occurred */
GISTSearchHeapItem heap; /* heap info, if heap tuple */
} data;
-} GISTSearchItem;
+} GISTSearchItem;
-#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
+#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
/*
* Within a GISTSearchTreeItem's chain, heap items always appear before
/* XLog stuff */
#define XLOG_GIST_PAGE_UPDATE 0x00
-/* #define XLOG_GIST_NEW_ROOT 0x20 */ /* not used anymore */
+ /* #define XLOG_GIST_NEW_ROOT 0x20 */ /* not used anymore */
#define XLOG_GIST_PAGE_SPLIT 0x30
-/* #define XLOG_GIST_INSERT_COMPLETE 0x40 */ /* not used anymore */
+ /* #define XLOG_GIST_INSERT_COMPLETE 0x40 */ /* not used anymore */
#define XLOG_GIST_CREATE_INDEX 0x50
#define XLOG_GIST_PAGE_DELETE 0x60
* If this operation completes a page split, by inserting a downlink for
* the split page, leftchild points to the left half of the split.
*/
- BlockNumber leftchild;
+ BlockNumber leftchild;
/* number of deleted offsets */
uint16 ntodelete;
{
RelFileNode node;
BlockNumber origblkno; /* splitted page */
- BlockNumber origrlink; /* rightlink of the page before split */
+ BlockNumber origrlink; /* rightlink of the page before split */
GistNSN orignsn; /* NSN of the page before split */
bool origleaf; /* was splitted page a leaf page? */
Page page;
/*
- * log sequence number from page->lsn to recognize page update and
- * compare it with page's nsn to recognize page split
+ * log sequence number from page->lsn to recognize page update and compare
+ * it with page's nsn to recognize page split
*/
GistNSN lsn;
extern XLogRecPtr gistXLogUpdate(RelFileNode node, Buffer buffer,
OffsetNumber *todelete, int ntodelete,
- IndexTuple *itup, int ntup,
+ IndexTuple *itup, int ntup,
Buffer leftchild);
extern XLogRecPtr gistXLogSplit(RelFileNode node,
{
BufferAccessStrategy strategy; /* our BULKWRITE strategy object */
Buffer current_buf; /* current insertion target page */
-} BulkInsertStateData;
+} BulkInsertStateData;
extern void RelationPutHeapTuple(Relation relation, Buffer buffer,
HeapTuple tuple);
extern Buffer RelationGetBufferForTuple(Relation relation, Size len,
Buffer otherBuffer, int options,
- struct BulkInsertStateData *bistate);
+ struct BulkInsertStateData * bistate);
#endif /* HIO_H */
* any visibility information, so we can overlay it on a visibility flag
* instead of using up a dedicated bit.
*/
-#define HEAP_TUPLE_HAS_MATCH HEAP_ONLY_TUPLE /* tuple has a join match */
+#define HEAP_TUPLE_HAS_MATCH HEAP_ONLY_TUPLE /* tuple has a join match */
/*
* HeapTupleHeader accessor macros
typedef struct IndexAttributeBitMapData
{
bits8 bits[(INDEX_MAX_KEYS + 8 - 1) / 8];
-} IndexAttributeBitMapData;
+} IndexAttributeBitMapData;
typedef IndexAttributeBitMapData *IndexAttributeBitMap;
int rs_mindex; /* marked tuple's saved index */
int rs_ntuples; /* number of visible tuples on page */
OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; /* their offsets */
-} HeapScanDescData;
+} HeapScanDescData;
/*
* We use the same IndexScanDescData structure for both amgettuple-based
Relation indexRelation; /* index relation descriptor */
Snapshot xs_snapshot; /* snapshot to see */
int numberOfKeys; /* number of index qualifier conditions */
- int numberOfOrderBys; /* number of ordering operators */
- ScanKey keyData; /* array of index qualifier descriptors */
- ScanKey orderByData; /* array of ordering op descriptors */
+ int numberOfOrderBys; /* number of ordering operators */
+ ScanKey keyData; /* array of index qualifier descriptors */
+ ScanKey orderByData; /* array of ordering op descriptors */
/* signaling to index AM about killing index tuples */
bool kill_prior_tuple; /* last-returned tuple is dead */
bool xs_hot_dead; /* T if all members of HOT chain are dead */
OffsetNumber xs_next_hot; /* next member of HOT chain, if any */
TransactionId xs_prev_xmax; /* previous HOT chain member's XMAX, if any */
-} IndexScanDescData;
+} IndexScanDescData;
/* Struct for heap-or-index scans of system tables */
typedef struct SysScanDescData
Relation irel; /* NULL if doing heap scan */
HeapScanDesc scan; /* only valid in heap-scan case */
IndexScanDesc iscan; /* only valid in index-scan case */
-} SysScanDescData;
+} SysScanDescData;
#endif /* RELSCAN_H */
int attdim);
extern void TupleDescInitEntryCollation(TupleDesc desc,
- AttrNumber attributeNumber,
- Oid collationid);
+ AttrNumber attributeNumber,
+ Oid collationid);
extern TupleDesc BuildDescForRelation(List *schema);
typedef enum
{
- SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
- SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */
- SYNCHRONOUS_COMMIT_REMOTE_FLUSH /* wait for local and remote flush */
-} SyncCommitLevel;
+ SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
+ SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */
+ SYNCHRONOUS_COMMIT_REMOTE_FLUSH /* wait for local and remote flush */
+} SyncCommitLevel;
/* Define the default setting for synchonous_commit */
-#define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH
+#define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH
/* Synchronous commit level */
extern int synchronous_commit;
int ckpt_segs_removed; /* # of xlog segments deleted */
int ckpt_segs_recycled; /* # of xlog segments recycled */
- int ckpt_sync_rels; /* # of relations synced */
- uint64 ckpt_longest_sync; /* Longest sync for one relation */
- uint64 ckpt_agg_sync_time; /* The sum of all the individual sync
- * times, which is not necessarily the
- * same as the total elapsed time for
- * the entire sync phase. */
+ int ckpt_sync_rels; /* # of relations synced */
+ uint64 ckpt_longest_sync; /* Longest sync for one relation */
+ uint64 ckpt_agg_sync_time; /* The sum of all the individual sync
+ * times, which is not necessarily the
+ * same as the total elapsed time for
+ * the entire sync phase. */
} CheckpointStatsData;
extern CheckpointStatsData CheckpointStats;
* read those buffers except during crash recovery or if wal_level != minimal,
* it is a win to use it in all cases where we sync on each write(). We could
* allow O_DIRECT with fsync(), but it is unclear if fsync() could process
- * writes not buffered in the kernel. Also, O_DIRECT is never enough to force
+ * writes not buffered in the kernel. Also, O_DIRECT is never enough to force
* data to the drives, it merely tries to bypass the kernel cache, so we still
* need O_SYNC/O_DSYNC.
*/
extern const char *forkNames[];
extern ForkNumber forkname_to_number(char *forkName);
-extern int forkname_chars(const char *str, ForkNumber *);
+extern int forkname_chars(const char *str, ForkNumber *);
extern char *relpathbackend(RelFileNode rnode, BackendId backend,
- ForkNumber forknum);
+ ForkNumber forknum);
extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
/* First argument is a RelFileNodeBackend */
extern Oid GetNewOid(Relation relation);
extern Oid GetNewOidWithIndex(Relation relation, Oid indexId,
AttrNumber oidcolumn);
-extern Oid GetNewRelFileNode(Oid reltablespace, Relation pg_class,
+extern Oid GetNewRelFileNode(Oid reltablespace, Relation pg_class,
char relpersistence);
#endif /* CATALOG_H */
OCLASS_FOREIGN_SERVER, /* pg_foreign_server */
OCLASS_USER_MAPPING, /* pg_user_mapping */
OCLASS_DEFACL, /* pg_default_acl */
- OCLASS_EXTENSION, /* pg_extension */
+ OCLASS_EXTENSION, /* pg_extension */
MAX_OCLASS /* MUST BE LAST */
} ObjectClass;
extern void recordDependencyOnCurrentExtension(const ObjectAddress *object);
extern long deleteDependencyRecordsFor(Oid classId, Oid objectId,
- bool skipExtensionDeps);
+ bool skipExtensionDeps);
extern long deleteDependencyRecordsForClass(Oid classId, Oid objectId,
Oid refclassId, char deptype);
extern Oid LookupCreationNamespace(const char *nspname);
extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid, Oid classid,
- Oid objid);
+ Oid objid);
extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
extern RangeVar *makeRangeVarFromNameList(List *names);
extern char *NameListToString(List *names);
/*
* Object access hooks are intended to be called just before or just after
- * performing certain actions on a SQL object. This is intended as
+ * performing certain actions on a SQL object. This is intended as
* infrastructure for security or logging pluggins.
*
* OAT_POST_CREATE should be invoked just after the the object is created.
* Hook, and a macro to invoke it.
*/
-typedef void (*object_access_hook_type)(ObjectAccessType access,
- Oid classId,
- Oid objectId,
- int subId);
+typedef void (*object_access_hook_type) (ObjectAccessType access,
+ Oid classId,
+ Oid objectId,
+ int subId);
extern PGDLLIMPORT object_access_hook_type object_access_hook;
(*object_access_hook)((access),(classId),(objectId),(subId)); \
} while(0)
-#endif /* OBJECTACCESS_H */
+#endif /* OBJECTACCESS_H */
int2 amsupport; /* total number of support functions that this
* AM uses */
bool amcanorder; /* does AM support order by column value? */
- bool amcanorderbyop; /* does AM support order by operator result? */
+ bool amcanorderbyop; /* does AM support order by operator result? */
bool amcanbackward; /* does AM support backward scan? */
bool amcanunique; /* does AM support UNIQUE indexes? */
bool amcanmulticol; /* does AM support multi-column indexes? */
char amoppurpose; /* is operator for 's'earch or 'o'rdering? */
Oid amopopr; /* the operator's pg_operator OID */
Oid amopmethod; /* the index access method this entry is for */
- Oid amopsortfamily; /* ordering opfamily OID, or 0 if search op */
+ Oid amopsortfamily; /* ordering opfamily OID, or 0 if search op */
} FormData_pg_amop;
/* allowed values of amoppurpose: */
* gist box_ops
*/
-DATA(insert ( 2593 603 603 1 s 493 783 0 ));
-DATA(insert ( 2593 603 603 2 s 494 783 0 ));
-DATA(insert ( 2593 603 603 3 s 500 783 0 ));
-DATA(insert ( 2593 603 603 4 s 495 783 0 ));
-DATA(insert ( 2593 603 603 5 s 496 783 0 ));
-DATA(insert ( 2593 603 603 6 s 499 783 0 ));
-DATA(insert ( 2593 603 603 7 s 498 783 0 ));
-DATA(insert ( 2593 603 603 8 s 497 783 0 ));
-DATA(insert ( 2593 603 603 9 s 2571 783 0 ));
+DATA(insert ( 2593 603 603 1 s 493 783 0 ));
+DATA(insert ( 2593 603 603 2 s 494 783 0 ));
+DATA(insert ( 2593 603 603 3 s 500 783 0 ));
+DATA(insert ( 2593 603 603 4 s 495 783 0 ));
+DATA(insert ( 2593 603 603 5 s 496 783 0 ));
+DATA(insert ( 2593 603 603 6 s 499 783 0 ));
+DATA(insert ( 2593 603 603 7 s 498 783 0 ));
+DATA(insert ( 2593 603 603 8 s 497 783 0 ));
+DATA(insert ( 2593 603 603 9 s 2571 783 0 ));
DATA(insert ( 2593 603 603 10 s 2570 783 0 ));
DATA(insert ( 2593 603 603 11 s 2573 783 0 ));
DATA(insert ( 2593 603 603 12 s 2572 783 0 ));
* gist point_ops
*/
DATA(insert ( 1029 600 600 11 s 506 783 0 ));
-DATA(insert ( 1029 600 600 1 s 507 783 0 ));
-DATA(insert ( 1029 600 600 5 s 508 783 0 ));
+DATA(insert ( 1029 600 600 1 s 507 783 0 ));
+DATA(insert ( 1029 600 600 5 s 508 783 0 ));
DATA(insert ( 1029 600 600 10 s 509 783 0 ));
-DATA(insert ( 1029 600 600 6 s 510 783 0 ));
+DATA(insert ( 1029 600 600 6 s 510 783 0 ));
DATA(insert ( 1029 600 600 15 o 517 783 1970 ));
DATA(insert ( 1029 603 600 27 s 433 783 0 ));
DATA(insert ( 1029 600 603 28 s 511 783 0 ));
* gist poly_ops (supports polygons)
*/
-DATA(insert ( 2594 604 604 1 s 485 783 0 ));
-DATA(insert ( 2594 604 604 2 s 486 783 0 ));
-DATA(insert ( 2594 604 604 3 s 492 783 0 ));
-DATA(insert ( 2594 604 604 4 s 487 783 0 ));
-DATA(insert ( 2594 604 604 5 s 488 783 0 ));
-DATA(insert ( 2594 604 604 6 s 491 783 0 ));
-DATA(insert ( 2594 604 604 7 s 490 783 0 ));
-DATA(insert ( 2594 604 604 8 s 489 783 0 ));
-DATA(insert ( 2594 604 604 9 s 2575 783 0 ));
+DATA(insert ( 2594 604 604 1 s 485 783 0 ));
+DATA(insert ( 2594 604 604 2 s 486 783 0 ));
+DATA(insert ( 2594 604 604 3 s 492 783 0 ));
+DATA(insert ( 2594 604 604 4 s 487 783 0 ));
+DATA(insert ( 2594 604 604 5 s 488 783 0 ));
+DATA(insert ( 2594 604 604 6 s 491 783 0 ));
+DATA(insert ( 2594 604 604 7 s 490 783 0 ));
+DATA(insert ( 2594 604 604 8 s 489 783 0 ));
+DATA(insert ( 2594 604 604 9 s 2575 783 0 ));
DATA(insert ( 2594 604 604 10 s 2574 783 0 ));
DATA(insert ( 2594 604 604 11 s 2577 783 0 ));
DATA(insert ( 2594 604 604 12 s 2576 783 0 ));
* gist circle_ops
*/
-DATA(insert ( 2595 718 718 1 s 1506 783 0 ));
-DATA(insert ( 2595 718 718 2 s 1507 783 0 ));
-DATA(insert ( 2595 718 718 3 s 1513 783 0 ));
-DATA(insert ( 2595 718 718 4 s 1508 783 0 ));
-DATA(insert ( 2595 718 718 5 s 1509 783 0 ));
-DATA(insert ( 2595 718 718 6 s 1512 783 0 ));
-DATA(insert ( 2595 718 718 7 s 1511 783 0 ));
-DATA(insert ( 2595 718 718 8 s 1510 783 0 ));
-DATA(insert ( 2595 718 718 9 s 2589 783 0 ));
+DATA(insert ( 2595 718 718 1 s 1506 783 0 ));
+DATA(insert ( 2595 718 718 2 s 1507 783 0 ));
+DATA(insert ( 2595 718 718 3 s 1513 783 0 ));
+DATA(insert ( 2595 718 718 4 s 1508 783 0 ));
+DATA(insert ( 2595 718 718 5 s 1509 783 0 ));
+DATA(insert ( 2595 718 718 6 s 1512 783 0 ));
+DATA(insert ( 2595 718 718 7 s 1511 783 0 ));
+DATA(insert ( 2595 718 718 8 s 1510 783 0 ));
+DATA(insert ( 2595 718 718 9 s 2589 783 0 ));
DATA(insert ( 2595 718 718 10 s 1515 783 0 ));
DATA(insert ( 2595 718 718 11 s 1514 783 0 ));
DATA(insert ( 2595 718 718 12 s 2590 783 0 ));
bool rolcreatedb; /* allowed to create databases? */
bool rolcatupdate; /* allowed to alter catalogs manually? */
bool rolcanlogin; /* allowed to log in as session user? */
- bool rolreplication; /* role used for streaming replication */
+ bool rolreplication; /* role used for streaming replication */
int4 rolconnlimit; /* max connections allowed (-1=no limit) */
/* remaining fields may be null; use heap_getattr to read them! */
Oid reltoastidxid; /* if toast table, OID of chunk_id index */
bool relhasindex; /* T if has (or has had) any indexes */
bool relisshared; /* T if shared across databases */
- char relpersistence; /* see RELPERSISTENCE_xxx constants below */
+ char relpersistence; /* see RELPERSISTENCE_xxx constants below */
char relkind; /* see RELKIND_xxx constants below */
int2 relnatts; /* number of user attributes */
#define RELKIND_TOASTVALUE 't' /* for out-of-line values */
#define RELKIND_VIEW 'v' /* view */
#define RELKIND_COMPOSITE_TYPE 'c' /* composite type */
-#define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
+#define RELKIND_FOREIGN_TABLE 'f' /* foreign table */
#define RELKIND_UNCATALOGED 'u' /* not yet cataloged */
#define RELPERSISTENCE_PERMANENT 'p' /* regular table */
*/
#define Natts_pg_collation 6
#define Anum_pg_collation_collname 1
-#define Anum_pg_collation_collnamespace 2
+#define Anum_pg_collation_collnamespace 2
#define Anum_pg_collation_collowner 3
#define Anum_pg_collation_collencoding 4
#define Anum_pg_collation_collcollate 5
#define PG_COLLATION_FN_H
extern Oid CollationCreate(const char *collname, Oid collnamespace,
- Oid collowner,
- int32 collencoding,
- const char *collcollate, const char *collctype);
+ Oid collowner,
+ int32 collencoding,
+ const char *collcollate, const char *collctype);
extern void RemoveCollationById(Oid collationOid);
#endif /* PG_COLLATION_FN_H */
extern Oid get_constraint_oid(Oid relid, const char *conname, bool missing_ok);
extern bool check_functional_grouping(Oid relid,
- Index varno, Index varlevelsup,
- List *grouping_columns,
- List **constraintDeps);
+ Index varno, Index varlevelsup,
+ List *grouping_columns,
+ List **constraintDeps);
#endif /* PG_CONSTRAINT_H */
/*
* Oldest XID still running. This is only needed to initialize hot standby
* mode from an online checkpoint, so we only bother calculating this for
- * online checkpoints and only when wal_level is hot_standby. Otherwise it's
- * set to InvalidTransactionId.
+ * online checkpoints and only when wal_level is hot_standby. Otherwise
+ * it's set to InvalidTransactionId.
*/
TransactionId oldestActiveXid;
} CheckPoint;
#define XLOG_SWITCH 0x40
#define XLOG_BACKUP_END 0x50
#define XLOG_PARAMETER_CHANGE 0x60
-#define XLOG_RESTORE_POINT 0x70
+#define XLOG_RESTORE_POINT 0x70
/*
extern void EnumValuesCreate(Oid enumTypeOid, List *vals);
extern void EnumValuesDelete(Oid enumTypeOid);
extern void AddEnumLabel(Oid enumTypeOid, const char *newVal,
- const char *neighbor, bool newValIsAfter);
+ const char *neighbor, bool newValIsAfter);
#endif /* PG_ENUM_H */
* typedef struct FormData_pg_extension
* ----------------
*/
-#define ExtensionRelationId 3079
+#define ExtensionRelationId 3079
CATALOG(pg_extension,3079)
{
NameData extname; /* extension name */
Oid extowner; /* extension owner */
Oid extnamespace; /* namespace of contained objects */
- bool extrelocatable; /* if true, allow ALTER EXTENSION SET SCHEMA */
+ bool extrelocatable; /* if true, allow ALTER EXTENSION SET SCHEMA */
/*
* VARIABLE LENGTH FIELDS start here.
*
* extversion should never be null, but the others can be.
*/
- text extversion; /* extension version name */
- Oid extconfig[1]; /* dumpable configuration tables */
+ text extversion; /* extension version name */
+ Oid extconfig[1]; /* dumpable configuration tables */
text extcondition[1]; /* WHERE clauses for config tables */
} FormData_pg_extension;
int2 indnatts; /* number of columns in index */
bool indisunique; /* is this a unique index? */
bool indisprimary; /* is this index for primary key? */
- bool indisexclusion; /* is this index for exclusion constraint? */
+ bool indisexclusion; /* is this index for exclusion constraint? */
bool indimmediate; /* is uniqueness enforced immediately? */
bool indisclustered; /* is this the index last clustered by? */
bool indisvalid; /* is this index valid for use by queries? */
DESCR("multiply");
DATA(insert OID = 918 ( "*" PGNSP PGUID b f f 21 790 790 914 0 int2_mul_cash - - ));
DESCR("multiply");
-DATA(insert OID = 3825 ( "/" PGNSP PGUID b f f 790 790 701 0 0 cash_div_cash - - ));
+DATA(insert OID = 3825 ( "/" PGNSP PGUID b f f 790 790 701 0 0 cash_div_cash - - ));
DESCR("divide");
DATA(insert OID = 965 ( "^" PGNSP PGUID b f f 701 701 701 0 0 dpow - - ));
Oid proallargtypes[1]; /* all param types (NULL if IN only) */
char proargmodes[1]; /* parameter modes (NULL if IN only) */
text proargnames[1]; /* parameter names (NULL if no names) */
- pg_node_tree proargdefaults; /* list of expression trees for argument
- * defaults (NULL if none) */
+ pg_node_tree proargdefaults;/* list of expression trees for argument
+ * defaults (NULL if none) */
text prosrc; /* procedure source text */
text probin; /* secondary procedure info (can be NULL) */
text proconfig[1]; /* procedure-local GUC settings */
DESCR("btree(internal)");
DATA(insert OID = 972 ( btvacuumcleanup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ btvacuumcleanup _null_ _null_ _null_ ));
DESCR("btree(internal)");
-DATA(insert OID = 1268 ( btcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ btcostestimate _null_ _null_ _null_ ));
+DATA(insert OID = 1268 ( btcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ btcostestimate _null_ _null_ _null_ ));
DESCR("btree(internal)");
DATA(insert OID = 2785 ( btoptions PGNSP PGUID 12 1 0 0 f f f t f s 2 0 17 "1009 16" _null_ _null_ _null_ _null_ btoptions _null_ _null_ _null_ ));
DESCR("btree(internal)");
DESCR("hash(internal)");
DATA(insert OID = 448 ( hashbuild PGNSP PGUID 12 1 0 0 f f f t f v 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ hashbuild _null_ _null_ _null_ ));
DESCR("hash(internal)");
-DATA(insert OID = 327 ( hashbuildempty PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "2281" _null_ _null_ _null_ _null_ hashbuildempty _null_ _null_ _null_ ));
+DATA(insert OID = 327 ( hashbuildempty PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "2281" _null_ _null_ _null_ _null_ hashbuildempty _null_ _null_ _null_ ));
DESCR("hash(internal)");
DATA(insert OID = 442 ( hashbulkdelete PGNSP PGUID 12 1 0 0 f f f t f v 4 0 2281 "2281 2281 2281 2281" _null_ _null_ _null_ _null_ hashbulkdelete _null_ _null_ _null_ ));
DESCR("hash(internal)");
DATA(insert OID = 425 ( hashvacuumcleanup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ hashvacuumcleanup _null_ _null_ _null_ ));
DESCR("hash(internal)");
-DATA(insert OID = 438 ( hashcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ hashcostestimate _null_ _null_ _null_ ));
+DATA(insert OID = 438 ( hashcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ hashcostestimate _null_ _null_ _null_ ));
DESCR("hash(internal)");
DATA(insert OID = 2786 ( hashoptions PGNSP PGUID 12 1 0 0 f f f t f s 2 0 17 "1009 16" _null_ _null_ _null_ _null_ hashoptions _null_ _null_ _null_ ));
DESCR("hash(internal)");
DESCR("gist(internal)");
DATA(insert OID = 782 ( gistbuild PGNSP PGUID 12 1 0 0 f f f t f v 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ gistbuild _null_ _null_ _null_ ));
DESCR("gist(internal)");
-DATA(insert OID = 326 ( gistbuildempty PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "2281" _null_ _null_ _null_ _null_ gistbuildempty _null_ _null_ _null_ ));
+DATA(insert OID = 326 ( gistbuildempty PGNSP PGUID 12 1 0 0 f f f t f v 1 0 2278 "2281" _null_ _null_ _null_ _null_ gistbuildempty _null_ _null_ _null_ ));
DESCR("gist(internal)");
DATA(insert OID = 776 ( gistbulkdelete PGNSP PGUID 12 1 0 0 f f f t f v 4 0 2281 "2281 2281 2281 2281" _null_ _null_ _null_ _null_ gistbulkdelete _null_ _null_ _null_ ));
DESCR("gist(internal)");
DATA(insert OID = 2561 ( gistvacuumcleanup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ gistvacuumcleanup _null_ _null_ _null_ ));
DESCR("gist(internal)");
-DATA(insert OID = 772 ( gistcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ gistcostestimate _null_ _null_ _null_ ));
+DATA(insert OID = 772 ( gistcostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ gistcostestimate _null_ _null_ _null_ ));
DESCR("gist(internal)");
DATA(insert OID = 2787 ( gistoptions PGNSP PGUID 12 1 0 0 f f f t f s 2 0 17 "1009 16" _null_ _null_ _null_ _null_ gistoptions _null_ _null_ _null_ ));
DESCR("gist(internal)");
DATA(insert OID = 1799 ( oidout PGNSP PGUID 12 1 0 0 f f f t f i 1 0 2275 "26" _null_ _null_ _null_ _null_ oidout _null_ _null_ _null_ ));
DESCR("I/O");
-DATA(insert OID = 3058 ( concat PGNSP PGUID 12 1 0 2276 f f f f f s 1 0 25 "2276" "{2276}" "{v}" _null_ _null_ text_concat _null_ _null_ _null_ ));
+DATA(insert OID = 3058 ( concat PGNSP PGUID 12 1 0 2276 f f f f f s 1 0 25 "2276" "{2276}" "{v}" _null_ _null_ text_concat _null_ _null_ _null_ ));
DESCR("concatenate values");
-DATA(insert OID = 3059 ( concat_ws PGNSP PGUID 12 1 0 2276 f f f f f s 2 0 25 "25 2276" "{25,2276}" "{i,v}" _null_ _null_ text_concat_ws _null_ _null_ _null_ ));
+DATA(insert OID = 3059 ( concat_ws PGNSP PGUID 12 1 0 2276 f f f f f s 2 0 25 "25 2276" "{25,2276}" "{i,v}" _null_ _null_ text_concat_ws _null_ _null_ _null_ ));
DESCR("concatenate values with separators");
DATA(insert OID = 3060 ( left PGNSP PGUID 12 1 0 0 f f f t f i 2 0 25 "25 23" _null_ _null_ _null_ _null_ text_left _null_ _null_ _null_ ));
DESCR("extract the first n characters");
DATA(insert OID = 3061 ( right PGNSP PGUID 12 1 0 0 f f f t f i 2 0 25 "25 23" _null_ _null_ _null_ _null_ text_right _null_ _null_ _null_ ));
DESCR("extract the last n characters");
-DATA(insert OID = 3062 ( reverse PGNSP PGUID 12 1 0 0 f f f t f i 1 0 25 "25" _null_ _null_ _null_ _null_ text_reverse _null_ _null_ _null_ ));
+DATA(insert OID = 3062 ( reverse PGNSP PGUID 12 1 0 0 f f f t f i 1 0 25 "25" _null_ _null_ _null_ _null_ text_reverse _null_ _null_ _null_ ));
DESCR("reverse text");
-DATA(insert OID = 3539 ( format PGNSP PGUID 12 1 0 2276 f f f f f s 2 0 25 "25 2276" "{25,2276}" "{i,v}" _null_ _null_ text_format _null_ _null_ _null_ ));
+DATA(insert OID = 3539 ( format PGNSP PGUID 12 1 0 2276 f f f f f s 2 0 25 "25 2276" "{25,2276}" "{i,v}" _null_ _null_ text_format _null_ _null_ _null_ ));
DESCR("format text message");
DATA(insert OID = 3540 ( format PGNSP PGUID 12 1 0 0 f f f f f s 1 0 25 "25" _null_ _null_ _null_ _null_ text_format_nv _null_ _null_ _null_ ));
DESCR("format text message");
DESCR("statistics: recovery conflicts in database caused by buffer deadlock");
DATA(insert OID = 3070 ( pg_stat_get_db_conflict_all PGNSP PGUID 12 1 0 0 f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_conflict_all _null_ _null_ _null_ ));
DESCR("statistics: recovery conflicts in database");
-DATA(insert OID = 3074 ( pg_stat_get_db_stat_reset_time PGNSP PGUID 12 1 0 0 f f f t f s 1 0 1184 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_stat_reset_time _null_ _null_ _null_ ));
+DATA(insert OID = 3074 ( pg_stat_get_db_stat_reset_time PGNSP PGUID 12 1 0 0 f f f t f s 1 0 1184 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_stat_reset_time _null_ _null_ _null_ ));
DESCR("statistics: last reset for a database");
DATA(insert OID = 2769 ( pg_stat_get_bgwriter_timed_checkpoints PGNSP PGUID 12 1 0 0 f f f t f s 0 0 20 "" _null_ _null_ _null_ _null_ pg_stat_get_bgwriter_timed_checkpoints _null_ _null_ _null_ ));
DESCR("statistics: number of timed checkpoints started by the bgwriter");
DESCR("gin(internal)");
DATA(insert OID = 2740 ( ginvacuumcleanup PGNSP PGUID 12 1 0 0 f f f t f v 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ ginvacuumcleanup _null_ _null_ _null_ ));
DESCR("gin(internal)");
-DATA(insert OID = 2741 ( gincostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ gincostestimate _null_ _null_ _null_ ));
+DATA(insert OID = 2741 ( gincostestimate PGNSP PGUID 12 1 0 0 f f f t f v 9 0 2278 "2281 2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ _null_ gincostestimate _null_ _null_ _null_ ));
DESCR("gin(internal)");
DATA(insert OID = 2788 ( ginoptions PGNSP PGUID 12 1 0 0 f f f t f s 2 0 17 "1009 16" _null_ _null_ _null_ _null_ ginoptions _null_ _null_ _null_ ));
DESCR("gin(internal)");
/* GIN array support */
-DATA(insert OID = 2743 ( ginarrayextract PGNSP PGUID 12 1 0 0 f f f t f i 3 0 2281 "2277 2281 2281" _null_ _null_ _null_ _null_ ginarrayextract _null_ _null_ _null_ ));
+DATA(insert OID = 2743 ( ginarrayextract PGNSP PGUID 12 1 0 0 f f f t f i 3 0 2281 "2277 2281 2281" _null_ _null_ _null_ _null_ ginarrayextract _null_ _null_ _null_ ));
DESCR("GIN array support");
DATA(insert OID = 2774 ( ginqueryarrayextract PGNSP PGUID 12 1 0 0 f f f t f i 7 0 2281 "2277 2281 21 2281 2281 2281 2281" _null_ _null_ _null_ _null_ ginqueryarrayextract _null_ _null_ _null_ ));
DESCR("GIN array support");
DATA(insert OID = 2932 ( xpath PGNSP PGUID 14 1 0 0 f f f t f i 2 0 143 "25 142" _null_ _null_ _null_ _null_ "select pg_catalog.xpath($1, $2, ''{}''::pg_catalog.text[])" _null_ _null_ _null_ ));
DESCR("evaluate XPath expression");
-DATA(insert OID = 2614 ( xmlexists PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "25 142" _null_ _null_ _null_ _null_ xmlexists _null_ _null_ _null_ ));
+DATA(insert OID = 2614 ( xmlexists PGNSP PGUID 12 1 0 0 f f f t f i 2 0 16 "25 142" _null_ _null_ _null_ _null_ xmlexists _null_ _null_ _null_ ));
DESCR("test XML value against XPath expression");
DATA(insert OID = 3049 ( xpath_exists PGNSP PGUID 12 1 0 0 f f f t f i 3 0 16 "25 142 1009" _null_ _null_ _null_ _null_ xpath_exists _null_ _null_ _null_ ));
/* -------------------------------------------------------------------------
*
* pg_seclabel.h
- * definition of the system "security label" relation (pg_seclabel)
+ * definition of the system "security label" relation (pg_seclabel)
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
{
- Oid objoid; /* OID of the object itself */
- Oid classoid; /* OID of table containing the object */
- int4 objsubid; /* column number, or 0 if not used */
- text provider; /* name of label provider */
- text label; /* security label of the object */
+ Oid objoid; /* OID of the object itself */
+ Oid classoid; /* OID of table containing the object */
+ int4 objsubid; /* column number, or 0 if not used */
+ text provider; /* name of label provider */
+ text label; /* security label of the object */
} FormData_pg_seclabel;
/* ----------------
#define Anum_pg_seclabel_provider 4
#define Anum_pg_seclabel_label 5
-#endif /* PG_SECLABEL_H */
+#endif /* PG_SECLABEL_H */
int4 typndims;
/*
- * Collation: 0 if type cannot use collations,
- * DEFAULT_COLLATION_OID for collatable base types, possibly other
- * OID for domains
+ * Collation: 0 if type cannot use collations, DEFAULT_COLLATION_OID for
+ * collatable base types, possibly other OID for domains
*/
Oid typcollation;
* a default expression for the type. Currently this is only used for
* domains.
*/
- pg_node_tree typdefaultbin; /* VARIABLE LENGTH FIELD */
+ pg_node_tree typdefaultbin; /* VARIABLE LENGTH FIELD */
/*
* typdefault is NULL if the type has no associated default value. If
#define XMLOID 142
DATA(insert OID = 143 ( _xml PGNSP PGUID -1 f b A f t \054 0 142 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 0 _null_ _null_ ));
-DATA(insert OID = 194 ( pg_node_tree PGNSP PGUID -1 f b S f t \054 0 0 0 pg_node_tree_in pg_node_tree_out pg_node_tree_recv pg_node_tree_send - - - i x f 0 -1 0 100 _null_ _null_ ));
+DATA(insert OID = 194 ( pg_node_tree PGNSP PGUID -1 f b S f t \054 0 0 0 pg_node_tree_in pg_node_tree_out pg_node_tree_recv pg_node_tree_send - - - i x f 0 -1 0 100 _null_ _null_ ));
DESCR("string representing an internal node tree");
#define PGNODETREEOID 194
* naming
*/
extern void smgrDoPendingDeletes(bool isCommit);
-extern int smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr);
+extern int smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr);
extern void AtSubCommit_smgr(void);
extern void AtSubAbort_smgr(void);
extern void PostPrepare_smgr(void);
extern void ExecRenameStmt(RenameStmt *stmt);
extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid);
-extern Oid AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
+extern Oid AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
Oid objid, Oid nspOid,
int Anum_name, int Anum_namespace, int Anum_owner,
AclObjectKind acl_kind);
extern void AlterCollationOwner(List *name, Oid newOwnerId);
extern void AlterCollationOwner_oid(Oid collationOid, Oid newOwnerId);
extern void AlterCollationNamespace(List *name, const char *newschema);
-extern Oid AlterCollationNamespace_oid(Oid collOid, Oid newNspOid);
+extern Oid AlterCollationNamespace_oid(Oid collOid, Oid newNspOid);
#endif /* COLLATIONCMDS_H */
extern void ProcessCopyOptions(CopyState cstate, bool is_from, List *options);
extern CopyState BeginCopyFrom(Relation rel, const char *filename,
- List *attnamelist, List *options);
+ List *attnamelist, List *options);
extern void EndCopyFrom(CopyState cstate);
extern bool NextCopyFrom(CopyState cstate, ExprContext *econtext,
- Datum *values, bool *nulls, Oid *tupleOid);
+ Datum *values, bool *nulls, Oid *tupleOid);
extern bool NextCopyFromRawFields(CopyState cstate,
- char ***fields, int *nfields);
+ char ***fields, int *nfields);
extern void CopyFromErrorCallback(void *arg);
extern DestReceiver *CreateCopyDestReceiver(void);
Oid db_id;
char src_path[1]; /* VARIABLE LENGTH STRING */
/* dst_path follows src_path */
-} xl_dbase_create_rec_old;
+} xl_dbase_create_rec_old;
typedef struct xl_dbase_drop_rec_old
{
/* Records dropping of a single subdirectory incl. contents */
Oid db_id;
char dir_path[1]; /* VARIABLE LENGTH STRING */
-} xl_dbase_drop_rec_old;
+} xl_dbase_drop_rec_old;
typedef struct xl_dbase_create_rec
{
const char *newschema);
extern Oid AlterFunctionNamespace_oid(Oid procOid, Oid nspOid);
extern void ExecuteDoStmt(DoStmt *stmt);
-extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
+extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
/* commands/operatorcmds.c */
extern void DefineOperator(List *names, List *parameters);
extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
extern void AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema);
extern Oid AlterOpFamilyNamespace_oid(Oid opfamilyOid, Oid newNspOid);
-extern Oid get_am_oid(const char *amname, bool missing_ok);
-extern Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok);
-extern Oid get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
+extern Oid get_am_oid(const char *amname, bool missing_ok);
+extern Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok);
+extern Oid get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
/* commands/tsearchcmds.c */
extern void DefineTSParser(List *names, List *parameters);
extern void RemoveUserMappingById(Oid umId);
extern void CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid);
extern Datum transformGenericOptions(Oid catalogId,
- Datum oldOptions,
- List *options,
- Oid fdwvalidator);
+ Datum oldOptions,
+ List *options,
+ Oid fdwvalidator);
/* support routines in commands/define.c */
extern void ExplainSeparatePlans(ExplainState *es);
extern void ExplainPropertyList(const char *qlabel, List *data,
- ExplainState *es);
+ ExplainState *es);
extern void ExplainPropertyText(const char *qlabel, const char *value,
- ExplainState *es);
+ ExplainState *es);
extern void ExplainPropertyInteger(const char *qlabel, int value,
- ExplainState *es);
+ ExplainState *es);
extern void ExplainPropertyLong(const char *qlabel, long value,
- ExplainState *es);
+ ExplainState *es);
extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
- ExplainState *es);
+ ExplainState *es);
#endif /* EXPLAIN_H */
* installation script.
*/
extern bool creating_extension;
-extern Oid CurrentExtensionObject;
+extern Oid CurrentExtensionObject;
extern void CreateExtension(CreateExtensionStmt *stmt);
extern void RemoveExtensions(DropStmt *stmt);
extern void RemoveExtensionById(Oid extId);
-extern Oid InsertExtensionTuple(const char *extName, Oid extOwner,
+extern Oid InsertExtensionTuple(const char *extName, Oid extOwner,
Oid schemaOid, bool relocatable, const char *extVersion,
Datum extConfig, Datum extCondition,
List *requiredExtensions);
extern void AlterLanguageOwner(const char *name, Oid newOwnerId);
extern void AlterLanguageOwner_oid(Oid oid, Oid newOwnerId);
extern bool PLTemplateExists(const char *languageName);
-extern Oid get_language_oid(const char *langname, bool missing_ok);
+extern Oid get_language_oid(const char *langname, bool missing_ok);
#endif /* PROCLANG_H */
extern char *GetSecurityLabel(const ObjectAddress *object,
const char *provider);
extern void SetSecurityLabel(const ObjectAddress *object,
- const char *provider, const char *label);
+ const char *provider, const char *label);
extern void DeleteSecurityLabel(const ObjectAddress *object);
/*
*/
extern void ExecSecLabelStmt(SecLabelStmt *stmt);
-typedef void (*check_object_relabel_type)(const ObjectAddress *object,
- const char *seclabel);
+typedef void (*check_object_relabel_type) (const ObjectAddress *object,
+ const char *seclabel);
extern void register_label_provider(const char *provider,
- check_object_relabel_type hook);
+ check_object_relabel_type hook);
-#endif /* SECLABEL_H */
+#endif /* SECLABEL_H */
extern void DropTrigger(Oid relid, const char *trigname,
DropBehavior behavior, bool missing_ok);
extern void RemoveTriggerById(Oid trigOid);
-extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok);
+extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok);
extern void renametrig(Oid relid, const char *oldname, const char *newname);
bool hasDependEntry);
extern void AlterTypeNamespace(List *names, const char *newschema);
extern Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid);
-extern Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
+extern Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
bool errorOnTableType);
* type-specific typanalyze function.
*
* Note: do not assume that the data being analyzed has the same datatype
- * shown in attr, ie do not trust attr->atttypid, attlen, etc. This is
+ * shown in attr, ie do not trust attr->atttypid, attlen, etc. This is
* because some index opclasses store a different type than the underlying
* column/expression. Instead use attrtypid, attrtypmod, and attrtype for
* information about the datatype being fed to the typanalyze function.
#define EXEC_FLAG_REWIND 0x0002 /* need efficient rescan */
#define EXEC_FLAG_BACKWARD 0x0004 /* need backward scan */
#define EXEC_FLAG_MARK 0x0008 /* need mark/restore */
-#define EXEC_FLAG_SKIP_TRIGGERS 0x0010 /* skip AfterTrigger calls */
+#define EXEC_FLAG_SKIP_TRIGGERS 0x0010 /* skip AfterTrigger calls */
/*
extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
const char *attrName);
extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
- const char *attrName);
+ const char *attrName);
extern Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno,
bool *isNull);
extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
extern void EvalPlanQualInit(EPQState *epqstate, EState *estate,
Plan *subplan, List *auxrowmarks, int epqParam);
extern void EvalPlanQualSetPlan(EPQState *epqstate,
- Plan *subplan, List *auxrowmarks);
+ Plan *subplan, List *auxrowmarks);
extern void EvalPlanQualSetTuple(EPQState *epqstate, Index rti,
HeapTuple tuple);
extern HeapTuple EvalPlanQualGetTuple(EPQState *epqstate, Index rti);
Oid inputCollation);
extern void sql_fn_parser_setup(struct ParseState *pstate,
- SQLFunctionParseInfoPtr pinfo);
+ SQLFunctionParseInfoPtr pinfo);
extern bool check_sql_fn_retval(Oid func_id, Oid rettype,
List *queryTreeList,
struct HashJoinTupleData *next; /* link to next tuple in same bucket */
uint32 hashvalue; /* tuple's hash code */
/* Tuple data, in MinimalTuple format, follows on a MAXALIGN boundary */
-} HashJoinTupleData;
+} HashJoinTupleData;
#define HJTUPLE_OVERHEAD MAXALIGN(sizeof(HashJoinTupleData))
#define HJTUPLE_MINTUPLE(hjtup) \
MemoryContext hashCxt; /* context for whole-hash-join storage */
MemoryContext batchCxt; /* context for this-batch-only storage */
-} HashJoinTableData;
+} HashJoinTableData;
#endif /* HASHJOIN_H */
extern void ExecReScanHash(HashState *node);
extern HashJoinTable ExecHashTableCreate(Hash *node, List *hashOperators,
- bool keepNulls);
+ bool keepNulls);
extern void ExecHashTableDestroy(HashJoinTable hashtable);
extern void ExecHashTableInsert(HashJoinTable hashtable,
TupleTableSlot *slot,
extern bool ExecScanHashBucket(HashJoinState *hjstate, ExprContext *econtext);
extern void ExecPrepHashTableForUnmatched(HashJoinState *hjstate);
extern bool ExecScanHashTableForUnmatched(HashJoinState *hjstate,
- ExprContext *econtext);
+ ExprContext *econtext);
extern void ExecHashTableReset(HashJoinTable hashtable);
extern void ExecHashTableResetMatchFlags(HashJoinTable hashtable);
extern void ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
/* The same, but passing a collation to use */
extern Datum DirectFunctionCall1WithCollation(PGFunction func, Oid collation,
- Datum arg1);
+ Datum arg1);
extern Datum DirectFunctionCall2WithCollation(PGFunction func, Oid collation,
- Datum arg1, Datum arg2);
+ Datum arg1, Datum arg2);
/* These are for invocation of a previously-looked-up function with a
* directly-computed parameter list. Note that neither arguments nor result
* We allow plugin modules to hook function entry/exit. This is intended
* as support for loadable security policy modules, which may want to
* perform additional privilege checks on function entry or exit, or to do
- * other internal bookkeeping. To make this possible, such modules must be
+ * other internal bookkeeping. To make this possible, such modules must be
* able not only to support normal function entry and exit, but also to trap
* the case where we bail out due to an error; and they must also be able to
* prevent inlining.
FHET_ABORT
} FmgrHookEventType;
-typedef bool (*needs_fmgr_hook_type)(Oid fn_oid);
+typedef bool (*needs_fmgr_hook_type) (Oid fn_oid);
-typedef void (*fmgr_hook_type)(FmgrHookEventType event,
- FmgrInfo *flinfo, Datum *arg);
+typedef void (*fmgr_hook_type) (FmgrHookEventType event,
+ FmgrInfo *flinfo, Datum *arg);
-extern PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook;
-extern PGDLLIMPORT fmgr_hook_type fmgr_hook;
+extern PGDLLIMPORT needs_fmgr_hook_type needs_fmgr_hook;
+extern PGDLLIMPORT fmgr_hook_type fmgr_hook;
#define FmgrHookIsNeeded(fn_oid) \
(!needs_fmgr_hook ? false : (*needs_fmgr_hook)(fn_oid))
NodeTag type;
/*
- * Cost estimation info. The startup_cost is time before retrieving
- * the first row, so it should include costs of connecting to the remote
- * host, sending over the query, etc. Note that PlanForeignScan also
- * ought to set baserel->rows and baserel->width if it can produce any
- * usable estimates of those values.
+ * Cost estimation info. The startup_cost is time before retrieving the
+ * first row, so it should include costs of connecting to the remote host,
+ * sending over the query, etc. Note that PlanForeignScan also ought to
+ * set baserel->rows and baserel->width if it can produce any usable
+ * estimates of those values.
*/
Cost startup_cost; /* cost expended before fetching any tuples */
Cost total_cost; /* total cost (assuming all tuples fetched) */
/*
* FDW private data, which will be available at execution time.
*
- * Note that everything in this list must be copiable by copyObject().
- * One way to store an arbitrary blob of bytes is to represent it as a
- * bytea Const. Usually, though, you'll be better off choosing a
- * representation that can be dumped usefully by nodeToString().
+ * Note that everything in this list must be copiable by copyObject(). One
+ * way to store an arbitrary blob of bytes is to represent it as a bytea
+ * Const. Usually, though, you'll be better off choosing a representation
+ * that can be dumped usefully by nodeToString().
*/
List *fdw_private;
} FdwPlan;
* Callback function signatures --- see fdwhandler.sgml for more info.
*/
-typedef FdwPlan * (*PlanForeignScan_function) (Oid foreigntableid,
- PlannerInfo *root,
- RelOptInfo *baserel);
+typedef FdwPlan *(*PlanForeignScan_function) (Oid foreigntableid,
+ PlannerInfo *root,
+ RelOptInfo *baserel);
typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
- struct ExplainState *es);
+ struct ExplainState *es);
typedef void (*BeginForeignScan_function) (ForeignScanState *node,
- int eflags);
+ int eflags);
-typedef TupleTableSlot * (*IterateForeignScan_function) (ForeignScanState *node);
+typedef TupleTableSlot *(*IterateForeignScan_function) (ForeignScanState *node);
typedef void (*ReScanForeignScan_function) (ForeignScanState *node);
bool missing_ok);
extern ForeignTable *GetForeignTable(Oid relid);
-extern Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok);
-extern Oid get_foreign_server_oid(const char *servername, bool missing_ok);
+extern Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok);
+extern Oid get_foreign_server_oid(const char *servername, bool missing_ok);
#endif /* FOREIGN_H */
extern void ClientAuthentication(Port *port);
/* Hook for plugins to get control in ClientAuthentication() */
-typedef void (*ClientAuthentication_hook_type)(Port *, int);
+typedef void (*ClientAuthentication_hook_type) (Port *, int);
extern PGDLLIMPORT ClientAuthentication_hook_type ClientAuthentication_hook;
#endif /* AUTH_H */
SockAddr laddr; /* local addr (postmaster) */
SockAddr raddr; /* remote addr (client) */
char *remote_host; /* name (or ip addr) of remote host */
- char *remote_hostname; /* name (not ip addr) of remote host, if available */
- int remote_hostname_resolv; /* +1 = remote_hostname is known to resolve to client's IP address;
- -1 = remote_hostname is known NOT to resolve to client's IP address;
- 0 = we have not done the forward DNS lookup yet */
+ char *remote_hostname;/* name (not ip addr) of remote host, if
+ * available */
+ int remote_hostname_resolv; /* +1 = remote_hostname is known to
+ * resolve to client's IP address; -1
+ * = remote_hostname is known NOT to
+ * resolve to client's IP address; 0 =
+ * we have not done the forward DNS
+ * lookup yet */
char *remote_port; /* text rep of remote port */
CAC_state canAcceptConnections; /* postmaster connection status */
extern int pq_putbytes(const char *s, size_t len);
extern int pq_flush(void);
extern int pq_flush_if_writable(void);
-extern bool pq_is_send_pending(void);
+extern bool pq_is_send_pending(void);
extern int pq_putmessage(char msgtype, const char *s, size_t len);
extern void pq_putmessage_noblock(char msgtype, const char *s, size_t len);
extern void pq_startcopyout(void);
List *es_subplanstates; /* List of PlanState for SubPlans */
- List *es_auxmodifytables; /* List of secondary ModifyTableStates */
+ List *es_auxmodifytables; /* List of secondary ModifyTableStates */
/*
* this ExprContext is for per-output-tuple operations, such as constraint
TupleTableSlot *inputslot; /* current input tuple's slot */
FmgrInfo *in_hash_funcs; /* hash functions for input datatype(s) */
FmgrInfo *cur_eq_funcs; /* equality functions for input vs. table */
-} TupleHashTableData;
+} TupleHashTableData;
typedef HASH_SEQ_STATUS TupleHashIterator;
TupleHashTable hashnulls; /* hash table for rows with null(s) */
bool havehashrows; /* TRUE if hashtable is not empty */
bool havenullrows; /* TRUE if hashnulls is not empty */
- MemoryContext hashtablecxt; /* memory context containing hash tables */
+ MemoryContext hashtablecxt; /* memory context containing hash tables */
MemoryContext hashtempcxt; /* temp memory context for hash tables */
ExprContext *innerecontext; /* econtext for computing inner tuples */
AttrNumber *keyColIdx; /* control data for hash tables */
PlanState **mt_plans; /* subplans (one per target rel) */
int mt_nplans; /* number of plans in the array */
int mt_whichplan; /* which one is being executed (0..n-1) */
- ResultRelInfo *resultRelInfo; /* per-subplan target relations */
+ ResultRelInfo *resultRelInfo; /* per-subplan target relations */
List **mt_arowmarks; /* per-subplan ExecAuxRowMark lists */
EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
bool fireBSTriggers; /* do we need to fire stmt triggers? */
int ms_nkeys;
ScanKey ms_scankeys; /* array of length ms_nkeys */
TupleTableSlot **ms_slots; /* array of length ms_nplans */
- int *ms_heap; /* array of length ms_nplans */
+ int *ms_heap; /* array of length ms_nplans */
int ms_heap_size; /* current active length of ms_heap[] */
- bool ms_initialized; /* are subplans started? */
+ bool ms_initialized; /* are subplans started? */
int ms_last_slot; /* last subplan slot we returned from */
} MergeAppendState;
Index varlevelsup);
extern Var *makeVarFromTargetEntry(Index varno,
- TargetEntry *tle);
+ TargetEntry *tle);
extern Var *makeWholeRowVar(RangeTblEntry *rte,
Index varno,
extern Alias *makeAlias(const char *aliasname, List *colnames);
extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod,
- Oid rcollid, CoercionForm rformat);
+ Oid rcollid, CoercionForm rformat);
extern RangeVar *makeRangeVar(char *schemaname, char *relname, int location);
void *parserSetupArg;
int numParams; /* number of ParamExternDatas following */
ParamExternData params[1]; /* VARIABLE LENGTH ARRAY */
-} ParamListInfoData;
+} ParamListInfoData;
/* ----------------
Node *setOperations; /* set-operation tree if this is top level of
* a UNION/INTERSECT/EXCEPT query */
- List *constraintDeps; /* a list of pg_constraint OIDs that the query
+ List *constraintDeps; /* a list of pg_constraint OIDs that the query
* depends on to be semantically valid */
} Query;
* Fields valid for a function RTE (else NULL):
*
* If the function returns RECORD, funccoltypes lists the column types
- * declared in the RTE's column type specification, funccoltypmods
- * lists their declared typmods, funccolcollations their collations.
- * Otherwise, those fields are NIL.
+ * declared in the RTE's column type specification, funccoltypmods lists
+ * their declared typmods, funccolcollations their collations. Otherwise,
+ * those fields are NIL.
*/
Node *funcexpr; /* expression tree for func call */
List *funccoltypes; /* OID list of column type OIDs */
List *funccoltypmods; /* integer list of column typmods */
- List *funccolcollations; /* OID list of column collation OIDs */
+ List *funccolcollations; /* OID list of column collation OIDs */
/*
* Fields valid for a values RTE (else NIL):
bool self_reference; /* is this a recursive self-reference? */
List *ctecoltypes; /* OID list of column type OIDs */
List *ctecoltypmods; /* integer list of column typmods */
- List *ctecolcollations; /* OID list of column collation OIDs */
+ List *ctecolcollations; /* OID list of column collation OIDs */
/*
* Fields valid in all RTEs:
* here, but it's cheap to get it along with the sortop, and requiring it
* to be valid eases comparisons to grouping items.) Note that this isn't
* actually enough information to determine an ordering: if the sortop is
- * collation-sensitive, a collation OID is needed too. We don't store the
+ * collation-sensitive, a collation OID is needed too. We don't store the
* collation in SortGroupClause because it's not available at the time the
* parser builds the SortGroupClause; instead, consult the exposed collation
* of the referenced targetlist expression to find out what it is.
List *ctecolnames; /* list of output column names */
List *ctecoltypes; /* OID list of output column type OIDs */
List *ctecoltypmods; /* integer list of output column typmods */
- List *ctecolcollations; /* OID list of column collation OIDs */
+ List *ctecolcollations; /* OID list of column collation OIDs */
} CommonTableExpr;
/* Convenience macro to get the output tlist of a CTE's query */
typedef enum ObjectType
{
OBJECT_AGGREGATE,
- OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
+ OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
OBJECT_CAST,
OBJECT_COLUMN,
OBJECT_CONSTRAINT,
*
* This represents creation of an index and/or an associated constraint.
* If indexOid isn't InvalidOid, we are not creating an index, just a
- * UNIQUE/PKEY constraint using an existing index. isconstraint must always
+ * UNIQUE/PKEY constraint using an existing index. isconstraint must always
* be true in this case, and the fields describing the index properties are
* empty.
* ----------------------
NodeTag type;
List *typeName; /* qualified name (list of Value strings) */
char *newVal; /* new enum value's name */
- char *newValNeighbor; /* neighboring enum value, if specified */
- bool newValIsAfter; /* place new enum value after neighbor? */
+ char *newValNeighbor; /* neighboring enum value, if specified */
+ bool newValIsAfter; /* place new enum value after neighbor? */
} AlterEnumStmt;
/* ----------------------
/*
* forthree -
- * the same for three lists
+ * the same for three lists
*/
#define forthree(cell1, list1, cell2, list2, cell3, list3) \
for ((cell1) = list_head(list1), (cell2) = list_head(list2), (cell3) = list_head(list3); \
CmdType operation; /* INSERT, UPDATE, or DELETE */
bool canSetTag; /* do we set the command tag/es_processed? */
List *resultRelations; /* integer list of RT indexes */
- int resultRelIndex; /* index of first resultRel in plan's list */
+ int resultRelIndex; /* index of first resultRel in plan's list */
List *plans; /* plan(s) producing source data */
List *returningLists; /* per-target-table RETURNING tlists */
List *rowMarks; /* PlanRowMarks (non-locking only) */
* that are being implemented by the index, while indexorderby is modified to
* have index column Vars on the left-hand side. Here, multiple expressions
* must appear in exactly the ORDER BY order, and this is not necessarily the
- * index column order. Only the expressions are provided, not the auxiliary
+ * index column order. Only the expressions are provided, not the auxiliary
* sort-order information from the ORDER BY SortGroupClauses; it's assumed
* that the sort ordering is fully determinable from the top-level operators.
* indexorderbyorig is unused at run time, but is needed for EXPLAIN.
Oid indexid; /* OID of index to scan */
List *indexqual; /* list of index quals (usually OpExprs) */
List *indexqualorig; /* the same in original form */
- List *indexorderby; /* list of index ORDER BY exprs */
- List *indexorderbyorig; /* the same in original form */
+ List *indexorderby; /* list of index ORDER BY exprs */
+ List *indexorderbyorig; /* the same in original form */
ScanDirection indexorderdir; /* forward or backward or don't care */
} IndexScan;
List *funccolnames; /* output column names (string Value nodes) */
List *funccoltypes; /* OID list of column type OIDs */
List *funccoltypmods; /* integer list of column typmods */
- List *funccolcollations; /* OID list of column collation OIDs */
+ List *funccolcollations; /* OID list of column collation OIDs */
} FunctionScan;
/* ----------------
char *relname; /* the relation/sequence name */
InhOption inhOpt; /* expand rel by inheritance? recursively act
* on children? */
- char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
+ char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
Alias *alias; /* table alias & optional column aliases */
int location; /* token location, or -1 if unknown */
} RangeVar;
/* Extra data useful for determining subplan's output type: */
Oid firstColType; /* Type of first column of subplan result */
int32 firstColTypmod; /* Typmod of first column of subplan result */
- Oid firstColCollation; /* Collation of first column of subplan result */
+ Oid firstColCollation; /* Collation of first column of
+ * subplan result */
/* Information about execution strategy: */
bool useHashTable; /* TRUE to store subselect output in a hash
* table (implies we are doing "IN") */
{
Expr xpr;
Oid coalescetype; /* type of expression result */
- Oid coalescecollid; /* OID of collation, or InvalidOid if none */
+ Oid coalescecollid; /* OID of collation, or InvalidOid if none */
List *args; /* the arguments */
int location; /* token location, or -1 if unknown */
} CoalesceExpr;
* 'args' carries all other arguments.
*
* Note: result type/typmod/collation are not stored, but can be deduced
- * from the XmlExprOp. The type/typmod fields are just used for display
+ * from the XmlExprOp. The type/typmod fields are just used for display
* purposes, and are NOT the true result type of the node.
*/
typedef enum XmlExprOp
struct Plan *non_recursive_plan; /* plan for non-recursive term */
/* These fields are workspace for createplan.c */
- Relids curOuterRels; /* outer rels above current node */
- List *curOuterParams; /* not-yet-assigned NestLoopParams */
+ Relids curOuterRels; /* outer rels above current node */
+ List *curOuterParams; /* not-yet-assigned NestLoopParams */
/* optional private data for join_search_hook, e.g., GEQO */
void *join_search_private;
bool predOK; /* true if predicate matches query */
bool unique; /* true if a unique index */
bool hypothetical; /* true if index doesn't really exist */
- bool amcanorderbyop; /* does AM support order by operator result? */
+ bool amcanorderbyop; /* does AM support order by operator result? */
bool amoptionalkey; /* can query omit key for the first column? */
bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
bool amhasgettuple; /* does AM have amgettuple interface? */
* equal to each other, where "equal" is according to the rules of the btree
* operator family(s) shown in ec_opfamilies, as well as the collation shown
* by ec_collation. (We restrict an EC to contain only equalities whose
- * operators belong to the same set of opfamilies. This could probably be
+ * operators belong to the same set of opfamilies. This could probably be
* relaxed, but for now it's not worth the trouble, since nearly all equality
* operators belong to only one btree opclass anyway. Similarly, we suppose
* that all or none of the input datatypes are collatable, so that a single
* to do so for Param slots. Duplicate detection is actually *necessary*
* in the case of NestLoop parameters since it serves to match up the usage
* of a Param (in the inner scan) with the assignment of the value (in the
- * NestLoop node). This might result in the same PARAM_EXEC slot being used
+ * NestLoop node). This might result in the same PARAM_EXEC slot being used
* by multiple NestLoop nodes or SubPlan nodes, but no harm is done since
* the same value would be assigned anyway.
*/
CONSTRAINT_EXCLUSION_OFF, /* do not use c_e */
CONSTRAINT_EXCLUSION_ON, /* apply c_e to all rels */
CONSTRAINT_EXCLUSION_PARTITION /* apply c_e to otherrels only */
-} ConstraintExclusionType;
+} ConstraintExclusionType;
/*
List *tidquals);
extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths);
extern MergeAppendPath *create_merge_append_path(PlannerInfo *root,
- RelOptInfo *rel,
- List *subpaths,
- List *pathkeys);
+ RelOptInfo *rel,
+ List *subpaths,
+ List *pathkeys);
extern ResultPath *create_result_path(List *quals);
extern MaterialPath *create_material_path(RelOptInfo *rel, Path *subpath);
extern UniquePath *create_unique_path(PlannerInfo *root, RelOptInfo *rel,
extern bool process_equivalence(PlannerInfo *root, RestrictInfo *restrictinfo,
bool below_outer_join);
extern Expr *canonicalize_ec_expression(Expr *expr,
- Oid req_type, Oid req_collation);
+ Oid req_type, Oid req_collation);
extern void reconsider_outer_join_clauses(PlannerInfo *root);
extern EquivalenceClass *get_eclass_for_sort_expr(PlannerInfo *root,
Expr *expr,
List *tlist,
bool canonicalize);
extern void initialize_mergeclause_eclasses(PlannerInfo *root,
- RestrictInfo *restrictinfo);
+ RestrictInfo *restrictinfo);
extern void update_mergeclause_eclasses(PlannerInfo *root,
- RestrictInfo *restrictinfo);
+ RestrictInfo *restrictinfo);
extern List *find_mergeclauses_for_pathkeys(PlannerInfo *root,
List *pathkeys,
bool outer_keys,
PlaceHolderVar *phv);
extern void find_placeholders_in_jointree(PlannerInfo *root);
extern void update_placeholder_eval_levels(PlannerInfo *root,
- SpecialJoinInfo *new_sjinfo);
+ SpecialJoinInfo *new_sjinfo);
extern void fix_placeholder_input_needed_levels(PlannerInfo *root);
extern void add_placeholders_to_base_rels(PlannerInfo *root);
extern void add_placeholders_to_joinrel(PlannerInfo *root,
extern void SS_finalize_plan(PlannerInfo *root, Plan *plan,
bool attach_initplans);
extern Param *SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan,
- Oid resulttype, int32 resulttypmod, Oid resultcollation);
+ Oid resulttype, int32 resulttypmod, Oid resultcollation);
extern Param *assign_nestloop_param(PlannerInfo *root, Var *var);
extern int SS_assign_special_param(PlannerInfo *root);
extern void assign_expr_collations(ParseState *pstate, Node *expr);
-extern Oid select_common_collation(ParseState *pstate, List *exprs, bool none_ok);
+extern Oid select_common_collation(ParseState *pstate, List *exprs, bool none_ok);
#endif /* PARSE_COLLATE_H */
int nsupers; /* number of superclasses */
Oid self; /* this class */
Oid *supervec; /* vector of superclasses */
-} InhPaths;
+} InhPaths;
/* Result codes for func_get_detail */
typedef enum
int32 *typmod_p);
extern Type typenameType(ParseState *pstate, const TypeName *typeName,
int32 *typmod_p);
-extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName);
+extern Oid typenameTypeId(ParseState *pstate, const TypeName *typeName);
extern void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName,
- Oid *typeid_p, int32 *typmod_p);
+ Oid *typeid_p, int32 *typmod_p);
extern char *TypeNameToString(const TypeName *typeName);
extern char *TypeNameListToString(List *typenames);
-extern Oid LookupCollation(ParseState *pstate, List *collnames, int location);
-extern Oid GetColumnDefCollation(ParseState *pstate, ColumnDef *coldef, Oid typeOid);
+extern Oid LookupCollation(ParseState *pstate, List *collnames, int location);
+extern Oid GetColumnDefCollation(ParseState *pstate, ColumnDef *coldef, Oid typeOid);
extern Type typeidType(Oid id);
BACKSLASH_QUOTE_OFF,
BACKSLASH_QUOTE_ON,
BACKSLASH_QUOTE_SAFE_ENCODING
-} BackslashQuoteType;
+} BackslashQuoteType;
/* GUC variables in scan.l (every one of these is a bad idea :-() */
extern int backslash_quote;
TRACK_FUNC_OFF,
TRACK_FUNC_PL,
TRACK_FUNC_ALL
-} TrackFunctionsLevel;
+} TrackFunctionsLevel;
/* ----------
* The types of backend -> collector messages
Oid st_databaseid;
Oid st_userid;
SockAddr st_clientaddr;
- char *st_clienthostname; /* MUST be null-terminated */
+ char *st_clienthostname; /* MUST be null-terminated */
/* Is backend currently waiting on an lmgr lock? */
bool st_waiting;
#define WIN32_ONLY_COMPILER
#endif
-/*
- * Make sure _WIN32_WINNT has the minumum required value.
+/*
+ * Make sure _WIN32_WINNT has the minumum required value.
* Leave a higher value in place.
*/
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0501
#undef ERROR
-/*
+/*
* The Mingw64 headers choke if this is already defined - they
* define it themselves.
*/
/* see also S_IRGRP etc below */
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif /* __BORLANDC__ */
+#endif /* __BORLANDC__ */
#define F_OK 0
#define W_OK 2
#define _O_SHORT_LIVED O_SHORT_LIVED
#endif /* ifndef O_RANDOM */
#endif /* __BORLANDC__ */
-
-#endif /* WIN32_ONLY_COMPILER */
+#endif /* WIN32_ONLY_COMPILER */
/* These aren't provided by either MingW or MSVC */
#ifndef __BORLANDC__
#define S_IWOTH 0
#define S_IXOTH 0
#define S_IRWXO 0
-#endif /* __BORLANDC__ */
+
+#endif /* __BORLANDC__ */
typedef struct IdentifySystemCmd
{
NodeTag type;
-} IdentifySystemCmd;
+} IdentifySystemCmd;
/* ----------------------
{
NodeTag type;
List *options;
-} BaseBackupCmd;
+} BaseBackupCmd;
/* ----------------------
{
NodeTag type;
XLogRecPtr startpoint;
-} StartReplicationCmd;
+} StartReplicationCmd;
#endif /* REPLNODES_H */
extern void SyncRepUpdateSyncStandbysDefined(void);
/* called by various procs */
-extern int SyncRepWakeQueue(bool all);
+extern int SyncRepWakeQueue(bool all);
extern bool check_synchronous_standby_names(char **newval, void **extra, GucSource source);
#endif /* _SYNCREP_H */
typedef struct
{
/*
- * The xlog locations that have been written, flushed, and applied
- * by standby-side. These may be invalid if the standby-side is unable
- * to or chooses not to report these.
+ * The xlog locations that have been written, flushed, and applied by
+ * standby-side. These may be invalid if the standby-side is unable to or
+ * chooses not to report these.
*/
XLogRecPtr write;
XLogRecPtr flush;
{
/*
* The current xmin and epoch from the standby, for Hot Standby feedback.
- * This may be invalid if the standby-side does not support feedback,
- * or Hot Standby is not yet available.
+ * This may be invalid if the standby-side does not support feedback, or
+ * Hot Standby is not yet available.
*/
- TransactionId xmin;
- uint32 epoch;
+ TransactionId xmin;
+ uint32 epoch;
/* Sender's system clock at the time of transmission */
TimestampTz sendTime;
#include "pgtime.h"
extern bool am_walreceiver;
-extern int wal_receiver_status_interval;
+extern int wal_receiver_status_interval;
extern bool hot_standby_feedback;
/*
pg_time_t startTime;
/*
- * receiveStart is the first byte position that will be received.
- * When startup process starts the walreceiver, it sets receiveStart
- * to the point where it wants the streaming to begin.
+ * receiveStart is the first byte position that will be received. When
+ * startup process starts the walreceiver, it sets receiveStart to the
+ * point where it wants the streaming to begin.
*/
XLogRecPtr receiveStart;
/*
* receivedUpto-1 is the last byte position that has already been
- * received. At the first startup of walreceiver, receivedUpto is
- * set to receiveStart. After that, walreceiver updates this whenever
- * it flushes the received WAL to disk.
+ * received. At the first startup of walreceiver, receivedUpto is set to
+ * receiveStart. After that, walreceiver updates this whenever it flushes
+ * the received WAL to disk.
*/
XLogRecPtr receivedUpto;
WALSNDSTATE_BACKUP,
WALSNDSTATE_CATCHUP,
WALSNDSTATE_STREAMING
-} WalSndState;
+} WalSndState;
/*
* Each walsender has a WalSnd struct in shared memory.
XLogRecPtr sentPtr; /* WAL has been sent up to this point */
/*
- * The xlog locations that have been written, flushed, and applied
- * by standby-side. These may be invalid if the standby-side has not
- * offered values yet.
+ * The xlog locations that have been written, flushed, and applied by
+ * standby-side. These may be invalid if the standby-side has not offered
+ * values yet.
*/
XLogRecPtr write;
XLogRecPtr flush;
slock_t mutex;
/*
- * Latch used by backends to wake up this walsender when it has work
- * to do.
+ * Latch used by backends to wake up this walsender when it has work to
+ * do.
*/
Latch latch;
/*
- * The priority order of the standby managed by this WALSender, as
- * listed in synchronous_standby_names, or 0 if not-listed.
- * Protected by SyncRepLock.
+ * The priority order of the standby managed by this WALSender, as listed
+ * in synchronous_standby_names, or 0 if not-listed. Protected by
+ * SyncRepLock.
*/
- int sync_standby_priority;
+ int sync_standby_priority;
} WalSnd;
extern WalSnd *MyWalSnd;
/*
* Synchronous replication queue. Protected by SyncRepLock.
*/
- SHM_QUEUE SyncRepQueue;
+ SHM_QUEUE SyncRepQueue;
/*
- * Current location of the head of the queue. All waiters should have
- * a waitLSN that follows this value. Protected by SyncRepLock.
+ * Current location of the head of the queue. All waiters should have a
+ * waitLSN that follows this value. Protected by SyncRepLock.
*/
XLogRecPtr lsn;
extern void SetRelationRuleStatus(Oid relationId, bool relHasRules,
bool relIsBecomingView);
-extern Oid get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok);
-extern Oid get_rewrite_oid_without_relid(const char *rulename, Oid *relid);
+extern Oid get_rewrite_oid(Oid relid, const char *rulename, bool missing_ok);
+extern Oid get_rewrite_oid_without_relid(const char *rulename, Oid *relid);
#endif /* REWRITESUPPORT_H */
#define InvalidBackendId (-1)
-extern PGDLLIMPORT BackendId MyBackendId; /* backend id of this backend */
+extern PGDLLIMPORT BackendId MyBackendId; /* backend id of this backend */
#endif /* BACKENDID_H */
#define BM_JUST_DIRTIED (1 << 5) /* dirtied since write started */
#define BM_PIN_COUNT_WAITER (1 << 6) /* have waiter for sole pin */
#define BM_CHECKPOINT_NEEDED (1 << 7) /* must write for checkpoint */
-#define BM_PERMANENT (1 << 8) /* permanent relation (not unlogged) */
+#define BM_PERMANENT (1 << 8) /* permanent relation (not
+ * unlogged) */
typedef bits16 BufFlags;
*/
typedef struct
{
- sig_atomic_t is_set;
- bool is_shared;
- int owner_pid;
+ sig_atomic_t is_set;
+ bool is_shared;
+ int owner_pid;
#ifdef WIN32
- HANDLE event;
+ HANDLE event;
#endif
} Latch;
extern void OwnLatch(volatile Latch *latch);
extern void DisownLatch(volatile Latch *latch);
extern bool WaitLatch(volatile Latch *latch, long timeout);
-extern int WaitLatchOrSocket(volatile Latch *latch, pgsocket sock,
+extern int WaitLatchOrSocket(volatile Latch *latch, pgsocket sock,
bool forRead, bool forWrite, long timeout);
extern void SetLatch(volatile Latch *latch);
extern void ResetLatch(volatile Latch *latch);
+
#define TestLatch(latch) (((volatile Latch *) latch)->is_set)
/*
PMSIGNAL_START_AUTOVAC_LAUNCHER, /* start an autovacuum launcher */
PMSIGNAL_START_AUTOVAC_WORKER, /* start an autovacuum worker */
PMSIGNAL_START_WALRECEIVER, /* start a walreceiver */
- PMSIGNAL_ADVANCE_STATE_MACHINE, /* advance postmaster's state machine */
+ PMSIGNAL_ADVANCE_STATE_MACHINE, /* advance postmaster's state machine */
NUM_PMSIGNALS /* Must be last value of enum! */
} PMSignalReason;
{
SHM_QUEUE link;
SERIALIZABLEXACT sxact;
-} PredXactListElementData;
+} PredXactListElementData;
typedef struct PredXactListElementData *PredXactListElement;
SERIALIZABLEXACT *OldCommittedSxact; /* shared copy of dummy sxact */
PredXactListElement element;
-} PredXactListData;
+} PredXactListData;
typedef struct PredXactListData *PredXactList;
SHM_QUEUE inLink; /* link for list of conflicts in to a sxact */
SERIALIZABLEXACT *sxactOut;
SERIALIZABLEXACT *sxactIn;
-} RWConflictData;
+} RWConflictData;
typedef struct RWConflictData *RWConflict;
{
SHM_QUEUE availableList;
RWConflict element;
-} RWConflictPoolHeaderData;
+} RWConflictPoolHeaderData;
typedef struct RWConflictPoolHeaderData *RWConflictPoolHeader;
* version, before the reading transaction is obsolete, we need some way to
* prevent errors from reuse of a tuple ID. Rather than attempting to clean
* up the targets as the related tuples are pruned or vacuumed, we check the
- * xmin on access. This should be far less costly.
+ * xmin on access. This should be far less costly.
*/
typedef struct PREDICATELOCKTARGET PREDICATELOCKTARGET;
PREDLOCKTAG_PAGE,
PREDLOCKTAG_TUPLE
/* TODO SSI: Other types may be needed for index locking */
-} PredicateLockTargetType;
+} PredicateLockTargetType;
/*
{
TWOPHASEPREDICATERECORD_XACT,
TWOPHASEPREDICATERECORD_LOCK
-} TwoPhasePredicateRecordType;
+} TwoPhasePredicateRecordType;
/*
* Per-transaction information to reconstruct a SERIALIZABLEXACT. Not
* syncRepState must not be touched except by owning process or WALSender.
* syncRepLinks used only while holding SyncRepLock.
*/
- Latch waitLatch; /* allow us to wait for sync rep */
- XLogRecPtr waitLSN; /* waiting for this LSN or higher */
- int syncRepState; /* wait state for sync rep */
- SHM_QUEUE syncRepLinks; /* list link if process is in syncrep queue */
+ Latch waitLatch; /* allow us to wait for sync rep */
+ XLogRecPtr waitLSN; /* waiting for this LSN or higher */
+ int syncRepState; /* wait state for sync rep */
+ SHM_QUEUE syncRepLinks; /* list link if process is in syncrep queue */
/*
* All PROCLOCK objects for locks held or awaited by this backend are
extern VirtualTransactionId *GetConflictingVirtualXIDs(TransactionId limitXmin, Oid dbOid);
extern pid_t CancelVirtualTransaction(VirtualTransactionId vxid, ProcSignalReason sigmode);
-extern bool MinimumActiveBackends(int min);
+extern bool MinimumActiveBackends(int min);
extern int CountDBBackends(Oid databaseid);
extern void CancelDBBackends(Oid databaseid, ProcSignalReason sigmode, bool conflictPending);
extern int CountUserBackends(Oid roleid);
MAIN_FORKNUM = 0,
FSM_FORKNUM,
VISIBILITYMAP_FORKNUM,
- INIT_FORKNUM
+ INIT_FORKNUM
/*
* NOTE: if you add a new fork, change MAX_FORKNUM below and update the
*/
typedef struct RelFileNodeBackend
{
- RelFileNode node;
+ RelFileNode node;
BackendId backend;
} RelFileNodeBackend;
bool usecompound;
/*
- * Remaining fields are only used during dictionary construction;
- * they are set up by NIStartBuild and cleared by NIFinishBuild.
+ * Remaining fields are only used during dictionary construction; they are
+ * set up by NIStartBuild and cleared by NIFinishBuild.
*/
- MemoryContext buildCxt; /* temp context for construction */
+ MemoryContext buildCxt; /* temp context for construction */
/* Temporary array of all words in the dict file */
SPELL **Spell;
extern bool is_member_of_role_nosuper(Oid member, Oid role);
extern bool is_admin_of_role(Oid member, Oid role);
extern void check_is_member_of_role(Oid member, Oid role);
-extern Oid get_role_oid(const char *rolname, bool missing_ok);
+extern Oid get_role_oid(const char *rolname, bool missing_ok);
extern void select_best_grantor(Oid roleId, AclMode privileges,
const Acl *acl, Oid ownerId,
/* genfile.c */
extern bytea *read_binary_file(const char *filename,
- int64 seek_offset, int64 bytes_to_read);
+ int64 seek_offset, int64 bytes_to_read);
extern Datum pg_stat_file(PG_FUNCTION_ARGS);
extern Datum pg_read_file(PG_FUNCTION_ARGS);
extern Datum pg_read_file_all(PG_FUNCTION_ARGS);
{
BYTEA_OUTPUT_ESCAPE,
BYTEA_OUTPUT_HEX
-} ByteaOutputType;
+} ByteaOutputType;
extern int bytea_output; /* ByteaOutputType, but int for GUC enum */
extern bool CheckDateTokenTables(void);
extern void ConvertTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl,
- struct tzEntry *abbrevs, int n);
+ struct tzEntry *abbrevs, int n);
extern void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl);
extern Datum pg_timezone_abbrevs(PG_FUNCTION_ARGS);
/* Support for constructing error strings separately from ereport() calls */
extern void pre_format_elog_string(int errnumber, const char *domain);
-extern char *format_elog_string(const char *fmt,...)
+extern char *
+format_elog_string(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(printf, 1, 2)));
PGERROR_TERSE, /* single-line error messages */
PGERROR_DEFAULT, /* recommended style */
PGERROR_VERBOSE /* all the facts, ma'am */
-} PGErrorVerbosity;
+} PGErrorVerbosity;
extern int Log_error_verbosity;
extern char *Log_line_prefix;
*/
typedef struct ConfigVariable
{
- char *name;
- char *value;
+ char *name;
+ char *value;
char *filename;
int sourceline;
- struct ConfigVariable *next;
+ struct ConfigVariable *next;
} ConfigVariable;
extern bool ParseConfigFile(const char *config_file, const char *calling_file,
extern Oid get_atttype(Oid relid, AttrNumber attnum);
extern int32 get_atttypmod(Oid relid, AttrNumber attnum);
extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,
- Oid *typid, int32 *typmod, Oid *collid);
+ Oid *typid, int32 *typmod, Oid *collid);
extern char *get_collation_name(Oid colloid);
extern char *get_constraint_name(Oid conoid);
extern Oid get_opclass_family(Oid opclass);
extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
extern Oid get_typmodin(Oid typid);
-extern Oid get_typcollation(Oid typid);
+extern Oid get_typcollation(Oid typid);
extern bool type_is_collatable(Oid typid);
extern Oid getBaseType(Oid typid);
extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);
* Utility functions in numeric.c
*/
extern bool numeric_is_nan(Numeric num);
-int32 numeric_maximum_size(int32 typmod);
+int32 numeric_maximum_size(int32 typmod);
extern char *numeric_out_sci(Numeric num, int scale);
#endif /* _PG_NUMERIC_H_ */
* all the auxiliary queries.)
*
* PORTAL_ONE_MOD_WITH: the portal contains one single SELECT query, but
- * it has data-modifying CTEs. This is currently treated the same as the
+ * it has data-modifying CTEs. This is currently treated the same as the
* PORTAL_ONE_RETURNING case because of the possibility of needing to fire
* triggers. It may act more like PORTAL_ONE_SELECT in future.
*
/* Presentation data, primarily used by the pg_cursors system view */
TimestampTz creation_time; /* time at which this portal was defined */
bool visible; /* include this portal in pg_cursors? */
-} PortalData;
+} PortalData;
/*
* PortalIsValid
* RBNode is intended to be used as the first field of a larger struct,
* whose additional fields carry whatever payload data the caller needs
* for a tree entry. (The total size of that larger struct is passed to
- * rb_create.) RBNode is declared here to support this usage, but
+ * rb_create.) RBNode is declared here to support this usage, but
* callers must treat it as an opaque struct.
*/
typedef struct RBNode
{
char iteratorState; /* workspace for iterating through tree */
- char color; /* node's current color, red or black */
+ char color; /* node's current color, red or black */
struct RBNode *left; /* left child, or RBNIL if none */
struct RBNode *right; /* right child, or RBNIL if none */
struct RBNode *parent; /* parent, or NULL (not RBNIL!) if none */
extern void rb_begin_iterate(RBTree *rb, RBOrderControl ctrl);
extern RBNode *rb_iterate(RBTree *rb);
-#endif /* RBTREE_H */
+#endif /* RBTREE_H */
* index access support info (used only for an index relation)
*
* Note: only default support procs for each opclass are cached, namely
- * those with lefttype and righttype equal to the opclass's opcintype.
- * The arrays are indexed by support function number, which is a
- * sufficient identifier given that restriction.
+ * those with lefttype and righttype equal to the opclass's opcintype. The
+ * arrays are indexed by support function number, which is a sufficient
+ * identifier given that restriction.
*
* Note: rd_amcache is available for index AMs to cache private data about
* an index. This must be just a cache since it may get reset at any time
Oid *rd_exclprocs; /* OIDs of exclusion ops' procs, if any */
uint16 *rd_exclstrats; /* exclusion ops' strategy numbers, if any */
void *rd_amcache; /* available for use by index AM */
- Oid *rd_indcollation; /* OIDs of index collations */
+ Oid *rd_indcollation; /* OIDs of index collations */
/*
* Hack for CLUSTER, rewriting ALTER TABLE, etc: when writing a new
* The "heap" API actually stores/sorts MinimalTuples, which means it doesn't
* preserve the system columns (tuple identity and transaction visibility
* info). The sort keys are specified by column numbers within the tuples
- * and sort operator OIDs. We save some cycles by passing and returning the
+ * and sort operator OIDs. We save some cycles by passing and returning the
* tuples in TupleTableSlots, rather than forming actual HeapTuples (which'd
- * have to be converted to MinimalTuples). This API works well for sorts
+ * have to be converted to MinimalTuples). This API works well for sorts
* executed as parts of plan trees.
*
* The "cluster" API stores/sorts full HeapTuples including all visibility
* go with this API, not the "begin_heap" one!
*
* The "index_btree" API stores/sorts IndexTuples (preserving all their
- * header fields). The sort keys are specified by a btree index definition.
+ * header fields). The sort keys are specified by a btree index definition.
*
* The "index_hash" API is similar to index_btree, but the tuples are
* actually sorted by their hash codes not the raw data.
extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc,
int nkeys, AttrNumber *attNums,
- Oid *sortOperators, Oid *collations, bool *nullsFirstFlags,
+ Oid *sortOperators, Oid *collations, bool *nullsFirstFlags,
int workMem, bool randomAccess);
extern Tuplesortstate *tuplesort_begin_cluster(TupleDesc tupDesc,
- Relation indexRel,
- int workMem, bool randomAccess);
+ Relation indexRel,
+ int workMem, bool randomAccess);
extern Tuplesortstate *tuplesort_begin_index_btree(Relation indexRel,
bool enforceUnique,
int workMem, bool randomAccess);
uint32 hash_mask,
int workMem, bool randomAccess);
extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
- Oid sortOperator, Oid sortCollation, bool nullsFirstFlag,
+ Oid sortOperator, Oid sortCollation, bool nullsFirstFlag,
int workMem, bool randomAccess);
extern void tuplesort_set_bound(Tuplesortstate *state, int64 bound);
/*
* Pre-set-up fmgr call info for the equality operator, the btree
- * comparison function, and the hash calculation function. These are kept
+ * comparison function, and the hash calculation function. These are kept
* in the type cache to avoid problems with memory leaks in repeated calls
- * to array_eq, array_cmp, hash_array. There is not currently a need to
+ * to array_eq, array_cmp, hash_array. There is not currently a need to
* maintain call info for the lt_opr or gt_opr.
*/
FmgrInfo eq_opr_finfo;
TupleDesc tupDesc;
/*
- * Private information about an enum type. NULL if not enum or
+ * Private information about an enum type. NULL if not enum or
* information hasn't been requested.
*/
struct TypeCacheEnumData *enumData;
extern Datum bitgt(PG_FUNCTION_ARGS);
extern Datum bitge(PG_FUNCTION_ARGS);
extern Datum bitcmp(PG_FUNCTION_ARGS);
+
/* avoid the names bitand and bitor, since they are C++ keywords */
extern Datum bit_and(PG_FUNCTION_ARGS);
extern Datum bit_or(PG_FUNCTION_ARGS);
XML_STANDALONE_NO,
XML_STANDALONE_NO_VALUE,
XML_STANDALONE_OMITTED
-} XmlStandaloneType;
+} XmlStandaloneType;
extern void pg_xml_init(void);
extern void xml_ereport(int level, int sqlcode, const char *msg);
{
XMLBINARY_BASE64,
XMLBINARY_HEX
-} XmlBinaryType;
+} XmlBinaryType;
extern int xmlbinary; /* XmlBinaryType, but int for guc enum */
ecpg_strndup(const char *str, size_t len)
{
size_t real_len = strlen(str);
- int use_len = (int) ((real_len > len) ? len : real_len);
+ int use_len = (int) ((real_len > len) ? len : real_len);
char *new = malloc(use_len + 1);
int
rgetmsg(int msgnum, char *s, int maxsize)
{
- (void) msgnum; /* keep the compiler quiet */
- (void) s; /* keep the compiler quiet */
- (void) maxsize; /* keep the compiler quiet */
+ (void) msgnum; /* keep the compiler quiet */
+ (void) s; /* keep the compiler quiet */
+ (void) maxsize; /* keep the compiler quiet */
return 0;
}
int
rtypalign(int offset, int type)
{
- (void) offset; /* keep the compiler quiet */
- (void) type; /* keep the compiler quiet */
+ (void) offset; /* keep the compiler quiet */
+ (void) type; /* keep the compiler quiet */
return 0;
}
int
rtypmsize(int type, int len)
{
- (void) type; /* keep the compiler quiet */
- (void) len; /* keep the compiler quiet */
+ (void) type; /* keep the compiler quiet */
+ (void) len; /* keep the compiler quiet */
return 0;
}
int
rtypwidth(int sqltype, int sqllen)
{
- (void) sqltype; /* keep the compiler quiet */
- (void) sqllen; /* keep the compiler quiet */
+ (void) sqltype; /* keep the compiler quiet */
+ (void) sqllen; /* keep the compiler quiet */
return 0;
}
struct sqlca_t *sqlca = ECPGget_sqlca();
int sqlcode;
- (void) arg; /* keep the compiler quiet */
+ (void) arg; /* keep the compiler quiet */
if (sqlstate == NULL)
sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR;
static void
auto_mem_destructor(void *arg)
{
- (void) arg; /* keep the compiler quiet */
+ (void) arg; /* keep the compiler quiet */
ECPGfree_auto_mem();
}
struct prepared_statement *this,
*prev;
- (void) questionmarks; /* quiet the compiler */
+ (void) questionmarks; /* quiet the compiler */
con = ecpg_get_connection(connection_name);
if (!ecpg_init(con, connection_name, lineno))
char *
ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
{
- (void)lineno; /* keep the compiler quiet */
+ (void) lineno; /* keep the compiler quiet */
return ecpg_prepared(name, ecpg_get_connection(connection_name));
}
#include "extern.h"
int ret_value = 0;
-bool autocommit = false,
+bool autocommit = false,
auto_create_c = false,
system_includes = false,
force_indicator = true,
int fnr,
c,
out_option = 0;
- bool verbose = false,
+ bool verbose = false,
header_mode = false;
struct _include_path *ip;
const char *progname;
/* variables */
-extern bool autocommit,
+extern bool autocommit,
auto_create_c,
system_includes,
force_indicator,
questionmarks,
regression_mode,
auto_prepare;
-extern int braces_open,
+extern int braces_open,
ret_value,
struct_level,
ecpg_internal_var;
}
retval = krb5_sendauth(info.pg_krb5_context, &auth_context,
- (krb5_pointer) & conn->sock, (char *) conn->krbsrvname,
+ (krb5_pointer) &conn->sock, (char *) conn->krbsrvname,
info.pg_krb5_client, server,
AP_OPTS_MUTUAL_REQUIRED,
NULL, 0, /* no creds, use ccache instead */
pgunlock_thread();
}
break;
-#else /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
+#else /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
/* No GSSAPI *or* SSPI support */
case AUTH_REQ_GSS:
case AUTH_REQ_GSS_CONT:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("GSSAPI authentication not supported\n"));
return STATUS_ERROR;
-#endif /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
+#endif /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */
#ifdef ENABLE_SSPI
case AUTH_REQ_SSPI:
pgunlock_thread();
break;
#else
+
/*
* No SSPI support. However, if we have GSSAPI but not SSPI
* support, AUTH_REQ_SSPI will have been handled in the codepath
- * for AUTH_REQ_GSSAPI above, so don't duplicate the case label
- * in that case.
+ * for AUTH_REQ_GSSAPI above, so don't duplicate the case label in
+ * that case.
*/
#if !defined(ENABLE_GSS)
case AUTH_REQ_SSPI:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSPI authentication not supported\n"));
return STATUS_ERROR;
-#endif /* !define(ENABLE_GSSAPI) */
-#endif /* ENABLE_SSPI */
+#endif /* !define(ENABLE_GSSAPI) */
+#endif /* ENABLE_SSPI */
case AUTH_REQ_CRYPT:
#endif
#define near
#include <shlobj.h>
-#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
+#ifdef WIN32_ONLY_COMPILER /* mstcpip.h is missing on mingw */
#include <mstcpip.h>
#endif
#else
else
#endif /* HAVE_UNIX_SOCKETS */
{
- char host_addr[NI_MAXHOST];
- bool display_host_addr;
+ char host_addr[NI_MAXHOST];
+ bool display_host_addr;
struct sockaddr_storage *addr = &conn->raddr.addr;
/*
- * Optionally display the network address with the hostname.
- * This is useful to distinguish between IPv4 and IPv6 connections.
+ * Optionally display the network address with the hostname. This is
+ * useful to distinguish between IPv4 and IPv6 connections.
*/
if (conn->pghostaddr != NULL)
strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
else if (addr->ss_family == AF_INET6)
{
if (inet_net_ntop(AF_INET6,
- &((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr,
+ &((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr,
128,
host_addr, sizeof(host_addr)) == NULL)
strcpy(host_addr, "???");
strcpy(host_addr, "???");
/*
- * If the user did not supply an IP address using 'hostaddr', and
- * 'host' was missing or does not match our lookup, display the
- * looked-up IP address.
+ * If the user did not supply an IP address using 'hostaddr', and
+ * 'host' was missing or does not match our lookup, display the
+ * looked-up IP address.
*/
display_host_addr = (conn->pghostaddr == NULL) &&
- ((conn->pghost == NULL) ||
- (strcmp(conn->pghost, host_addr) != 0));
+ ((conn->pghost == NULL) ||
+ (strcmp(conn->pghost, host_addr) != 0));
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not connect to server: %s\n"
- "\tIs the server running on host \"%s\"%s%s%s and accepting\n"
+ "\tIs the server running on host \"%s\"%s%s%s and accepting\n"
"\tTCP/IP connections on port %s?\n"),
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
(conn->pghostaddr && conn->pghostaddr[0] != '\0')
? conn->pghostaddr
: (conn->pghost && conn->pghost[0] != '\0')
- ? conn->pghost
- : DefaultHost,
- /* display the IP address only if not already output */
+ ? conn->pghost
+ : DefaultHost,
+ /* display the IP address only if not already output */
display_host_addr ? " (" : "",
display_host_addr ? host_addr : "",
display_host_addr ? ")" : "",
if (setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPALIVE,
(char *) &idle, sizeof(idle)) < 0)
{
- char sebuf[256];
+ char sebuf[256];
appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("setsockopt(TCP_KEEPALIVE) failed: %s\n"),
+ libpq_gettext("setsockopt(TCP_KEEPALIVE) failed: %s\n"),
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return 0;
}
return 1;
}
-
-#else /* Win32 */
+#else /* Win32 */
#ifdef SIO_KEEPALIVE_VALS
/*
* Enable keepalives and set the keepalive values on Win32,
static int
setKeepalivesWin32(PGconn *conn)
{
- struct tcp_keepalive ka;
- DWORD retsize;
- int idle = 0;
- int interval = 0;
+ struct tcp_keepalive ka;
+ DWORD retsize;
+ int idle = 0;
+ int interval = 0;
if (conn->keepalives_idle)
idle = atoi(conn->keepalives_idle);
if (idle <= 0)
- idle = 2 * 60 * 60; /* 2 hours = default */
+ idle = 2 * 60 * 60; /* 2 hours = default */
if (conn->keepalives_interval)
interval = atoi(conn->keepalives_interval);
if (interval <= 0)
- interval = 1; /* 1 second = default */
+ interval = 1; /* 1 second = default */
ka.onoff = 1;
ka.keepalivetime = idle * 1000;
!= 0)
{
appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("WSAIoctl(SIO_KEEPALIVE_VALS) failed: %ui\n"),
+ libpq_gettext("WSAIoctl(SIO_KEEPALIVE_VALS) failed: %ui\n"),
WSAGetLastError());
return 0;
}
return 1;
}
-#endif /* SIO_KEEPALIVE_VALS */
-#endif /* WIN32 */
+#endif /* SIO_KEEPALIVE_VALS */
+#endif /* WIN32 */
/* ----------
* connectDBStart -
|| !setKeepalivesInterval(conn)
|| !setKeepalivesCount(conn))
err = 1;
-#else /* WIN32 */
+#else /* WIN32 */
#ifdef SIO_KEEPALIVE_VALS
else if (!setKeepalivesWin32(conn))
err = 1;
-#endif /* SIO_KEEPALIVE_VALS */
-#endif /* WIN32 */
+#endif /* SIO_KEEPALIVE_VALS */
+#endif /* WIN32 */
if (err)
{
if (getpeereid(conn->sock, &uid, &gid) != 0)
{
appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get peer credentials: %s\n"),
- pqStrerror(errno, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not get peer credentials: %s\n"),
+ pqStrerror(errno, sebuf, sizeof(sebuf)));
goto error_return;
}
#elif defined(SO_PEERCRED)
so_len != sizeof(peercred))
{
appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get peer credentials: %s\n"),
- pqStrerror(errno, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not get peer credentials: %s\n"),
+ pqStrerror(errno, sebuf, sizeof(sebuf)));
goto error_return;
}
uid = peercred.uid;
#elif defined(HAVE_GETPEERUCRED)
ucred_t *ucred;
- ucred = NULL; /* must be initialized to NULL */
+ ucred = NULL; /* must be initialized to NULL */
if (getpeerucred(conn->sock, &ucred) == -1)
{
appendPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get peer credentials: %s\n"),
- pqStrerror(errno, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not get peer credentials: %s\n"),
+ pqStrerror(errno, sebuf, sizeof(sebuf)));
goto error_return;
}
{
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not get effective UID from peer credentials: %s\n"),
- pqStrerror(errno, sebuf, sizeof(sebuf)));
+ pqStrerror(errno, sebuf, sizeof(sebuf)));
ucred_free(ucred);
goto error_return;
}
conn->requirepeer, pass->pw_name);
goto error_return;
}
-#else /* can't support requirepeer */
+#else /* can't support requirepeer */
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("requirepeer parameter is not supported on this platform\n"));
goto error_return;
* failure in sufficient detail to decide what to return. We do not want
* to report that the server is not up just because we didn't have a valid
* password, for example. In fact, any sort of authentication request
- * implies the server is up. (We need this check since the libpq side
- * of things might have pulled the plug on the connection before getting
- * an error as such from the postmaster.)
+ * implies the server is up. (We need this check since the libpq side of
+ * things might have pulled the plug on the connection before getting an
+ * error as such from the postmaster.)
*/
if (conn->auth_req_received)
return PQPING_OK;
/*
* If we failed to get any ERROR response from the postmaster, report
- * PQPING_NO_RESPONSE. This result could be somewhat misleading for a
+ * PQPING_NO_RESPONSE. This result could be somewhat misleading for a
* pre-7.4 server, since it won't send back a SQLSTATE, but those are long
- * out of support. Another corner case where the server could return a
+ * out of support. Another corner case where the server could return a
* failure without a SQLSTATE is fork failure, but NO_RESPONSE isn't
* totally unreasonable for that anyway. We expect that every other
* failure case in a modern server will produce a report with a SQLSTATE.
return PQPING_NO_RESPONSE;
/*
- * Report PQPING_REJECT if server says it's not accepting connections.
- * (We distinguish this case mainly for the convenience of pg_ctl.)
+ * Report PQPING_REJECT if server says it's not accepting connections. (We
+ * distinguish this case mainly for the convenience of pg_ctl.)
*/
if (strcmp(conn->last_sqlstate, ERRCODE_CANNOT_CONNECT_NOW) == 0)
return PQPING_REJECT;
{
/* We don't allow PQexec during COPY BOTH */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("PQexec not allowed during COPY BOTH\n"));
- return false;
+ libpq_gettext("PQexec not allowed during COPY BOTH\n"));
+ return false;
}
/* check for loss of connection, too */
if (conn->status == CONNECTION_BAD)
* than one --- but merge error messages if we get more than one error
* result.
*
- * We have to stop if we see copy in/out/both, however. We will resume parsing
- * after application performs the data transfer.
+ * We have to stop if we see copy in/out/both, however. We will resume
+ * parsing after application performs the data transfer.
*
* Also stop if the connection is lost (else we'll loop infinitely).
*/
(ISOCTDIGIT(strtext[i + 1])) &&
(ISOCTDIGIT(strtext[i + 2])))
{
- int byte;
+ int byte;
byte = OCTVAL(strtext[i++]);
- byte = (byte <<3) +OCTVAL(strtext[i++]);
- byte = (byte <<3) +OCTVAL(strtext[i++]);
+ byte = (byte << 3) + OCTVAL(strtext[i++]);
+ byte = (byte << 3) + OCTVAL(strtext[i++]);
buffer[j++] = byte;
}
}
{
switch (conn->setenv_state)
{
- /*
- * The _CLIENT_ENCODING_SEND code is slightly different
- * from _OPTION_SEND below (e.g., no getenv() call), which
- * is why a different state is used.
- */
+ /*
+ * The _CLIENT_ENCODING_SEND code is slightly different from
+ * _OPTION_SEND below (e.g., no getenv() call), which is why a
+ * different state is used.
+ */
case SETENV_STATE_CLIENT_ENCODING_SEND:
{
char setQuery[100]; /* note length limit in
case 'H': /* Start Copy Out */
conn->asyncStatus = PGASYNC_COPY_OUT;
break;
+
/*
- * Don't need to process CopyBothResponse here because
- * it never arrives from the server during protocol 2.0.
+ * Don't need to process CopyBothResponse here because it
+ * never arrives from the server during protocol 2.0.
*/
default:
printfPQExpBuffer(&conn->errorMessage,
/*
* On end-of-copy, exit COPY_OUT or COPY_BOTH mode and let caller
* read status with PQgetResult(). The normal case is that it's
- * Copy Done, but we let parseInput read that. If error, we expect
- * the state was already changed.
+ * Copy Done, but we let parseInput read that. If error, we
+ * expect the state was already changed.
*/
if (msgLength == -1)
conn->asyncStatus = PGASYNC_BUSY;
verify_peer_name_matches_certificate(PGconn *conn)
{
/*
- * If told not to verify the peer name, don't do it. Return true indicating
- * that the verification was successful.
+ * If told not to verify the peer name, don't do it. Return true
+ * indicating that the verification was successful.
*/
if (strcmp(conn->sslmode, "verify-full") != 0)
return true;
!(conn->sslrootcert && strlen(conn->sslrootcert) > 0) ||
!(conn->sslcrl && strlen(conn->sslcrl) > 0))
have_homedir = pqGetHomeDirectory(homedir, sizeof(homedir));
- else /* won't need it */
+ else /* won't need it */
have_homedir = false;
/* Read the client certificate file */
"Either provide the file or change sslmode to disable server certificate verification.\n"));
else
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("root certificate file \"%s\" does not exist\n"
- "Either provide the file or change sslmode to disable server certificate verification.\n"), fnbuf);
+ libpq_gettext("root certificate file \"%s\" does not exist\n"
+ "Either provide the file or change sslmode to disable server certificate verification.\n"), fnbuf);
return -1;
}
}
extern int PQisthreadsafe(void);
extern PGPing PQping(const char *conninfo);
extern PGPing PQpingParams(const char **keywords,
- const char **values, int expand_dbname);
+ const char **values, int expand_dbname);
/* Force the write buffer to be written (or at least try) */
extern int PQflush(PGconn *conn);
char *pgtty; /* tty on which the backend messages is
* displayed (OBSOLETE, NOT USED) */
char *connect_timeout; /* connection timeout (numeric string) */
- char *client_encoding_initial; /* encoding to use */
+ char *client_encoding_initial; /* encoding to use */
char *pgoptions; /* options to start the backend with */
char *appname; /* application name */
char *fbappname; /* fallback application name */
PGTransactionStatusType xactStatus; /* never changes to ACTIVE */
PGQueryClass queryclass;
char *last_query; /* last SQL command, or NULL if unknown */
- char last_sqlstate[6]; /* last reported SQLSTATE */
+ char last_sqlstate[6]; /* last reported SQLSTATE */
bool options_valid; /* true if OK to attempt connection */
bool nonblocking; /* whether this connection is using nonblock
* sending semantics */
SockAddr raddr; /* Remote address */
ProtocolVersion pversion; /* FE/BE protocol version in use */
int sversion; /* server version, e.g. 70401 for 7.4.1 */
- bool auth_req_received; /* true if any type of auth req received */
+ bool auth_req_received; /* true if any type of auth req
+ * received */
bool password_needed; /* true if server demanded a password */
bool dot_pgpass_used; /* true if used .pgpass */
bool sigpipe_so; /* have we masked SIGPIPE via SO_NOSIGPIPE? */
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("PL/Perl function must return reference to hash or array")));
+ errmsg("PL/Perl function must return reference to hash or array")));
return (Datum) 0; /* shut up compiler */
}
else
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
#ifndef HeUTF8
-#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
- SvUTF8(HeKEY_sv(he)) : \
- (U32)HeKUTF8(he))
+#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
+ SvUTF8(HeKEY_sv(he)) : \
+ (U32)HeKUTF8(he))
#endif
/* declare routines from plperl.c for access by .xs files */
SV *plperl_spi_query_prepared(char *, int, SV **);
void plperl_spi_freeplan(char *);
void plperl_spi_cursor_close(char *);
-char *plperl_sv_to_literal(SV *, char *);
+char *plperl_sv_to_literal(SV *, char *);
static inline char *
utf_u2e(const char *utf8_str, size_t len)
{
- char *ret = (char*)pg_do_encoding_conversion((unsigned char*)utf8_str, len, PG_UTF8, GetDatabaseEncoding());
+ char *ret = (char *) pg_do_encoding_conversion((unsigned char *) utf8_str, len, PG_UTF8, GetDatabaseEncoding());
+
if (ret == utf8_str)
ret = pstrdup(ret);
return ret;
static inline char *
utf_e2u(const char *str)
{
- char *ret = (char*)pg_do_encoding_conversion((unsigned char*)str, strlen(str), GetDatabaseEncoding(), PG_UTF8);
+ char *ret = (char *) pg_do_encoding_conversion((unsigned char *) str, strlen(str), GetDatabaseEncoding(), PG_UTF8);
+
if (ret == str)
ret = pstrdup(ret);
return ret;
static inline char *
sv2cstr(SV *sv)
{
- char *val;
- STRLEN len;
+ char *val;
+ STRLEN len;
/*
* get a utf8 encoded char * out of perl. *note* it may not be valid utf8!
static inline SV *
cstr2sv(const char *str)
{
- SV *sv;
- char *utf8_str = utf_e2u(str);
+ SV *sv;
+ char *utf8_str = utf_e2u(str);
sv = newSVpv(utf8_str, 0);
SvUTF8_on(sv);
/* Create datatype info */
argdtype = plpgsql_build_datatype(argtypeid,
-1,
- function->fn_input_collation);
+ function->fn_input_collation);
/* Disallow pseudotype argument */
/* (note we already replaced polymorphic types) */
(void) plpgsql_build_variable("$0", 0,
build_datatype(typeTup,
-1,
- function->fn_input_collation),
+ function->fn_input_collation),
true);
}
}
var = plpgsql_build_variable("tg_when", 0,
plpgsql_build_datatype(TEXTOID,
-1,
- function->fn_input_collation),
+ function->fn_input_collation),
true);
function->tg_when_varno = var->dno;
var = plpgsql_build_variable("tg_level", 0,
plpgsql_build_datatype(TEXTOID,
-1,
- function->fn_input_collation),
+ function->fn_input_collation),
true);
function->tg_level_varno = var->dno;
var = plpgsql_build_variable("tg_op", 0,
plpgsql_build_datatype(TEXTOID,
-1,
- function->fn_input_collation),
+ function->fn_input_collation),
true);
function->tg_op_varno = var->dno;
var = plpgsql_build_variable("tg_argv", 0,
plpgsql_build_datatype(TEXTARRAYOID,
-1,
- function->fn_input_collation),
+ function->fn_input_collation),
true);
function->tg_argv_varno = var->dno;
/*
* If we find a record/row variable but can't match a field name, throw
- * error if there was no core resolution for the ColumnRef either. In
+ * error if there was no core resolution for the ColumnRef either. In
* that situation, the reference is inevitably going to fail, and
- * complaining about the record/row variable is likely to be more
- * on-point than the core parser's error message. (It's too bad we
- * don't have access to transformColumnRef's internal crerr state here,
- * as in case of a conflict with a table name this could still be less
- * than the most helpful error message possible.)
+ * complaining about the record/row variable is likely to be more on-point
+ * than the core parser's error message. (It's too bad we don't have
+ * access to transformColumnRef's internal crerr state here, as in case of
+ * a conflict with a table name this could still be less than the most
+ * helpful error message possible.)
*/
myvar = resolve_column_ref(pstate, expr, cref, (var == NULL));
var = plpgsql_build_variable(refname, 0,
plpgsql_build_datatype(attrStruct->atttypid,
attrStruct->atttypmod,
- attrStruct->attcollation),
+ attrStruct->attcollation),
false);
/* Add the variable to the row */
static int exec_stmt_forc(PLpgSQL_execstate *estate,
PLpgSQL_stmt_forc *stmt);
static int exec_stmt_foreach_a(PLpgSQL_execstate *estate,
- PLpgSQL_stmt_foreach_a *stmt);
+ PLpgSQL_stmt_foreach_a *stmt);
static int exec_stmt_open(PLpgSQL_execstate *estate,
PLpgSQL_stmt_open *stmt);
static int exec_stmt_fetch(PLpgSQL_execstate *estate,
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
ExprContext *old_eval_econtext = estate->eval_econtext;
- ErrorData *save_cur_error = estate->cur_error;
+ ErrorData *save_cur_error = estate->cur_error;
estate->err_text = gettext_noop("during statement block entry");
if (t_var->datatype->typoid != t_oid)
t_var->datatype = plpgsql_build_datatype(t_oid,
-1,
- estate->func->fn_input_collation);
+ estate->func->fn_input_collation);
/* now we can assign to the variable */
exec_assign_value(estate,
static int
exec_stmt_foreach_a(PLpgSQL_execstate *estate, PLpgSQL_stmt_foreach_a *stmt)
{
- ArrayType *arr;
- Oid arrtype;
- PLpgSQL_datum *loop_var;
- Oid loop_var_elem_type;
- bool found = false;
- int rc = PLPGSQL_RC_OK;
- ArrayIterator array_iterator;
- Oid iterator_result_type;
- Datum value;
- bool isnull;
+ ArrayType *arr;
+ Oid arrtype;
+ PLpgSQL_datum *loop_var;
+ Oid loop_var_elem_type;
+ bool found = false;
+ int rc = PLPGSQL_RC_OK;
+ ArrayIterator array_iterator;
+ Oid iterator_result_type;
+ Datum value;
+ bool isnull;
/* get the value of the array expression */
value = exec_eval_expr(estate, stmt->expr, &isnull, &arrtype);
if (stmt->slice < 0 || stmt->slice > ARR_NDIM(arr))
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("slice dimension (%d) is out of the valid range 0..%d",
- stmt->slice, ARR_NDIM(arr))));
+ errmsg("slice dimension (%d) is out of the valid range 0..%d",
+ stmt->slice, ARR_NDIM(arr))));
/* Set up the loop variable and see if it is of an array type */
loop_var = estate->datums[stmt->varno];
loop_var));
/*
- * Sanity-check the loop variable type. We don't try very hard here,
- * and should not be too picky since it's possible that exec_assign_value
- * can coerce values of different types. But it seems worthwhile to
- * complain if the array-ness of the loop variable is not right.
+ * Sanity-check the loop variable type. We don't try very hard here, and
+ * should not be too picky since it's possible that exec_assign_value can
+ * coerce values of different types. But it seems worthwhile to complain
+ * if the array-ness of the loop variable is not right.
*/
if (stmt->slice > 0 && loop_var_elem_type == InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("FOREACH ... SLICE loop variable must be of an array type")));
+ errmsg("FOREACH ... SLICE loop variable must be of an array type")));
if (stmt->slice == 0 && loop_var_elem_type != InvalidOid)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("FOREACH loop variable must not be of an array type")));
+ errmsg("FOREACH loop variable must not be of an array type")));
/* Create an iterator to step through the array */
array_iterator = array_create_iterator(arr, stmt->slice);
/*
* We need to do subscript evaluation, which might require
* evaluating general expressions; and the caller might have
- * done that too in order to prepare the input Datum. We
- * have to save and restore the caller's SPI_execute result,
- * if any.
+ * done that too in order to prepare the input Datum. We have
+ * to save and restore the caller's SPI_execute result, if
+ * any.
*/
save_eval_tuptable = estate->eval_tuptable;
estate->eval_tuptable = NULL;
errmsg("array subscript in assignment must not be null")));
/*
- * Clean up in case the subscript expression wasn't simple.
- * We can't do exec_eval_cleanup, but we can do this much
- * (which is safe because the integer subscript value is
- * surely pass-by-value), and we must do it in case the
- * next subscript expression isn't simple either.
+ * Clean up in case the subscript expression wasn't
+ * simple. We can't do exec_eval_cleanup, but we can do
+ * this much (which is safe because the integer subscript
+ * value is surely pass-by-value), and we must do it in
+ * case the next subscript expression isn't simple either.
*/
if (estate->eval_tuptable != NULL)
SPI_freetuptable(estate->eval_tuptable);
/* XXX there's no SPI_getcollid, as yet */
if (fno > 0)
collid = rec->tupdesc->attrs[fno - 1]->attcollation;
- else /* no system column types have collation */
+ else /* no system column types have collation */
collid = InvalidOid;
break;
}
* Because we only store one execution tree for a simple expression, we
* can't handle recursion cases. So, if we see the tree is already busy
* with an evaluation in the current xact, we just return FALSE and let the
- * caller run the expression the hard way. (Other alternatives such as
+ * caller run the expression the hard way. (Other alternatives such as
* creating a new tree for a recursive call either introduce memory leaks,
* or add enough bookkeeping to be doubtful wins anyway.) Another case that
* is covered by the expr_simple_in_use test is where a previous execution
/* sizeof(ParamListInfoData) includes the first array element */
paramLI = (ParamListInfo)
palloc0(sizeof(ParamListInfoData) +
- (estate->ndatums - 1) *sizeof(ParamExternData));
+ (estate->ndatums - 1) * sizeof(ParamExternData));
paramLI->paramFetch = plpgsql_param_fetch;
paramLI->paramFetchArg = (void *) estate;
paramLI->parserSetup = (ParserSetupHook) plpgsql_parser_setup;
extern PLpgSQL_type *plpgsql_parse_wordrowtype(char *ident);
extern PLpgSQL_type *plpgsql_parse_cwordrowtype(List *idents);
extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod,
- Oid collation);
+ Oid collation);
extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
PLpgSQL_type *dtype,
bool add2namespace);
extern Oid exec_get_datum_type(PLpgSQL_execstate *estate,
PLpgSQL_datum *datum);
extern Oid exec_get_datum_collation(PLpgSQL_execstate *estate,
- PLpgSQL_datum *datum);
+ PLpgSQL_datum *datum);
/* ----------
* Functions for namespace handling in pl_funcs.c
struct PLyObToDatum;
typedef Datum (*PLyObToDatumFunc) (struct PLyObToDatum *, int32 typmod,
- PyObject *);
+ PyObject *);
typedef struct PLyObToDatum
{
typedef struct PLyExceptionEntry
{
- int sqlstate; /* hash key, must be first */
- PyObject *exc; /* corresponding exception */
+ int sqlstate; /* hash key, must be first */
+ PyObject *exc; /* corresponding exception */
} PLyExceptionEntry;
/* most of the remaining of the declarations, all static */
/*
- * These should only be called once from _PG_init. Initialize the
+ * These should only be called once from _PG_init. Initialize the
* Python interpreter and global data.
*/
static void PLy_init_interp(void);
static PLyProcedure *PLy_procedure_get(Oid fn_oid, bool is_trigger);
static PLyProcedure *PLy_procedure_create(HeapTuple procTup,
- Oid fn_oid, bool is_trigger);
+ Oid fn_oid, bool is_trigger);
static void PLy_procedure_compile(PLyProcedure *, const char *);
static char *PLy_procedure_munge_source(const char *, const char *);
HeapTuple rv = NULL;
PyObject *volatile plargs = NULL;
PyObject *volatile plrv = NULL;
- TriggerData *tdata;
+ TriggerData *tdata;
Assert(CALLED_AS_TRIGGER(fcinfo));
/*
- * Input/output conversion for trigger tuples. Use the result
- * TypeInfo variable to store the tuple conversion info. We do
- * this over again on each call to cover the possibility that the
- * relation's tupdesc changed since the trigger was last called.
- * PLy_input_tuple_funcs and PLy_output_tuple_funcs are
- * responsible for not doing repetitive work.
+ * Input/output conversion for trigger tuples. Use the result TypeInfo
+ * variable to store the tuple conversion info. We do this over again on
+ * each call to cover the possibility that the relation's tupdesc changed
+ * since the trigger was last called. PLy_input_tuple_funcs and
+ * PLy_output_tuple_funcs are responsible for not doing repetitive work.
*/
tdata = (TriggerData *) fcinfo->context;
if (!proc->is_setof || proc->setof == NULL)
{
/*
- * Simple type returning function or first time for SETOF function:
- * actually execute the function.
+ * Simple type returning function or first time for SETOF
+ * function: actually execute the function.
*/
plargs = PLy_function_build_args(fcinfo, proc);
plrv = PLy_procedure_call(proc, "args", plargs);
PLy_procedure_call(PLyProcedure *proc, char *kargs, PyObject *vargs)
{
PyObject *rv;
- int volatile save_subxact_level = list_length(explicit_subtransactions);
+ int volatile save_subxact_level = list_length(explicit_subtransactions);
PyDict_SetItemString(proc->globals, kargs, vargs);
PG_TRY();
{
#if PY_VERSION_HEX >= 0x03020000
- rv = PyEval_EvalCode(proc->code,
- proc->globals, proc->globals);
+ rv = PyEval_EvalCode(proc->code,
+ proc->globals, proc->globals);
#else
- rv = PyEval_EvalCode((PyCodeObject *) proc->code,
- proc->globals, proc->globals);
+ rv = PyEval_EvalCode((PyCodeObject *) proc->code,
+ proc->globals, proc->globals);
#endif
- /*
- * Since plpy will only let you close subtransactions that
- * you started, you cannot *unnest* subtransactions, only
- * *nest* them without closing.
- */
- Assert(list_length(explicit_subtransactions) >= save_subxact_level);
+ /*
+ * Since plpy will only let you close subtransactions that you
+ * started, you cannot *unnest* subtransactions, only *nest* them
+ * without closing.
+ */
+ Assert(list_length(explicit_subtransactions) >= save_subxact_level);
}
PG_CATCH();
{
/* If there are composite input arguments, they might have changed */
for (i = 0; i < proc->nargs; i++)
{
- Oid relid;
- HeapTuple relTup;
+ Oid relid;
+ HeapTuple relTup;
/* Short-circuit on first changed argument */
if (!valid)
PLy_procedure_get(Oid fn_oid, bool is_trigger)
{
HeapTuple procTup;
- PLyProcedureEntry * volatile entry;
+ PLyProcedureEntry *volatile entry;
bool found;
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
procStruct->prorettype != RECORDOID)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("PL/Python functions cannot return type %s",
- format_type_be(procStruct->prorettype))));
+ errmsg("PL/Python functions cannot return type %s",
+ format_type_be(procStruct->prorettype))));
}
if (rvTypeStruct->typtype == TYPTYPE_COMPOSITE ||
arg->out.d.typmod = desc->tdtypmod;
/* proceed with normal I/O function caching */
PLy_output_tuple_funcs(arg, desc);
- /* it should change is_rowtype to 1, so we won't go through this again
- * unless the the output record description changes */
+
+ /*
+ * it should change is_rowtype to 1, so we won't go through this again
+ * unless the the output record description changes
+ */
Assert(arg->is_rowtype == 1);
}
}
/*
- * Convert a Python object to a PostgreSQL tuple, using all supported
- * conversion methods: tuple as a sequence, as a mapping or as an object that
- * has __getattr__ support.
+ * Convert a Python object to a PostgreSQL tuple, using all supported
+ * conversion methods: tuple as a sequence, as a mapping or as an object that
+ * has __getattr__ support.
*/
static HeapTuple
PLyObject_ToTuple(PLyTypeInfo *info, TupleDesc desc, PyObject *plrv)
{
HeapTuple tuple = NULL;
Datum rv;
- PLyTypeInfo info;
+ PLyTypeInfo info;
TupleDesc desc;
if (typmod != -1)
/*
* methods
*/
- PLy_subtransaction_dealloc, /* tp_dealloc */
+ PLy_subtransaction_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- PLy_subtransaction_methods, /* tp_tpmethods */
+ PLy_subtransaction_methods, /* tp_tpmethods */
};
static PyMethodDef PLy_methods[] = {
PG_TRY();
{
- int i;
+ int i;
/*
- * the other loop might throw an exception, if PLyTypeInfo
- * member isn't properly initialized the Py_DECREF(plan) will
- * go boom
+ * the other loop might throw an exception, if PLyTypeInfo member
+ * isn't properly initialized the Py_DECREF(plan) will go boom
*/
for (i = 0; i < nargs; i++)
{
elog(ERROR, "cache lookup failed for type %u", typeId);
Py_DECREF(optr);
+
/*
- * set optr to NULL, so we won't try to unref it again in
- * case of an error
+ * set optr to NULL, so we won't try to unref it again in case of
+ * an error
*/
optr = NULL;
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("plpy.prepare does not support composite types")));
+ errmsg("plpy.prepare does not support composite types")));
ReleaseSysCache(typeTup);
}
}
PG_CATCH();
{
- ErrorData *edata;
+ ErrorData *edata;
PLyExceptionEntry *entry;
- PyObject *exc;
+ PyObject *exc;
/* Save error info */
MemoryContextSwitchTo(oldcontext);
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact, it
- * will have left us in a disconnected state. We need this hack to
- * return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
+ * have left us in a disconnected state. We need this hack to return
+ * to connected state.
*/
SPI_restore_connection();
PG_TRY();
{
- char * volatile nulls;
+ char *volatile nulls;
volatile int j;
if (nargs > 0)
PG_CATCH();
{
int k;
- ErrorData *edata;
+ ErrorData *edata;
PLyExceptionEntry *entry;
- PyObject *exc;
+ PyObject *exc;
/* Save error info */
MemoryContextSwitchTo(oldcontext);
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact, it
- * will have left us in a disconnected state. We need this hack to
- * return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
+ * have left us in a disconnected state. We need this hack to return
+ * to connected state.
*/
SPI_restore_connection();
}
PG_CATCH();
{
- ErrorData *edata;
- PLyExceptionEntry *entry;
- PyObject *exc;
+ ErrorData *edata;
+ PLyExceptionEntry *entry;
+ PyObject *exc;
/* Save error info */
MemoryContextSwitchTo(oldcontext);
CurrentResourceOwner = oldowner;
/*
- * If AtEOSubXact_SPI() popped any SPI context of the subxact, it
- * will have left us in a disconnected state. We need this hack to
- * return to connected state.
+ * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will
+ * have left us in a disconnected state. We need this hack to return
+ * to connected state.
*/
SPI_restore_connection();
PLy_free(subxactdata);
/*
- * AtEOSubXact_SPI() should not have popped any SPI context, but
- * just in case it did, make sure we remain connected.
+ * AtEOSubXact_SPI() should not have popped any SPI context, but just in
+ * case it did, make sure we remain connected.
*/
SPI_restore_connection();
if (PyModule_AddObject(plpy, "spiexceptions", excmod) < 0)
PLy_elog(ERROR, "failed to add the spiexceptions module");
-/*
+/*
* XXX it appears that in some circumstances the reference count of the
* spiexceptions module drops to zero causing a Python assert failure when
* the garbage collector visits the module. This has been observed on the
- * buildfarm. To fix this, add an additional ref for the module here.
+ * buildfarm. To fix this, add an additional ref for the module here.
*
* This shouldn't cause a memory leak - we don't want this garbage collected,
* and this function shouldn't be called more than once per backend.
static void
PLy_spi_exception_set(PyObject *excclass, ErrorData *edata)
{
- PyObject *args = NULL;
- PyObject *spierror = NULL;
- PyObject *spidata = NULL;
+ PyObject *args = NULL;
+ PyObject *spierror = NULL;
+ PyObject *spidata = NULL;
args = Py_BuildValue("(s)", edata->message);
if (!args)
char *tbmsg;
int tb_depth;
StringInfoData emsg;
- PyObject *exc, *val, *tb;
- const char *primary = NULL;
- char *detail = NULL;
- char *hint = NULL;
- char *query = NULL;
+ PyObject *exc,
+ *val,
+ *tb;
+ const char *primary = NULL;
+ char *detail = NULL;
+ char *hint = NULL;
+ char *query = NULL;
int position = 0;
PyErr_Fetch(&exc, &val, &tb);
static void
PLy_get_spi_error_data(PyObject *exc, char **detail, char **hint, char **query, int *position)
{
- PyObject *spidata = NULL;
+ PyObject *spidata = NULL;
spidata = PyObject_GetAttrString(exc, "spidata");
if (!spidata)
static char *
get_source_line(const char *src, int lineno)
{
- const char *s = NULL;
- const char *next = src;
- int current = 0;
+ const char *s = NULL;
+ const char *next = src;
+ int current = 0;
while (current < lineno)
{
appendStringInfoString(&tbstr, "Traceback (most recent call last):");
while (tb != NULL && tb != Py_None)
{
- PyObject *volatile tb_prev = NULL;
- PyObject *volatile frame = NULL;
- PyObject *volatile code = NULL;
- PyObject *volatile name = NULL;
- PyObject *volatile lineno = NULL;
+ PyObject *volatile tb_prev = NULL;
+ PyObject *volatile frame = NULL;
+ PyObject *volatile code = NULL;
+ PyObject *volatile name = NULL;
+ PyObject *volatile lineno = NULL;
PG_TRY();
{
/* The first frame always points at <module>, skip it. */
if (*tb_depth > 0)
{
- char *proname;
- char *fname;
- char *line;
- long plain_lineno;
+ char *proname;
+ char *fname;
+ char *line;
+ long plain_lineno;
/*
- * The second frame points at the internal function, but
- * to mimick Python error reporting we want to say
- * <module>.
+ * The second frame points at the internal function, but to mimick
+ * Python error reporting we want to say <module>.
*/
if (*tb_depth == 1)
fname = "<module>";
if (proname == NULL)
appendStringInfo(
- &tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
- plain_lineno - 1, fname);
+ &tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
+ plain_lineno - 1, fname);
else
appendStringInfo(
&tbstr, "\n PL/Python function \"%s\", line %ld, in %s",
- proname, plain_lineno - 1, fname);
+ proname, plain_lineno - 1, fname);
if (PLy_curr_procedure)
{
/*
- * If we know the current procedure, append the exact
- * line from the source, again mimicking Python's
- * traceback.py module behavior. We could store the
- * already line-split source to avoid splitting it
- * every time, but producing a traceback is not the
- * most important scenario to optimize for.
+ * If we know the current procedure, append the exact line
+ * from the source, again mimicking Python's traceback.py
+ * module behavior. We could store the already line-split
+ * source to avoid splitting it every time, but producing a
+ * traceback is not the most important scenario to optimize
+ * for.
*/
line = get_source_line(PLy_curr_procedure->src, plain_lineno);
if (line)
return o;
}
-
#endif /* PY_MAJOR_VERSION >= 3 */
#if PY_MAJOR_VERSION < 3
**********************************************************************/
typedef struct pltcl_interp_desc
{
- Oid user_id; /* Hash key (must be first!) */
- Tcl_Interp *interp; /* The interpreter */
- Tcl_HashTable query_hash; /* pltcl_query_desc structs */
+ Oid user_id; /* Hash key (must be first!) */
+ Tcl_Interp *interp; /* The interpreter */
+ Tcl_HashTable query_hash; /* pltcl_query_desc structs */
} pltcl_interp_desc;
**********************************************************************/
typedef struct pltcl_proc_key
{
- Oid proc_id; /* Function OID */
+ Oid proc_id; /* Function OID */
+
/*
* is_trigger is really a bool, but declare as Oid to ensure this struct
* contains no padding
*/
- Oid is_trigger; /* is it a trigger function? */
- Oid user_id; /* User calling the function, or 0 */
+ Oid is_trigger; /* is it a trigger function? */
+ Oid user_id; /* User calling the function, or 0 */
} pltcl_proc_key;
typedef struct pltcl_proc_ptr
{
- pltcl_proc_key proc_key; /* Hash key (must be first!) */
+ pltcl_proc_key proc_key; /* Hash key (must be first!) */
pltcl_proc_desc *proc_ptr;
} pltcl_proc_ptr;
static void throw_tcl_error(Tcl_Interp *interp, const char *proname);
static pltcl_proc_desc *compile_pltcl_function(Oid fn_oid, Oid tgreloid,
- bool pltrusted);
+ bool pltrusted);
static int pltcl_elog(ClientData cdata, Tcl_Interp *interp,
int argc, CONST84 char *argv[]);
ereport(WARNING,
(errmsg("could not determine encoding for locale \"%s\": codeset is \"%s\"",
ctype, sys),
- errdetail("Please report this to <pgsql-bugs@postgresql.org>.")));
+ errdetail("Please report this to <pgsql-bugs@postgresql.org>.")));
#endif
}
#if defined(B64)
B64 b64;
#endif
-} C_block;
+} C_block;
/*
* Convert twenty-four-bit long in host-order
WORD PrintNameOffset;
WORD PrintNameLength;
WCHAR PathBuffer[1];
-} REPARSE_JUNCTION_DATA_BUFFER;
+} REPARSE_JUNCTION_DATA_BUFFER;
#define REPARSE_JUNCTION_DATA_BUFFER_HEADER_SIZE \
FIELD_OFFSET(REPARSE_JUNCTION_DATA_BUFFER, SubstituteNameOffset)
if (fgets(line, maxsize, pgver) == NULL)
{
perror("fgets failure");
- pclose(pgver); /* no error checking */
+ pclose(pgver); /* no error checking */
return NULL;
}
return "Not enough memory";
#endif
#ifdef EAI_NODATA
-#if !defined(WIN64) && !defined(WIN32_ONLY_COMPILER) /* MSVC/WIN64 duplicate */
+#if !defined(WIN64) && !defined(WIN32_ONLY_COMPILER) /* MSVC/WIN64 duplicate */
case EAI_NODATA:
return "No host data of that type was found";
#endif
if (sa->sa_family == AF_INET)
{
if (inet_net_ntop(AF_INET, &((struct sockaddr_in *) sa)->sin_addr,
- sa->sa_family == AF_INET ? 32 : 128,
- node, nodelen) == NULL)
- return EAI_MEMORY;
+ sa->sa_family == AF_INET ? 32 : 128,
+ node, nodelen) == NULL)
+ return EAI_MEMORY;
}
else
return EAI_MEMORY;
inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
/*
- * We need to cover both the address family constants used by the PG
- * inet type (PGSQL_AF_INET and PGSQL_AF_INET6) and those used by the
- * system libraries (AF_INET and AF_INET6). We can safely assume
- * PGSQL_AF_INET == AF_INET, but the INET6 constants are very likely
- * to be different. If AF_INET6 isn't defined, silently ignore it.
+ * We need to cover both the address family constants used by the PG inet
+ * type (PGSQL_AF_INET and PGSQL_AF_INET6) and those used by the system
+ * libraries (AF_INET and AF_INET6). We can safely assume PGSQL_AF_INET
+ * == AF_INET, but the INET6 constants are very likely to be different.
+ * If AF_INET6 isn't defined, silently ignore it.
*/
switch (af)
{
else if (path_contains_parent_reference(path))
return false;
#ifdef WIN32
+
/*
- * On Win32, a drive letter _not_ followed by a slash, e.g. 'E:abc', is
- * relative to the cwd on that drive, or the drive's root directory
- * if that drive has no cwd. Because the path itself cannot tell us
- * which is the case, we have to assume the worst, i.e. that it is not
- * below the cwd. We could use GetFullPathName() to find the full path
- * but that could change if the current directory for the drive changes
- * underneath us, so we just disallow it.
+ * On Win32, a drive letter _not_ followed by a slash, e.g. 'E:abc', is
+ * relative to the cwd on that drive, or the drive's root directory if
+ * that drive has no cwd. Because the path itself cannot tell us which is
+ * the case, we have to assume the worst, i.e. that it is not below the
+ * cwd. We could use GetFullPathName() to find the full path but that
+ * could change if the current directory for the drive changes underneath
+ * us, so we just disallow it.
*/
else if (isalpha((unsigned char) path[0]) && path[1] == ':' &&
- !IS_DIR_SEP(path[2]))
+ !IS_DIR_SEP(path[2]))
return false;
#endif
else
- return true;
+ return true;
}
/*
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
/* bufend == NULL is for sprintf, where we assume buf is big enough */
FILE *stream; /* eventual output destination, or NULL */
int nchars; /* # chars already sent to stream */
-} PrintfTarget;
+} PrintfTarget;
/*
* Info about the type and value of a formatting parameter. Note that we
ATYPE_LONGLONG,
ATYPE_DOUBLE,
ATYPE_CHARPTR
-} PrintfArgType;
+} PrintfArgType;
typedef union
{
int64 ll;
double d;
char *cptr;
-} PrintfArgValue;
+} PrintfArgValue;
-static void flushbuffer(PrintfTarget * target);
-static int dopr(PrintfTarget * target, const char *format, va_list args);
+static void flushbuffer(PrintfTarget *target);
+static int dopr(PrintfTarget *target, const char *format, va_list args);
int
/* call this only when stream is defined */
static void
-flushbuffer(PrintfTarget * target)
+flushbuffer(PrintfTarget *target)
{
size_t nc = target->bufptr - target->bufstart;
static void fmtstr(char *value, int leftjust, int minlen, int maxwidth,
- int pointflag, PrintfTarget * target);
-static void fmtptr(void *value, PrintfTarget * target);
+ int pointflag, PrintfTarget *target);
+static void fmtptr(void *value, PrintfTarget *target);
static void fmtint(int64 value, char type, int forcesign,
int leftjust, int minlen, int zpad, int precision, int pointflag,
- PrintfTarget * target);
-static void fmtchar(int value, int leftjust, int minlen, PrintfTarget * target);
+ PrintfTarget *target);
+static void fmtchar(int value, int leftjust, int minlen, PrintfTarget *target);
static void fmtfloat(double value, char type, int forcesign,
int leftjust, int minlen, int zpad, int precision, int pointflag,
- PrintfTarget * target);
-static void dostr(const char *str, int slen, PrintfTarget * target);
-static void dopr_outch(int c, PrintfTarget * target);
+ PrintfTarget *target);
+static void dostr(const char *str, int slen, PrintfTarget *target);
+static void dopr_outch(int c, PrintfTarget *target);
static int adjust_sign(int is_negative, int forcesign, int *signvalue);
static void adjust_padlen(int minlen, int vallen, int leftjust, int *padlen);
static void leading_pad(int zpad, int *signvalue, int *padlen,
- PrintfTarget * target);
-static void trailing_pad(int *padlen, PrintfTarget * target);
+ PrintfTarget *target);
+static void trailing_pad(int *padlen, PrintfTarget *target);
/*
* dopr(): poor man's version of doprintf
*/
static int
-dopr(PrintfTarget * target, const char *format, va_list args)
+dopr(PrintfTarget *target, const char *format, va_list args)
{
const char *format_start = format;
int ch;
static void
fmtstr(char *value, int leftjust, int minlen, int maxwidth,
- int pointflag, PrintfTarget * target)
+ int pointflag, PrintfTarget *target)
{
int padlen,
vallen; /* amount to pad */
}
static void
-fmtptr(void *value, PrintfTarget * target)
+fmtptr(void *value, PrintfTarget *target)
{
int vallen;
char convert[64];
static void
fmtint(int64 value, char type, int forcesign, int leftjust,
int minlen, int zpad, int precision, int pointflag,
- PrintfTarget * target)
+ PrintfTarget *target)
{
uint64 base;
int dosign;
}
static void
-fmtchar(int value, int leftjust, int minlen, PrintfTarget * target)
+fmtchar(int value, int leftjust, int minlen, PrintfTarget *target)
{
int padlen = 0; /* amount to pad */
static void
fmtfloat(double value, char type, int forcesign, int leftjust,
int minlen, int zpad, int precision, int pointflag,
- PrintfTarget * target)
+ PrintfTarget *target)
{
int signvalue = 0;
int vallen;
}
static void
-dostr(const char *str, int slen, PrintfTarget * target)
+dostr(const char *str, int slen, PrintfTarget *target)
{
while (slen > 0)
{
}
static void
-dopr_outch(int c, PrintfTarget * target)
+dopr_outch(int c, PrintfTarget *target)
{
if (target->bufend != NULL && target->bufptr >= target->bufend)
{
static void
-leading_pad(int zpad, int *signvalue, int *padlen, PrintfTarget * target)
+leading_pad(int zpad, int *signvalue, int *padlen, PrintfTarget *target)
{
if (*padlen > 0 && zpad)
{
static void
-trailing_pad(int *padlen, PrintfTarget * target)
+trailing_pad(int *padlen, PrintfTarget *target)
{
while (*padlen < 0)
{
* that we zap the actual environ member. However, there are some libc
* implementations (notably recent BSDs) that do not obey SUS but copy the
* presented string. This method fails on such platforms. Hopefully all
- * such platforms have unsetenv() and thus won't be using this hack.
- * See: http://www.greenend.org.uk/rjk/2008/putenv.html
+ * such platforms have unsetenv() and thus won't be using this hack. See:
+ * http://www.greenend.org.uk/rjk/2008/putenv.html
*
* Note that repeatedly setting and unsetting a var using this code will
* leak memory.
*/
static PID_TYPE
isolation_start_test(const char *testname,
- _stringlist ** resultfiles,
- _stringlist ** expectfiles,
- _stringlist ** tags)
+ _stringlist ** resultfiles,
+ _stringlist ** expectfiles,
+ _stringlist ** tags)
{
PID_TYPE pid;
char infile[MAXPGPATH];
#include "isolationtester.h"
-static PGconn **conns = NULL;
-static int nconns = 0;
+static PGconn **conns = NULL;
+static int nconns = 0;
-static void run_all_permutations(TestSpec *testspec);
-static void run_all_permutations_recurse(TestSpec *testspec, int nsteps, Step **steps);
-static void run_named_permutations(TestSpec *testspec);
-static void run_permutation(TestSpec *testspec, int nsteps, Step **steps);
+static void run_all_permutations(TestSpec * testspec);
+static void run_all_permutations_recurse(TestSpec * testspec, int nsteps, Step ** steps);
+static void run_named_permutations(TestSpec * testspec);
+static void run_permutation(TestSpec * testspec, int nsteps, Step ** steps);
-static int step_qsort_cmp(const void *a, const void *b);
-static int step_bsearch_cmp(const void *a, const void *b);
+static int step_qsort_cmp(const void *a, const void *b);
+static int step_bsearch_cmp(const void *a, const void *b);
static void printResultSet(PGresult *res);
exit_nicely(void)
{
int i;
+
for (i = 0; i < nconns; i++)
PQfinish(conns[i]);
exit(1);
/*
* If the user supplies a parameter on the command line, use it as the
- * conninfo string; otherwise default to setting dbname=postgres and
- * using environment variables or defaults for all other connection
- * parameters.
+ * conninfo string; otherwise default to setting dbname=postgres and using
+ * environment variables or defaults for all other connection parameters.
*/
if (argc > 1)
conninfo = argv[1];
conns = calloc(nconns, sizeof(PGconn *));
for (i = 0; i < testspec->nsessions; i++)
{
- PGresult *res;
+ PGresult *res;
conns[i] = PQconnectdb(conninfo);
if (PQstatus(conns[i]) != CONNECTION_OK)
/* Set the session index fields in steps. */
for (i = 0; i < testspec->nsessions; i++)
{
- Session *session = testspec->sessions[i];
- int stepindex;
+ Session *session = testspec->sessions[i];
+ int stepindex;
+
for (stepindex = 0; stepindex < session->nsteps; stepindex++)
session->steps[stepindex]->session = i;
}
* Run all permutations of the steps and sessions.
*/
static void
-run_all_permutations(TestSpec *testspec)
+run_all_permutations(TestSpec * testspec)
{
int nsteps;
int i;
steps = malloc(sizeof(Step *) * nsteps);
/*
- * To generate the permutations, we conceptually put the steps of
- * each session on a pile. To generate a permuation, we pick steps
- * from the piles until all piles are empty. By picking steps from
- * piles in different order, we get different permutations.
+ * To generate the permutations, we conceptually put the steps of each
+ * session on a pile. To generate a permuation, we pick steps from the
+ * piles until all piles are empty. By picking steps from piles in
+ * different order, we get different permutations.
*
- * A pile is actually just an integer which tells how many steps
- * we've already picked from this pile.
+ * A pile is actually just an integer which tells how many steps we've
+ * already picked from this pile.
*/
piles = malloc(sizeof(int) * testspec->nsessions);
for (i = 0; i < testspec->nsessions; i++)
}
static void
-run_all_permutations_recurse(TestSpec *testspec, int nsteps, Step **steps)
+run_all_permutations_recurse(TestSpec * testspec, int nsteps, Step ** steps)
{
- int i;
- int found = 0;
+ int i;
+ int found = 0;
for (i = 0; i < testspec->nsessions; i++)
{
* Run permutations given in the test spec
*/
static void
-run_named_permutations(TestSpec *testspec)
+run_named_permutations(TestSpec * testspec)
{
- int i, j;
- int n;
- int nallsteps;
- Step **allsteps;
+ int i,
+ j;
+ int n;
+ int nallsteps;
+ Step **allsteps;
/* First create a lookup table of all steps */
nallsteps = 0;
for (i = 0; i < testspec->npermutations; i++)
{
Permutation *p = testspec->permutations[i];
- Step **steps;
+ Step **steps;
steps = malloc(p->nsteps * sizeof(Step *));
for (j = 0; j < p->nsteps; j++)
{
steps[j] = *((Step **) bsearch(p->stepnames[j], allsteps, nallsteps,
- sizeof(Step *), &step_bsearch_cmp));
+ sizeof(Step *), &step_bsearch_cmp));
if (steps[j] == NULL)
{
fprintf(stderr, "undefined step \"%s\" specified in permutation\n", p->stepnames[j]);
static int
step_qsort_cmp(const void *a, const void *b)
{
- Step *stepa = *((Step **) a);
- Step *stepb = *((Step **) b);
+ Step *stepa = *((Step **) a);
+ Step *stepb = *((Step **) b);
return strcmp(stepa->name, stepb->name);
}
static int
step_bsearch_cmp(const void *a, const void *b)
{
- char *stepname = (char *) a;
- Step *step = *((Step **) b);
+ char *stepname = (char *) a;
+ Step *step = *((Step **) b);
return strcmp(stepname, step->name);
}
* Run one permutation
*/
static void
-run_permutation(TestSpec *testspec, int nsteps, Step **steps)
+run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
{
- PGresult *res;
- int i;
+ PGresult *res;
+ int i;
printf("\nstarting permutation:");
for (i = 0; i < nsteps; i++)
/* Perform steps */
for (i = 0; i < nsteps; i++)
{
- Step *step = steps[i];
+ Step *step = steps[i];
+
printf("step %s: %s\n", step->name, step->sql);
res = PQexec(conns[step->session], step->sql);
- switch(PQresultStatus(res))
+ switch (PQresultStatus(res))
{
case PGRES_COMMAND_OK:
break;
static void
printResultSet(PGresult *res)
{
- int nFields;
- int i, j;
-
- /* first, print out the attribute names */
- nFields = PQnfields(res);
- for (i = 0; i < nFields; i++)
- printf("%-15s", PQfname(res, i));
- printf("\n\n");
-
- /* next, print out the rows */
- for (i = 0; i < PQntuples(res); i++)
- {
- for (j = 0; j < nFields; j++)
- printf("%-15s", PQgetvalue(res, i, j));
- printf("\n");
- }
+ int nFields;
+ int i,
+ j;
+
+ /* first, print out the attribute names */
+ nFields = PQnfields(res);
+ for (i = 0; i < nFields; i++)
+ printf("%-15s", PQfname(res, i));
+ printf("\n\n");
+
+ /* next, print out the rows */
+ for (i = 0; i < PQntuples(res); i++)
+ {
+ for (j = 0; j < nFields; j++)
+ printf("%-15s", PQgetvalue(res, i, j));
+ printf("\n");
+ }
}
struct Step
{
- int session;
+ int session;
char *name;
char *sql;
};
{
int nsteps;
char **stepnames;
-} Permutation;
+} Permutation;
typedef struct
{
char *setupsql;
char *teardownsql;
- Session **sessions;
+ Session **sessions;
int nsessions;
Permutation **permutations;
int npermutations;
-} TestSpec;
+} TestSpec;
-extern TestSpec parseresult;
+extern TestSpec parseresult;
extern int spec_yyparse(void);
}
/*
- * Install any requested extensions. We use CREATE IF NOT EXISTS
- * so that this will work whether or not the extension is preinstalled.
+ * Install any requested extensions. We use CREATE IF NOT EXISTS so that
+ * this will work whether or not the extension is preinstalled.
*/
for (sl = loadextension; sl != NULL; sl = sl->next)
{