Remove gsql SSH command and program

ReviewDb is gone, hence gsql is no longer needed.

Change-Id: I580b9ec9943fdedac4814d3f66c030ba4534fc30
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2018-12-10 11:48:42 +01:00 committed by Dave Borowitz
parent fd94230090
commit 0f595f671d
12 changed files with 2 additions and 252 deletions

View File

@ -1204,8 +1204,7 @@ Below you find a list of capabilities available:
[[capability_accessDatabase]]
=== Access Database
Allow users to access the database using the `gsql` command, and view code
review metadata refs in repositories.
Allow users to view code review metadata refs in repositories.
[[capability_administrateServer]]

View File

@ -1,64 +0,0 @@
= gerrit gsql
== NAME
gerrit gsql - Administrative interface to active database.
== SYNOPSIS
[verse]
--
_ssh_ -p <port> <host> _gerrit gsql_
[--format {PRETTY | JSON | JSON_SINGLE}]
[-c QUERY]
--
== DESCRIPTION
Provides interactive query support directly against the underlying
SQL database used by the host Gerrit server. All SQL statements
are supported, including SELECT, UPDATE, INSERT, DELETE and ALTER.
== OPTIONS
--format::
Set the format records are output in. In PRETTY (the
default) records are displayed in a tabular output suitable
for reading by a human on a sufficiently wide terminal.
In JSON mode records are output as JSON objects using the
column names as the property names, one object per line.
In JSON_SINGLE mode the whole result set is output as a
single JSON object.
-c::
Execute the single query statement supplied, and then exit.
== ACCESS
Caller must have been granted the
link:access-control.html#capability_accessDatabase[Access Database]
global capability.
== SCRIPTING
Intended for interactive use only, unless format is JSON, or
JSON_SINGLE.
== EXAMPLES
To manually correct a user's SSH user name:
----
$ ssh -p 29418 review.example.com gerrit gsql
Welcome to Gerrit Code Review v2.0.25
(PostgreSQL 8.3.8)
Type '\h' for help. Type '\r' to clear the buffer.
gerrit> update accounts set ssh_user_name = 'alice' where account_id=1;
UPDATE 1; 1 ms
gerrit> \q
Bye
$ ssh -p 29418 review.example.com gerrit flush-caches --cache sshkeys --cache accounts
----
GERRIT
------
Part of link:index.html[Gerrit Code Review]
SEARCHBOX
---------

View File

@ -130,9 +130,6 @@ link:cmd-flush-caches.html[gerrit flush-caches]::
link:cmd-gc.html[gerrit gc]::
Run the Git garbage collection.
link:cmd-gsql.html[gerrit gsql]::
Administrative interface to active database.
link:cmd-index-activate.html[gerrit index activate]::
Activate the latest index version available.

View File

@ -187,27 +187,6 @@ interfaces (including HTTP and SSH) are available.
CAUTION: When using the Inspector, be careful not to modify the internal state
of the system.
=== Querying the database
The embedded H2 database can be queried and updated from the command line. If
the daemon is not running, run:
----
$(bazel info output_base)/external/local_jdk/bin/java \
-jar bazel-bin/gerrit.war gsql -d ../gerrit_testsite -s
----
NOTE: To learn why using `java -jar` isn't sufficient, see
<<special_bazel_java_version,this explanation>>.
Alternatively, if the daemon is running and the database is in use, use an
administrator user account to connect over SSH:
----
ssh -p 29418 user@localhost gerrit gsql
----
== Switching between branches
When using `git checkout` without `--recurse-submodules` to switch between

View File

@ -1,55 +0,0 @@
= gsql
== NAME
gsql - Administrative interface to idle database
== SYNOPSIS
[verse]
--
_java_ -jar gerrit.war _gsql_
-d <SITE_PATH>
--
== DESCRIPTION
Interactive query support against the configured SQL database.
All SQL statements are supported, including SELECT, UPDATE, INSERT,
DELETE and ALTER.
This command is primarily intended to access a local H2 database
which is not currently open by a Gerrit daemon. To access an open
database use link:cmd-gsql.html[gerrit gsql] over SSH.
== OPTIONS
-d::
--site-path::
Location of the gerrit.config file, and all other per-site
configuration data, supporting libraries and log files.
== CONTEXT
This command can only be run on a server which has direct
connectivity to the metadata database, and local access to the
managed Git repositories.
== EXAMPLES
To manually correct a user's SSH user name:
----
$ java -jar gerrit.war gsql
Welcome to Gerrit Code Review v2.0.25
(PostgreSQL 8.3.8)
Type '\h' for help. Type '\r' to clear the buffer.
gerrit> update accounts set ssh_user_name = 'alice' where account_id=1;
UPDATE 1; 1 ms
gerrit> \q
Bye
----
GERRIT
------
Part of link:index.html[Gerrit Code Review]
SEARCHBOX
---------

View File

@ -15,9 +15,6 @@ link:pgm-init.html[init]::
link:pgm-daemon.html[daemon]::
Gerrit HTTP, SSH network server.
link:pgm-gsql.html[gsql]::
Administrative interface to idle database.
link:pgm-prolog-shell.html[prolog-shell]::
Simple interactive Prolog interpreter.

View File

@ -22,7 +22,7 @@ import java.util.List;
/** Server wide capabilities. Represented as {@link Permission} objects. */
public class GlobalCapability {
/** Ability to access the database (with gsql). */
/** Ability to view code review metadata refs in repositories. */
public static final String ACCESS_DATABASE = "accessDatabase";
/**

View File

@ -94,7 +94,6 @@ public final class GerritLauncher {
System.err.println(" init Initialize a Gerrit installation");
System.err.println(" reindex Rebuild the secondary index");
System.err.println(" daemon Run the Gerrit network daemons");
System.err.println(" gsql Run the interactive query console");
System.err.println(" version Display the build version number");
System.err.println(" passwd Set or change password in secure.config");

View File

@ -1,34 +0,0 @@
// Copyright (C) 2009 The Android Open Source Project
//
// Licensed 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.
package com.google.gerrit.pgm;
import com.google.gerrit.pgm.util.SiteProgram;
import com.google.gerrit.sshd.commands.QueryShell;
import org.kohsuke.args4j.Option;
/** Run Gerrit's SQL query tool */
// TODO(dborowitz): Delete this program.
public class Gsql extends SiteProgram {
@Option(name = "--format", usage = "Set output format")
private QueryShell.OutputFormat format = QueryShell.OutputFormat.PRETTY;
@Option(name = "-c", metaVar = "SQL QUERY", usage = "Query to execute")
private String query;
@Override
public int run() throws Exception {
throw die("SQL not supported; ReviewDb no longer exists");
}
}

View File

@ -1,61 +0,0 @@
// Copyright (C) 2009 The Android Open Source Project
//
// Licensed 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.
package com.google.gerrit.sshd.commands;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.sshd.AdminHighPriorityCommand;
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
import com.google.inject.Inject;
import org.kohsuke.args4j.Option;
/** Opens a query processor. */
@AdminHighPriorityCommand
@RequiresCapability(GlobalCapability.ACCESS_DATABASE)
@CommandMetaData(name = "gsql", description = "Administrative interface to active database")
final class AdminQueryShell extends SshCommand {
@Inject private PermissionBackend permissionBackend;
@Inject private QueryShell.Factory factory;
@Option(name = "--format", usage = "Set output format")
private QueryShell.OutputFormat format = QueryShell.OutputFormat.PRETTY;
@Option(name = "-c", metaVar = "SQL QUERY", usage = "Query to execute")
private String query;
@Override
protected void run() throws Failure {
try {
permissionBackend.currentUser().check(GlobalPermission.ACCESS_DATABASE);
} catch (AuthException err) {
throw die(err.getMessage());
} catch (PermissionBackendException e) {
throw new Failure(1, "unavailable", e);
}
QueryShell shell = factory.create(in, out);
shell.setOutputFormat(format);
if (query != null) {
shell.execute(query);
} else {
shell.run();
}
}
}

View File

@ -90,7 +90,6 @@ public class DefaultCommandModule extends CommandModule {
command(gerrit, CreateGroupCommand.class);
command(gerrit, CreateProjectCommand.class);
command(gerrit, SetHeadCommand.class);
command(gerrit, AdminQueryShell.class);
if (slaveMode) {
command("git-receive-pack").to(ReceiveSlaveMode.class);

View File

@ -17,7 +17,6 @@ package com.google.gerrit.acceptance.ssh;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -27,7 +26,6 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.Sandboxed;
import com.google.gerrit.acceptance.UseSsh;
import com.google.gerrit.common.data.GlobalCapability;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -64,7 +62,6 @@ public class SshCommandsIT extends AbstractDaemonTest {
"create-branch",
"create-group",
"create-project",
"gsql",
"index",
"query",
"receive-pack",
@ -113,9 +110,6 @@ public class SshCommandsIT extends AbstractDaemonTest {
@Test
@Sandboxed
public void sshCommandCanBeExecuted() throws Exception {
// Access Database capability is required to run the "gerrit gsql" command
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
testCommandExecution(MASTER_COMMANDS);
restartAsSlave();