Mercurial > hg > amuse
view base/database/implementations-setup.lisp @ 310:f99fd6a7bbfc
Add midi-db.
Ignore-this: c6f4fc32efa4453ddbdc478793eedd52
A basic implementation for working with MIDI files stored in the database.
It is a test case for `versioned' data, but only partially implemented at the moment.
darcs-hash:20100223152703-16a00-4388d2720907d777a1c6c6b3a010885ce0fe06a7.gz
author | j.forth <j.forth@gold.ac.uk> |
---|---|
date | Tue, 23 Feb 2010 15:27:03 +0000 |
parents | 2519652145c3 |
children | 6a3adca16910 |
line wrap: on
line source
(cl:in-package #:amuse-database-admin) (defun create-implementations-table (&optional (database *amuse-database*)) (%create-implementations-table database) (%create-implementation-stored-routines database)) (defun drop-implementations-table (&optional (database *amuse-database*)) (%drop-implementations-table database) (%drop-implementation-stored-routines database)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Helper functions (defun %create-implementations-table (database) #.(clsql:locally-enable-sql-reader-syntax) (clsql:create-table "amuse_implementations" '(([|implementation-id|] clsql:smallint :unsigned :not-null :auto-increment :primary-key) ([|implementation-name|] (varchar 255) :not-null :unique)) :database database :transactions t) #.(clsql:locally-disable-sql-reader-syntax)) (defun %drop-implementations-table (database) (clsql:drop-table "amuse_implementations" :if-does-not-exist :ignore :database database)) (defun %create-implementation-stored-routines (database) (%create-db-fun-get-impl-id database) (%create-db-fun-get-impl-name database)) (defun %drop-implementation-stored-routines (database) (%drop-db-fun-get-impl-id database) (%drop-db-fun-get-impl-name database)) (defun %create-db-fun-get-impl-id (database) (clsql:execute-command " CREATE FUNCTION get_impl_id ( impl_name VARCHAR(255)) RETURNS SMALLINT READS SQL DATA RETURN (SELECT implementation_id FROM amuse_implementations WHERE implementation_name = impl_name);" :database database)) (defun %drop-db-fun-get-impl-id (database) (clsql:execute-command " DROP FUNCTION get_impl_id" :database database)) (defun %create-db-fun-get-impl-name (database) (clsql:execute-command " CREATE FUNCTION get_impl_name ( impl_id SMALLINT) RETURNS VARCHAR(255) READS SQL DATA RETURN (SELECT implementation_name FROM amuse_implementations WHERE implementation_id = impl_id);" :database database)) (defun %drop-db-fun-get-impl-name (database) (clsql:execute-command " DROP FUNCTION get_impl_name" :database database))