diff options
| author | Dean Rasheed <dean.a.rasheed@gmail.com> | 2021-07-15 08:49:45 +0100 |
|---|---|---|
| committer | Dean Rasheed <dean.a.rasheed@gmail.com> | 2021-07-15 08:49:45 +0100 |
| commit | 2bfb50b3df11399ed80347dd03bfaf8cd5acf962 (patch) | |
| tree | 126051120d4735ba8619d4102a65e92d366f36e0 /src/include | |
| parent | ffc9ddaea33f6dfd3dfa95828a0970fbb617bf8a (diff) | |
| download | postgresql-2bfb50b3df11399ed80347dd03bfaf8cd5acf962.tar.gz | |
Improve reporting of "conflicting or redundant options" errors.
When reporting "conflicting or redundant options" errors, try to
ensure that errposition() is used, to help the user identify the
offending option.
Formerly, errposition() was invoked in less than 60% of cases. This
patch raises that to over 90%, but there remain a few places where the
ParseState is not readily available. Using errdetail() might improve
the error in such cases, but that is left as a task for the future.
Additionally, since this error is thrown from over 100 places in the
codebase, introduce a dedicated function to throw it, reducing code
duplication.
Extracted from a slightly larger patch by Vignesh C. Reviewed by
Bharath Rupireddy, Alvaro Herrera, Dilip Kumar, Hou Zhijie, Peter
Smith, Daniel Gustafsson, Julien Rouhaud and me.
Discussion: https://postgr.es/m/CALDaNm33FFSS5tVyvmkoK2cCMuDVxcui=gFrjti9ROfynqSAGA@mail.gmail.com
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/commands/defrem.h | 7 | ||||
| -rw-r--r-- | src/include/commands/publicationcmds.h | 4 | ||||
| -rw-r--r-- | src/include/commands/subscriptioncmds.h | 4 | ||||
| -rw-r--r-- | src/include/commands/typecmds.h | 2 | ||||
| -rw-r--r-- | src/include/commands/user.h | 2 |
5 files changed, 10 insertions, 9 deletions
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 42bf1c7519..f84d09959c 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -56,7 +56,7 @@ extern ObjectAddress CreateCast(CreateCastStmt *stmt); extern ObjectAddress CreateTransform(CreateTransformStmt *stmt); extern void IsThereFunctionInNamespace(const char *proname, int pronargs, oidvector *proargtypes, Oid nspOid); -extern void ExecuteDoStmt(DoStmt *stmt, bool atomic); +extern void ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic); extern void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest); extern TupleDesc CallStmtResultDesc(CallStmt *stmt); extern Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok); @@ -121,8 +121,8 @@ extern ObjectAddress AlterForeignServerOwner(const char *name, Oid newOwnerId); extern void AlterForeignServerOwner_oid(Oid, Oid newOwnerId); extern ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId); extern void AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId); -extern ObjectAddress CreateForeignDataWrapper(CreateFdwStmt *stmt); -extern ObjectAddress AlterForeignDataWrapper(AlterFdwStmt *stmt); +extern ObjectAddress CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt); +extern ObjectAddress AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt); extern ObjectAddress CreateForeignServer(CreateForeignServerStmt *stmt); extern ObjectAddress AlterForeignServer(AlterForeignServerStmt *stmt); extern ObjectAddress CreateUserMapping(CreateUserMappingStmt *stmt); @@ -153,5 +153,6 @@ extern List *defGetQualifiedName(DefElem *def); extern TypeName *defGetTypeName(DefElem *def); extern int defGetTypeLength(DefElem *def); extern List *defGetStringList(DefElem *def); +extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate) pg_attribute_noreturn(); #endif /* DEFREM_H */ diff --git a/src/include/commands/publicationcmds.h b/src/include/commands/publicationcmds.h index 00e2e626e6..efea01f2a9 100644 --- a/src/include/commands/publicationcmds.h +++ b/src/include/commands/publicationcmds.h @@ -18,8 +18,8 @@ #include "catalog/objectaddress.h" #include "nodes/parsenodes.h" -extern ObjectAddress CreatePublication(CreatePublicationStmt *stmt); -extern void AlterPublication(AlterPublicationStmt *stmt); +extern ObjectAddress CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt); +extern void AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt); extern void RemovePublicationRelById(Oid proid); extern ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId); diff --git a/src/include/commands/subscriptioncmds.h b/src/include/commands/subscriptioncmds.h index 3b926f35d7..8bf25ee66c 100644 --- a/src/include/commands/subscriptioncmds.h +++ b/src/include/commands/subscriptioncmds.h @@ -18,9 +18,9 @@ #include "catalog/objectaddress.h" #include "nodes/parsenodes.h" -extern ObjectAddress CreateSubscription(CreateSubscriptionStmt *stmt, +extern ObjectAddress CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt, bool isTopLevel); -extern ObjectAddress AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel); +extern ObjectAddress AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt, bool isTopLevel); extern void DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel); extern ObjectAddress AlterSubscriptionOwner(const char *name, Oid newOwnerId); diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h index 880679127b..d5e22811d0 100644 --- a/src/include/commands/typecmds.h +++ b/src/include/commands/typecmds.h @@ -25,7 +25,7 @@ extern ObjectAddress DefineType(ParseState *pstate, List *names, List *parameter extern void RemoveTypeById(Oid typeOid); extern ObjectAddress DefineDomain(CreateDomainStmt *stmt); extern ObjectAddress DefineEnum(CreateEnumStmt *stmt); -extern ObjectAddress DefineRange(CreateRangeStmt *stmt); +extern ObjectAddress DefineRange(ParseState *pstate, CreateRangeStmt *stmt); extern ObjectAddress AlterEnum(AlterEnumStmt *stmt); extern ObjectAddress DefineCompositeType(RangeVar *typevar, List *coldeflist); extern Oid AssignTypeArrayOid(void); diff --git a/src/include/commands/user.h b/src/include/commands/user.h index 028e0dde56..0b7a3cd65f 100644 --- a/src/include/commands/user.h +++ b/src/include/commands/user.h @@ -25,7 +25,7 @@ typedef void (*check_password_hook_type) (const char *username, const char *shad extern PGDLLIMPORT check_password_hook_type check_password_hook; extern Oid CreateRole(ParseState *pstate, CreateRoleStmt *stmt); -extern Oid AlterRole(AlterRoleStmt *stmt); +extern Oid AlterRole(ParseState *pstate, AlterRoleStmt *stmt); extern Oid AlterRoleSet(AlterRoleSetStmt *stmt); extern void DropRole(DropRoleStmt *stmt); extern void GrantRole(GrantRoleStmt *stmt); |
