1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

pgindent run before PG 9.1 beta 1.

This commit is contained in:
Bruce Momjian
2011-04-10 11:42:00 -04:00
parent 9a8b73147c
commit bf50caf105
446 changed files with 5737 additions and 5258 deletions

View File

@@ -282,26 +282,26 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid)
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);
@@ -386,9 +386,11 @@ AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
{
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;
@@ -410,7 +412,7 @@ AlterObjectNamespace(Relation rel, int oidCacheId, int nameCacheId,
/* Permission checks ... superusers can always do it */
if (!superuser())
{
Datum owner;
Datum owner;
Oid ownerId;
AclResult aclresult;

View File

@@ -95,7 +95,7 @@ static void compute_index_stats(Relation onerel, double totalrows,
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);
@@ -160,8 +160,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt,
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;
@@ -853,10 +853,10 @@ examine_attribute(Relation onerel, int attnum, Node *index_expr)
/*
* 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)

View File

@@ -718,7 +718,7 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
TransactionId OldestXmin;
TransactionId FreezeXid;
RewriteState rwstate;
bool use_sort;
bool use_sort;
Tuplesortstate *tuplesort;
double num_tuples = 0,
tups_vacuumed = 0,
@@ -813,11 +813,11 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
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);
@@ -869,8 +869,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid 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 (;;)
{
@@ -984,8 +984,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
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)
{
@@ -1554,7 +1554,7 @@ reform_and_rewrite_tuple(HeapTuple tuple,
bool newRelHasOids, RewriteState rwstate)
{
HeapTuple copiedTuple;
int i;
int i;
heap_deform_tuple(tuple, oldTupDesc, values, isnull);

View File

@@ -34,7 +34,7 @@
#include "utils/syscache.h"
static void AlterCollationOwner_internal(Relation rel, Oid collationOid,
Oid newOwnerId);
Oid newOwnerId);
/*
* CREATE COLLATION
@@ -46,10 +46,10 @@ DefineCollation(List *names, List *parameters)
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;
@@ -63,7 +63,7 @@ DefineCollation(List *names, List *parameters)
foreach(pl, parameters)
{
DefElem *defel = (DefElem *) lfirst(pl);
DefElem *defel = (DefElem *) lfirst(pl);
DefElem **defelp;
if (pg_strcasecmp(defel->defname, "from") == 0)
@@ -97,7 +97,7 @@ DefineCollation(List *names, List *parameters)
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);
@@ -123,7 +123,7 @@ DefineCollation(List *names, List *parameters)
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,
@@ -391,7 +391,7 @@ AlterCollationNamespace(List *name, const char *newschema)
Oid
AlterCollationNamespace_oid(Oid collOid, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
char *collation_name;

View File

@@ -37,8 +37,8 @@
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
@@ -46,12 +46,13 @@ CommentObject(CommentStmt *stmt)
* (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,
@@ -62,10 +63,10 @@ CommentObject(CommentStmt *stmt)
}
/*
* 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);
@@ -78,6 +79,7 @@ CommentObject(CommentStmt *stmt)
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

View File

@@ -335,7 +335,8 @@ AlterConversionOwner_internal(Relation rel, Oid conversionOid, Oid newOwnerId)
void
AlterConversionNamespace(List *name, const char *newschema)
{
Oid convOid, nspOid;
Oid convOid,
nspOid;
Relation rel;
rel = heap_open(ConversionRelationId, RowExclusiveLock);
@@ -361,7 +362,7 @@ AlterConversionNamespace(List *name, const char *newschema)
Oid
AlterConversionNamespace_oid(Oid convOid, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(ConversionRelationId, RowExclusiveLock);

View File

@@ -115,7 +115,7 @@ typedef struct CopyStateData
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 */
@@ -161,8 +161,8 @@ typedef struct CopyStateData
/* 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
@@ -266,10 +266,10 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
/* 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);
@@ -278,8 +278,8 @@ static void CopyOneRowTo(CopyState cstate, Oid tupleOid,
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,
@@ -748,17 +748,17 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
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;
@@ -770,8 +770,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
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);
@@ -1136,8 +1136,8 @@ BeginCopy(bool is_from,
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",
@@ -1300,9 +1300,9 @@ BeginCopy(bool is_from,
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() ||
@@ -1552,8 +1552,8 @@ CopyTo(CopyState cstate)
*/
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)
@@ -2001,9 +2001,9 @@ CopyFrom(CopyState cstate)
{
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);
}
@@ -2159,7 +2159,7 @@ BeginCopyFrom(Relation rel,
{
/* 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++;
}
@@ -2255,7 +2255,7 @@ BeginCopyFrom(Relation rel,
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 *));
@@ -2291,7 +2291,7 @@ NextCopyFromRawFields(CopyState cstate, char ***fields, int *nfields)
{
cstate->cur_lineno++;
if (CopyReadLine(cstate))
return false; /* done */
return false; /* done */
}
cstate->cur_lineno++;
@@ -2300,9 +2300,9 @@ NextCopyFromRawFields(CopyState cstate, char ***fields, int *nfields)
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;
@@ -2341,7 +2341,7 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
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;
@@ -2456,18 +2456,18 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
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)
@@ -2485,14 +2485,14 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
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)
@@ -2524,8 +2524,8 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
/*
* 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++)
{
@@ -3023,12 +3023,12 @@ GetDecimalFromHex(char hex)
* 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).
@@ -3090,8 +3090,8 @@ CopyReadAttributesText(CopyState cstate)
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 */
@@ -3307,8 +3307,8 @@ CopyReadAttributesCSV(CopyState cstate)
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 */

View File

@@ -680,8 +680,8 @@ createdb(const CreatedbStmt *stmt)
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 ||
@@ -1849,10 +1849,10 @@ get_database_oid(const char *dbname, bool missing_ok)
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;
}

View File

@@ -59,26 +59,26 @@ static void ExplainNode(PlanState *planstate, List *ancestors,
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);
@@ -89,7 +89,7 @@ static void ExplainTargetRel(Plan *plan, Index rti, 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,
@@ -1358,7 +1358,7 @@ show_scan_qual(List *qual, const char *qlabel,
{
bool useprefix;
useprefix = (IsA(planstate->plan, SubqueryScan) || es->verbose);
useprefix = (IsA(planstate->plan, SubqueryScan) ||es->verbose);
show_qual(qual, qlabel, planstate, ancestors, useprefix, es);
}

View File

@@ -56,8 +56,8 @@
/* 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
@@ -66,8 +66,8 @@ typedef struct ExtensionControlFile
{
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? */
@@ -85,9 +85,9 @@ typedef struct ExtensionVersionInfo
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 */
@@ -107,7 +107,7 @@ static void ApplyExtensionUpdates(Oid extensionOid,
/*
* 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
@@ -142,10 +142,10 @@ get_extension_oid(const char *extname, bool missing_ok)
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;
}
@@ -237,8 +237,8 @@ check_valid_extension_name(const char *extensionname)
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,
@@ -256,16 +256,16 @@ check_valid_extension_name(const char *extensionname)
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 ".."
@@ -290,7 +290,7 @@ check_valid_version_name(const char *versionname)
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.")));
/*
@@ -299,7 +299,7 @@ check_valid_version_name(const char *versionname)
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 \"--\".")));
/*
@@ -308,8 +308,8 @@ check_valid_version_name(const char *versionname)
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 ".."
@@ -318,7 +318,7 @@ check_valid_version_name(const char *versionname)
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.")));
}
@@ -386,7 +386,7 @@ get_extension_script_directory(ExtensionControlFile *control)
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;
}
@@ -434,7 +434,7 @@ get_extension_script_filename(ExtensionControlFile *control,
/*
* 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,
@@ -448,8 +448,8 @@ parse_extension_control_file(ExtensionControlFile *control,
char *filename;
FILE *file;
ConfigVariable *item,
*head = NULL,
*tail = NULL;
*head = NULL,
*tail = NULL;
/*
* Locate the file to read. Auxiliary files are optional.
@@ -553,8 +553,8 @@ parse_extension_control_file(ExtensionControlFile *control,
/* 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
@@ -632,12 +632,12 @@ static char *
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);
@@ -675,7 +675,7 @@ read_extension_script_file(const ExtensionControlFile *control,
* 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
@@ -774,7 +774,7 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
List *requiredSchemas,
const char *schemaName, Oid schemaOid)
{
char *filename;
char *filename;
char *save_client_min_messages,
*save_log_min_messages,
*save_search_path;
@@ -809,8 +809,8 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
* 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));
@@ -832,8 +832,8 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
* 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));
@@ -855,32 +855,32 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
/*
* 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))));
}
/*
@@ -890,11 +890,11 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
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);
@@ -1004,7 +1004,7 @@ get_ext_ver_list(ExtensionControlFile *control)
struct dirent *de;
location = get_extension_script_directory(control);
dir = AllocateDir(location);
dir = AllocateDir(location);
while ((de = ReadDir(dir, location)) != NULL)
{
char *vername;
@@ -1094,7 +1094,7 @@ identify_update_path(ExtensionControlFile *control,
* 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,
@@ -1132,7 +1132,7 @@ 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)
@@ -1178,10 +1178,10 @@ CreateExtension(CreateExtensionStmt *stmt)
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;
@@ -1195,10 +1195,10 @@ CreateExtension(CreateExtensionStmt *stmt)
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)
{
@@ -1218,8 +1218,8 @@ CreateExtension(CreateExtensionStmt *stmt)
}
/*
* 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,
@@ -1306,8 +1306,8 @@ CreateExtension(CreateExtensionStmt *stmt)
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;
@@ -1351,9 +1351,9 @@ CreateExtension(CreateExtensionStmt *stmt)
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);
@@ -1362,7 +1362,7 @@ CreateExtension(CreateExtensionStmt *stmt)
{
/*
* 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);
@@ -1380,13 +1380,13 @@ CreateExtension(CreateExtensionStmt *stmt)
* 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);
@@ -1397,13 +1397,13 @@ CreateExtension(CreateExtensionStmt *stmt)
* 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;
@@ -1453,8 +1453,8 @@ CreateExtension(CreateExtensionStmt *stmt)
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);
@@ -1653,7 +1653,7 @@ RemoveExtensionById(Oid extId)
/*
* 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
@@ -1663,14 +1663,14 @@ RemoveExtensionById(Oid extId)
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))
@@ -1699,11 +1699,11 @@ pg_available_extensions(PG_FUNCTION_ARGS)
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)
{
@@ -1762,7 +1762,7 @@ pg_available_extensions(PG_FUNCTION_ARGS)
/*
* 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
@@ -1772,14 +1772,14 @@ pg_available_extensions(PG_FUNCTION_ARGS)
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))
@@ -1808,11 +1808,11 @@ pg_available_extension_versions(PG_FUNCTION_ARGS)
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)
{
@@ -1867,7 +1867,7 @@ get_available_versions_for_extension(ExtensionControlFile *pcontrol,
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)
{
@@ -1962,11 +1962,11 @@ Datum
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;
@@ -2079,8 +2079,8 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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;
@@ -2092,8 +2092,8 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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,
@@ -2103,8 +2103,8 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
/*
* 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)
@@ -2115,12 +2115,12 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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 */
@@ -2136,7 +2136,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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);
@@ -2162,7 +2162,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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,
@@ -2193,7 +2193,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
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,
@@ -2231,12 +2231,12 @@ AlterExtensionNamespace(List *names, const char *newschema)
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)
@@ -2275,7 +2275,7 @@ AlterExtensionNamespace(List *names, const char *newschema)
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 */
@@ -2285,8 +2285,8 @@ AlterExtensionNamespace(List *names, const char *newschema)
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)
{
@@ -2323,10 +2323,10 @@ AlterExtensionNamespace(List *names, const char *newschema)
{
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.)
*/
@@ -2388,13 +2388,13 @@ void
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;
@@ -2402,8 +2402,8 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
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,
@@ -2426,10 +2426,10 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
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);
@@ -2499,8 +2499,8 @@ ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
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;
}
@@ -2545,8 +2545,8 @@ ApplyExtensionUpdates(Oid extensionOid,
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];
@@ -2573,7 +2573,7 @@ ApplyExtensionUpdates(Oid extensionOid,
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);
@@ -2668,9 +2668,9 @@ ApplyExtensionUpdates(Oid 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;
}
@@ -2682,10 +2682,10 @@ ApplyExtensionUpdates(Oid extensionOid,
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);
@@ -2697,10 +2697,10 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt)
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);

View File

@@ -586,8 +586,8 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
*/
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
{
@@ -643,8 +643,8 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
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,

View File

@@ -1665,7 +1665,7 @@ CreateCast(CreateCastStmt *stmt)
* 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
@@ -1830,7 +1830,7 @@ DropCast(DropCastStmt *stmt)
Oid
get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok)
{
Oid oid;
Oid oid;
oid = GetSysCacheOid2(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),

View File

@@ -395,7 +395,7 @@ DefineIndex(RangeVar *heapRelation,
indexRelationId =
index_create(rel, indexRelationName, indexRelationId,
indexInfo, indexColNames,
accessMethodId, tablespaceId, collationObjectId, classObjectId,
accessMethodId, tablespaceId, collationObjectId, classObjectId,
coloptions, reloptions, primary,
isconstraint, deferrable, initdeferred,
allowSystemTableMods,
@@ -840,14 +840,14 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
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))
@@ -864,7 +864,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
}
else
{
indexInfo->ii_KeyAttrNumbers[attn] = 0; /* marks expression */
indexInfo->ii_KeyAttrNumbers[attn] = 0; /* marks expression */
indexInfo->ii_Expressions = lappend(indexInfo->ii_Expressions,
expr);
@@ -876,7 +876,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
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),
@@ -904,8 +904,8 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
/*
* 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))
{

View File

@@ -126,7 +126,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
if (!HeapTupleIsValid(htup) && !missing_ok)
{
HeapTuple amtup;
HeapTuple amtup;
amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(amID));
if (!HeapTupleIsValid(amtup))
@@ -134,8 +134,8 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
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;
@@ -143,7 +143,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname, bool missing_ok)
/*
* 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.
*/
@@ -202,7 +202,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
if (!HeapTupleIsValid(htup) && !missing_ok)
{
HeapTuple amtup;
HeapTuple amtup;
amtup = SearchSysCache1(AMOID, ObjectIdGetDatum(amID));
if (!HeapTupleIsValid(amtup))
@@ -219,7 +219,7 @@ OpClassCacheLookup(Oid amID, List *opclassname, bool missing_ok)
/*
* 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.
*/
@@ -1088,11 +1088,11 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
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.)
@@ -1108,8 +1108,8 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
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);
}
@@ -1276,7 +1276,7 @@ storeOperators(List *opfamilyname, Oid amoid,
foreach(l, operators)
{
OpFamilyMember *op = (OpFamilyMember *) lfirst(l);
char oppurpose;
char oppurpose;
/*
* If adding to an existing family, check for conflict with an
@@ -1566,7 +1566,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
{
ereport(NOTICE,
(errmsg("operator class \"%s\" does not exist for access method \"%s\"",
NameListToString(stmt->opclassname), stmt->amname)));
NameListToString(stmt->opclassname), stmt->amname)));
return;
}
@@ -1617,7 +1617,7 @@ RemoveOpFamily(RemoveOpFamilyStmt *stmt)
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;
}
@@ -2029,7 +2029,7 @@ AlterOpClassNamespace(List *name, char *access_method, const char *newschema)
Oid
AlterOpClassNamespace_oid(Oid opclassOid, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
@@ -2238,7 +2238,7 @@ AlterOpFamilyNamespace(List *name, char *access_method, const char *newschema)
Oid
AlterOpFamilyNamespace_oid(Oid opfamilyOid, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);

View File

@@ -464,7 +464,8 @@ AlterOperatorNamespace(List *names, List *argtypes, const char *newschema)
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);
@@ -490,7 +491,7 @@ AlterOperatorNamespace(List *names, List *argtypes, const char *newschema)
Oid
AlterOperatorNamespace_oid(Oid operOid, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(OperatorRelationId, RowExclusiveLock);

View File

@@ -255,10 +255,10 @@ PortalCleanup(Portal portal)
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;

View File

@@ -382,7 +382,7 @@ EvaluateParams(PreparedStatement *pstmt, List *params,
/* 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;

View File

@@ -1,7 +1,7 @@
/* -------------------------------------------------------------------------
*
* 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
@@ -28,7 +28,7 @@
typedef struct
{
const char *provider_name;
check_object_relabel_type hook;
check_object_relabel_type hook;
} LabelProvider;
static List *label_provider_list = NIL;
@@ -42,9 +42,9 @@ void
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
@@ -55,16 +55,16 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
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);
@@ -82,10 +82,10 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
}
/*
* 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);
@@ -98,6 +98,7 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
switch (stmt->objtype)
{
case OBJECT_COLUMN:
/*
* Allow security labels only on columns of tables, views,
* composite types, and foreign tables (which are the only
@@ -117,7 +118,7 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
}
/* 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);
@@ -140,8 +141,8 @@ char *
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;
@@ -196,8 +197,8 @@ SetSecurityLabel(const ObjectAddress *object,
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];
@@ -281,8 +282,8 @@ void
DeleteSecurityLabel(const ObjectAddress *object)
{
Relation pg_seclabel;
ScanKeyData skey[3];
SysScanDesc scan;
ScanKeyData skey[3];
SysScanDesc scan;
HeapTuple oldtup;
int nkeys;
@@ -323,8 +324,8 @@ DeleteSecurityLabel(const ObjectAddress *object)
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));

View File

@@ -287,7 +287,7 @@ ResetSequence(Oid seq_relid)
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);
@@ -1037,7 +1037,7 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel)
/*
* 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)

View File

@@ -286,9 +286,9 @@ static void ATWrongRelkindError(Relation rel, int allowed_targets);
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,
@@ -311,7 +311,7 @@ static void ATExecSetOptions(Relation rel, const char *colName,
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,
@@ -320,9 +320,9 @@ static void ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
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,
@@ -339,7 +339,7 @@ static void ATPrepAlterColumnType(List **wqueue,
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,
@@ -351,7 +351,7 @@ static void ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel,
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);
@@ -412,7 +412,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId)
/*
* 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),
@@ -547,7 +547,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId)
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);
@@ -706,7 +706,7 @@ DropErrorMsgWrongType(const char *relname, char wrongkind, char rightkind)
/*
* RemoveRelations
* Implements DROP TABLE, DROP INDEX, DROP SEQUENCE, DROP VIEW,
* DROP FOREIGN TABLE
* DROP FOREIGN TABLE
*/
void
RemoveRelations(DropStmt *drop)
@@ -1454,11 +1454,11 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
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)
@@ -2061,8 +2061,8 @@ renameatt_internal(Oid myrelid,
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.
@@ -2138,7 +2138,7 @@ renameatt_internal(Oid myrelid,
ListCell *lo;
child_oids = find_typed_table_dependencies(targetrelation->rd_rel->reltype,
RelationGetRelationName(targetrelation),
RelationGetRelationName(targetrelation),
behavior);
foreach(lo, child_oids)
@@ -2211,11 +2211,11 @@ void
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);
}
@@ -2460,7 +2460,7 @@ void
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.
@@ -2531,7 +2531,7 @@ AlterTable(AlterTableStmt *stmt)
}
ATController(rel, stmt->cmds, interpretInhOption(stmt->relation->inhOpt),
lockmode);
lockmode);
}
/*
@@ -2549,7 +2549,7 @@ void
AlterTableInternal(Oid relid, List *cmds, bool recurse)
{
Relation rel;
LOCKMODE lockmode = AlterTableGetLockLevel(cmds);
LOCKMODE lockmode = AlterTableGetLockLevel(cmds);
rel = relation_open(relid, lockmode);
@@ -2581,31 +2581,33 @@ 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 */
@@ -2615,12 +2617,12 @@ AlterTableGetLockLevel(List *cmds)
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:
@@ -2629,7 +2631,7 @@ AlterTableGetLockLevel(List *cmds)
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;
@@ -2644,14 +2646,17 @@ AlterTableGetLockLevel(List *cmds)
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
@@ -2666,26 +2671,29 @@ AlterTableGetLockLevel(List *cmds)
}
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:
@@ -2698,7 +2706,7 @@ AlterTableGetLockLevel(List *cmds)
cmd_lockmode = ShareUpdateExclusiveLock;
break;
default: /* oops */
default: /* oops */
elog(ERROR, "unrecognized alter table type: %d",
(int) cmd->subtype);
break;
@@ -2773,7 +2781,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
{
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;
@@ -2793,19 +2801,19 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
* 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;
@@ -2818,7 +2826,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
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;
@@ -2830,7 +2838,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
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;
@@ -2849,7 +2857,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
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 */
@@ -2865,7 +2873,7 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
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;
@@ -2904,14 +2912,14 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
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;
@@ -3072,11 +3080,11 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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);
@@ -3092,7 +3100,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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:
@@ -3156,7 +3164,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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,
@@ -3164,7 +3172,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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,
@@ -3172,7 +3180,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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,
@@ -3180,7 +3188,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
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,
@@ -3254,8 +3262,8 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
* (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)
{
@@ -3386,8 +3394,8 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
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);
@@ -3723,7 +3731,7 @@ ATGetQueueEntry(List **wqueue, Relation rel)
static void
ATSimplePermissions(Relation rel, int allowed_targets)
{
int actual_target;
int actual_target;
switch (rel->rd_rel->relkind)
{
@@ -3779,16 +3787,16 @@ ATWrongRelkindError(Relation rel, int allowed_targets)
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:
@@ -4032,7 +4040,7 @@ find_typed_table_dependencies(Oid typeOid, const char *typeName, DropBehavior be
(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));
}
@@ -4103,9 +4111,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* 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)
{
@@ -4133,10 +4141,10 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
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)
@@ -4265,7 +4273,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
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;
@@ -5170,10 +5178,11 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
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)
@@ -5216,7 +5225,7 @@ ATExecAddIndexConstraint(AlteredTableInfo *tab, Relation rel,
*/
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));
@@ -5337,9 +5346,9 @@ ATAddCheckConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
/*
* 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;
@@ -5655,8 +5664,8 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
/*
* 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)
{
@@ -5718,8 +5727,8 @@ ATExecValidateConstraint(Relation rel, const char *constrName)
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)
{
@@ -5729,17 +5738,16 @@ ATExecValidateConstraint(Relation rel, const char *constrName)
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);
@@ -6571,12 +6579,12 @@ ATPrepAlterColumnType(List **wqueue,
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)
{
@@ -6596,13 +6604,13 @@ ATPrepAlterColumnType(List **wqueue,
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),
@@ -6615,7 +6623,7 @@ ATPrepAlterColumnType(List **wqueue,
else
{
transform = (Node *) makeVar(1, attnum,
attTup->atttypid, attTup->atttypmod, attTup->attcollation,
attTup->atttypid, attTup->atttypmod, attTup->attcollation,
0);
}
@@ -6649,14 +6657,14 @@ ATPrepAlterColumnType(List **wqueue,
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);
}
@@ -6699,7 +6707,7 @@ ATColumnChangeRequiresRewrite(Node *expr, AttrNumber varattno)
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;
@@ -6924,13 +6932,14 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
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,
@@ -7940,7 +7949,7 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst,
*/
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);
}
@@ -8558,18 +8567,18 @@ ATExecDropInherit(Relation rel, RangeVar *parent, LOCKMODE lockmode)
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;
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)
if (options == NIL)
return;
ftrel = heap_open(ForeignTableRelationId, RowExclusiveLock);
@@ -8579,7 +8588,7 @@ ATExecGenericOptions(Relation rel, List *options)
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);
@@ -8718,8 +8727,8 @@ AlterTableNamespace(RangeVar *relation, const char *newschema,
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 */
@@ -8836,7 +8845,7 @@ AlterIndexNamespaces(Relation classRel, Relation rel,
*/
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;

View File

@@ -559,7 +559,7 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid)
(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(),
@@ -573,8 +573,8 @@ create_tablespace_directories(const char *location, const Oid tablespaceoid)
/*
* 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))
{
@@ -1353,10 +1353,10 @@ get_tablespace_oid(const char *tablespacename, bool missing_ok)
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;
}

View File

@@ -144,11 +144,11 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
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);
@@ -244,7 +244,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
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),
@@ -480,8 +480,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
* 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)
{
@@ -1036,8 +1036,8 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior,
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;
}
@@ -1083,9 +1083,9 @@ RemoveTriggerById(Oid trigOid)
/*
* 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;
@@ -1960,7 +1960,7 @@ ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo,
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.
@@ -2035,7 +2035,7 @@ ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo,
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.
@@ -2378,7 +2378,7 @@ ExecBRUpdateTriggers(EState *estate, EPQState *epqstate,
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.
@@ -2461,7 +2461,7 @@ ExecIRUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
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.
@@ -2891,7 +2891,7 @@ typedef struct AfterTriggerEventDataOneCtid
{
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) ? \

View File

@@ -407,7 +407,8 @@ RenameTSParser(List *oldname, const char *newname)
void
AlterTSParserNamespace(List *name, const char *newschema)
{
Oid prsId, nspOid;
Oid prsId,
nspOid;
Relation rel;
rel = heap_open(TSParserRelationId, RowExclusiveLock);
@@ -429,7 +430,7 @@ AlterTSParserNamespace(List *name, const char *newschema)
Oid
AlterTSParserNamespace_oid(Oid prsId, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(TSParserRelationId, RowExclusiveLock);
@@ -685,7 +686,8 @@ RenameTSDictionary(List *oldname, const char *newname)
void
AlterTSDictionaryNamespace(List *name, const char *newschema)
{
Oid dictId, nspOid;
Oid dictId,
nspOid;
Relation rel;
rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
@@ -708,7 +710,7 @@ AlterTSDictionaryNamespace(List *name, const char *newschema)
Oid
AlterTSDictionaryNamespace_oid(Oid dictId, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
@@ -1218,7 +1220,8 @@ RenameTSTemplate(List *oldname, const char *newname)
void
AlterTSTemplateNamespace(List *name, const char *newschema)
{
Oid tmplId, nspOid;
Oid tmplId,
nspOid;
Relation rel;
rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
@@ -1240,7 +1243,7 @@ AlterTSTemplateNamespace(List *name, const char *newschema)
Oid
AlterTSTemplateNamespace_oid(Oid tmplId, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(TSTemplateRelationId, RowExclusiveLock);
@@ -1668,7 +1671,8 @@ RenameTSConfiguration(List *oldname, const char *newname)
void
AlterTSConfigurationNamespace(List *name, const char *newschema)
{
Oid cfgId, nspOid;
Oid cfgId,
nspOid;
Relation rel;
rel = heap_open(TSConfigRelationId, RowExclusiveLock);
@@ -1691,7 +1695,7 @@ AlterTSConfigurationNamespace(List *name, const char *newschema)
Oid
AlterTSConfigurationNamespace_oid(Oid cfgId, Oid newNspOid)
{
Oid oldNspOid;
Oid oldNspOid;
Relation rel;
rel = heap_open(TSConfigRelationId, RowExclusiveLock);

View File

@@ -138,7 +138,7 @@ DefineType(List *names, List *parameters)
DefElem *byValueEl = NULL;
DefElem *alignmentEl = NULL;
DefElem *storageEl = NULL;
DefElem *collatableEl = NULL;
DefElem *collatableEl = NULL;
Oid inputOid;
Oid outputOid;
Oid receiveOid = InvalidOid;
@@ -537,7 +537,7 @@ DefineType(List *names, List *parameters)
* 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 =
@@ -1179,7 +1179,7 @@ DefineEnum(CreateEnumStmt *stmt)
-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);
@@ -2416,7 +2416,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
CONSTRAINT_CHECK, /* Constraint Type */
false, /* Is Deferrable */
false, /* Is Deferred */
true, /* Is Validated */
true, /* Is Validated */
InvalidOid, /* not a relation constraint */
NULL,
0,

View File

@@ -84,7 +84,7 @@ CreateRole(CreateRoleStmt *stmt)
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 */
@@ -98,7 +98,7 @@ CreateRole(CreateRoleStmt *stmt)
DefElem *dcreaterole = NULL;
DefElem *dcreatedb = NULL;
DefElem *dcanlogin = NULL;
DefElem *disreplication = NULL;
DefElem *disreplication = NULL;
DefElem *dconnlimit = NULL;
DefElem *daddroleto = NULL;
DefElem *drolemembers = NULL;
@@ -240,9 +240,10 @@ CreateRole(CreateRoleStmt *stmt)
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;
@@ -287,7 +288,7 @@ CreateRole(CreateRoleStmt *stmt)
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
{
@@ -384,8 +385,8 @@ CreateRole(CreateRoleStmt *stmt)
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))
{
@@ -467,7 +468,7 @@ AlterRole(AlterRoleStmt *stmt)
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 */
@@ -479,7 +480,7 @@ AlterRole(AlterRoleStmt *stmt)
DefElem *dcreaterole = NULL;
DefElem *dcreatedb = NULL;
DefElem *dcanlogin = NULL;
DefElem *disreplication = NULL;
DefElem *disreplication = NULL;
DefElem *dconnlimit = NULL;
DefElem *drolemembers = NULL;
DefElem *dvalidUntil = NULL;

View File

@@ -527,7 +527,7 @@ vac_update_relstats(Relation relation,
/*
* 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)
{
@@ -839,8 +839,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, bool do_toast, bool for_wraparound,
* 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);
@@ -852,8 +852,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, bool do_toast, bool for_wraparound,
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)

View File

@@ -705,15 +705,16 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
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.

View File

@@ -132,8 +132,8 @@ check_datestyle(char **newval, void **extra, GucSource source)
* 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)
@@ -262,9 +262,9 @@ check_timezone(char **newval, void **extra, GucSource source)
{
/*
* 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
@@ -289,7 +289,7 @@ check_timezone(char **newval, void **extra, GucSource source)
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;
@@ -391,13 +391,13 @@ check_timezone(char **newval, void **extra, GucSource source)
*
* 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;
@@ -567,7 +567,7 @@ show_log_timezone(void)
* 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
@@ -719,7 +719,7 @@ check_transaction_deferrable(bool *newval, void **extra, GucSource source)
*
* 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.
*/
@@ -851,8 +851,8 @@ check_session_authorization(char **newval, void **extra, GucSource source)
{
/*
* 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;
}
@@ -977,7 +977,7 @@ const char *
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

View File

@@ -120,7 +120,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
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;
@@ -130,6 +130,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
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.
@@ -240,7 +241,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
}
else
{
Oid relid;
Oid relid;
/*
* now set the parameters for keys/inheritance etc. All of these are
@@ -437,8 +438,8 @@ DefineView(ViewStmt *stmt, const char *queryString)
/*
* 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,
@@ -447,7 +448,7 @@ DefineView(ViewStmt *stmt, const char *queryString)
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
@@ -500,7 +501,7 @@ DefineView(ViewStmt *stmt, const char *queryString)
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