postgres-xl

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


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?


Solution

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