annotate base/database/implementations-setup.lisp @ 218:385935631532

Add function assigning a list of composition identifiers to a dataset. Ignore-this: aa2078c1427801491a54d23ffca7da70 darcs-hash:20090716170022-16a00-d95599a9631d18530c0d0d51ef095133f9bbde5a.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents e1842efb1dd4
children 6a3adca16910
rev   line source
j@216 1 (cl:in-package #:amuse-database-admin)
j@216 2
j@216 3 (defun create-implementations-table (&optional
j@216 4 (database *amuse-database*))
j@216 5 (%create-implementations-table database)
j@216 6 (%create-implementation-stored-routines database))
j@216 7
j@216 8 (defun drop-implementations-table (&optional
j@216 9 (database *amuse-database*))
j@216 10 (%drop-implementations-table database)
j@216 11 (%drop-implementation-stored-routines database))
j@216 12
j@216 13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@216 14 ;;; Helper functions
j@216 15
j@216 16 (defun %create-implementations-table (database)
j@216 17 #.(clsql:locally-enable-sql-reader-syntax)
j@216 18 (clsql:create-table "amuse_implementations"
j@216 19 '(([|implementation-id|] clsql:smallint :unsigned
j@216 20 :not-null :auto-increment :primary-key)
j@216 21 ([|implementation-name|] (varchar 255)
j@216 22 :not-null :unique))
j@216 23 :database database
j@216 24 :transactions t)
j@216 25 #.(clsql:locally-disable-sql-reader-syntax))
j@216 26
j@216 27 (defun %drop-implementations-table (database)
j@216 28 (clsql:drop-table "amuse_implementations"
j@216 29 :if-does-not-exist :ignore
j@216 30 :database database))
j@216 31
j@216 32 (defun %create-implementation-stored-routines (database)
j@216 33 (%create-db-fun-get-impl-id database)
j@216 34 (%create-db-fun-get-impl-name database))
j@216 35
j@216 36 (defun %drop-implementation-stored-routines (database)
j@216 37 (%drop-db-fun-get-impl-id database)
j@216 38 (%drop-db-fun-get-impl-name database))
j@216 39
j@216 40 (defun %create-db-fun-get-impl-id (database)
j@216 41 (clsql:execute-command "
j@216 42 CREATE FUNCTION get_impl_id (
j@216 43 impl_name VARCHAR(255))
j@216 44 RETURNS SMALLINT
j@218 45 READS SQL DATA
j@216 46 RETURN (SELECT implementation_id
j@216 47 FROM amuse_implementations
j@216 48 WHERE implementation_name = impl_name);"
j@216 49 :database database))
j@216 50
j@216 51 (defun %drop-db-fun-get-impl-id (database)
j@216 52 (clsql:execute-command "
j@216 53 DROP FUNCTION get_impl_id"
j@216 54 :database database))
j@216 55
j@216 56 (defun %create-db-fun-get-impl-name (database)
j@216 57 (clsql:execute-command "
j@216 58 CREATE FUNCTION get_impl_name (
j@216 59 impl_id SMALLINT)
j@216 60 RETURNS VARCHAR(255)
j@218 61 READS SQL DATA
j@216 62 RETURN (SELECT implementation_name
j@216 63 FROM amuse_implementations
j@216 64 WHERE implementation_id = impl_id);"
j@216 65 :database database))
j@216 66
j@216 67 (defun %drop-db-fun-get-impl-name (database)
j@216 68 (clsql:execute-command "
j@216 69 DROP FUNCTION get_impl_name"
j@216 70 :database database))