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@251
|
13
|
j@251
|
14 ;;;=====================================================================
|
j@216
|
15 ;;; Helper functions
|
j@251
|
16 ;;;=====================================================================
|
j@216
|
17
|
j@216
|
18 (defun %create-implementations-table (database)
|
j@216
|
19 #.(clsql:locally-enable-sql-reader-syntax)
|
j@216
|
20 (clsql:create-table "amuse_implementations"
|
j@216
|
21 '(([|implementation-id|] clsql:smallint :unsigned
|
j@216
|
22 :not-null :auto-increment :primary-key)
|
j@216
|
23 ([|implementation-name|] (varchar 255)
|
j@216
|
24 :not-null :unique))
|
j@216
|
25 :database database
|
j@216
|
26 :transactions t)
|
j@216
|
27 #.(clsql:locally-disable-sql-reader-syntax))
|
j@216
|
28
|
j@216
|
29 (defun %drop-implementations-table (database)
|
j@216
|
30 (clsql:drop-table "amuse_implementations"
|
j@216
|
31 :if-does-not-exist :ignore
|
j@216
|
32 :database database))
|
j@216
|
33
|
j@216
|
34 (defun %create-implementation-stored-routines (database)
|
j@216
|
35 (%create-db-fun-get-impl-id database)
|
j@216
|
36 (%create-db-fun-get-impl-name database))
|
j@216
|
37
|
j@216
|
38 (defun %drop-implementation-stored-routines (database)
|
j@216
|
39 (%drop-db-fun-get-impl-id database)
|
j@216
|
40 (%drop-db-fun-get-impl-name database))
|
j@216
|
41
|
j@216
|
42 (defun %create-db-fun-get-impl-id (database)
|
j@216
|
43 (clsql:execute-command "
|
j@216
|
44 CREATE FUNCTION get_impl_id (
|
j@216
|
45 impl_name VARCHAR(255))
|
j@216
|
46 RETURNS SMALLINT
|
j@218
|
47 READS SQL DATA
|
j@216
|
48 RETURN (SELECT implementation_id
|
j@216
|
49 FROM amuse_implementations
|
j@216
|
50 WHERE implementation_name = impl_name);"
|
j@216
|
51 :database database))
|
j@216
|
52
|
j@216
|
53 (defun %drop-db-fun-get-impl-id (database)
|
j@216
|
54 (clsql:execute-command "
|
j@216
|
55 DROP FUNCTION get_impl_id"
|
j@216
|
56 :database database))
|
j@216
|
57
|
j@216
|
58 (defun %create-db-fun-get-impl-name (database)
|
j@216
|
59 (clsql:execute-command "
|
j@216
|
60 CREATE FUNCTION get_impl_name (
|
j@216
|
61 impl_id SMALLINT)
|
j@216
|
62 RETURNS VARCHAR(255)
|
j@218
|
63 READS SQL DATA
|
j@216
|
64 RETURN (SELECT implementation_name
|
j@216
|
65 FROM amuse_implementations
|
j@216
|
66 WHERE implementation_id = impl_id);"
|
j@216
|
67 :database database))
|
j@216
|
68
|
j@216
|
69 (defun %drop-db-fun-get-impl-name (database)
|
j@216
|
70 (clsql:execute-command "
|
j@216
|
71 DROP FUNCTION get_impl_name"
|
j@216
|
72 :database database))
|