mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Post-PG 10 beta1 pgindent run
perltidy run not included.
This commit is contained in:
@@ -428,7 +428,7 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
|
||||
|
||||
address =
|
||||
get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
|
||||
&rel, AccessExclusiveLock, false);
|
||||
&rel, AccessExclusiveLock, false);
|
||||
|
||||
/*
|
||||
* If a relation was involved, it would have been opened and locked. We
|
||||
|
||||
@@ -1275,7 +1275,7 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
|
||||
nrels,
|
||||
i;
|
||||
ListCell *lc;
|
||||
bool has_child;
|
||||
bool has_child;
|
||||
|
||||
/*
|
||||
* Find all members of inheritance set. We only need AccessShareLock on
|
||||
|
||||
@@ -268,9 +268,9 @@ AlterCollation(AlterCollationStmt *stmt)
|
||||
elog(ERROR, "invalid collation version change");
|
||||
else if (oldversion && newversion && strcmp(newversion, oldversion) != 0)
|
||||
{
|
||||
bool nulls[Natts_pg_collation];
|
||||
bool replaces[Natts_pg_collation];
|
||||
Datum values[Natts_pg_collation];
|
||||
bool nulls[Natts_pg_collation];
|
||||
bool replaces[Natts_pg_collation];
|
||||
Datum values[Natts_pg_collation];
|
||||
|
||||
ereport(NOTICE,
|
||||
(errmsg("changing version from %s to %s",
|
||||
@@ -379,8 +379,8 @@ get_icu_language_tag(const char *localename)
|
||||
uloc_toLanguageTag(localename, buf, sizeof(buf), TRUE, &status);
|
||||
if (U_FAILURE(status))
|
||||
ereport(ERROR,
|
||||
(errmsg("could not convert locale name \"%s\" to language tag: %s",
|
||||
localename, u_errorName(status))));
|
||||
(errmsg("could not convert locale name \"%s\" to language tag: %s",
|
||||
localename, u_errorName(status))));
|
||||
|
||||
return pstrdup(buf);
|
||||
}
|
||||
@@ -405,7 +405,7 @@ get_icu_locale_comment(const char *localename)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* USE_ICU */
|
||||
#endif /* USE_ICU */
|
||||
|
||||
|
||||
Datum
|
||||
@@ -493,7 +493,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
|
||||
CollationCreate(localebuf, nspid, GetUserId(), COLLPROVIDER_LIBC, enc,
|
||||
localebuf, localebuf,
|
||||
get_collation_actual_version(COLLPROVIDER_LIBC, localebuf),
|
||||
get_collation_actual_version(COLLPROVIDER_LIBC, localebuf),
|
||||
if_not_exists);
|
||||
|
||||
CommandCounterIncrement();
|
||||
@@ -526,7 +526,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
|
||||
CollationCreate(alias, nspid, GetUserId(), COLLPROVIDER_LIBC, enc,
|
||||
locale, locale,
|
||||
get_collation_actual_version(COLLPROVIDER_LIBC, locale),
|
||||
get_collation_actual_version(COLLPROVIDER_LIBC, locale),
|
||||
true);
|
||||
CommandCounterIncrement();
|
||||
}
|
||||
@@ -546,7 +546,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Start the loop at -1 to sneak in the root locale without too much
|
||||
@@ -563,7 +563,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
Oid collid;
|
||||
|
||||
if (i == -1)
|
||||
name = ""; /* ICU root locale */
|
||||
name = ""; /* ICU root locale */
|
||||
else
|
||||
name = ucol_getAvailable(i);
|
||||
|
||||
@@ -572,7 +572,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
collid = CollationCreate(psprintf("%s-x-icu", langtag),
|
||||
nspid, GetUserId(), COLLPROVIDER_ICU, -1,
|
||||
collcollate, collcollate,
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
|
||||
if_not_exists);
|
||||
|
||||
CreateComments(collid, CollationRelationId, 0,
|
||||
@@ -585,29 +585,29 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status);
|
||||
if (U_FAILURE(status))
|
||||
ereport(ERROR,
|
||||
(errmsg("could not get keyword values for locale \"%s\": %s",
|
||||
name, u_errorName(status))));
|
||||
(errmsg("could not get keyword values for locale \"%s\": %s",
|
||||
name, u_errorName(status))));
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
uenum_reset(en, &status);
|
||||
while ((val = uenum_next(en, NULL, &status)))
|
||||
{
|
||||
char *localeid = psprintf("%s@collation=%s", name, val);
|
||||
char *localeid = psprintf("%s@collation=%s", name, val);
|
||||
|
||||
langtag = get_icu_language_tag(localeid);
|
||||
langtag = get_icu_language_tag(localeid);
|
||||
collcollate = U_ICU_VERSION_MAJOR_NUM >= 54 ? langtag : localeid;
|
||||
collid = CollationCreate(psprintf("%s-x-icu", langtag),
|
||||
nspid, GetUserId(), COLLPROVIDER_ICU, -1,
|
||||
nspid, GetUserId(), COLLPROVIDER_ICU, -1,
|
||||
collcollate, collcollate,
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, collcollate),
|
||||
if_not_exists);
|
||||
CreateComments(collid, CollationRelationId, 0,
|
||||
get_icu_locale_comment(localeid));
|
||||
}
|
||||
if (U_FAILURE(status))
|
||||
ereport(ERROR,
|
||||
(errmsg("could not get keyword values for locale \"%s\": %s",
|
||||
name, u_errorName(status))));
|
||||
(errmsg("could not get keyword values for locale \"%s\": %s",
|
||||
name, u_errorName(status))));
|
||||
uenum_close(en);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ typedef struct CopyStateData
|
||||
List *attnumlist; /* integer list of attnums to copy */
|
||||
char *filename; /* filename, or NULL for STDIN/STDOUT */
|
||||
bool is_program; /* is 'filename' a program to popen? */
|
||||
copy_data_source_cb data_source_cb; /* function for reading data*/
|
||||
copy_data_source_cb data_source_cb; /* function for reading data */
|
||||
bool binary; /* binary format? */
|
||||
bool oids; /* include OIDs? */
|
||||
bool freeze; /* freeze rows on loading? */
|
||||
@@ -532,7 +532,7 @@ CopySendEndOfRow(CopyState cstate)
|
||||
(void) pq_putmessage('d', fe_msgbuf->data, fe_msgbuf->len);
|
||||
break;
|
||||
case COPY_CALLBACK:
|
||||
Assert(false); /* Not yet supported. */
|
||||
Assert(false); /* Not yet supported. */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -855,8 +855,8 @@ dropdb(const char *dbname, bool missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_IN_USE),
|
||||
errmsg("database \"%s\" is used by an active logical replication slot",
|
||||
dbname),
|
||||
errmsg("database \"%s\" is used by an active logical replication slot",
|
||||
dbname),
|
||||
errdetail_plural("There is %d active slot",
|
||||
"There are %d active slots",
|
||||
nslots_active, nslots_active)));
|
||||
@@ -2134,7 +2134,8 @@ dbase_redo(XLogReaderState *record)
|
||||
* which can happen in some cases.
|
||||
*
|
||||
* This will lock out walsenders trying to connect to db-specific
|
||||
* slots for logical decoding too, so it's safe for us to drop slots.
|
||||
* slots for logical decoding too, so it's safe for us to drop
|
||||
* slots.
|
||||
*/
|
||||
LockSharedObjectForSession(DatabaseRelationId, xlrec->db_id, 0, AccessExclusiveLock);
|
||||
ResolveRecoveryConflictWithDatabase(xlrec->db_id);
|
||||
|
||||
@@ -336,7 +336,7 @@ defGetStringList(DefElem *def)
|
||||
if (nodeTag(def->arg) != T_List)
|
||||
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(def->arg));
|
||||
|
||||
foreach(cell, (List *)def->arg)
|
||||
foreach(cell, (List *) def->arg)
|
||||
{
|
||||
Node *str = (Node *) lfirst(cell);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ RemoveObjects(DropStmt *stmt)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is an aggregate function",
|
||||
NameListToString(castNode(ObjectWithArgs, object)->objname)),
|
||||
NameListToString(castNode(ObjectWithArgs, object)->objname)),
|
||||
errhint("Use DROP AGGREGATE to drop aggregate functions.")));
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
@@ -145,7 +145,7 @@ owningrel_does_not_exist_skipping(List *object, const char **msg, char **name)
|
||||
RangeVar *parent_rel;
|
||||
|
||||
parent_object = list_truncate(list_copy(object),
|
||||
list_length(object) - 1);
|
||||
list_length(object) - 1);
|
||||
|
||||
if (schema_does_not_exist_skipping(parent_object, msg, name))
|
||||
return true;
|
||||
@@ -328,6 +328,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
case OBJECT_FUNCTION:
|
||||
{
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
@@ -340,6 +341,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
case OBJECT_AGGREGATE:
|
||||
{
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
@@ -352,6 +354,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
case OBJECT_OPERATOR:
|
||||
{
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
@@ -390,7 +393,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
msg = gettext_noop("trigger \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_POLICY:
|
||||
@@ -399,7 +402,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
msg = gettext_noop("policy \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_EVENT_TRIGGER:
|
||||
@@ -412,7 +415,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
msg = gettext_noop("rule \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_FDW:
|
||||
|
||||
@@ -2250,7 +2250,7 @@ stringify_grantobjtype(GrantObjectType objtype)
|
||||
}
|
||||
|
||||
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
|
||||
return "???"; /* keep compiler quiet */
|
||||
return "???"; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2292,5 +2292,5 @@ stringify_adefprivs_objtype(GrantObjectType objtype)
|
||||
}
|
||||
|
||||
elog(ERROR, "unrecognized grant object type: %d", (int) objtype);
|
||||
return "???"; /* keep compiler quiet */
|
||||
return "???"; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
@@ -878,8 +878,8 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
|
||||
ownerId = GetUserId();
|
||||
|
||||
/*
|
||||
* Check that there is no other foreign server by this name.
|
||||
* Do nothing if IF NOT EXISTS was enforced.
|
||||
* Check that there is no other foreign server by this name. Do nothing if
|
||||
* IF NOT EXISTS was enforced.
|
||||
*/
|
||||
if (GetForeignServerByName(stmt->servername, true) != NULL)
|
||||
{
|
||||
@@ -1171,20 +1171,20 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
|
||||
if (stmt->if_not_exists)
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("user mapping for \"%s\" already exists for server %s, skipping",
|
||||
MappingUserName(useId),
|
||||
stmt->servername)));
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("user mapping for \"%s\" already exists for server %s, skipping",
|
||||
MappingUserName(useId),
|
||||
stmt->servername)));
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
return InvalidObjectAddress;
|
||||
}
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("user mapping for \"%s\" already exists for server %s",
|
||||
MappingUserName(useId),
|
||||
stmt->servername)));
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("user mapping for \"%s\" already exists for server %s",
|
||||
MappingUserName(useId),
|
||||
stmt->servername)));
|
||||
}
|
||||
|
||||
fdw = GetForeignDataWrapper(srv->fdwid);
|
||||
@@ -1275,8 +1275,8 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
|
||||
if (!OidIsValid(umId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("user mapping for \"%s\" does not exist for the server",
|
||||
MappingUserName(useId))));
|
||||
errmsg("user mapping for \"%s\" does not exist for the server",
|
||||
MappingUserName(useId))));
|
||||
|
||||
user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);
|
||||
|
||||
@@ -1390,13 +1390,13 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
|
||||
if (!stmt->missing_ok)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("user mapping for \"%s\" does not exist for the server",
|
||||
MappingUserName(useId))));
|
||||
errmsg("user mapping for \"%s\" does not exist for the server",
|
||||
MappingUserName(useId))));
|
||||
|
||||
/* IF EXISTS specified, just note it */
|
||||
ereport(NOTICE,
|
||||
(errmsg("user mapping for \"%s\" does not exist for the server, skipping",
|
||||
MappingUserName(useId))));
|
||||
(errmsg("user mapping for \"%s\" does not exist for the server, skipping",
|
||||
MappingUserName(useId))));
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ parse_publication_options(List *options,
|
||||
*publish_delete = true;
|
||||
|
||||
/* Parse options */
|
||||
foreach (lc, options)
|
||||
foreach(lc, options)
|
||||
{
|
||||
DefElem *defel = (DefElem *) lfirst(lc);
|
||||
|
||||
@@ -106,9 +106,9 @@ parse_publication_options(List *options,
|
||||
errmsg("invalid publish list")));
|
||||
|
||||
/* Process the option list. */
|
||||
foreach (lc, publish_list)
|
||||
foreach(lc, publish_list)
|
||||
{
|
||||
char *publish_opt = (char *)lfirst(lc);
|
||||
char *publish_opt = (char *) lfirst(lc);
|
||||
|
||||
if (strcmp(publish_opt, "insert") == 0)
|
||||
*publish_insert = true;
|
||||
@@ -157,7 +157,7 @@ CreatePublication(CreatePublicationStmt *stmt)
|
||||
if (stmt->for_all_tables && !superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to create FOR ALL TABLES publication"))));
|
||||
(errmsg("must be superuser to create FOR ALL TABLES publication"))));
|
||||
|
||||
rel = heap_open(PublicationRelationId, RowExclusiveLock);
|
||||
|
||||
@@ -228,7 +228,7 @@ CreatePublication(CreatePublicationStmt *stmt)
|
||||
*/
|
||||
static void
|
||||
AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
|
||||
HeapTuple tup)
|
||||
HeapTuple tup)
|
||||
{
|
||||
bool nulls[Natts_pg_publication];
|
||||
bool replaces[Natts_pg_publication];
|
||||
@@ -237,7 +237,7 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
|
||||
bool publish_insert;
|
||||
bool publish_update;
|
||||
bool publish_delete;
|
||||
ObjectAddress obj;
|
||||
ObjectAddress obj;
|
||||
|
||||
parse_publication_options(stmt->options,
|
||||
&publish_given, &publish_insert,
|
||||
@@ -275,7 +275,7 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
|
||||
}
|
||||
else
|
||||
{
|
||||
List *relids = GetPublicationRelations(HeapTupleGetOid(tup));
|
||||
List *relids = GetPublicationRelations(HeapTupleGetOid(tup));
|
||||
|
||||
/*
|
||||
* We don't want to send too many individual messages, at some point
|
||||
@@ -283,11 +283,11 @@ AlterPublicationOptions(AlterPublicationStmt *stmt, Relation rel,
|
||||
*/
|
||||
if (list_length(relids) < MAX_RELCACHE_INVAL_MSGS)
|
||||
{
|
||||
ListCell *lc;
|
||||
ListCell *lc;
|
||||
|
||||
foreach (lc, relids)
|
||||
foreach(lc, relids)
|
||||
{
|
||||
Oid relid = lfirst_oid(lc);
|
||||
Oid relid = lfirst_oid(lc);
|
||||
|
||||
CacheInvalidateRelcacheByRelid(relid);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
|
||||
PublicationAddTables(pubid, rels, false, stmt);
|
||||
else if (stmt->tableAction == DEFELEM_DROP)
|
||||
PublicationDropTables(pubid, rels, false);
|
||||
else /* DEFELEM_SET */
|
||||
else /* DEFELEM_SET */
|
||||
{
|
||||
List *oldrelids = GetPublicationRelations(pubid);
|
||||
List *delrels = NIL;
|
||||
@@ -358,6 +358,7 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
|
||||
{
|
||||
Relation oldrel = heap_open(oldrelid,
|
||||
ShareUpdateExclusiveLock);
|
||||
|
||||
delrels = lappend(delrels, oldrel);
|
||||
}
|
||||
}
|
||||
@@ -366,8 +367,8 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
|
||||
PublicationDropTables(pubid, delrels, true);
|
||||
|
||||
/*
|
||||
* Don't bother calculating the difference for adding, we'll catch
|
||||
* and skip existing ones when doing catalog update.
|
||||
* Don't bother calculating the difference for adding, we'll catch and
|
||||
* skip existing ones when doing catalog update.
|
||||
*/
|
||||
PublicationAddTables(pubid, rels, true, stmt);
|
||||
|
||||
@@ -386,8 +387,8 @@ AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
|
||||
void
|
||||
AlterPublication(AlterPublicationStmt *stmt)
|
||||
{
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
|
||||
rel = heap_open(PublicationRelationId, RowExclusiveLock);
|
||||
|
||||
@@ -444,9 +445,9 @@ RemovePublicationById(Oid pubid)
|
||||
void
|
||||
RemovePublicationRelById(Oid proid)
|
||||
{
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
Form_pg_publication_rel pubrel;
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
Form_pg_publication_rel pubrel;
|
||||
|
||||
rel = heap_open(PublicationRelRelationId, RowExclusiveLock);
|
||||
|
||||
@@ -570,14 +571,14 @@ static void
|
||||
PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
|
||||
AlterPublicationStmt *stmt)
|
||||
{
|
||||
ListCell *lc;
|
||||
ListCell *lc;
|
||||
|
||||
Assert(!stmt || !stmt->for_all_tables);
|
||||
|
||||
foreach(lc, rels)
|
||||
{
|
||||
Relation rel = (Relation) lfirst(lc);
|
||||
ObjectAddress obj;
|
||||
ObjectAddress obj;
|
||||
|
||||
/* Must be owner of the table or superuser. */
|
||||
if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
|
||||
@@ -602,9 +603,9 @@ PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
|
||||
static void
|
||||
PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
|
||||
{
|
||||
ObjectAddress obj;
|
||||
ListCell *lc;
|
||||
Oid prid;
|
||||
ObjectAddress obj;
|
||||
ListCell *lc;
|
||||
Oid prid;
|
||||
|
||||
foreach(lc, rels)
|
||||
{
|
||||
@@ -632,7 +633,7 @@ PublicationDropTables(Oid pubid, List *rels, bool missing_ok)
|
||||
/*
|
||||
* Internal workhorse for changing a publication owner
|
||||
*/
|
||||
static void
|
||||
static void
|
||||
AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
{
|
||||
Form_pg_publication form;
|
||||
@@ -663,8 +664,8 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
if (form->puballtables && !superuser_arg(newOwnerId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("permission denied to change owner of publication \"%s\"",
|
||||
NameStr(form->pubname)),
|
||||
errmsg("permission denied to change owner of publication \"%s\"",
|
||||
NameStr(form->pubname)),
|
||||
errhint("The owner of a FOR ALL TABLES publication must be a superuser.")));
|
||||
}
|
||||
|
||||
@@ -686,9 +687,9 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
ObjectAddress
|
||||
AlterPublicationOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
Oid subid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
Oid subid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
ObjectAddress address;
|
||||
|
||||
rel = heap_open(PublicationRelationId, RowExclusiveLock);
|
||||
@@ -719,8 +720,8 @@ AlterPublicationOwner(const char *name, Oid newOwnerId)
|
||||
void
|
||||
AlterPublicationOwner_oid(Oid subid, Oid newOwnerId)
|
||||
{
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(PublicationRelationId, RowExclusiveLock);
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ static Form_pg_sequence_data read_seq_tuple(Relation rel,
|
||||
Buffer *buf, HeapTuple seqdatatuple);
|
||||
static LOCKMODE alter_sequence_get_lock_level(List *options);
|
||||
static void init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
bool isInit,
|
||||
Form_pg_sequence seqform,
|
||||
bool *changed_seqform,
|
||||
Form_pg_sequence_data seqdataform, List **owned_by);
|
||||
bool isInit,
|
||||
Form_pg_sequence seqform,
|
||||
bool *changed_seqform,
|
||||
Form_pg_sequence_data seqdataform, List **owned_by);
|
||||
static void do_setval(Oid relid, int64 next, bool iscalled);
|
||||
static void process_owned_by(Relation seqrel, List *owned_by, bool for_identity);
|
||||
|
||||
@@ -117,7 +117,7 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq)
|
||||
{
|
||||
FormData_pg_sequence seqform;
|
||||
FormData_pg_sequence_data seqdataform;
|
||||
bool changed_seqform = false; /* not used here */
|
||||
bool changed_seqform = false; /* not used here */
|
||||
List *owned_by;
|
||||
CreateStmt *stmt = makeNode(CreateStmt);
|
||||
Oid seqoid;
|
||||
@@ -703,9 +703,9 @@ nextval_internal(Oid relid, bool check_permissions)
|
||||
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, maxv);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
|
||||
errmsg("nextval: reached maximum value of sequence \"%s\" (%s)",
|
||||
RelationGetRelationName(seqrel), buf)));
|
||||
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
|
||||
errmsg("nextval: reached maximum value of sequence \"%s\" (%s)",
|
||||
RelationGetRelationName(seqrel), buf)));
|
||||
}
|
||||
next = minv;
|
||||
}
|
||||
@@ -726,9 +726,9 @@ nextval_internal(Oid relid, bool check_permissions)
|
||||
|
||||
snprintf(buf, sizeof(buf), INT64_FORMAT, minv);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
|
||||
errmsg("nextval: reached minimum value of sequence \"%s\" (%s)",
|
||||
RelationGetRelationName(seqrel), buf)));
|
||||
(errcode(ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED),
|
||||
errmsg("nextval: reached minimum value of sequence \"%s\" (%s)",
|
||||
RelationGetRelationName(seqrel), buf)));
|
||||
}
|
||||
next = maxv;
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
/* AS type */
|
||||
if (as_type != NULL)
|
||||
{
|
||||
Oid newtypid = typenameTypeId(pstate, defGetTypeName(as_type));
|
||||
Oid newtypid = typenameTypeId(pstate, defGetTypeName(as_type));
|
||||
|
||||
if (newtypid != INT2OID &&
|
||||
newtypid != INT4OID &&
|
||||
@@ -1399,7 +1399,7 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
for_identity
|
||||
? errmsg("identity column type must be smallint, integer, or bigint")
|
||||
: errmsg("sequence type must be smallint, integer, or bigint")));
|
||||
: errmsg("sequence type must be smallint, integer, or bigint")));
|
||||
|
||||
if (!isInit)
|
||||
{
|
||||
@@ -1411,11 +1411,11 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
*/
|
||||
if ((seqform->seqtypid == INT2OID && seqform->seqmax == PG_INT16_MAX) ||
|
||||
(seqform->seqtypid == INT4OID && seqform->seqmax == PG_INT32_MAX) ||
|
||||
(seqform->seqtypid == INT8OID && seqform->seqmax == PG_INT64_MAX))
|
||||
(seqform->seqtypid == INT8OID && seqform->seqmax == PG_INT64_MAX))
|
||||
reset_max_value = true;
|
||||
if ((seqform->seqtypid == INT2OID && seqform->seqmin == PG_INT16_MIN) ||
|
||||
(seqform->seqtypid == INT4OID && seqform->seqmin == PG_INT32_MIN) ||
|
||||
(seqform->seqtypid == INT8OID && seqform->seqmin == PG_INT64_MIN))
|
||||
(seqform->seqtypid == INT8OID && seqform->seqmin == PG_INT64_MIN))
|
||||
reset_min_value = true;
|
||||
}
|
||||
|
||||
@@ -1479,7 +1479,7 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
seqform->seqmax = PG_INT64_MAX;
|
||||
}
|
||||
else
|
||||
seqform->seqmax = -1; /* descending seq */
|
||||
seqform->seqmax = -1; /* descending seq */
|
||||
*changed_seqform = true;
|
||||
seqdataform->log_cnt = 0;
|
||||
}
|
||||
@@ -1494,8 +1494,8 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("MAXVALUE (%s) is out of range for sequence data type %s",
|
||||
bufx, format_type_be(seqform->seqtypid))));
|
||||
errmsg("MAXVALUE (%s) is out of range for sequence data type %s",
|
||||
bufx, format_type_be(seqform->seqtypid))));
|
||||
}
|
||||
|
||||
/* MINVALUE (null arg means NO MINVALUE) */
|
||||
@@ -1518,7 +1518,7 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
seqform->seqmin = PG_INT64_MIN;
|
||||
}
|
||||
else
|
||||
seqform->seqmin = 1; /* ascending seq */
|
||||
seqform->seqmin = 1; /* ascending seq */
|
||||
*changed_seqform = true;
|
||||
seqdataform->log_cnt = 0;
|
||||
}
|
||||
@@ -1533,8 +1533,8 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("MINVALUE (%s) is out of range for sequence data type %s",
|
||||
bufm, format_type_be(seqform->seqtypid))));
|
||||
errmsg("MINVALUE (%s) is out of range for sequence data type %s",
|
||||
bufm, format_type_be(seqform->seqtypid))));
|
||||
}
|
||||
|
||||
/* crosscheck min/max */
|
||||
@@ -1560,9 +1560,9 @@ init_params(ParseState *pstate, List *options, bool for_identity,
|
||||
else if (isInit)
|
||||
{
|
||||
if (seqform->seqincrement > 0)
|
||||
seqform->seqstart = seqform->seqmin; /* ascending seq */
|
||||
seqform->seqstart = seqform->seqmin; /* ascending seq */
|
||||
else
|
||||
seqform->seqstart = seqform->seqmax; /* descending seq */
|
||||
seqform->seqstart = seqform->seqmax; /* descending seq */
|
||||
*changed_seqform = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ CreateStatistics(CreateStatsStmt *stmt)
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("statistics object \"%s\" already exists, skipping",
|
||||
namestr)));
|
||||
errmsg("statistics object \"%s\" already exists, skipping",
|
||||
namestr)));
|
||||
return InvalidObjectAddress;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
*synchronous_commit = NULL;
|
||||
|
||||
/* Parse options */
|
||||
foreach (lc, options)
|
||||
foreach(lc, options)
|
||||
{
|
||||
DefElem *defel = (DefElem *) lfirst(lc);
|
||||
|
||||
@@ -200,8 +200,8 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given,
|
||||
}
|
||||
|
||||
/*
|
||||
* Do additional checking for disallowed combination when
|
||||
* slot_name = NONE was used.
|
||||
* Do additional checking for disallowed combination when slot_name = NONE
|
||||
* was used.
|
||||
*/
|
||||
if (slot_name && *slot_name_given && !*slot_name)
|
||||
{
|
||||
@@ -367,7 +367,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
values[Anum_pg_subscription_subsynccommit - 1] =
|
||||
CStringGetTextDatum(synchronous_commit);
|
||||
values[Anum_pg_subscription_subpublications - 1] =
|
||||
publicationListToArray(publications);
|
||||
publicationListToArray(publications);
|
||||
|
||||
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
|
||||
|
||||
@@ -386,12 +386,12 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
*/
|
||||
if (connect)
|
||||
{
|
||||
XLogRecPtr lsn;
|
||||
char *err;
|
||||
WalReceiverConn *wrconn;
|
||||
List *tables;
|
||||
ListCell *lc;
|
||||
char table_state;
|
||||
XLogRecPtr lsn;
|
||||
char *err;
|
||||
WalReceiverConn *wrconn;
|
||||
List *tables;
|
||||
ListCell *lc;
|
||||
char table_state;
|
||||
|
||||
/* Try to connect to the publisher. */
|
||||
wrconn = walrcv_connect(conninfo, true, stmt->subname, &err);
|
||||
@@ -412,7 +412,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
* info.
|
||||
*/
|
||||
tables = fetch_table_list(wrconn, publications);
|
||||
foreach (lc, tables)
|
||||
foreach(lc, tables)
|
||||
{
|
||||
RangeVar *rv = (RangeVar *) lfirst(lc);
|
||||
Oid relid;
|
||||
@@ -431,9 +431,9 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
(errmsg("synchronized table states")));
|
||||
|
||||
/*
|
||||
* If requested, create permanent slot for the subscription.
|
||||
* We won't use the initial snapshot for anything, so no need
|
||||
* to export it.
|
||||
* If requested, create permanent slot for the subscription. We
|
||||
* won't use the initial snapshot for anything, so no need to
|
||||
* export it.
|
||||
*/
|
||||
if (create_slot)
|
||||
{
|
||||
@@ -442,8 +442,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
walrcv_create_slot(wrconn, slotname, false,
|
||||
CRS_NOEXPORT_SNAPSHOT, &lsn);
|
||||
ereport(NOTICE,
|
||||
(errmsg("created replication slot \"%s\" on publisher",
|
||||
slotname)));
|
||||
(errmsg("created replication slot \"%s\" on publisher",
|
||||
slotname)));
|
||||
}
|
||||
}
|
||||
PG_CATCH();
|
||||
@@ -478,7 +478,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
|
||||
static void
|
||||
AlterSubscription_refresh(Subscription *sub, bool copy_data)
|
||||
{
|
||||
char *err;
|
||||
char *err;
|
||||
List *pubrel_names;
|
||||
List *subrel_states;
|
||||
Oid *subrel_local_oids;
|
||||
@@ -505,31 +505,31 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
|
||||
subrel_states = GetSubscriptionRelations(sub->oid);
|
||||
|
||||
/*
|
||||
* Build qsorted array of local table oids for faster lookup.
|
||||
* This can potentially contain all tables in the database so
|
||||
* speed of lookup is important.
|
||||
* Build qsorted array of local table oids for faster lookup. This can
|
||||
* potentially contain all tables in the database so speed of lookup is
|
||||
* important.
|
||||
*/
|
||||
subrel_local_oids = palloc(list_length(subrel_states) * sizeof(Oid));
|
||||
off = 0;
|
||||
foreach(lc, subrel_states)
|
||||
{
|
||||
SubscriptionRelState *relstate = (SubscriptionRelState *) lfirst(lc);
|
||||
|
||||
subrel_local_oids[off++] = relstate->relid;
|
||||
}
|
||||
qsort(subrel_local_oids, list_length(subrel_states),
|
||||
sizeof(Oid), oid_cmp);
|
||||
|
||||
/*
|
||||
* Walk over the remote tables and try to match them to locally
|
||||
* known tables. If the table is not known locally create a new state
|
||||
* for it.
|
||||
* Walk over the remote tables and try to match them to locally known
|
||||
* tables. If the table is not known locally create a new state for it.
|
||||
*
|
||||
* Also builds array of local oids of remote tables for the next step.
|
||||
*/
|
||||
off = 0;
|
||||
pubrel_local_oids = palloc(list_length(pubrel_names) * sizeof(Oid));
|
||||
|
||||
foreach (lc, pubrel_names)
|
||||
foreach(lc, pubrel_names)
|
||||
{
|
||||
RangeVar *rv = (RangeVar *) lfirst(lc);
|
||||
Oid relid;
|
||||
@@ -546,7 +546,7 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
|
||||
list_length(subrel_states), sizeof(Oid), oid_cmp))
|
||||
{
|
||||
SetSubscriptionRelState(sub->oid, relid,
|
||||
copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY,
|
||||
copy_data ? SUBREL_STATE_INIT : SUBREL_STATE_READY,
|
||||
InvalidXLogRecPtr);
|
||||
ereport(NOTICE,
|
||||
(errmsg("added subscription for table %s.%s",
|
||||
@@ -556,20 +556,20 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
|
||||
}
|
||||
|
||||
/*
|
||||
* Next remove state for tables we should not care about anymore using
|
||||
* the data we collected above
|
||||
* Next remove state for tables we should not care about anymore using the
|
||||
* data we collected above
|
||||
*/
|
||||
qsort(pubrel_local_oids, list_length(pubrel_names),
|
||||
sizeof(Oid), oid_cmp);
|
||||
|
||||
for (off = 0; off < list_length(subrel_states); off++)
|
||||
{
|
||||
Oid relid = subrel_local_oids[off];
|
||||
Oid relid = subrel_local_oids[off];
|
||||
|
||||
if (!bsearch(&relid, pubrel_local_oids,
|
||||
list_length(pubrel_names), sizeof(Oid), oid_cmp))
|
||||
{
|
||||
char *namespace;
|
||||
char *namespace;
|
||||
|
||||
RemoveSubscriptionRel(sub->oid, relid);
|
||||
|
||||
@@ -596,7 +596,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
|
||||
HeapTuple tup;
|
||||
Oid subid;
|
||||
bool update_tuple = false;
|
||||
Subscription *sub;
|
||||
Subscription *sub;
|
||||
|
||||
rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
|
||||
|
||||
@@ -644,7 +644,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
|
||||
|
||||
if (slotname)
|
||||
values[Anum_pg_subscription_subslotname - 1] =
|
||||
DirectFunctionCall1(namein, CStringGetDatum(slotname));
|
||||
DirectFunctionCall1(namein, CStringGetDatum(slotname));
|
||||
else
|
||||
nulls[Anum_pg_subscription_subslotname - 1] = true;
|
||||
replaces[Anum_pg_subscription_subslotname - 1] = true;
|
||||
@@ -663,8 +663,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
|
||||
|
||||
case ALTER_SUBSCRIPTION_ENABLED:
|
||||
{
|
||||
bool enabled,
|
||||
enabled_given;
|
||||
bool enabled,
|
||||
enabled_given;
|
||||
|
||||
parse_subscription_options(stmt->options, NULL,
|
||||
&enabled_given, &enabled, NULL,
|
||||
@@ -702,14 +702,14 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
|
||||
case ALTER_SUBSCRIPTION_PUBLICATION:
|
||||
case ALTER_SUBSCRIPTION_PUBLICATION_REFRESH:
|
||||
{
|
||||
bool copy_data;
|
||||
bool copy_data;
|
||||
|
||||
parse_subscription_options(stmt->options, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, ©_data,
|
||||
NULL);
|
||||
|
||||
values[Anum_pg_subscription_subpublications - 1] =
|
||||
publicationListToArray(stmt->publication);
|
||||
publicationListToArray(stmt->publication);
|
||||
replaces[Anum_pg_subscription_subpublications - 1] = true;
|
||||
|
||||
update_tuple = true;
|
||||
@@ -733,7 +733,7 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
|
||||
|
||||
case ALTER_SUBSCRIPTION_REFRESH:
|
||||
{
|
||||
bool copy_data;
|
||||
bool copy_data;
|
||||
|
||||
if (!sub->enabled)
|
||||
ereport(ERROR,
|
||||
@@ -791,14 +791,13 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
char *slotname;
|
||||
char originname[NAMEDATALEN];
|
||||
char *err = NULL;
|
||||
RepOriginId originid;
|
||||
WalReceiverConn *wrconn = NULL;
|
||||
StringInfoData cmd;
|
||||
RepOriginId originid;
|
||||
WalReceiverConn *wrconn = NULL;
|
||||
StringInfoData cmd;
|
||||
|
||||
/*
|
||||
* Lock pg_subscription with AccessExclusiveLock to ensure
|
||||
* that the launcher doesn't restart new worker during dropping
|
||||
* the subscription
|
||||
* Lock pg_subscription with AccessExclusiveLock to ensure that the
|
||||
* launcher doesn't restart new worker during dropping the subscription
|
||||
*/
|
||||
rel = heap_open(SubscriptionRelationId, AccessExclusiveLock);
|
||||
|
||||
@@ -833,8 +832,8 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
InvokeObjectDropHook(SubscriptionRelationId, subid, 0);
|
||||
|
||||
/*
|
||||
* Lock the subscription so nobody else can do anything with it
|
||||
* (including the replication workers).
|
||||
* Lock the subscription so nobody else can do anything with it (including
|
||||
* the replication workers).
|
||||
*/
|
||||
LockSharedObject(SubscriptionRelationId, subid, 0, AccessExclusiveLock);
|
||||
|
||||
@@ -895,7 +894,10 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
if (originid != InvalidRepOriginId)
|
||||
replorigin_drop(originid);
|
||||
|
||||
/* If there is no slot associated with the subscription, we can finish here. */
|
||||
/*
|
||||
* If there is no slot associated with the subscription, we can finish
|
||||
* here.
|
||||
*/
|
||||
if (!slotname)
|
||||
{
|
||||
heap_close(rel, NoLock);
|
||||
@@ -903,8 +905,8 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise drop the replication slot at the publisher node using
|
||||
* the replication connection.
|
||||
* Otherwise drop the replication slot at the publisher node using the
|
||||
* replication connection.
|
||||
*/
|
||||
load_file("libpqwalreceiver", false);
|
||||
|
||||
@@ -922,14 +924,15 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
|
||||
PG_TRY();
|
||||
{
|
||||
WalRcvExecResult *res;
|
||||
WalRcvExecResult *res;
|
||||
|
||||
res = walrcv_exec(wrconn, cmd.data, 0, NULL);
|
||||
|
||||
if (res->status != WALRCV_OK_COMMAND)
|
||||
ereport(ERROR,
|
||||
(errmsg("could not drop the replication slot \"%s\" on publisher",
|
||||
slotname),
|
||||
errdetail("The error was: %s", res->err)));
|
||||
(errmsg("could not drop the replication slot \"%s\" on publisher",
|
||||
slotname),
|
||||
errdetail("The error was: %s", res->err)));
|
||||
else
|
||||
ereport(NOTICE,
|
||||
(errmsg("dropped replication slot \"%s\" on publisher",
|
||||
@@ -973,9 +976,9 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
if (!superuser_arg(newOwnerId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("permission denied to change owner of subscription \"%s\"",
|
||||
NameStr(form->subname)),
|
||||
errhint("The owner of a subscription must be a superuser.")));
|
||||
errmsg("permission denied to change owner of subscription \"%s\"",
|
||||
NameStr(form->subname)),
|
||||
errhint("The owner of a subscription must be a superuser.")));
|
||||
|
||||
form->subowner = newOwnerId;
|
||||
CatalogTupleUpdate(rel, &tup->t_self, tup);
|
||||
@@ -1055,24 +1058,24 @@ AlterSubscriptionOwner_oid(Oid subid, Oid newOwnerId)
|
||||
static List *
|
||||
fetch_table_list(WalReceiverConn *wrconn, List *publications)
|
||||
{
|
||||
WalRcvExecResult *res;
|
||||
StringInfoData cmd;
|
||||
TupleTableSlot *slot;
|
||||
Oid tableRow[2] = {TEXTOID, TEXTOID};
|
||||
ListCell *lc;
|
||||
bool first;
|
||||
List *tablelist = NIL;
|
||||
WalRcvExecResult *res;
|
||||
StringInfoData cmd;
|
||||
TupleTableSlot *slot;
|
||||
Oid tableRow[2] = {TEXTOID, TEXTOID};
|
||||
ListCell *lc;
|
||||
bool first;
|
||||
List *tablelist = NIL;
|
||||
|
||||
Assert(list_length(publications) > 0);
|
||||
|
||||
initStringInfo(&cmd);
|
||||
appendStringInfo(&cmd, "SELECT DISTINCT t.schemaname, t.tablename\n"
|
||||
" FROM pg_catalog.pg_publication_tables t\n"
|
||||
" WHERE t.pubname IN (");
|
||||
" FROM pg_catalog.pg_publication_tables t\n"
|
||||
" WHERE t.pubname IN (");
|
||||
first = true;
|
||||
foreach (lc, publications)
|
||||
foreach(lc, publications)
|
||||
{
|
||||
char *pubname = strVal(lfirst(lc));
|
||||
char *pubname = strVal(lfirst(lc));
|
||||
|
||||
if (first)
|
||||
first = false;
|
||||
|
||||
@@ -363,9 +363,9 @@ static ObjectAddress ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
|
||||
static ObjectAddress ATExecColumnDefault(Relation rel, const char *colName,
|
||||
Node *newDefault, LOCKMODE lockmode);
|
||||
static ObjectAddress ATExecAddIdentity(Relation rel, const char *colName,
|
||||
Node *def, LOCKMODE lockmode);
|
||||
Node *def, LOCKMODE lockmode);
|
||||
static ObjectAddress ATExecSetIdentity(Relation rel, const char *colName,
|
||||
Node *def, LOCKMODE lockmode);
|
||||
Node *def, LOCKMODE lockmode);
|
||||
static ObjectAddress ATExecDropIdentity(Relation rel, const char *colName, bool missing_ok, LOCKMODE lockmode);
|
||||
static void ATPrepSetStatistics(Relation rel, const char *colName,
|
||||
Node *newValue, LOCKMODE lockmode);
|
||||
@@ -643,8 +643,8 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
|
||||
descriptor->tdhasoid = (localHasOids || parentOidCount > 0);
|
||||
|
||||
/*
|
||||
* If a partitioned table doesn't have the system OID column, then none
|
||||
* of its partitions should have it.
|
||||
* If a partitioned table doesn't have the system OID column, then none of
|
||||
* its partitions should have it.
|
||||
*/
|
||||
if (stmt->partbound && parentOidCount == 0 && localHasOids)
|
||||
ereport(ERROR,
|
||||
@@ -1112,9 +1112,9 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
|
||||
}
|
||||
|
||||
/*
|
||||
* Similarly, if we previously locked some other partition's heap, and
|
||||
* the name we're looking up no longer refers to that relation, release
|
||||
* the now-useless lock.
|
||||
* Similarly, if we previously locked some other partition's heap, and the
|
||||
* name we're looking up no longer refers to that relation, release the
|
||||
* now-useless lock.
|
||||
*/
|
||||
if (relOid != oldRelOid && OidIsValid(state->partParentOid))
|
||||
{
|
||||
@@ -2219,8 +2219,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DUPLICATE_COLUMN),
|
||||
errmsg("column \"%s\" specified more than once",
|
||||
coldef->colname)));
|
||||
errmsg("column \"%s\" specified more than once",
|
||||
coldef->colname)));
|
||||
}
|
||||
prev = rest;
|
||||
rest = next;
|
||||
@@ -4541,7 +4541,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
|
||||
values[ex->attnum - 1] = ExecEvalExpr(ex->exprstate,
|
||||
econtext,
|
||||
&isnull[ex->attnum - 1]);
|
||||
&isnull[ex->attnum - 1]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5589,12 +5589,12 @@ static void
|
||||
ATPrepDropNotNull(Relation rel, bool recurse, bool recursing)
|
||||
{
|
||||
/*
|
||||
* If the parent is a partitioned table, like check constraints, we do
|
||||
* not support removing the NOT NULL while partitions exist.
|
||||
* If the parent is a partitioned table, like check constraints, we do not
|
||||
* support removing the NOT NULL while partitions exist.
|
||||
*/
|
||||
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
{
|
||||
PartitionDesc partdesc = RelationGetPartitionDesc(rel);
|
||||
PartitionDesc partdesc = RelationGetPartitionDesc(rel);
|
||||
|
||||
Assert(partdesc != NULL);
|
||||
if (partdesc->nparts > 0 && !recurse && !recursing)
|
||||
@@ -5639,8 +5639,8 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
|
||||
if (get_attidentity(RelationGetRelid(rel), attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
/*
|
||||
* Check that the attribute is not in a primary key
|
||||
@@ -5768,7 +5768,7 @@ ATPrepSetNotNull(Relation rel, bool recurse, bool recursing)
|
||||
*/
|
||||
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
{
|
||||
PartitionDesc partdesc = RelationGetPartitionDesc(rel);
|
||||
PartitionDesc partdesc = RelationGetPartitionDesc(rel);
|
||||
|
||||
if (partdesc && partdesc->nparts > 0 && !recurse && !recursing)
|
||||
ereport(ERROR,
|
||||
@@ -5867,8 +5867,8 @@ ATExecColumnDefault(Relation rel, const char *colName,
|
||||
if (get_attidentity(RelationGetRelid(rel), attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel)),
|
||||
errmsg("column \"%s\" of relation \"%s\" is an identity column",
|
||||
colName, RelationGetRelationName(rel)),
|
||||
newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
|
||||
|
||||
/*
|
||||
@@ -5959,8 +5959,8 @@ ATExecAddIdentity(Relation rel, const char *colName,
|
||||
if (attTup->atthasdef)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("column \"%s\" of relation \"%s\" already has a default value",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" already has a default value",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
attTup->attidentity = cdef->identity;
|
||||
CatalogTupleUpdate(attrelation, &tuple->t_self, tuple);
|
||||
@@ -5986,7 +5986,7 @@ static ObjectAddress
|
||||
ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmode)
|
||||
{
|
||||
ListCell *option;
|
||||
DefElem *generatedEl = NULL;
|
||||
DefElem *generatedEl = NULL;
|
||||
HeapTuple tuple;
|
||||
Form_pg_attribute attTup;
|
||||
AttrNumber attnum;
|
||||
@@ -5995,7 +5995,7 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
|
||||
|
||||
foreach(option, castNode(List, def))
|
||||
{
|
||||
DefElem *defel = lfirst_node(DefElem, option);
|
||||
DefElem *defel = lfirst_node(DefElem, option);
|
||||
|
||||
if (strcmp(defel->defname, "generated") == 0)
|
||||
{
|
||||
@@ -6036,8 +6036,8 @@ ATExecSetIdentity(Relation rel, const char *colName, Node *def, LOCKMODE lockmod
|
||||
if (!attTup->attidentity)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("column \"%s\" of relation \"%s\" is not an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" is not an identity column",
|
||||
colName, RelationGetRelationName(rel))));
|
||||
|
||||
if (generatedEl)
|
||||
{
|
||||
@@ -11137,7 +11137,7 @@ CreateInheritance(Relation child_rel, Relation parent_rel)
|
||||
inhseqno + 1,
|
||||
catalogRelation,
|
||||
parent_rel->rd_rel->relkind ==
|
||||
RELKIND_PARTITIONED_TABLE);
|
||||
RELKIND_PARTITIONED_TABLE);
|
||||
|
||||
/* Now we're done with pg_inherits */
|
||||
heap_close(catalogRelation, RowExclusiveLock);
|
||||
|
||||
@@ -340,7 +340,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
|
||||
foreach(lc, varList)
|
||||
{
|
||||
TriggerTransition *tt = lfirst_node(TriggerTransition, lc);
|
||||
TriggerTransition *tt = lfirst_node(TriggerTransition, lc);
|
||||
|
||||
if (!(tt->isTable))
|
||||
ereport(ERROR,
|
||||
@@ -359,21 +359,21 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is a partitioned table",
|
||||
RelationGetRelationName(rel)),
|
||||
errdetail("Triggers on partitioned tables cannot have transition tables.")));
|
||||
errdetail("Triggers on partitioned tables cannot have transition tables.")));
|
||||
|
||||
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is a foreign table",
|
||||
RelationGetRelationName(rel)),
|
||||
errdetail("Triggers on foreign tables cannot have transition tables.")));
|
||||
errdetail("Triggers on foreign tables cannot have transition tables.")));
|
||||
|
||||
if (rel->rd_rel->relkind == RELKIND_VIEW)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is a view",
|
||||
RelationGetRelationName(rel)),
|
||||
errdetail("Triggers on views cannot have transition tables.")));
|
||||
errdetail("Triggers on views cannot have transition tables.")));
|
||||
|
||||
if (stmt->timing != TRIGGER_TYPE_AFTER)
|
||||
ereport(ERROR,
|
||||
@@ -396,7 +396,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
if (newtablename != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("NEW TABLE cannot be specified multiple times")));
|
||||
errmsg("NEW TABLE cannot be specified multiple times")));
|
||||
|
||||
newtablename = tt->name;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
if (oldtablename != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("OLD TABLE cannot be specified multiple times")));
|
||||
errmsg("OLD TABLE cannot be specified multiple times")));
|
||||
|
||||
oldtablename = tt->name;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
strcmp(newtablename, oldtablename) == 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("OLD TABLE name and NEW TABLE name cannot be the same")));
|
||||
errmsg("OLD TABLE name and NEW TABLE name cannot be the same")));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -782,12 +782,12 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
|
||||
|
||||
if (oldtablename)
|
||||
values[Anum_pg_trigger_tgoldtable - 1] = DirectFunctionCall1(namein,
|
||||
CStringGetDatum(oldtablename));
|
||||
CStringGetDatum(oldtablename));
|
||||
else
|
||||
nulls[Anum_pg_trigger_tgoldtable - 1] = true;
|
||||
if (newtablename)
|
||||
values[Anum_pg_trigger_tgnewtable - 1] = DirectFunctionCall1(namein,
|
||||
CStringGetDatum(newtablename));
|
||||
CStringGetDatum(newtablename));
|
||||
else
|
||||
nulls[Anum_pg_trigger_tgnewtable - 1] = true;
|
||||
|
||||
@@ -3412,7 +3412,8 @@ typedef struct AfterTriggersData
|
||||
AfterTriggerEventList events; /* deferred-event list */
|
||||
int query_depth; /* current query list index */
|
||||
AfterTriggerEventList *query_stack; /* events pending from each query */
|
||||
Tuplestorestate **fdw_tuplestores; /* foreign tuples for one row from each query */
|
||||
Tuplestorestate **fdw_tuplestores; /* foreign tuples for one row from
|
||||
* each query */
|
||||
Tuplestorestate **old_tuplestores; /* all old tuples from each query */
|
||||
Tuplestorestate **new_tuplestores; /* all new tuples from each query */
|
||||
int maxquerydepth; /* allocated len of above array */
|
||||
@@ -3778,8 +3779,8 @@ AfterTriggerExecute(AfterTriggerEvent event,
|
||||
case AFTER_TRIGGER_FDW_FETCH:
|
||||
{
|
||||
Tuplestorestate *fdw_tuplestore =
|
||||
GetTriggerTransitionTuplestore
|
||||
(afterTriggers.fdw_tuplestores);
|
||||
GetTriggerTransitionTuplestore
|
||||
(afterTriggers.fdw_tuplestores);
|
||||
|
||||
if (!tuplestore_gettupleslot(fdw_tuplestore, true, false,
|
||||
trig_tuple_slot1))
|
||||
@@ -5130,7 +5131,7 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
|
||||
Assert(oldtup != NULL);
|
||||
old_tuplestore =
|
||||
GetTriggerTransitionTuplestore
|
||||
(afterTriggers.old_tuplestores);
|
||||
(afterTriggers.old_tuplestores);
|
||||
tuplestore_puttuple(old_tuplestore, oldtup);
|
||||
}
|
||||
if ((event == TRIGGER_EVENT_INSERT &&
|
||||
@@ -5143,14 +5144,14 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
|
||||
Assert(newtup != NULL);
|
||||
new_tuplestore =
|
||||
GetTriggerTransitionTuplestore
|
||||
(afterTriggers.new_tuplestores);
|
||||
(afterTriggers.new_tuplestores);
|
||||
tuplestore_puttuple(new_tuplestore, newtup);
|
||||
}
|
||||
|
||||
/* If transition tables are the only reason we're here, return. */
|
||||
if ((event == TRIGGER_EVENT_DELETE && !trigdesc->trig_delete_after_row) ||
|
||||
(event == TRIGGER_EVENT_INSERT && !trigdesc->trig_insert_after_row) ||
|
||||
(event == TRIGGER_EVENT_UPDATE && !trigdesc->trig_update_after_row))
|
||||
(event == TRIGGER_EVENT_INSERT && !trigdesc->trig_insert_after_row) ||
|
||||
(event == TRIGGER_EVENT_UPDATE && !trigdesc->trig_update_after_row))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5253,7 +5254,7 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo,
|
||||
{
|
||||
fdw_tuplestore =
|
||||
GetTriggerTransitionTuplestore
|
||||
(afterTriggers.fdw_tuplestores);
|
||||
(afterTriggers.fdw_tuplestores);
|
||||
new_event.ate_flags = AFTER_TRIGGER_FDW_FETCH;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1685,7 +1685,7 @@ deserialize_deflist(Datum txt)
|
||||
*wsptr++ = '\0';
|
||||
result = lappend(result,
|
||||
makeDefElem(pstrdup(workspace),
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
state = CS_WAITKEY;
|
||||
}
|
||||
}
|
||||
@@ -1717,7 +1717,7 @@ deserialize_deflist(Datum txt)
|
||||
*wsptr++ = '\0';
|
||||
result = lappend(result,
|
||||
makeDefElem(pstrdup(workspace),
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
state = CS_WAITKEY;
|
||||
}
|
||||
}
|
||||
@@ -1732,7 +1732,7 @@ deserialize_deflist(Datum txt)
|
||||
*wsptr++ = '\0';
|
||||
result = lappend(result,
|
||||
makeDefElem(pstrdup(workspace),
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
state = CS_WAITKEY;
|
||||
}
|
||||
else
|
||||
@@ -1751,7 +1751,7 @@ deserialize_deflist(Datum txt)
|
||||
*wsptr++ = '\0';
|
||||
result = lappend(result,
|
||||
makeDefElem(pstrdup(workspace),
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
(Node *) makeString(pstrdup(startvalue)), -1));
|
||||
}
|
||||
else if (state != CS_WAITKEY)
|
||||
ereport(ERROR,
|
||||
|
||||
@@ -1463,7 +1463,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
|
||||
(errmsg("role \"%s\" is a member of role \"%s\"",
|
||||
rolename, get_rolespec_name(memberRole)))));
|
||||
rolename, get_rolespec_name(memberRole)))));
|
||||
|
||||
/*
|
||||
* Check if entry for this role/member already exists; if so, give
|
||||
@@ -1478,7 +1478,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("role \"%s\" is already a member of role \"%s\"",
|
||||
get_rolespec_name(memberRole), rolename)));
|
||||
get_rolespec_name(memberRole), rolename)));
|
||||
ReleaseSysCache(authmem_tuple);
|
||||
continue;
|
||||
}
|
||||
@@ -1587,7 +1587,7 @@ DelRoleMems(const char *rolename, Oid roleid,
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("role \"%s\" is not a member of role \"%s\"",
|
||||
get_rolespec_name(memberRole), rolename)));
|
||||
get_rolespec_name(memberRole), rolename)));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1337,7 +1337,7 @@ lazy_scan_heap(Relation onerel, int options, LVRelStats *vacrelstats,
|
||||
*/
|
||||
initStringInfo(&buf);
|
||||
appendStringInfo(&buf,
|
||||
_("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),
|
||||
_("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),
|
||||
nkeep, OldestXmin);
|
||||
appendStringInfo(&buf, _("There were %.0f unused item pointers.\n"),
|
||||
nunused);
|
||||
@@ -1912,8 +1912,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
/* If we haven't prefetched this lot yet, do so now. */
|
||||
if (prefetchedUntil > blkno)
|
||||
{
|
||||
BlockNumber prefetchStart;
|
||||
BlockNumber pblkno;
|
||||
BlockNumber prefetchStart;
|
||||
BlockNumber pblkno;
|
||||
|
||||
prefetchStart = blkno & ~(PREFETCH_SIZE - 1);
|
||||
for (pblkno = prefetchStart; pblkno <= blkno; pblkno++)
|
||||
|
||||
@@ -469,11 +469,11 @@ DefineView(ViewStmt *stmt, const char *queryString,
|
||||
if (stmt->withCheckOption == LOCAL_CHECK_OPTION)
|
||||
stmt->options = lappend(stmt->options,
|
||||
makeDefElem("check_option",
|
||||
(Node *) makeString("local"), -1));
|
||||
(Node *) makeString("local"), -1));
|
||||
else if (stmt->withCheckOption == CASCADED_CHECK_OPTION)
|
||||
stmt->options = lappend(stmt->options,
|
||||
makeDefElem("check_option",
|
||||
(Node *) makeString("cascaded"), -1));
|
||||
(Node *) makeString("cascaded"), -1));
|
||||
|
||||
/*
|
||||
* Check that the view is auto-updatable if WITH CHECK OPTION was
|
||||
|
||||
Reference in New Issue
Block a user