Skip to content

Commit

Permalink
[MERGE PG15] Adds missing oid columns and indexes to YB system tables
Browse files Browse the repository at this point in the history
Summary: Adds missing oid columns and indexes to YB system tables

Test Plan: N/A

Reviewers: mihnea, neil

Reviewed By: neil

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D24959
  • Loading branch information
arpang authored and nocaway committed Jul 20, 2023
1 parent 06d9200 commit 065c1a2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 50 deletions.
5 changes: 2 additions & 3 deletions src/postgres/src/backend/catalog/objectaddress.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ static const ObjectPropertyType ObjectProperty[] =
YbTablegroupOidIndexId,
YBTABLEGROUPOID,
-1,
/* ObjectIdAttributeNumber */
Anum_pg_tablegroup_oid,
Anum_pg_yb_tablegroup_oid,
Anum_pg_yb_tablegroup_grpname,
InvalidAttrNumber,
Anum_pg_yb_tablegroup_grpowner,
Expand Down Expand Up @@ -640,12 +639,12 @@ static const ObjectPropertyType ObjectProperty[] =
false
},
{
/* YB_TODO(neil) Need name for the new entry */
"ybprofile",
YbProfileRelationId,
YbProfileOidIndexId,
-1,
-1,
Anum_pg_yb_profile_oid,
Anum_pg_yb_profile_prfname,
InvalidAttrNumber,
InvalidAttrNumber,
Expand Down
19 changes: 7 additions & 12 deletions src/postgres/src/backend/commands/tablegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,12 @@ CreateTableGroup(CreateTableGroupStmt *stmt)
rel = table_open(YbTablegroupRelationId, RowExclusiveLock);
MemSet(nulls, false, sizeof(nulls));

/* YB_TODO(alex@yugabyte)
*
* - Postgres no longer has hidden OID. A column for OID must be included if oid is needed.
* - The following is a suggestion of what to do.
* tablegroupoid = GetNewOidWithIndex(rel, TablegroupOidIndexId, Anum_pg_yb_tablegroup_oid);
* values[Anum_pg_yb_tablegroup_oid - 1] = ObjectIdGetDatum(tablegroupoid);
/* YB_TODO(aagrawal@yugabyte)
* - Need to verify if following assignments to "values[]" are correct.
*/
tablegroupoid = YB_HACK_INVALID_OID;

tablegroupoid = GetNewOidWithIndex(rel, YbTablegroupOidIndexId,
Anum_pg_yb_tablegroup_oid);

values[Anum_pg_yb_tablegroup_grpname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->tablegroupname));
Expand Down Expand Up @@ -230,15 +227,13 @@ CreateTableGroup(CreateTableGroupStmt *stmt)
*/
if (OidIsValid(binary_upgrade_next_tablegroup_oid))
{
/* YB_TODO(alex) Needs to decide which column should be OID.
* Following code assign oid as 1st column - values[0]
*/
int Anum_pg_yb_tablegroup_oid = 0;
values[Anum_pg_yb_tablegroup_oid] = binary_upgrade_next_tablegroup_oid;
tablegroupoid = binary_upgrade_next_tablegroup_oid;
binary_upgrade_next_tablegroup_oid = InvalidOid;
}
}

values[Anum_pg_yb_tablegroup_oid - 1] = ObjectIdGetDatum(tablegroupoid);

tuple = heap_form_tuple(rel->rd_att, values, nulls);

CatalogTupleInsert(rel, tuple);
Expand Down
20 changes: 8 additions & 12 deletions src/postgres/src/backend/commands/yb_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "access/sysattr.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
Expand Down Expand Up @@ -137,14 +138,9 @@ YbCreateProfile(YbCreateProfileStmt *stmt)
/* Set lock time to 0 as it is not implemented yet. */
values[Anum_pg_yb_profile_prfpasswordlocktime - 1] = 0;

/* YB_TODO
* Need to assign oid to values.
* prfid = ??;
* Anum_pg_ybprofile_oid = ??
* values[Anum_pg_ybprofile_oid] = prfid;
*/
prfid = 0;
values[0] = prfid;
prfid =
GetNewOidWithIndex(rel, YbProfileOidIndexId, Anum_pg_yb_profile_oid);
values[Anum_pg_yb_profile_oid - 1] = ObjectIdGetDatum(prfid);
tuple = heap_form_tuple(rel->rd_att, values, nulls);

CatalogTupleInsert(rel, tuple);
Expand Down Expand Up @@ -398,11 +394,11 @@ yb_create_role_profile_map(Oid roleid, Oid prfid)

nulls[Anum_pg_yb_role_profile_rolprflockeduntil - 1] = true;

tuple = heap_form_tuple(rel->rd_att, values, nulls);
roleprfid = GetNewOidWithIndex(rel, YbRoleProfileOidIndexId,
Anum_pg_yb_role_profile_oid);
values[Anum_pg_yb_role_profile_oid - 1] = ObjectIdGetDatum(roleprfid);

/* YB_TODO(neil) Need to define role id and assign to values */
roleprfid = 0;
values[0] = roleprfid;
tuple = heap_form_tuple(rel->rd_att, values, nulls);
CatalogTupleInsert(rel, tuple);

ybRecordDependencyOnProfile(AuthIdRelationId, roleid, prfid);
Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/include/catalog/pg_yb_catalog_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ CATALOG(pg_yb_catalog_version,8010,YBCatalogVersionRelationId) BKI_SHARED_RELATI
*/
typedef FormData_yb_pg_catalog_version *Form_yb_pg_catalog_version;

DECLARE_UNIQUE_INDEX_PKEY(pg_yb_catalog_version_db_oid_index, 8012, YBCatalogVersionDbOidIndexId, on pg_yb_catalog_version using btree(db_oid oid_ops));

#endif /* PG_YB_CATALOG_VERSION_H */
19 changes: 3 additions & 16 deletions src/postgres/src/include/catalog/pg_yb_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
CATALOG(pg_yb_profile,8051,YbProfileRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(8053,YbProfileRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
NameData prfname; /* profile name */
int32 prfmaxfailedloginattempts; /* no. of attempts allowed */
int32 prfpasswordlocktime; /* secs to lock out an account */
Expand All @@ -39,22 +40,8 @@ CATALOG(pg_yb_profile,8051,YbProfileRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_
*/
typedef FormData_pg_yb_profile *Form_pg_yb_profile;

#ifdef YB_TODO
/* YB_TODO(neil) Need to rework on these entries.
* Postgres doesn't use these macros any longer?
*/
DECLARE_UNIQUE_INDEX(pg_yb_catalog_version_db_oid_index, 8012, on pg_yb_catalog_version using btree(db_oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_yb_profile_oid_index, 8052, on pg_yb_profile using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_yb_role_profile_oid_index, 8055, on pg_yb_role_profile using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_yb_profile_prfname_index, 8057, on pg_yb_profile using btree(prfname name_ops));
#endif

#define YBCatalogVersionDbOidIndexId 8012

#define YbProfileOidIndexId 8052

#define YbRoleProfileOidIndexId 8055
DECLARE_UNIQUE_INDEX_PKEY(pg_yb_profile_oid_index, 8052, YbProfileOidIndexId, on pg_yb_profile using btree(oid oid_ops));
DECLARE_UNIQUE_INDEX(pg_yb_profile_prfname_index, 8057, YbProfileRolnameIndexId, on pg_yb_profile using btree(prfname name_ops));

#define YbProfileRolnameIndexId 8057

#endif /* PG_YB_PROFILE_H */
3 changes: 3 additions & 0 deletions src/postgres/src/include/catalog/pg_yb_role_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
CATALOG(pg_yb_role_profile,8054,YbRoleProfileRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(8056,YbRoleProfileRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
Oid rolprfrole; /* OID of the role */
Oid rolprfprofile; /* OID of the profile */
char rolprfstatus; /* Refer to the status
Expand All @@ -45,6 +46,8 @@ CATALOG(pg_yb_role_profile,8054,YbRoleProfileRelationId) BKI_SHARED_RELATION BKI
*/
typedef FormData_pg_yb_role_profile *Form_pg_yb_role_profile;

DECLARE_UNIQUE_INDEX_PKEY(pg_yb_role_profile_oid_index, 8055, YbRoleProfileOidIndexId, on pg_yb_role_profile using btree(oid oid_ops));

/*
* Symbolic values for rolprfstatus
*/
Expand Down
9 changes: 2 additions & 7 deletions src/postgres/src/include/catalog/pg_yb_tablegroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
CATALOG(pg_yb_tablegroup,8036,YbTablegroupRelationId) BKI_ROWTYPE_OID(8038,YbTablegroupRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
NameData grpname; /* tablegroup name */
Oid grpowner; /* owner of tablegroup */
Oid grptablespace; /* tablespace of tablegroup */
Expand All @@ -44,12 +45,6 @@ CATALOG(pg_yb_tablegroup,8036,YbTablegroupRelationId) BKI_ROWTYPE_OID(8038,YbTab
*/
typedef FormData_pg_yb_tablegroup *Form_pg_yb_tablegroup;

#define Anum_pg_tablegroup_oid 1

#define YbTablegroupOidIndexId 8037
DECLARE_UNIQUE_INDEX(pg_yb_tablegroup_oid_index, 8037, YbTablegroupOidIndexId, on pg_yb_tablegroup using btree(oid oid_ops));

#define YBCatalogVersionDbOidIndexId 8012
DECLARE_UNIQUE_INDEX(pg_yb_catalog_version_db_oid_index, 8012, YBCatalogVersionDbOidIndexId, on pg_yb_catalog_version using btree(db_oid oid_ops));
DECLARE_UNIQUE_INDEX_PKEY(pg_yb_tablegroup_oid_index, 8037, YbTablegroupOidIndexId, on pg_yb_tablegroup using btree(oid oid_ops));

#endif /* PG_YB_TABLEGROUP_H */

0 comments on commit 065c1a2

Please sign in to comment.