diff --git a/src/pgsql/pgsql-ddl.lisp b/src/pgsql/pgsql-ddl.lisp index 9faeb64..4e087b4 100644 --- a/src/pgsql/pgsql-ddl.lisp +++ b/src/pgsql/pgsql-ddl.lisp @@ -198,15 +198,19 @@ ;; here always quote the constraint name, currently the name ;; comes from one source only, the PostgreSQL database catalogs, ;; so don't question it, quote it. + ;; + ;; The constraint name could begin with numbers of follow other + ;; force-quoting PostgreSQL rules, so we really quote it (using + ;; ~s here). (format stream - "ALTER TABLE ~a DROP CONSTRAINT~:[~; IF EXISTS~] ~a~@[ CASCADE~];" + "ALTER TABLE ~a DROP CONSTRAINT~:[~; IF EXISTS~] ~s~@[ CASCADE~];" (format-table-name (index-table index)) if-exists (index-conname index) cascade)) (t - (format stream "DROP INDEX~:[~; IF EXISTS~] ~@[~a.~]~a~@[ CASCADE~];" + (format stream "DROP INDEX~:[~; IF EXISTS~] ~@[~s.~]~s~@[ CASCADE~];" if-exists schema-name index-name cascade)))))