Skip to content

Commit

Permalink
Fixes review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gurkanindibay committed Dec 26, 2023
1 parent d345216 commit 1cc19a4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*-------------------------------------------------------------------------
*
* citus_database_size.c
* Includes all database related functions that are used.
*
* Copyright (c) Citus Data, Inc.
*
*-------------------------------------------------------------------------
*/

#include "postgres.h"

#include "fmgr.h"
Expand All @@ -18,20 +28,20 @@

static int GroupLookupFromDatabase(int64 databaseOid, bool missingOk);
PG_FUNCTION_INFO_V1(citus_internal_database_size_by_name);
PG_FUNCTION_INFO_V1(citus_dist_database_size_by_oid);
PG_FUNCTION_INFO_V1(citus_dist_database_size_by_name);
PG_FUNCTION_INFO_V1(citus_database_size_oid);
PG_FUNCTION_INFO_V1(citus_database_size_name);


/*
* This function obtains the size of a database given its oid,
* in distributed multi-node environment.
* It first obtains the database name using the oid, and then
* calls the function citus_dist_database_size_by_name, which
* calls the function citus_database_size_name, which
* is the C function for citus_database_size(name).
* Since oid may change among nodes, we need to use the name
*/
Datum
citus_dist_database_size_by_oid(PG_FUNCTION_ARGS)
citus_database_size_oid(PG_FUNCTION_ARGS)
{
CheckCitusVersion(ERROR);

Expand All @@ -53,7 +63,7 @@ citus_dist_database_size_by_oid(PG_FUNCTION_ARGS)
}
else
{
Datum size = DirectFunctionCall1(citus_dist_database_size_by_name, NameGetDatum(
Datum size = DirectFunctionCall1(citus_database_size_name, NameGetDatum(
dbName));
PG_RETURN_DATUM(size);
}
Expand All @@ -68,7 +78,7 @@ citus_dist_database_size_by_oid(PG_FUNCTION_ARGS)
* This function is the C function for citus_internal.pg_database_size_local(name).
*/
Datum
citus_dist_database_size_by_name(PG_FUNCTION_ARGS)
citus_database_size_name(PG_FUNCTION_ARGS)
{
uint32 connectionFlag = 0;

Expand Down Expand Up @@ -108,13 +118,6 @@ citus_dist_database_size_by_name(PG_FUNCTION_ARGS)
if (groupId == GetLocalGroupId())
{
/*local database */
elog(DEBUG1,
"Initiating process to get the size of the local database.\n"
"Database Name: %s\n"
"Server Group ID: %d\n"
"Worker Node Name: %s\n"
"Worker Node Port: %d",
dbName->data, groupId, workerNodeName, workerNodePort);
PG_RETURN_INT64(DirectFunctionCall1(citus_internal_database_size_by_name,
NameGetDatum(dbName)));
}
Expand Down Expand Up @@ -156,7 +159,7 @@ citus_dist_database_size_by_name(PG_FUNCTION_ARGS)


/*
* This function obtains the size of a database given its name,
* citus_internal_database_size_by_name obtains the size of a database given its name,
* similar to the function pg_database_size(name).
* However, since we need to override pg_database_size,
* we create this wrapper function to achieve the same functionality.
Expand Down
4 changes: 2 additions & 2 deletions src/backend/distributed/sql/citus--12.1-1--12.2-1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ CREATE TABLE citus.pg_dist_database (
ALTER TABLE citus.pg_dist_database SET SCHEMA pg_catalog;
GRANT SELECT ON pg_catalog.pg_dist_database TO public;

#include "udfs/citus_internal_pg_database_size_local/12.2-1.sql"
#include "udfs/citus_pg_dist_database/12.2-1.sql"
#include "udfs/pg_database_size_local/12.2-1.sql"
#include "udfs/citus_database_size/12.2-1.sql"
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
-- citus--12.2-1--12.1-1

DROP FUNCTION pg_catalog.citus_internal_database_command(text);


#include "../udfs/citus_add_rebalance_strategy/10.1-1.sql"


DROP FUNCTION citus_internal.pg_database_size_local(name);
DROP FUNCTION pg_catalog.citus_database_size(name);
DROP FUNCTION pg_catalog.citus_database_size(oid);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_database_size(db_name name)
RETURNS bigint
LANGUAGE C
VOLATILE
AS 'MODULE_PATHNAME', $$citus_dist_database_size_by_name$$;
AS 'MODULE_PATHNAME', $$citus_database_size_name$$;
COMMENT ON FUNCTION pg_catalog.citus_database_size(name) IS
'calculates the size of a database in bytes by its name in a multi-node cluster';

CREATE OR REPLACE FUNCTION pg_catalog.citus_database_size(db_oid oid)
RETURNS bigint
LANGUAGE C
VOLATILE
AS 'MODULE_PATHNAME', $$citus_dist_database_size_by_oid$$;
AS 'MODULE_PATHNAME', $$citus_database_size_oid$$;
COMMENT ON FUNCTION pg_catalog.citus_database_size(oid) IS
'calculates the size of a database in bytes by its oid in a multi-node cluster';

0 comments on commit 1cc19a4

Please sign in to comment.