How can I drop a Postgres-XL database that has its name starting with a digit?

雨燕双飞 提交于 2019-12-12 03:51:11

问题


I am really new to Postgres-XL, and I have just created a testing cluster, running postgres-xl-9.5r1.3.

It's set-up on three nodes, one node GTM, and two with both a Coordinator and a Datanode on each.

I am planning on load balancing between these two nodes, but at the moment I am just connecting and running SQL queries on the first coordinator.

While testing some basic commands, I created a a few testing databases, one of which has a fully numeric name, "213", and one with a name that starts with a digit, "123test". When trying to drop either of these, I get a syntax error:

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"

Dropping a database that has a name which starts with a letter works just fine.

Would anyone know how to go about and delete these databases? Am I doing something wrong, or is this an issue with Postgres-XL?


回答1:


I have reached out to the Postgres-XL team via their bug reporting mailing list, and it seems this is a bug related to how database names are quoted while sending down commands to the remote node.

The following patch, as supplied by the Postgres-XL team, should fix this:

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);
                }


来源:https://stackoverflow.com/questions/39143887/how-can-i-drop-a-postgres-xl-database-that-has-its-name-starting-with-a-digit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!