Skip to content

Commit

Permalink
Change DDL Statements based on feedback in FP Review
Browse files Browse the repository at this point in the history
Rename enums to have YB prefix
Fix include names. Change syntax to FAILED_LOGIN_ATTEMPTS
Replace Enable/Disable with Lock/Unlock
  • Loading branch information
vrajat committed Dec 13, 2022
1 parent e56698f commit 95b7626
Show file tree
Hide file tree
Showing 27 changed files with 124 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected Map<String, String> getTServerFlags() {
@Test(expected = PSQLException.class)
public void testCreateProfileIsDisabled() throws Exception {
try (Statement stmt = connection.createStatement()) {
stmt.execute("CREATE PROFILE p1 FAILED ATTEMPTS 3");
stmt.execute("CREATE PROFILE p1 FAILED_LOGIN_ATTEMPTS 3");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public void cleanup() throws Exception {
public void setup() throws Exception {
try (Statement stmt = connection.createStatement()) {
stmt.execute(String.format("CREATE USER %s PASSWORD '%s'", USERNAME, PASSWORD));
stmt.execute(String.format("CREATE PROFILE %s FAILED ATTEMPTS %d",
stmt.execute(String.format("CREATE PROFILE %s LIMIT FAILED_LOGIN_ATTEMPTS %d",
PROFILE_1_NAME, PRF_1_FAILED_ATTEMPTS));
stmt.execute(String.format("CREATE PROFILE %s FAILED ATTEMPTS %d",
stmt.execute(String.format("CREATE PROFILE %s LIMIT FAILED_LOGIN_ATTEMPTS %d",
PROFILE_2_NAME, PRF_2_FAILED_ATTEMPTS));
stmt.execute(String.format("ALTER USER %s PROFILE ATTACH %s",
USERNAME, PROFILE_1_NAME));
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/backend/catalog/aclchk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3804,7 +3804,7 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
case OBJECT_TABLESPACE:
msg = gettext_noop("permission denied for tablespace %s");
break;
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
msg = gettext_noop("permission denied for profile %s");
break;
case OBJECT_TSCONFIGURATION:
Expand Down Expand Up @@ -3971,7 +3971,7 @@ aclcheck_error(AclResult aclerr, ObjectType objtype,
case OBJECT_DEFACL:
case OBJECT_DOMCONSTRAINT:
case OBJECT_PUBLICATION_REL:
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
case OBJECT_ROLE:
case OBJECT_TRANSFORM:
case OBJECT_TSPARSER:
Expand Down
14 changes: 7 additions & 7 deletions src/postgres/src/backend/catalog/dependency.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
#include "commands/extension.h"
#include "commands/policy.h"
#include "commands/proclang.h"
#include "commands/profile.h"
#include "commands/publicationcmds.h"
#include "commands/schemacmds.h"
#include "commands/seclabel.h"
#include "commands/sequence.h"
#include "commands/tablegroup.h"
#include "commands/trigger.h"
#include "commands/typecmds.h"
#include "commands/ybc_profile.h"
#include "nodes/nodeFuncs.h"
#include "parser/parsetree.h"
#include "rewrite/rewriteRemove.h"
Expand Down Expand Up @@ -179,8 +179,8 @@ static const Oid object_classes[] = {
PublicationRelRelationId, /* OCLASS_PUBLICATION_REL */
SubscriptionRelationId, /* OCLASS_SUBSCRIPTION */
TransformRelationId, /* OCLASS_TRANSFORM */
YbProfileRelationId, /* OCLASS_PROFILE */
YbRoleProfileRelationId, /* OCLASS_ROLE_PROFILE */
YbProfileRelationId, /* OCLASS_YBPROFILE */
YbRoleProfileRelationId, /* OCLASS_ROLE_YBPROFILE */
};


Expand Down Expand Up @@ -1319,11 +1319,11 @@ doDeletion(const ObjectAddress *object, int flags)
RemoveTablegroupById(object->objectId);
break;

case OCLASS_PROFILE:
case OCLASS_YBPROFILE:
RemoveProfileById(object->objectId);
break;

case OCLASS_ROLE_PROFILE:
case OCLASS_ROLE_YBPROFILE:
RemoveRoleProfileById(object->objectId);
break;
/*
Expand Down Expand Up @@ -2549,10 +2549,10 @@ getObjectClass(const ObjectAddress *object)
return OCLASS_DATABASE;

case YbProfileRelationId:
return OCLASS_PROFILE;
return OCLASS_YBPROFILE;

case YbRoleProfileRelationId:
return OCLASS_ROLE_PROFILE;
return OCLASS_ROLE_YBPROFILE;

case YbTablegroupRelationId:
return OCLASS_TBLGROUP;
Expand Down
28 changes: 14 additions & 14 deletions src/postgres/src/backend/catalog/objectaddress.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "commands/extension.h"
#include "commands/profile.h"
#include "commands/policy.h"
#include "commands/proclang.h"
#include "commands/tablespace.h"
#include "commands/tablegroup.h"
#include "commands/trigger.h"
#include "commands/ybc_profile.h"
#include "foreign/foreign.h"
#include "funcapi.h"
#include "miscadmin.h"
Expand Down Expand Up @@ -515,7 +515,7 @@ static const ObjectPropertyType ObjectProperty[] =
InvalidAttrNumber,
InvalidAttrNumber,
InvalidAttrNumber,
OBJECT_PROFILE,
OBJECT_YBPROFILE,
true
}
};
Expand Down Expand Up @@ -747,9 +747,9 @@ static const struct object_type_map
{
"statistics object", OBJECT_STATISTIC_EXT
},
/* OBJECT_PROFILE */
/* OBJECT_YBPROFILE */
{
"profile", OBJECT_PROFILE
"profile", OBJECT_YBPROFILE
}
};

Expand Down Expand Up @@ -915,7 +915,7 @@ get_object_address(ObjectType objtype, Node *object,
case OBJECT_PUBLICATION:
case OBJECT_SUBSCRIPTION:
case OBJECT_YBTABLEGROUP:
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
address = get_object_address_unqualified(objtype,
(Value *) object, missing_ok);
break;
Expand Down Expand Up @@ -1225,7 +1225,7 @@ get_object_address_unqualified(ObjectType objtype,
address.objectId = get_subscription_oid(name, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
address.classId = YbProfileRelationId;
address.objectId = get_profile_oid(name, missing_ok);
address.objectSubId = 0;
Expand Down Expand Up @@ -2183,7 +2183,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
case OBJECT_TABCONSTRAINT:
case OBJECT_OPCLASS:
case OBJECT_OPFAMILY:
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
objnode = (Node *) name;
break;
case OBJECT_ACCESS_METHOD:
Expand Down Expand Up @@ -2479,7 +2479,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
if (!pg_statistics_object_ownercheck(address.objectId, roleid))
aclcheck_error_type(ACLCHECK_NOT_OWNER, address.objectId);
break;
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
/* A profile can be dropped by the super user or yb_db_admin */
if (!superuser() && !IsYbDbAdminUser(GetUserId()))
ereport(ERROR,
Expand Down Expand Up @@ -3658,14 +3658,14 @@ getObjectDescription(const ObjectAddress *object)
ReleaseSysCache(trfTup);
break;
}
case OCLASS_PROFILE:
case OCLASS_YBPROFILE:
{
char *profile;
profile = get_profile_name(object->objectId);
appendStringInfo(&buffer, _("profile %s"), profile);
break;
}
case OCLASS_ROLE_PROFILE:
case OCLASS_ROLE_YBPROFILE:
{
Oid roleid = get_role_oid_from_role_profile(object->objectId);
appendStringInfo(&buffer, _("a profile is attached to role %s"),
Expand Down Expand Up @@ -4179,11 +4179,11 @@ getObjectTypeDescription(const ObjectAddress *object)
appendStringInfoString(&buffer, "transform");
break;

case OCLASS_PROFILE:
case OCLASS_YBPROFILE:
appendStringInfoString(&buffer, "profile");
break;

case OCLASS_ROLE_PROFILE:
case OCLASS_ROLE_YBPROFILE:
appendStringInfoString(&buffer, "role profile");
break;
/*
Expand Down Expand Up @@ -5254,7 +5254,7 @@ getObjectIdentityParts(const ObjectAddress *object,
heap_close(transformDesc, AccessShareLock);
}
break;
case OCLASS_PROFILE:
case OCLASS_YBPROFILE:
{
char *profile;
profile = get_profile_name(object->objectId);
Expand All @@ -5264,7 +5264,7 @@ getObjectIdentityParts(const ObjectAddress *object,
quote_identifier(profile));
break;
}
case OCLASS_ROLE_PROFILE:
case OCLASS_ROLE_YBPROFILE:
{
Oid roleid = get_role_oid_from_role_profile(object->objectId);
if (roleid == InvalidOid)
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/backend/commands/alter.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
case OCLASS_PUBLICATION_REL:
case OCLASS_SUBSCRIPTION:
case OCLASS_TRANSFORM:
case OCLASS_PROFILE:
case OCLASS_ROLE_PROFILE:
case OCLASS_YBPROFILE:
case OCLASS_ROLE_YBPROFILE:
/* ignore object types that don't have schema-qualified names */
break;

Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/backend/commands/dropcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ does_not_exist_skipping(ObjectType objtype, Node *object)
msg = gettext_noop("tablegroup \"%s\" does not exist, skipping");
name = strVal((Value *) object);
break;
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
msg = gettext_noop("profile \"%s\" does not exist, skipping");
name = strVal((Value *) object);
break;
Expand Down
10 changes: 5 additions & 5 deletions src/postgres/src/backend/commands/event_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ EventTriggerSupportsObjectType(ObjectType obtype)
/* no support for event triggers on event triggers */
return false;
case OBJECT_YBTABLEGROUP:
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
/* no support for event triggers on tablegroups or profile*/
return false;
case OBJECT_ACCESS_METHOD:
Expand Down Expand Up @@ -1201,8 +1201,8 @@ EventTriggerSupportsObjectClass(ObjectClass objclass)
case OCLASS_TBLGROUP:
/* no support for event triggers on tablegroups */
return false;
case OCLASS_PROFILE:
case OCLASS_ROLE_PROFILE:
case OCLASS_YBPROFILE:
case OCLASS_ROLE_YBPROFILE:
/* no support for event triggers on profiles */
return false;
case OCLASS_CLASS:
Expand Down Expand Up @@ -2275,7 +2275,7 @@ stringify_grant_objtype(ObjectType objtype)
return "TABLEGROUP";
case OBJECT_TABLESPACE:
return "TABLESPACE";
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
return "PROFILE";
case OBJECT_TYPE:
return "TYPE";
Expand Down Expand Up @@ -2361,7 +2361,7 @@ stringify_adefprivs_objtype(ObjectType objtype)
return "TABLEGROUPS";
case OBJECT_TABLESPACE:
return "TABLESPACES";
case OBJECT_PROFILE:
case OBJECT_YBPROFILE:
return "PROFILES";
case OBJECT_TYPE:
return "TYPES";
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -11648,8 +11648,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
case OCLASS_PUBLICATION_REL:
case OCLASS_SUBSCRIPTION:
case OCLASS_TRANSFORM:
case OCLASS_PROFILE:
case OCLASS_ROLE_PROFILE:
case OCLASS_YBPROFILE:
case OCLASS_ROLE_YBPROFILE:

/*
* We don't expect any of these sorts of objects to depend on
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/backend/commands/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include "catalog/pg_db_role_setting.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "commands/profile.h"
#include "commands/seclabel.h"
#include "commands/user.h"
#include "commands/ybc_profile.h"
#include "libpq/crypt.h"
#include "miscadmin.h"
#include "storage/lmgr.h"
Expand Down
5 changes: 2 additions & 3 deletions src/postgres/src/backend/commands/ybc_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/profile.h"
#include "commands/seclabel.h"
#include "commands/tablecmds.h"
#include "commands/ybccmds.h"
#include "commands/ybc_profile.h"
#include "common/file_perm.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
Expand Down Expand Up @@ -321,8 +321,7 @@ CreateRoleProfile(Oid roleid, const char *rolename, const char *prfname)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("permission denied to attach role \"%s\" to profile \"%s\"",
rolename, prfname),
errhint("Must be superuser or a member of the yb_db_admin "
"role to create a profile.")));
errhint("Must be superuser or a member of the yb_db_admin")));

/*
* Check that there is a profile by this name.
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/backend/executor/ybcModifyTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "catalog/pg_yb_role_profile.h"
#include "catalog/pg_yb_role_profile_d.h"
#include "catalog/yb_type.h"
#include "commands/profile.h"
#include "commands/ybc_profile.h"
#include "utils/relcache.h"
#include "utils/rel.h"
#include "utils/lsyscache.h"
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src/backend/libpq/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include "access/htup_details.h"
#include "catalog/pg_yb_role_profile.h"
#include "commands/profile.h"
#include "commands/user.h"
#include "commands/ybc_profile.h"
#include "common/ip.h"
#include "common/md5.h"
#include "common/scram-common.h"
Expand Down
Loading

0 comments on commit 95b7626

Please sign in to comment.