Skip to content

Commit

Permalink
[yugabyte#13423] YSQL: Remove unused PgEnv class
Browse files Browse the repository at this point in the history
Summary: PgEnv class is not used. Removing for code cleanup.

Test Plan: Jenkins

Reviewers: jason, alex

Reviewed By: alex

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D18514
  • Loading branch information
d-uspenskiy committed Jul 26, 2022
1 parent 5285c15 commit 497f3f2
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 99 deletions.
2 changes: 1 addition & 1 deletion src/postgres/src/backend/utils/misc/pg_yb_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ YBInitPostgresBackend(
*
* TODO: do we really need to DB name / username here?
*/
HandleYBStatus(YBCPgInitSession(/* pg_env */ NULL, db_name ? db_name : user_name));
HandleYBStatus(YBCPgInitSession(db_name ? db_name : user_name));
}
}

Expand Down
49 changes: 0 additions & 49 deletions src/yb/yql/pggate/pg_env.h

This file was deleted.

1 change: 0 additions & 1 deletion src/yb/yql/pggate/pg_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#include "yb/yql/pggate/pg_client.h"
#include "yb/yql/pggate/pg_gate_fwd.h"
#include "yb/yql/pggate/pg_env.h"
#include "yb/yql/pggate/pg_operation_buffer.h"
#include "yb/yql/pggate/pg_perform_future.h"
#include "yb/yql/pggate/pg_tabledesc.h"
Expand Down
1 change: 0 additions & 1 deletion src/yb/yql/pggate/pg_statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "yb/util/bytes_formatter.h"

#include "yb/yql/pggate/pg_env.h"
#include "yb/yql/pggate/pg_expr.h"
#include "yb/yql/pggate/pg_memctx.h"
#include "yb/yql/pggate/pg_session.h"
Expand Down
1 change: 0 additions & 1 deletion src/yb/yql/pggate/pg_truncate_colocated.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define YB_YQL_PGGATE_PG_TRUNCATE_COLOCATED_H_

#include "yb/yql/pggate/pg_dml_write.h"
#include "yb/yql/pggate/pg_env.h"
#include "yb/yql/pggate/pg_session.h"
#include "yb/yql/pggate/pg_statement.h"

Expand Down
15 changes: 1 addition & 14 deletions src/yb/yql/pggate/pggate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,20 +442,7 @@ const YBCPgTypeEntity *PgApiImpl::FindTypeEntity(int type_oid) {

//--------------------------------------------------------------------------------------------------

Status PgApiImpl::CreateEnv(PgEnv **pg_env) {
*pg_env = pg_env_.get();
return Status::OK();
}

Status PgApiImpl::DestroyEnv(PgEnv *pg_env) {
pg_env_ = nullptr;
return Status::OK();
}

//--------------------------------------------------------------------------------------------------

Status PgApiImpl::InitSession(const PgEnv *pg_env,
const string& database_name) {
Status PgApiImpl::InitSession(const string& database_name) {
CHECK(!pg_session_);
auto session = make_scoped_refptr<PgSession>(&pg_client_,
database_name,
Expand Down
11 changes: 1 addition & 10 deletions src/yb/yql/pggate/pggate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "yb/util/status_fwd.h"

#include "yb/yql/pggate/pg_client.h"
#include "yb/yql/pggate/pg_env.h"
#include "yb/yql/pggate/pg_expr.h"
#include "yb/yql/pggate/pg_gate_fwd.h"
#include "yb/yql/pggate/pg_statement.h"
Expand Down Expand Up @@ -123,13 +122,9 @@ class PgApiImpl {
void Interrupt();
void ResetCatalogReadTime();

// Initialize ENV within which PGSQL calls will be executed.
Status CreateEnv(PgEnv **pg_env);
Status DestroyEnv(PgEnv *pg_env);

// Initialize a session to process statements that come from the same client connection.
// If database_name is empty, a session is created without connecting to any database.
Status InitSession(const PgEnv *pg_env, const std::string& database_name);
Status InitSession(const std::string& database_name);

PgMemctx *CreateMemctx();
Status DestroyMemctx(PgMemctx *memctx);
Expand Down Expand Up @@ -619,10 +614,6 @@ class PgApiImpl {
// TODO Rename to client_ when YBClient is removed.
PgClient pg_client_;

// TODO(neil) Map for environments (we should have just one ENV?). Environments should contain
// all the custom flags the PostgreSQL sets. We ignore them all for now.
PgEnv::SharedPtr pg_env_;

scoped_refptr<server::HybridClock> clock_;

// Local tablet-server shared memory segment handle.
Expand Down
2 changes: 1 addition & 1 deletion src/yb/yql/pggate/test/pggate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Status PggateTest::Init(const char *test_name, int num_tablet_servers) {
YBCInitPgGate(type_table, count, callbacks);

// Setup session.
CHECK_YBC_STATUS(YBCPgInitSession(nullptr /* pg_env */, nullptr /* database_name */));
CHECK_YBC_STATUS(YBCPgInitSession(nullptr /* database_name */));

// Setup database
SetupDB();
Expand Down
3 changes: 0 additions & 3 deletions src/yb/yql/pggate/ybc_pg_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
extern "C" {
#endif // __cplusplus

// TODO(neil) Handle to Env. Each Postgres process might need just one ENV, maybe more.
YB_DEFINE_HANDLE_TYPE(PgEnv)

// Handle to a session. Postgres should create one YBCPgSession per client connection.
YB_DEFINE_HANDLE_TYPE(PgSession)

Expand Down
14 changes: 2 additions & 12 deletions src/yb/yql/pggate/ybc_pggate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "yb/docdb/primitive_value.h"
#include "yb/docdb/value_type.h"

#include "yb/yql/pggate/pg_env.h"
#include "yb/yql/pggate/pg_expr.h"
#include "yb/yql/pggate/pg_gate_fwd.h"
#include "yb/yql/pggate/pg_memctx.h"
Expand Down Expand Up @@ -163,18 +162,9 @@ const YBCPgCallbacks *YBCGetPgCallbacks() {
return pgapi->pg_callbacks();
}

YBCStatus YBCPgCreateEnv(YBCPgEnv *pg_env) {
return ToYBCStatus(pgapi->CreateEnv(pg_env));
}

YBCStatus YBCPgDestroyEnv(YBCPgEnv pg_env) {
return ToYBCStatus(pgapi->DestroyEnv(pg_env));
}

YBCStatus YBCPgInitSession(const YBCPgEnv pg_env,
const char *database_name) {
YBCStatus YBCPgInitSession(const char *database_name) {
const string db_name(database_name ? database_name : "");
return ToYBCStatus(pgapi->InitSession(pg_env, db_name));
return ToYBCStatus(pgapi->InitSession(db_name));
}

YBCPgMemctx YBCPgCreateMemctx() {
Expand Down
8 changes: 2 additions & 6 deletions src/yb/yql/pggate/ybc_pggate.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,16 @@ void YBCInterruptPgGate();
//--------------------------------------------------------------------------------------------------
// Environment and Session.

// Initialize ENV within which PGSQL calls will be executed.
YBCStatus YBCPgCreateEnv(YBCPgEnv *pg_env);
YBCStatus YBCPgDestroyEnv(YBCPgEnv pg_env);

// Initialize a session to process statements that come from the same client connection.
YBCStatus YBCPgInitSession(const YBCPgEnv pg_env, const char *database_name);
YBCStatus YBCPgInitSession(const char *database_name);

// Initialize YBCPgMemCtx.
// - Postgres uses memory context to hold all of its allocated space. Once all associated operations
// are done, the context is destroyed.
// - There YugaByte objects are bound to Postgres operations. All of these objects' allocated
// memory will be held by YBCPgMemCtx, whose handle belongs to Postgres MemoryContext. Once all
// Postgres operations are done, associated YugaByte memory context (YBCPgMemCtx) will be
// destroyed toghether with Postgres memory context.
// destroyed together with Postgres memory context.
YBCPgMemctx YBCPgCreateMemctx();
YBCStatus YBCPgDestroyMemctx(YBCPgMemctx memctx);
YBCStatus YBCPgResetMemctx(YBCPgMemctx memctx);
Expand Down

0 comments on commit 497f3f2

Please sign in to comment.