【问题标题】:How can I drop a Postgres-XL database that has its name starting with a digit?如何删除名称以数字开头的 Postgres-XL 数据库?
【发布时间】:2016-09-01 17:30:34
【问题描述】:

我是 Postgres-XL 的新手,我刚刚创建了一个测试集群,运行 postgres-xl-9.5r1.3。

它设置在三个节点上,一个节点 GTM,两个节点上都有一个 Coordinator 和一个 Datanode。

我正计划在这两个节点之间进行负载平衡,但目前我只是在第一个协调器上连接和运行 SQL 查询。

在测试一些基本命令时,我创建了一些测试数据库,其中一个具有全数字名称“213”,另一个具有以数字开头的名称“123test”。当尝试删除其中任何一个时,我得到一个语法错误:

postgres=# DROP DATABASE "213";
ERROR:  syntax error at or near "213"

postgres=# drop database 123test;
ERROR:  syntax error at or near "123"
LINE 1: drop database 123test;

postgres=# drop database "123test";
ERROR:  syntax error at or near "123"

删除名称以字母开头的数据库就可以了。

有人知道如何删除这些数据库吗?我做错了什么,还是 Postgres-XL 有问题?

【问题讨论】:

  • 似乎是 Postgres-XL 的问题,因为使用“普通”Postgres 可以正常工作

标签: postgres-xl


【解决方案1】:

我已经通过他们的错误报告邮件列表联系了 Postgres-XL 团队,这似乎是与在向远程节点发送命令时如何引用数据库名称有关的错误。

Postgres-XL 团队提供的以下补丁应该可以解决这个问题:

diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index cc8e06e..b73be0a 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -807,7 +807,8 @@ standard_ProcessUtility(Node *parsetree,
                    DropDBCleanConnection(stmt->dbname);

                    /* Clean also remote Coordinators */
-                   sprintf(query, "CLEAN CONNECTION TO ALL FOR DATABASE %s;", stmt->dbname);
+                   sprintf(query, "CLEAN CONNECTION TO ALL FOR DATABASE %s;",
+                           quote_identifier(stmt->dbname));

                    ExecUtilityStmtOnNodes(query, NULL, sentToRemote, true, EXEC_ON_ALL_NODES, false);
                }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 2014-11-02
    • 2016-03-17
    • 2014-03-29
    • 2022-11-23
    • 1970-01-01
    相关资源
    最近更新 更多