From 551d30f50da6e0dbef8868581054fcac6f7f654f Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 11 Jan 2018 14:24:16 +0200 Subject: [PATCH] gp_activate_standby() doesn't need to be callable from SQL. --- src/backend/access/transam/xlog.c | 2 +- src/backend/utils/gp/segadmin.c | 8 ++--- src/include/catalog/pg_proc.sql | 2 -- src/include/catalog/pg_proc_gp.h | 6 +--- src/include/utils/builtins.h | 2 +- .../storage/walrepl/run/segadmin/__init__.py | 0 .../walrepl/run/segadmin/ans/add_standby.ans | 4 --- .../walrepl/run/segadmin/sql/add_standby.sql | 6 ---- .../walrepl/run/segadmin/test_query.py | 30 ------------------- 9 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/__init__.py delete mode 100644 src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/ans/add_standby.ans delete mode 100644 src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/sql/add_standby.sql delete mode 100644 src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/test_query.py diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b3ee213f24..347fb6b7a9 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6558,7 +6558,7 @@ UpdateCatalogForStandbyPromotion(void) Gp_role = GP_ROLE_UTILITY; StartTransactionCommand(); GetTransactionSnapshot(); - DirectFunctionCall1(gp_activate_standby, (Datum) 0); + gp_activate_standby(); /* close the transaction we started above */ CommitTransactionCommand(); Gp_role = old_role; diff --git a/src/backend/utils/gp/segadmin.c b/src/backend/utils/gp/segadmin.c index aae8d73c12..68805cfeaa 100644 --- a/src/backend/utils/gp/segadmin.c +++ b/src/backend/utils/gp/segadmin.c @@ -850,8 +850,8 @@ catalog_activate_standby(int16 standbydbid, int16 olddbid) * Returns: * true upon success, otherwise throws error. */ -Datum -gp_activate_standby(PG_FUNCTION_ARGS) +bool +gp_activate_standby(void) { int16 olddbid = GpIdentity.dbid; int16 newdbid; @@ -872,7 +872,7 @@ gp_activate_standby(PG_FUNCTION_ARGS) * Job is already done, nothing needs to be done. We mostly crashed * after updating the catalogs. */ - PG_RETURN_BOOL(true); + return true; } mirroring_sanity_check(SUPERUSER | UTILITY_MODE | STANDBY_ONLY, @@ -888,7 +888,7 @@ gp_activate_standby(PG_FUNCTION_ARGS) primaryMirrorSetNewDbid(newdbid); /* done */ - PG_RETURN_BOOL(true); + return true; } Datum diff --git a/src/include/catalog/pg_proc.sql b/src/include/catalog/pg_proc.sql index 97a0b8eb60..92ff95ebcf 100644 --- a/src/include/catalog/pg_proc.sql +++ b/src/include/catalog/pg_proc.sql @@ -362,8 +362,6 @@ CREATE FUNCTION gp_remove_segment(int2) RETURNS bool LANGUAGE internal VOLATILE AS 'gp_remove_segment' WITH (OID=5051, DESCRIPTION="Remove a primary segment from the system catalog"); - CREATE FUNCTION gp_activate_standby() RETURNS bool LANGUAGE internal VOLATILE AS 'gp_activate_standby' WITH (OID=5053, DESCRIPTION="Activate a standby"); - CREATE FUNCTION gp_request_fts_probe_scan() RETURNS bool LANGUAGE internal VOLATILE AS 'gp_request_fts_probe_scan' EXECUTE ON MASTER WITH (OID=5035, DESCRIPTION="Request a FTS probe scan and wait for response"); diff --git a/src/include/catalog/pg_proc_gp.h b/src/include/catalog/pg_proc_gp.h index 750d3da55e..437d4fbc56 100644 --- a/src/include/catalog/pg_proc_gp.h +++ b/src/include/catalog/pg_proc_gp.h @@ -22,7 +22,7 @@ WARNING: DO NOT MODIFY THE FOLLOWING SECTION: Generated by catullus.pl version 8 - on Wed Jan 10 14:47:24 2018 + on Thu Jan 11 14:21:56 2018 Please make your changes in pg_proc.sql */ @@ -725,10 +725,6 @@ DESCR("Perform the catalog operations necessary for adding a new segment"); DATA(insert OID = 5051 ( gp_remove_segment PGNSP PGUID 12 1 0 0 f f f f f v 1 0 16 "21" _null_ _null_ _null_ _null_ gp_remove_segment _null_ _null_ _null_ n a )); DESCR("Remove a primary segment from the system catalog"); -/* gp_activate_standby() => bool */ -DATA(insert OID = 5053 ( gp_activate_standby PGNSP PGUID 12 1 0 0 f f f f f v 0 0 16 "" _null_ _null_ _null_ _null_ gp_activate_standby _null_ _null_ _null_ n a )); -DESCR("Activate a standby"); - /* gp_request_fts_probe_scan() => bool */ DATA(insert OID = 5035 ( gp_request_fts_probe_scan PGNSP PGUID 12 1 0 0 f f f f f v 0 0 16 "" _null_ _null_ _null_ _null_ gp_request_fts_probe_scan _null_ _null_ _null_ n m )); DESCR("Request a FTS probe scan and wait for response"); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index a86c29d1f3..2869cd5d16 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -1175,7 +1175,7 @@ extern Datum gp_deprecated(PG_FUNCTION_ARGS); extern Datum gp_add_master_standby_port(PG_FUNCTION_ARGS); extern Datum gp_add_master_standby(PG_FUNCTION_ARGS); extern Datum gp_remove_master_standby(PG_FUNCTION_ARGS); -extern Datum gp_activate_standby(PG_FUNCTION_ARGS); +extern bool gp_activate_standby(void); extern Datum gp_add_segment_primary(PG_FUNCTION_ARGS); extern Datum gp_add_segment_mirror(PG_FUNCTION_ARGS); diff --git a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/__init__.py b/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/ans/add_standby.ans b/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/ans/add_standby.ans deleted file mode 100644 index ab9d88d733..0000000000 --- a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/ans/add_standby.ans +++ /dev/null @@ -1,4 +0,0 @@ -set gp_role = utility; -SET -select gp_activate_standby(); -psql:/path/sql_file:1: ERROR: gp_activate_standby can only be run on the standby master (segadmin.c:303) diff --git a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/sql/add_standby.sql b/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/sql/add_standby.sql deleted file mode 100644 index bf9a37a486..0000000000 --- a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/sql/add_standby.sql +++ /dev/null @@ -1,6 +0,0 @@ --- start_ignore -SET gp_create_table_random_default_distribution=off; --- end_ignore -set gp_role = utility; - -select gp_activate_standby(); diff --git a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/test_query.py b/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/test_query.py deleted file mode 100644 index 9b637df4d1..0000000000 --- a/src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/run/segadmin/test_query.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Copyright (c) 2004-Present Pivotal Software, Inc. - -This program and the accompanying materials are made available under -the terms of the under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -""" - -from tinctest import logger -from mpp.lib.PSQL import PSQL -from mpp.models import SQLTestCase - -class Segadmin(SQLTestCase): - """ - @gucs gp_create_table_random_default_distribution=off - """ - - sql_dir = 'sql' - ans_dir = 'ans' - out_dir = 'output' - -- GitLab