forked from marijnh/Postmodern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostmodern.html
5580 lines (5053 loc) · 249 KB
/
postmodern.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<!-- 2021-04-23 Fri 10:09 -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Postmodern Reference Manual</title>
<meta name="generator" content="Org mode">
<meta name="author" content="Sabra Crolleton">
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { width: 90%; }
/*]]>*/-->
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
<style>pre.src{background:#343131;color:white;} </style>
<script type="text/javascript">
// @license magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt Public Domain
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.add("code-highlighted");
target.classList.add("code-highlighted");
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.classList.remove("code-highlighted");
target.classList.remove("code-highlighted");
}
}
/*]]>*///-->
// @license-end
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="content">
<header>
<h1 class="title">Postmodern Reference Manual</h1>
</header><nav id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#connecting">Connecting</a>
<ul>
<li><a href="#dfc95b36-94d7-42ab-827b-8622f593e7f6">class database-connection</a></li>
<li><a href="#d4aa3e04-ab90-4271-b3e7-60a48e4f2e49">function connect (database user-name password host &key (port 5432) pooled-p use-ssl service application-name)</a></li>
<li><a href="#e140fab3-b6fe-4e88-b9ca-241bbb64fce4">variable <code>*default-use-ssl*</code></a></li>
<li><a href="#9a1a03af-a67e-4419-9066-d79a81885f81">method disconnect (database-connection)</a></li>
<li><a href="#a660d0cc-4795-41df-b183-0ea31f6b6584">function connected-p (database-connection)</a></li>
<li><a href="#426a8f5d-5dc7-4973-a1fc-11b488afcd82">method reconnect (database-connection)</a></li>
<li><a href="#9b9cf868-214b-4026-8f80-25b23f445c91">variable <code>*database*</code></a></li>
<li><a href="#056d4921-c834-4655-a487-83314f22da42">macro with-connection (spec &body body)</a></li>
<li><a href="#0e0c03e9-7681-433f-ae75-8f06c9685221">macro call-with-connection (spec thunk)</a></li>
<li><a href="#a74be5d0-9b86-4c15-b738-76cd92908d25">function connect-toplevel (database user-name password host &key (port 5432))</a></li>
<li><a href="#a63f929c-805d-42d5-8fbe-f1c01e62b50a">function disconnect-toplevel ()</a></li>
<li><a href="#56c370e4-8f4e-414a-82b6-ae4408fc0b61">function clear-connection-pool ()</a></li>
<li><a href="#97aa1ebb-ef91-4254-a6b7-bfcd8128ad96">variable <code>*max-pool-size*</code></a></li>
<li><a href="#09583f9a-388a-400a-bb3c-d118242508c8">function list-connections ()</a></li>
</ul>
</li>
<li><a href="#querying">Querying</a>
<ul>
<li><a href="#5a8c24fb-6d7b-4952-8520-b5e8ea98dd77">macro query (query &rest args/format)</a></li>
<li><a href="#71106869-4169-49c8-ba7d-ce6b9fc7d780">macro execute (query &rest args)</a></li>
<li><a href="#66aa9f57-ac8a-4457-9891-3453682518e0">macro doquery (query (&rest names) &body body)</a></li>
<li><a href="#625b6ade-7b09-49dc-b288-78c550b25d83">macro prepare (query &optional (format :rows))</a></li>
<li><a href="#b2ed5fb5-d5f5-4425-b30e-5c40a2997eee">macro defprepared (name query &optional (format :rows))</a></li>
<li><a href="#73823e7b-1fc5-40b2-908f-cec99ac1bc9e">macro defprepared-with-names (name (&rest args) (query &rest query-args) &optional (format :rows))</a></li>
<li><a href="#453612e6-2835-41b2-8305-01b6b5473138">macro with-transaction ((&optional name isolation-level) &body body)</a></li>
<li><a href="#10b5d3e9-b174-4f02-8c47-6eb3430e60fe">function commit-transaction (transaction)</a></li>
<li><a href="#58a7459f-a1f4-4797-83b5-8b5257ca2cf7">function abort-transaction (transaction)</a></li>
<li><a href="#orga83cda7">function rollback-transaction (transaction)</a></li>
<li><a href="#5899097b-a5fb-4b7a-961b-3c65a95f81d4">macro with-savepoint (name &body body)</a></li>
<li><a href="#a6d99838-ed98-4839-ac13-c03ecbfd6f96">function release-savepoint (savepoint)</a></li>
<li><a href="#1f84633f-e567-42c6-bcfc-2167dad89165">function rollback-savepoint (savepoint)</a></li>
<li><a href="#919494ae-625f-4f63-b271-6cc5d0b16549">method commit-hooks (transaction-or-savepoint), setf (commit-hooks transaction-or-savepoint)</a></li>
<li><a href="#94700fa6-1f29-4c0f-86ad-487e640933b9">function abort-hooks (transaction-or-savepoint), setf (abort-hooks transaction-or-savepoint)</a></li>
<li><a href="#44dac415-f1b2-4f01-bb05-a31c6c977b4c">variable <code>*isolation-level*</code></a></li>
<li><a href="#5fdcafe3-5da4-48ee-8bb0-8567c7e00837">macro with-logical-transaction ((&optional name isolation-level) &body body)</a></li>
<li><a href="#7d237c64-5c3e-44a6-8b7c-6eecc4379b71">function abort-logical-transaction (transaction-or-savepoint)</a></li>
<li><a href="#ae0f0c99-0bda-491e-99a5-3a61e0a86166">function commit-logical-transaction (transaction-or-savepoint)</a></li>
<li><a href="#bf78478f-92a2-4162-963d-b4e101b23154">variable <code>*current-logical-transaction*</code></a></li>
<li><a href="#6ad767b2-75b7-48ee-a260-6caece5bad62">macro ensure-transaction (&body body)</a></li>
<li><a href="#9ca2ed2b-60ea-4e34-b370-a4f54c1f1dcd">macro ensure-transaction-with-isolation-level (isolation-level &body body)</a></li>
</ul>
</li>
<li><a href="#prepared-statement-helper-functions">Helper functions for Prepared Statements</a>
<ul>
<li><a href="#533331a5-6780-41bd-9ae8-2efac3a3c2c2">defparameter <b>allow-overwriting-prepared-statements</b></a></li>
<li><a href="#7ca58f04-2ad5-4896-b8c2-b13b276b4f5b">function prepared-statement-exists-p (name)</a></li>
<li><a href="#3788ef72-d6a7-4e3b-acad-3f2608914dfb">function list-prepared-statements (&optional (names-only nil))</a></li>
<li><a href="#7ec6297f-85a7-419e-a9d4-8f6e2ceb9559">function drop-prepared-statement (statement-name &key (location :both) (database <code>*database*</code>))</a></li>
<li><a href="#b6049a3a-55a2-44be-9dc0-1af2849e2128">function list-postmodern-prepared-statements (&optional (names-only nil))</a></li>
<li><a href="#06ea4b19-3d57-4f08-b92d-d477bf61c456">function find-postgresql-prepared-statement (name)</a></li>
<li><a href="#b728be40-afaf-45d3-849c-3b7e27b3b0c1">function find-postmodern-prepared-statement (name)</a></li>
<li><a href="#967c2e66-3ec9-4e07-9de9-1a06d758ac27">function reset-prepared-statement (condition)</a></li>
<li><a href="#a172b4cb-826f-4bcf-9c50-70676bb7599a">function get-pid ()</a></li>
<li><a href="#b0afcff9-dfa9-466a-a3a2-06b189eac23a">function get-pid-from-postmodern ()</a></li>
<li><a href="#10b17274-a4d8-4805-adbe-b7386fe28cfb">function cancel-backend (pid)</a></li>
<li><a href="#203185f5-030c-48e7-8767-e765ac96f8cb">function terminate-backend (pid)</a></li>
</ul>
</li>
<li><a href="#database-management">Database Management</a>
<ul>
<li><a href="#c3da07c5-73e2-407c-a4cf-155b3ae416b2">function create-database (database-name &key (encoding "UTF8") (connection-limit -1) owner limit-public-access comment collation template)</a></li>
<li><a href="#database-management">function drop-database (database)</a></li>
</ul>
</li>
<li><a href="#daos">Database access objects</a>
<ul>
<li><a href="#d1d4b5c3-8c21-478e-8ac1-404e4ffdbec5">metaclass dao-class</a></li>
<li><a href="#9027b960-0a1a-4b64-a621-d1d4ab2906f0">Out of Sync Dao Objects</a></li>
<li><a href="#b12ed2b8-fc3f-4d3a-ba2a-3c9484d770dc">method dao-keys (class)</a></li>
<li><a href="#34196ad8-c657-4fd0-a475-e2f0b81ff86c">method dao-keys (dao)</a></li>
<li><a href="#orgb67a65a">method find-primary-key-column</a></li>
<li><a href="#d5835157-a4ba-4bf0-abbd-214b5a90bc80">method dao-exists-p (dao)</a></li>
<li><a href="#24bce212-b7c3-4526-a869-92c0218f187d">method make-dao (type &rest args &key &allow-other-keys)</a></li>
<li><a href="#orge539b94">method fetch-defaults (dao)</a></li>
<li><a href="#orgd986f5f">method find-primary-key-column (class)</a></li>
<li><a href="#f7351c36-cb79-43a2-8a5b-5f8aac8ea2d9">macro define-dao-finalization (((dao-name class) &rest keyword-args) &body body)</a></li>
<li><a href="#73e62fab-5bfa-4986-b8c4-992e4d0a134b">method get-dao (type &rest keys)</a></li>
<li><a href="#cd11fa85-5019-4b94-a24c-d0857d633bd2">macro select-dao (type &optional (test t) &rest sort)</a></li>
<li><a href="#6273d302-4199-44a0-aa18-3d8f91affd84">macro do-select-dao (((type type-var) &optional (test t) &rest sort) &body body)</a></li>
<li><a href="#6e5766fb-14dd-4f1e-a68a-fd14d781ac9e">macro query-dao (type query &rest args)</a></li>
<li><a href="#702edc9e-ef43-4df1-9e99-dac6047bdecc">function do-query-dao (((type type-var) query &rest args) &body body)</a></li>
<li><a href="#4a1219dc-d0bc-4fb7-81c9-cb734cb051cc">variable <code>*ignore-unknown-columns*</code></a></li>
<li><a href="#4a83ef48-a40a-423c-a97c-3d6743ce940c">method insert-dao (dao)</a></li>
<li><a href="#08306ea2-4027-40e8-a9df-8bb2fbc63b3e">method update-dao (dao)</a></li>
<li><a href="#4697a909-970c-492b-b1d6-7e05895f8882">function save-dao (dao)</a></li>
<li><a href="#62a09a7f-8583-404d-b9f3-28b1eb416b0f">function save-dao/transaction (dao)</a></li>
<li><a href="#8eeaf5dd-a802-4ba0-9983-dc153ffc1dae">method upsert-dao (dao)</a></li>
<li><a href="#b135af85-b194-4a5c-9c2d-be87f6827877">method delete-dao (dao)</a></li>
<li><a href="#436e6c77-8550-4462-a956-3affe6d0970c">function dao-table-name (class)</a></li>
<li><a href="#289d7bc0-b4a3-45e3-991b-14b9cfbdcf68">function dao-table-definition (class)</a></li>
<li><a href="#d8aa15a1-7dfc-47b3-ae14-70626c33bcc3">macro with-column-writers ((&rest writers) &body body)</a></li>
</ul>
</li>
<li><a href="#table-definition">Table definition and creation</a>
<ul>
<li><a href="#16d26863-ae01-49f3-9350-8ea2d5ca363c">macro deftable (name &body definition)</a></li>
<li><a href="#d7e145ff-9666-43eb-813d-78a87116532e">variable <code>*table-name*</code></a></li>
<li><a href="#00432de6-10f6-4e52-85d9-6c622e6c37ec">variable <code>*table-symbol*</code></a></li>
<li><a href="#01902b36-20f9-4644-9347-fa6cbead2334">function !dao-def ()</a></li>
<li><a href="#b0e0a7d4-1c23-4ba2-88a4-dac55a3584c8">function !index (&rest columns), !unique-index (&rest columns)</a></li>
<li><a href="#eba9236f-a947-4194-8337-4d0f828f5542">function !foreign (target fields &rest target-fields/on-delete/on-update/deferrable/initially-deferred)</a></li>
<li><a href="#5ccbe683-8a43-4373-9371-529a3007bd40">function !unique (target-fields &key deferrable initially-deferred)</a></li>
<li><a href="#e1834b87-e348-44ab-9361-0ad1021d1163">function create-table (symbol)</a></li>
<li><a href="#eba2d105-d5c7-49c0-bfed-828e4ff53b09">function create-all-tables ()</a></li>
<li><a href="#a49e80c8-3204-4803-b263-a0cac063ea12">function create-package-tables (package)</a></li>
<li><a href="#a932fe23-c677-4bb7-8df8-6dd2adf2beff">variables <code>*table-name*</code>, <code>*table-symbol*</code></a></li>
<li><a href="#f6879b3f-12dc-44a4-b92e-03dbedd0b1cd">function drop-table (table-name &key if-exists cascade)</a></li>
<li><a href="#9b329d91-58c8-4153-950f-4e58b71455dc">Introduction to Multi-table dao class objects</a></li>
</ul>
</li>
<li><a href="#roles">Roles</a>
<ul>
<li><a href="#694123c8-957f-4b11-a344-094525d35e7f">function role-exists-p (role-name)</a></li>
<li><a href="#07a9f936-c1b7-4a7d-b5a5-57cd6a24870a">function create-role</a></li>
<li><a href="#e527824a-811e-41fa-ae49-2dd24f436ed3">function drop-role (role-name &optional (new-owner "postgres") (database :all))</a></li>
<li><a href="#20f2425f-6a17-46b0-a8b7-22843a7f11e1">function alter-role-search-path (role search-path)</a></li>
<li><a href="#08c10e1f-96a3-4f3b-8b9c-f4a0251d43cd">function change-password (role password &optional expiration-date)</a></li>
<li><a href="#41e66f79-aa57-4f00-b218-5f1a85c7d970">function grant-role-permissions (role-type name &key (schema :public) (tables :all) (databases :all))</a></li>
<li><a href="#ac447228-8f95-4a30-840d-10a1a9a418f4">function grant-readonly-permissions (schema-name role-name &optional (table-name nil))</a></li>
<li><a href="#1a271dc1-5e76-4b90-84d5-423a24059e8b">function grant-editor-permissions (schema-name role-name &optional (table-name nil))</a></li>
<li><a href="#4ac88ea3-bf89-462b-a9dd-cfa115234fb3">function grant-admin-permissions (schema-name role-name &optional (table-name nil))</a></li>
<li><a href="#6e7e67b0-0fb1-461e-a842-a6e6c59f4c2f">function revoke-all-on-table (table-name role-name)</a></li>
<li><a href="#77975516-0416-428c-a9c8-6655b5aebedd">function list-role-accessible-databases (role-name)</a></li>
<li><a href="#a5bdaaca-11e5-438d-83a8-495cef9b85fa">function list-roles (&optional (lt nil))</a></li>
<li><a href="#fd161f71-a334-4959-8b42-dda5271ef6d5">function list-role-permissions (&optional role)</a></li>
</ul>
</li>
<li><a href="#database-information">Database Information</a>
<ul>
<li><a href="#22c6eb1c-c0ca-44fc-a8f1-590fda047866">function add-comment (type name comment &optional (second-name ""))</a></li>
<li><a href="#org61732f5">find-comments (type identifier)</a></li>
<li><a href="#d993f27b-95d6-4a5b-bdf3-3e06beed0213">function get-database-comment (database-name)</a></li>
<li><a href="#29d56bfd-15a0-40bb-b7f1-a1683b392695">function postgresql-version ()</a></li>
<li><a href="#29d56bfd-15a0-40bb-b7f1-a1683b392695">function database-version ()</a></li>
<li><a href="#69269619-9b8a-4e88-8ede-777182579d0a">function current-database ()</a></li>
<li><a href="#03fec9c2-6282-4b33-abf8-4db16044cf52">function database-exists-p (database-name)</a></li>
<li><a href="#d8827c9d-64ff-4334-9a14-1ca4536f8d0a">function database-size (&optional database-name)</a></li>
<li><a href="#25b5233f-9a2c-4e39-8902-4a0b88e3b5b3">function num-records-in-database ()</a></li>
<li><a href="#b5909c41-f24b-4678-8bd9-759d543c4d81">function list-databases (&key (order-by-size nil) (size t))</a></li>
<li><a href="#ff1d636e-12ba-4fb0-8513-7f808617b956">function list-database-functions ()</a></li>
<li><a href="#5810bfc5-9338-4a6b-807f-bc72265771a0">function list-database-users ()</a></li>
<li><a href="#36e580f9-d647-4f6d-869b-0fcd347fb9d5">function list-database-access-rights (&optional database-name)</a></li>
<li><a href="#3aeac559-710e-4f60-b687-33b25a6f575a">function list-available-types ()</a></li>
<li><a href="#da41c0fb-9479-4e23-bdf2-ba73db959e36">function list-available-collations ()</a></li>
<li><a href="#f6a3893a-0d39-4484-9d3d-40d0ba2e05fd">function list-available-extensions ()</a></li>
<li><a href="#2855d5f5-3957-49ba-9d07-f61464e6da28">function list-installed-extensions ()</a></li>
<li><a href="#5bc847be-5de4-4e64-8feb-7256f58b1a0a">function list-templates ()</a></li>
<li><a href="#e0ce24b7-5619-4ab7-9912-48ebfca4605f">function change-toplevel-database (new-database user password host)</a></li>
<li><a href="#932d1dde-71e2-4f26-bac4-17a238101e24">function cache-hit-ratio ()</a></li>
<li><a href="#84bc40e4-44bf-4c1e-91d2-b32ba77f86c4">function bloat-measurement ()</a></li>
<li><a href="#10ec1cf5-e865-43e9-a093-8f27916af0d2">function unused-indexes ()</a></li>
<li><a href="#c532268f-61d7-4613-85cc-460d7d92aab0">function check-query-performance (&optional (ob nil) (num-calls 100) (limit 20))</a></li>
</ul>
</li>
<li><a href="#constraints">Constraints</a>
<ul>
<li><a href="#e20d9e5c-b0a7-44a6-8907-ad205ec1e0b8">function list-unique-or-primary-constraints (table-name)</a></li>
<li><a href="#4b8a62cb-647b-4c3b-b2a7-58476fff58d1">function list-all-constraints (table-name)</a></li>
<li><a href="#4f692c41-549f-462d-b98c-a8f7e400f4cc">function describe-constraint (table-name constraint-name)</a></li>
<li><a href="#dfe5a61e-7450-47b7-a17b-0d9bd83e1706">function describe-foreign-key-constraints ()</a></li>
</ul>
</li>
<li><a href="#indexes">Indexes/Indices</a>
<ul>
<li><a href="#21392a30-a33c-4330-9a96-abaebcc0af66">function create-index (name &key unique if-not-exists concurrently on using fields)</a></li>
<li><a href="#6bfcf7a6-6c14-4fad-82f4-5be599f1466b">function drop-index (name &key concurrently if-exists cascade)</a></li>
<li><a href="#42f1ee95-201b-4d66-b02e-1b35b0e1614c">function list-indices (&optional strings-p)</a></li>
<li><a href="#72f27f96-392f-4f33-a152-e15888a98c5d">function list-table-indices (table-name &optional strings-p)</a></li>
<li><a href="#c01dc7a8-0153-4857-acad-cb7ec8eccbdc">function index-exists-p (name)</a></li>
<li><a href="#07e4d320-8201-4cc5-803d-c83ee681d103">function list-indexed-column-and-attributes (table-name)</a></li>
<li><a href="#56922f26-5ab4-4c1a-98a2-a0ab56eff9bb">function list-index-definitions (table-name)</a></li>
</ul>
</li>
<li><a href="#keys">Keys</a>
<ul>
<li><a href="#5bf78e17-6506-4f49-b103-9900978f8344">function find-primary-key-info (table-name &optional (just-key nil))</a></li>
<li><a href="#68d136c2-a216-4def-87f9-726f72dda631">function list-foreign-keys (table-name)</a></li>
</ul>
</li>
<li><a href="#schema">Schema/Schemata</a>
<ul>
<li><a href="#9b1b791c-5e04-4512-91cb-9b44fac7b76e">macro with-schema ((namespace &key :strict t :if-not-exist :create :drop-after) &body body)</a></li>
<li><a href="#cb98d8fa-8750-4d3c-b7c2-a060205609d6">function list-schemata ()</a></li>
<li><a href="#612d3bfd-36e2-4b27-a3e9-9f4e4cf15428">function list-schemas ()</a></li>
<li><a href="#a8a3a0df-edf5-4f17-bb97-a3d76973d078">function schema-exists-p (schema)</a></li>
<li><a href="#06e76060-e646-4fe8-b1b3-142afb2e370b">function create-schema (schema)</a></li>
<li><a href="#79d7fdbb-54d7-48e1-821d-9379e3940577">function drop-schema (schema &key (if-exists nil) (cascade nil))</a></li>
<li><a href="#b8999d95-0ef5-492e-af5b-cfbdc91278e6">function get-search-path ()</a></li>
<li><a href="#125a3594-080f-40eb-997d-d7ef927420e6">function set-search-path (path)</a></li>
<li><a href="#cfacd9fe-b640-4aee-985b-149f4b9ce930">function split-fully-qualified-tablename (name)</a></li>
<li><a href="#orgb3c3ee3">function get-schema-comment (schema-name)</a></li>
</ul>
</li>
<li><a href="#sequences">Sequences</a>
<ul>
<li><a href="#4d295beb-7a6d-402e-a831-00db88584cb4">function create-sequence (name &key temp if-not-exists increment min-value max-value start cache)</a></li>
<li><a href="#47336489-34f5-401b-be21-2d7cb0b47e85">function sequence-next (sequence)</a></li>
<li><a href="#e316b343-ad9c-4610-b074-0d554e4b63ed">function drop-sequence (name &key if-exists cascade)</a></li>
<li><a href="#320f409d-dfc2-4145-b106-0e642b21fa95">function list-sequences (&optional strings-p)</a></li>
<li><a href="#da78ff64-0fb8-41a7-b17e-1f24ec8abe63">function sequence-exists-p (name)</a></li>
</ul>
</li>
<li><a href="#tables">Tables</a>
<ul>
<li><a href="#ba11f8df-3297-4720-a267-02896b49575a">function list-tables (&optional strings-p)</a></li>
<li><a href="#ad67dcb1-7123-47dc-9402-e5adcecc7e6a">function list-all-tables (&optional (fully-qualified-names-only nil))</a></li>
<li><a href="#37cd0ae4-b9b2-4776-a58e-dc396e639161">function list-tables-in-schema (&optional (schema-name "public") (strings-p nil))</a></li>
<li><a href="#5d66ed97-c2b2-4ac5-aede-d6fb70a983c8">function list-table-sizes (&key (schema "public") (order-by-size nil) (size t))</a></li>
<li><a href="#55bb44d8-2732-4257-aabd-d38c5e72ef0f">function table-exists-p (name)</a></li>
<li><a href="#bb623170-32c2-43b4-807d-66c34efe9c40">function table-size (table-name)</a></li>
<li><a href="#ee444ea2-f49f-41c9-905c-177d89770254">function table-description (name &optional schema-name)</a></li>
<li><a href="#795b7f54-85ee-4c77-b962-9176f93ad7ac">function table-description-plus (table-name)</a></li>
<li><a href="#org9fbac58">function table-description-menu (table-name &key char-max-length data-type-length</a></li>
<li><a href="#org3b5ba30">function list-check-constraints (table-name)</a></li>
<li><a href="#74baf413-72fb-4f17-abb0-1e7535af33ab">function list-columns (table-name)</a></li>
<li><a href="#9ada61bd-a670-49f3-8c04-cf025cde431f">function list-columns-with-types (table-name)</a></li>
<li><a href="#11e937a0-91f6-4475-b393-8f4f2e5d9659">function column-exists-p (table-name column-name &optional schema-name)</a></li>
<li><a href="#8ab55683-e44b-44df-bb11-67909d402383">function get-table-oid (table-name &optional schema-name)</a></li>
<li><a href="#e8d6e402-5c76-4533-9b5c-a823b9582c26">function get-table-comment (table-name &optional schema-name)</a></li>
<li><a href="#e8d6e402-5c76-4533-9b5c-a823b9582c26">function get-column-comments (database schema table)</a></li>
<li><a href="#orgd3c1c8c">function rename-table (old-name new-name)</a></li>
<li><a href="#org2e651d7">function rename-column (table-name old-name new-name)</a></li>
</ul>
</li>
<li><a href="#tablespaces">Tablespaces</a>
<ul>
<li><a href="#70537823-781b-47dd-8c38-9936756c666c">function list-tablespaces ()</a></li>
</ul>
</li>
<li><a href="#triggers">Triggers</a>
<ul>
<li><a href="#7327ab9a-b79e-4180-8165-434fd4c8d383">function describe-triggers ()</a></li>
<li><a href="#3bcdabed-dd01-4457-bc18-284598aee0a4">function list-triggers (&optional table-name)</a></li>
<li><a href="#fc3761c2-fc2e-42e4-86f2-0e918c891b5e">function list-detailed-triggers ()</a></li>
</ul>
</li>
<li><a href="#views">Views</a>
<ul>
<li><a href="#4fd820d9-857e-48fa-a62b-e2d72313a10c">function list-views (&optional strings-p)</a></li>
<li><a href="#f9ba3cce-95e0-45a0-9ede-5654bb71e98e">function view-exists-p (name)</a></li>
<li><a href="#bbf87da5-981c-42ad-b97e-38c7fafbf8ca">function describe-views (&optional (schema "public")</a></li>
</ul>
</li>
<li><a href="#misc-utility-functions">Miscellaneous Utility Functions</a>
<ul>
<li><a href="#9e576b29-c33d-425d-8759-e8e5e8367593">function coalesce (&rest arguments)</a></li>
<li><a href="#441f2929-9c04-4b01-8b85-7c474e200755">function execute-file (filename &optional (print nil))</a></li>
<li><a href="#fcf022af-ae93-470d-be11-23a25acf0bb9">function num-records-in-database ()</a></li>
<li><a href="#1870a515-3f02-45c6-b42c-97659580f257">function postgres-array-string-to-list (str)</a></li>
<li><a href="#6fa88adf-cd17-40a8-beb2-0ecea529f6db">function postgres-array-string-to-array (str)</a></li>
</ul>
</li>
<li><a href="#b9ec79c0-8e2e-4bad-adcd-e8aa9b6c9a27">Imported From s-sql</a>
<ul>
<li><a href="#8c74e736-6b4f-4996-88c4-f087f46cff05">macro sql (form)</a></li>
<li><a href="#ace3cbb6-04f0-435b-b2d9-55e2612ea01b">function sql-compile (form)</a></li>
<li><a href="#55a205bf-c9f4-450c-aa86-45cce006ee79">deftype smallint ()</a></li>
<li><a href="#80a15f41-d550-4f3b-adc5-4558d3ddf166">deftype bigint ()</a></li>
<li><a href="#4a38ba2c-b03b-4887-905b-1bf85cd3f607">deftype numeric (&optional precision/scale scale)</a></li>
<li><a href="#8e094b66-fcc0-4f6e-91dd-5f3c63a7e8a0">deftype double-precision ()</a></li>
<li><a href="#f4e4e8ac-2d8c-4dea-991f-af57fa589932">deftype bytea ()</a></li>
<li><a href="#a18ec054-2fcb-482f-bda5-988ab94e9763">deftype text ()</a></li>
<li><a href="#d4aa0266-7d2d-4207-909f-8b5767be03fd">deftype varchar (length)</a></li>
<li><a href="#20cabfe5-d425-422d-a91a-06e7c4cf0a30">deftype serial ()</a></li>
<li><a href="#15d4e630-03c8-4fe0-9b1e-b42a2b42910b">deftype serial8 ()</a></li>
<li><a href="#f862411e-45cb-4f24-9caa-15edbe804999">deftype db-null ()</a></li>
<li><a href="#24878142-d801-4fb0-b58b-b59454ee414d">function from-sql-name (str)</a></li>
<li><a href="#0205cc17-d05d-4ac1-96eb-1c2431e948c8">function parse-queries (file-content)</a></li>
<li><a href="#de3bb099-ed34-423a-9bcd-535e1a5f588b">function read-queries (filename)</a></li>
<li><a href="#a6245312-f133-481b-8aed-2bd7c4d4b972">function sql-escape-string (string)</a></li>
<li><a href="#73012d8f-1e5d-4518-8df8-368a4fae3441">method sql-escape (arg)</a></li>
<li><a href="#1723409d-0013-459a-a89c-236d1c7f2fb5">macro register-sql-operators (arity &rest names)</a></li>
<li><a href="#678a9397-e784-42bf-ba21-7d1d8a5816e2">variable <code>*escape-sql-names-p*</code></a></li>
<li><a href="#3cbda7a6-974c-475d-a87c-90353ac15b75">function to-sql-name (name &optional (escape-p <code>*escape-sql-names-p*</code>) (ignore-reserved-words nil))</a></li>
<li><a href="#2970d836-dcaa-4b49-aa95-27aa9d3d4f3f">condition sql-error</a></li>
</ul>
</li>
<li><a href="#5ccb5ff2-0d42-48d4-90c0-2ef6e7f8f1c7">Conditions Imported From cl-postgres</a>
<ul>
<li><a href="#b16b281c-2103-4f65-bb48-d9ac0083a302">condition database-connection-error</a></li>
<li><a href="#06f35002-f176-4bae-b9cc-271b8b3b2cf1">condition database-error</a></li>
<li><a href="#77cc7700-9573-4280-ba3a-cb368fa96dcc">function database-error-constraint-name (err)</a></li>
<li><a href="#52fe59d2-396d-4c36-9a94-5ef452702d79">function database-error-extract-name (err)</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<p>
This is the reference manual for the component named postmodern, which is part
of a library of the same name.
</p>
<p>
Note that this package also exports the database-connection and database-error
types from CL-postgres and a few operators from S-SQL.
</p>
<p>
query, execute, and any other function that would logically need to communicate
with the database will raise a condition of the type database-error when
something goes wrong. As a special case, errors that break the connection
(socket errors, database shutdowns) will be raised as subtypes of
database-connection-error, providing a :reconnect restart to re-try the
operation that encountered to the error.
</p>
<div id="outline-container-connecting" class="outline-2">
<h2 id="connecting">Connecting</h2>
<div class="outline-text-2" id="text-connecting">
</div>
<div id="outline-container-dfc95b36-94d7-42ab-827b-8622f593e7f6" class="outline-3">
<h3 id="dfc95b36-94d7-42ab-827b-8622f593e7f6">class database-connection</h3>
<div class="outline-text-3" id="text-dfc95b36-94d7-42ab-827b-8622f593e7f6">
<p>
Representation of a database connection. Contains login information in order to
be able to automatically re-establish a connection when it is somehow closed.
</p>
</div>
</div>
<div id="outline-container-d4aa3e04-ab90-4271-b3e7-60a48e4f2e49" class="outline-3">
<h3 id="d4aa3e04-ab90-4271-b3e7-60a48e4f2e49">function connect (database user-name password host &key (port 5432) pooled-p use-ssl service application-name)</h3>
<div class="outline-text-3" id="text-d4aa3e04-ab90-4271-b3e7-60a48e4f2e49">
<p>
→ database-connection
</p>
<p>
Create a new database connection for the given user and the database. Port will
default to 5432, which is where most PostgreSQL servers are running. If
pooled-p is T, a connection will be taken from a pool of connections of this
type, if one is available there, and when the connection is disconnected it will
be put back into this pool instead. use-ssl can be :no, :try, :require, :yes, or :full
and defaults to the value of <code>*default-use-ssl*</code>
</p>
<ul class="org-ul">
<li>:try means if the server supports it</li>
<li>:require means use provided ssl certificate with no verification</li>
<li>:yes means verify that the server cert is issued by a trusted CA, but does not verify the server hostname</li>
<li>:full means expect a CA-signed cert for the supplied hostname and verify the server hostname</li>
</ul>
<p>
If you set it to anything other than :no be sure to also load the CL+SSL library.
</p>
<p>
Service defaults to "postgres".
</p>
<p>
Application-name defaults to a blank string. If provided, Postgresl can use it to track applications with multiple connections.
</p>
</div>
</div>
<div id="outline-container-e140fab3-b6fe-4e88-b9ca-241bbb64fce4" class="outline-3">
<h3 id="e140fab3-b6fe-4e88-b9ca-241bbb64fce4">variable <code>*default-use-ssl*</code></h3>
<div class="outline-text-3" id="text-e140fab3-b6fe-4e88-b9ca-241bbb64fce4">
<p>
The default for connect's use-ssl argument.
Valid settings are :no, :try, :require, :yes, or :full
:try means if the server supports it
:require means use provided ssl certificate with no verification
:yes means verify that the server cert is issued by a trusted CA, but does not verify the server hostname
:full means expect a CA-signed cert for the supplied hostname and verify the server hostname
If you set it to anything other than :no be sure to also load the CL+SSL library.
</p>
</div>
</div>
<div id="outline-container-9a1a03af-a67e-4419-9066-d79a81885f81" class="outline-3">
<h3 id="9a1a03af-a67e-4419-9066-d79a81885f81">method disconnect (database-connection)</h3>
<div class="outline-text-3" id="text-9a1a03af-a67e-4419-9066-d79a81885f81">
<p>
Disconnects a normal database connection, or moves a pooled connection into the
pool.
</p>
</div>
</div>
<div id="outline-container-a660d0cc-4795-41df-b183-0ea31f6b6584" class="outline-3">
<h3 id="a660d0cc-4795-41df-b183-0ea31f6b6584">function connected-p (database-connection)</h3>
<div class="outline-text-3" id="text-a660d0cc-4795-41df-b183-0ea31f6b6584">
<p>
→ boolean
</p>
<p>
Returns a boolean indicating whether the given connection is still connected to
the server.
</p>
</div>
</div>
<div id="outline-container-426a8f5d-5dc7-4973-a1fc-11b488afcd82" class="outline-3">
<h3 id="426a8f5d-5dc7-4973-a1fc-11b488afcd82">method reconnect (database-connection)</h3>
<div class="outline-text-3" id="text-426a8f5d-5dc7-4973-a1fc-11b488afcd82">
<p>
Reconnect a disconnected database connection. This is not allowed for pooled
connections ― after they are disconnected they might be in use by some other
process, and should no longer be used.
</p>
</div>
</div>
<div id="outline-container-9b9cf868-214b-4026-8f80-25b23f445c91" class="outline-3">
<h3 id="9b9cf868-214b-4026-8f80-25b23f445c91">variable <code>*database*</code></h3>
<div class="outline-text-3" id="text-9b9cf868-214b-4026-8f80-25b23f445c91">
<p>
Special variable holding the current database connection information. Most
functions and macros operating on a database assume this binds to a connected
database.
</p>
</div>
</div>
<div id="outline-container-056d4921-c834-4655-a487-83314f22da42" class="outline-3">
<h3 id="056d4921-c834-4655-a487-83314f22da42">macro with-connection (spec &body body)</h3>
<div class="outline-text-3" id="text-056d4921-c834-4655-a487-83314f22da42">
<p>
Evaluates the body with <code>*database*</code> bound to a connection as specified by spec,
which should be list that connect can be applied to.
</p>
</div>
</div>
<div id="outline-container-0e0c03e9-7681-433f-ae75-8f06c9685221" class="outline-3">
<h3 id="0e0c03e9-7681-433f-ae75-8f06c9685221">macro call-with-connection (spec thunk)</h3>
<div class="outline-text-3" id="text-0e0c03e9-7681-433f-ae75-8f06c9685221">
<p>
The functional backend to with-connection. Binds <code>*database*</code> to a new connection
as specified by spec, which should be a list that connect can be applied to, and
runs the zero-argument function given as second argument in the new environment.
When the function returns or throws, the new connection is disconnected.
</p>
</div>
</div>
<div id="outline-container-a74be5d0-9b86-4c15-b738-76cd92908d25" class="outline-3">
<h3 id="a74be5d0-9b86-4c15-b738-76cd92908d25">function connect-toplevel (database user-name password host &key (port 5432))</h3>
<div class="outline-text-3" id="text-a74be5d0-9b86-4c15-b738-76cd92908d25">
<p>
Bind the <code>*database*</code> to a new connection. Use this if you only need one
connection, or if you want a connection for debugging from the REPL.
</p>
</div>
</div>
<div id="outline-container-a63f929c-805d-42d5-8fbe-f1c01e62b50a" class="outline-3">
<h3 id="a63f929c-805d-42d5-8fbe-f1c01e62b50a">function disconnect-toplevel ()</h3>
<div class="outline-text-3" id="text-a63f929c-805d-42d5-8fbe-f1c01e62b50a">
<p>
Disconnect the <code>*database*</code>.
</p>
</div>
</div>
<div id="outline-container-56c370e4-8f4e-414a-82b6-ae4408fc0b61" class="outline-3">
<h3 id="56c370e4-8f4e-414a-82b6-ae4408fc0b61">function clear-connection-pool ()</h3>
<div class="outline-text-3" id="text-56c370e4-8f4e-414a-82b6-ae4408fc0b61">
<p>
Disconnect and remove all connections from the connection pools.
</p>
</div>
</div>
<div id="outline-container-97aa1ebb-ef91-4254-a6b7-bfcd8128ad96" class="outline-3">
<h3 id="97aa1ebb-ef91-4254-a6b7-bfcd8128ad96">variable <code>*max-pool-size*</code></h3>
<div class="outline-text-3" id="text-97aa1ebb-ef91-4254-a6b7-bfcd8128ad96">
<p>
Set the maximum amount of connections kept in a single connection pool, where a
pool consists of all the stored connections with the exact same connect
arguments. Defaults to NIL, which means there is no maximum.
</p>
</div>
</div>
<div id="outline-container-09583f9a-388a-400a-bb3c-d118242508c8" class="outline-3">
<h3 id="09583f9a-388a-400a-bb3c-d118242508c8">function list-connections ()</h3>
<div class="outline-text-3" id="text-09583f9a-388a-400a-bb3c-d118242508c8">
<p>
→ list
</p>
<p>
List the current postgresql connections to the currently connected database. It
does this by returningo info from pg_stat_activity on open connections.
</p>
</div>
</div>
</div>
<div id="outline-container-querying" class="outline-2">
<h2 id="querying">Querying</h2>
<div class="outline-text-2" id="text-querying">
</div>
<div id="outline-container-5a8c24fb-6d7b-4952-8520-b5e8ea98dd77" class="outline-3">
<h3 id="5a8c24fb-6d7b-4952-8520-b5e8ea98dd77">macro query (query &rest args/format)</h3>
<div class="outline-text-3" id="text-5a8c24fb-6d7b-4952-8520-b5e8ea98dd77">
<p>
→ result
</p>
<p>
Execute the given query, which can be either a string or an S-SQL form
(list starting with a keyword). If the query contains placeholders ($1, $2, etc)
their values can be given as extra arguments. If one of these arguments
is a keyword occurring in the table below, it will not be used as a query
argument, but will determine the format in which the results are returned
instead. Any of the following formats can be used, with the default being :rows:
</p>
<table>
<colgroup>
<col class="org-left">
<col class="org-left">
</colgroup>
<tbody>
<tr>
<td class="org-left">:none</td>
<td class="org-left">Ignore the result values.</td>
</tr>
<tr>
<td class="org-left">:lists, :rows</td>
<td class="org-left">Return a list of lists, each list containing the values for a row.</td>
</tr>
<tr>
<td class="org-left">:list, :row</td>
<td class="org-left">Return a single row as a list.</td>
</tr>
<tr>
<td class="org-left">:alists</td>
<td class="org-left">Return a list of alists which map column names to values, with the names represented as keywords.</td>
</tr>
<tr>
<td class="org-left">:alist</td>
<td class="org-left">Return a single row as an alist.</td>
</tr>
<tr>
<td class="org-left">:str-alists</td>
<td class="org-left">Like :alists, but use the original column names.</td>
</tr>
<tr>
<td class="org-left">:str-alist</td>
<td class="org-left">Return a single row as an alist, with strings for names.</td>
</tr>
<tr>
<td class="org-left">:plists</td>
<td class="org-left">Return a list of plists which map column names to values,with the names represented as keywords.</td>
</tr>
<tr>
<td class="org-left">:plist</td>
<td class="org-left">Return a single row as a plist.</td>
</tr>
<tr>
<td class="org-left">:column</td>
<td class="org-left">Return a single column as a list.</td>
</tr>
<tr>
<td class="org-left">:single</td>
<td class="org-left">Return a single value. Will raise an error if the query returns more than one field. If the query returns more than one row, it returns the first row.</td>
</tr>
<tr>
<td class="org-left">:single!</td>
<td class="org-left">Like :single except that it will throw an error when the number of selected rows is not equal to 1.</td>
</tr>
<tr>
<td class="org-left">:array-hash</td>
<td class="org-left">Return an array of hashtables which map column names to hash table keys</td>
</tr>
<tr>
<td class="org-left">:json-strs</td>
<td class="org-left">Return a list of strings where each row is a json object expressed as a string</td>
</tr>
<tr>
<td class="org-left">:json-strs</td>
<td class="org-left">Return a single string where the row returned is a json object expressed as a string</td>
</tr>
<tr>
<td class="org-left">:json-array-str</td>
<td class="org-left">Return a string containing a json array, each element in the array is a selected row expressed as a json object</td>
</tr>
<tr>
<td class="org-left">(:dao type)</td>
<td class="org-left">Return a list of DAOs of the given type. The names of the fields returned by the query must match slots in the DAO class the same way as with query-dao.</td>
</tr>
<tr>
<td class="org-left">(:dao type :single)</td>
<td class="org-left">Return a single DAO of the given type.</td>
</tr>
</tbody>
</table>
<p>
Some Examples:
</p>
</div>
<div id="outline-container-org1df5ad1" class="outline-4">
<h4 id="org1df5ad1">Default</h4>
<div class="outline-text-4" id="text-org1df5ad1">
<p>
The default is :lists
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:<</span> 'id 3)))
((1 2147483645 <span style="color: #e67128;">"text one"</span>) (2 0 <span style="color: #e67128;">"text two"</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-orgd713b12" class="outline-4">
<h4 id="orgd713b12">Single</h4>
<div class="outline-text-4" id="text-orgd713b12">
<p>
Returns a single field. Will throw an error if the queries returns more than one field or more than one row
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:=</span> 'id 3)) <span style="color: #23d7d7;">:single</span>)
<span style="color: #e67128;">"text three"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-org91dec3e" class="outline-4">
<h4 id="org91dec3e">List</h4>
<div class="outline-text-4" id="text-org91dec3e">
<p>
Returns a list containing the selected fields. Will throw an error if the query returns more than one row
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:=</span> 'id 3)) <span style="color: #23d7d7;">:list</span>)
(3 3 <span style="color: #e67128;">"text three"</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf237aae" class="outline-4">
<h4 id="orgf237aae">Lists</h4>
<div class="outline-text-4" id="text-orgf237aae">
<p>
This is the default
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:<</span> 'id 3)) <span style="color: #23d7d7;">:lists</span>)
((1 2147483645 <span style="color: #e67128;">"text one"</span>) (2 0 <span style="color: #e67128;">"text two"</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-orgafa618c" class="outline-4">
<h4 id="orgafa618c">Alist</h4>
<div class="outline-text-4" id="text-orgafa618c">
<p>
Returns an alist containing the field name as a keyword and the selected fields. Will throw an error if the query returns more than one row.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'test-data <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:=</span> 'id 3)) <span style="color: #23d7d7;">:alist</span>)
((<span style="color: #23d7d7;">:ID</span> . 3) (<span style="color: #23d7d7;">:INT4</span> . 3) (<span style="color: #23d7d7;">:TEXT</span> . <span style="color: #e67128;">"text three"</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-org189c4f0" class="outline-4">
<h4 id="org189c4f0">Str-alist</h4>
<div class="outline-text-4" id="text-org189c4f0">
<p>
Returns an alist containing the field name as a lower case string and the selected fields. Will throw an error if the query returns more than one row.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:=</span> 'id 3)) <span style="color: #23d7d7;">:str-alist</span>)
((<span style="color: #e67128;">"id"</span> . 3) (<span style="color: #e67128;">"int4"</span> . 3) (<span style="color: #e67128;">"text"</span> . <span style="color: #e67128;">"text three"</span>))
</pre>
</div>
</div>
</div>
<div id="outline-container-org283c509" class="outline-4">
<h4 id="org283c509">Alists</h4>
<div class="outline-text-4" id="text-org283c509">
<p>
Returns a list of alists containing the field name as a keyword and the selected fields.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:<</span> 'id 3)) <span style="color: #23d7d7;">:alists</span>)
(((<span style="color: #23d7d7;">:ID</span> . 1) (<span style="color: #23d7d7;">:INT4</span> . 2147483645) (<span style="color: #23d7d7;">:TEXT</span> . <span style="color: #e67128;">"text one"</span>))
((<span style="color: #23d7d7;">:ID</span> . 2) (<span style="color: #23d7d7;">:INT4</span> . 0) (<span style="color: #23d7d7;">:TEXT</span> . <span style="color: #e67128;">"text two"</span>)))
</pre>
</div>
</div>
</div>
<div id="outline-container-org76b2790" class="outline-4">
<h4 id="org76b2790">Str-alists</h4>
<div class="outline-text-4" id="text-org76b2790">
<p>
Returns a list of alists containing the field name as a lower case string and the selected fields.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:<</span> 'id 3)) <span style="color: #23d7d7;">:str-alists</span>)
(((<span style="color: #e67128;">"id"</span> . 1) (<span style="color: #e67128;">"int4"</span> . 2147483645) (<span style="color: #e67128;">"text"</span> . <span style="color: #e67128;">"text one"</span>))
((<span style="color: #e67128;">"id"</span> . 2) (<span style="color: #e67128;">"int4"</span> . 0) (<span style="color: #e67128;">"text"</span> . <span style="color: #e67128;">"text two"</span>)))
</pre>
</div>
</div>
</div>
<div id="outline-container-orgfd25e3d" class="outline-4">
<h4 id="orgfd25e3d">Plist</h4>
<div class="outline-text-4" id="text-orgfd25e3d">
<p>
Returns a plist containing the field name as a keyword and the selected fields. Will throw an error if the query returns more than one row.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:=</span> 'id 3)) <span style="color: #23d7d7;">:plist</span>)
(<span style="color: #23d7d7;">:ID</span> 3 <span style="color: #23d7d7;">:INT4</span> 3 <span style="color: #23d7d7;">:TEXT</span> <span style="color: #e67128;">"text three"</span>)
</pre>
</div>
</div>
</div>
<div id="outline-container-org5ca5d33" class="outline-4">
<h4 id="org5ca5d33">Plists</h4>
<div class="outline-text-4" id="text-org5ca5d33">
<p>
Returns a list of plists containing the field name as a keyword and the selected fields.
</p>
<div class="org-src-container">
<pre class="src src-lisp">(query (<span style="color: #23d7d7;">:select</span> 'id 'int4 'text <span style="color: #23d7d7;">:from</span> 'short-data-type-tests <span style="color: #23d7d7;">:where</span> (<span style="color: #23d7d7;">:<</span> 'id 3)) <span style="color: #23d7d7;">:plists</span>)
((<span style="color: #23d7d7;">:ID</span> 1 <span style="color: #23d7d7;">:INT4</span> 2147483645 <span style="color: #23d7d7;">:TEXT</span> <span style="color: #e67128;">"text one"</span>) (<span style="color: #23d7d7;">:ID</span> 2 <span style="color: #23d7d7;">:INT4</span> 0 <span style="color: #23d7d7;">:TEXT</span> <span style="color: #e67128;">"text two"</span>))
</pre>
</div>
</div>