[postmodern-devel] IF-EXISTS operator for DROP-* ops

Daniel White daniel at whitehouse.id.au
Thu May 28 12:44:20 UTC 2009


I'm wanting to use the IF EXISTS modifier for the various DROP
operations, and it seems like the semantics of CASCADE works best for
this case.

The following is a proof of concept implementation.  If there aren't
any issues or complaints I'll write a patch that covers the rest of
the DROP operations.

(defvar *expand-if-exists* nil)

(defun expand-if-exists ()
  (when *expand-if-exists*
    `("IF EXISTS ")))

(def-sql-op :if-exists (op)
  (let ((*expand-if-exists* t))
    (sql-expand op)))

(def-sql-op :drop-sequence (name)
  `("DROP SEQUENCE " ,@(expand-if-exists) ,@(sql-expand name)))

(sql (:if-exists (:drop-sequence 'sequence)))

Cheers,
-- 
Daniel White




More information about the postmodern-devel mailing list