annotate base/database/implementations-setup.lisp @ 288:d1e5bbcc5ea4

Rationalise base and geerdes classes, constructors and methods. Ignore-this: d9d4d88566a6d110844d91d4c70513cd Towards a more standardised interface. Some of these changes (generalised constructors and reader functions) are necessary for amuse-database-admin functionality and some other CHARM-like things. darcs-hash:20090716154406-16a00-8a9b4fb1fc1f5ba75af66a1bbd87e1bb68e02493.gz
author j.forth <j.forth@gold.ac.uk>
date Thu, 16 Jul 2009 16:44:06 +0100
parents 00d35eb70ef9
children 385935631532
rev   line source
j@287 1 (cl:in-package #:amuse-database-admin)
j@287 2
j@287 3 (defun create-implementations-table (&optional
j@287 4 (database *amuse-database*))
j@287 5 (%create-implementations-table database)
j@287 6 (%create-implementation-stored-routines database))
j@287 7
j@287 8 (defun drop-implementations-table (&optional
j@287 9 (database *amuse-database*))
j@287 10 (%drop-implementations-table database)
j@287 11 (%drop-implementation-stored-routines database))
j@287 12
j@287 13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@287 14 ;;; Helper functions
j@287 15
j@287 16 (defun %create-implementations-table (database)
j@287 17 #.(clsql:locally-enable-sql-reader-syntax)
j@287 18 (clsql:create-table "amuse_implementations"
j@287 19 '(([|implementation-id|] clsql:smallint :unsigned
j@287 20 :not-null :auto-increment :primary-key)
j@287 21 ([|implementation-name|] (varchar 255)
j@287 22 :not-null :unique))
j@287 23 :database database
j@287 24 :transactions t)
j@287 25 #.(clsql:locally-disable-sql-reader-syntax))
j@287 26
j@287 27 (defun %drop-implementations-table (database)
j@287 28 (clsql:drop-table "amuse_implementations"
j@287 29 :if-does-not-exist :ignore
j@287 30 :database database))
j@287 31
j@287 32 (defun %create-implementation-stored-routines (database)
j@287 33 (%create-db-fun-get-impl-id database)
j@287 34 (%create-db-fun-get-impl-name database))
j@287 35
j@287 36 (defun %drop-implementation-stored-routines (database)
j@287 37 (%drop-db-fun-get-impl-id database)
j@287 38 (%drop-db-fun-get-impl-name database))
j@287 39
j@287 40 (defun %create-db-fun-get-impl-id (database)
j@287 41 (clsql:execute-command "
j@287 42 CREATE FUNCTION get_impl_id (
j@287 43 impl_name VARCHAR(255))
j@287 44 RETURNS SMALLINT
j@287 45 RETURN (SELECT implementation_id
j@287 46 FROM amuse_implementations
j@287 47 WHERE implementation_name = impl_name);"
j@287 48 :database database))
j@287 49
j@287 50 (defun %drop-db-fun-get-impl-id (database)
j@287 51 (clsql:execute-command "
j@287 52 DROP FUNCTION get_impl_id"
j@287 53 :database database))
j@287 54
j@287 55 (defun %create-db-fun-get-impl-name (database)
j@287 56 (clsql:execute-command "
j@287 57 CREATE FUNCTION get_impl_name (
j@287 58 impl_id SMALLINT)
j@287 59 RETURNS VARCHAR(255)
j@287 60 RETURN (SELECT implementation_name
j@287 61 FROM amuse_implementations
j@287 62 WHERE implementation_id = impl_id);"
j@287 63 :database database))
j@287 64
j@287 65 (defun %drop-db-fun-get-impl-name (database)
j@287 66 (clsql:execute-command "
j@287 67 DROP FUNCTION get_impl_name"
j@287 68 :database database))