From 7c146c46b9b2854c4951dbfeecfecc1064c9a35a Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sat, 16 Feb 2019 15:48:46 +0100 Subject: [PATCH] Citus support small bug fixes. When calling the create_distributed_table() function, the column name is given as a literal parameter to the function and should be quoted that way, with single quotes. In particular, if our column-name is already double-quoted, we need to get rid of those extra quotes. Also, the source-table-name might be a cons object when qualified, or a plain string when not schema-qualified. Adjust the citus-find-table code to take that into account. --- src/pgsql/pgsql-ddl-citus.lisp | 2 +- src/utils/citus.lisp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pgsql/pgsql-ddl-citus.lisp b/src/pgsql/pgsql-ddl-citus.lisp index 2fe2028..7239fdf 100644 --- a/src/pgsql/pgsql-ddl-citus.lisp +++ b/src/pgsql/pgsql-ddl-citus.lisp @@ -17,4 +17,4 @@ (rule-col-name (column-name (citus-distributed-rule-using rule)))) (format stream "SELECT create_distributed_table('~a', '~a');" (format-table-name rule-table) - (apply-identifier-case rule-col-name)))) + (ensure-unquoted rule-col-name)))) diff --git a/src/utils/citus.lisp b/src/utils/citus.lisp index 541e6e2..b846cdb 100644 --- a/src/utils/citus.lisp +++ b/src/utils/citus.lisp @@ -70,7 +70,10 @@ table-name schema-name)))))) (defun citus-find-table (catalog table) - (let* ((table-name (cdr (table-source-name table))) + (let* ((source-name (table-source-name table)) + (table-name (etypecase source-name + (string source-name) + (cons (cdr source-name)))) (schema-name (schema-name (table-schema table)))) (or (find-table (find-schema catalog schema-name) table-name) (error (make-condition 'citus-rule-table-not-found