From 01e19983da49f3c94588418aa8c5e0df7f6626cb Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Fri, 24 Aug 2012 13:21:21 -0400 Subject: [PATCH] db: split example logs into one per scribble file to make drdr happy --- collects/db/scribblings/config.rkt | 34 +- collects/db/scribblings/connect.scrbl | 8 + collects/db/scribblings/db.scrbl | 3 + collects/db/scribblings/example-log.rktd | 664 ------------------ collects/db/scribblings/log-for-connect.rktd | 82 +++ collects/db/scribblings/log-for-query.rktd | 282 ++++++++ .../db/scribblings/log-for-sql-types.rktd | 155 ++++ collects/db/scribblings/log-for-using-db.rktd | 172 +++++ collects/db/scribblings/log-for-util.rktd | 49 ++ collects/db/scribblings/query.scrbl | 7 + collects/db/scribblings/sql-types.scrbl | 7 + collects/db/scribblings/using-db.scrbl | 9 + collects/db/scribblings/util.scrbl | 6 + 13 files changed, 806 insertions(+), 672 deletions(-) delete mode 100644 collects/db/scribblings/example-log.rktd create mode 100644 collects/db/scribblings/log-for-connect.rktd create mode 100644 collects/db/scribblings/log-for-query.rktd create mode 100644 collects/db/scribblings/log-for-sql-types.rktd create mode 100644 collects/db/scribblings/log-for-using-db.rktd create mode 100644 collects/db/scribblings/log-for-util.rktd diff --git a/collects/db/scribblings/config.rkt b/collects/db/scribblings/config.rkt index 2fd2f9d6d0..15f54721bd 100644 --- a/collects/db/scribblings/config.rkt +++ b/collects/db/scribblings/config.rkt @@ -21,17 +21,35 @@ ;; ---- #| -The log-based-eval should be run in an environment that defines -the DSN 'db-scribble-env as a PostgreSQL data source. +Whenever examples are changed, added, removed, or reordered, the +example log files must be regenerated. To do so, set log-mode below to +'record and run setup. Regenerating the logs require an environment +that defines the DSN 'db-scribble-env as a PostgreSQL data source. + +Set log-mode back to 'replay before checking in the changes. + +Use one evaluator (and log file) per scribble file, so that when DrDr +runs scribble files individually, they still work. |# -(define-runtime-path example-log "example-log.rktd") -(define the-eval (make-log-based-eval example-log 'replay)) +(define log-mode 'replay) -(the-eval '(require racket/class - db - db/util/postgresql - db/util/datetime)) +(define (make-pg-eval log-file init?) + (let ([ev (make-log-based-eval log-file log-mode)]) + (ev '(require racket/class + db + db/util/postgresql + db/util/datetime)) + (when init? + (ev '(begin + ;; Must be kept in sync with beginning of using-db.scrbl + (define pgc (dsn-connect 'db-scribble-env)) + (query-exec pgc "create temporary table the_numbers (n integer, d varchar(20))") + (query-exec pgc "insert into the_numbers values (0, 'nothing')") + (query-exec pgc "insert into the_numbers values (1, 'the loneliest number')") + (query-exec pgc "insert into the_numbers values (2, 'company')") + (query-exec pgc "insert into the_numbers values (3, 'a crowd')")))) + ev)) #| The fake eval is for eg connection examples diff --git a/collects/db/scribblings/connect.scrbl b/collects/db/scribblings/connect.scrbl index 516a0643f7..ac70e7c878 100644 --- a/collects/db/scribblings/connect.scrbl +++ b/collects/db/scribblings/connect.scrbl @@ -3,10 +3,15 @@ scribble/eval scribble/struct racket/sandbox + racket/runtime-path "config.rkt" (for-label db openssl)) + +@(define-runtime-path log-file "log-for-connect.rktd") +@(define the-eval (make-pg-eval log-file #t)) + @title[#:tag "connect"]{Connections} This section describes functions for creating connections as well as @@ -749,3 +754,6 @@ Provides only @racket[odbc-connect], @racket[odbc-driver-connect], @racketmodname[db], this module immediately attempts to load the ODBC native library when required, and it raises an exception if it cannot be found. + + +@(close-eval the-eval) diff --git a/collects/db/scribblings/db.scrbl b/collects/db/scribblings/db.scrbl index 4fe3eb2943..d817877302 100644 --- a/collects/db/scribblings/db.scrbl +++ b/collects/db/scribblings/db.scrbl @@ -1,6 +1,7 @@ #lang scribble/doc @(require scribble/manual scribble/struct + scribble/eval "config.rkt") @title{DB: Database Connectivity} @@ -56,3 +57,5 @@ code from Jay McCarthy's @tt{sqlite} package. @include-section["sql-types.scrbl"] @include-section["util.scrbl"] @include-section["notes.scrbl"] + +@(close-eval fake-eval) diff --git a/collects/db/scribblings/example-log.rktd b/collects/db/scribblings/example-log.rktd deleted file mode 100644 index e2469bfb1f..0000000000 --- a/collects/db/scribblings/example-log.rktd +++ /dev/null @@ -1,664 +0,0 @@ -;; This file was created by make-log-based-eval -((require racket/class db db/util/postgresql db/util/datetime) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((require db) ((3) 0 () 0 () () (c values c (void))) #"" #"") -((define pgc (dsn-connect 'db-scribble-env)) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-exec - pgc - "create temporary table the_numbers (n integer, d varchar(20))") - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-exec pgc "insert into the_numbers values (0, 'nothing')") - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-exec pgc "insert into the_numbers values (1, 'the loneliest number')") - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-exec pgc "insert into the_numbers values (2, 'company')") - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query pgc "insert into the_numbers values (3, 'a crowd')") - ((3) - 1 - (((lib "db/private/generic/interfaces.rkt") - . - deserialize-info:simple-result-v0)) - 0 - () - () - (c values c (0 (c (c command u . "INSERT 0 1"))))) - #"" - #"") -((query pgc "select n, d from the_numbers where n % 2 = 0") - ((3) - 1 - (((lib "db/private/generic/interfaces.rkt") - . - deserialize-info:rows-result-v0)) - 0 - () - () - (c - values - c - (0 - (c - (c - (c name u . "n") - c - (c typeid . 23) - c - (c type-size . 4) - c - (c type-mod . -1)) - c - (c - (c name u . "d") - c - (c typeid . 1043) - c - (c type-size . -1) - c - (c type-mod . 24))) - (c (v! 0 (u . "nothing")) c (v! 2 (u . "company")))))) - #"" - #"") -((query-rows pgc "select n, d from the_numbers where n % 2 = 0") - ((3) - 0 - () - 0 - () - () - (c values c (c (v! 0 (u . "nothing")) c (v! 2 (u . "company"))))) - #"" - #"") -((query-row pgc "select * from the_numbers where n = 0") - ((3) 0 () 0 () () (c values c (v! 0 (u . "nothing")))) - #"" - #"") -((query-list pgc "select d from the_numbers order by n") - ((3) - 0 - () - 0 - () - () - (c - values - c - (c - (u . "nothing") - c - (u . "the loneliest number") - c - (u . "company") - c - (u . "a crowd")))) - #"" - #"") -((query-value pgc "select count(*) from the_numbers") - ((3) 0 () 0 () () (c values c 4)) - #"" - #"") -((query-value pgc "select d from the_numbers where n = 5") - ((3) - 0 - () - 0 - () - () - (c - exn - c - "query-value: query returned wrong number of rows\n statement: \"select d from the_numbers where n = 5\"\n expected: 1\n got: 0")) - #"" - #"") -((query-maybe-value pgc "select d from the_numbers where n = 5") - ((3) 0 () 0 () () (c values c #f)) - #"" - #"") -((for - (((n d) (in-query pgc "select * from the_numbers where n < 4"))) - (printf "~a: ~a\n" n d)) - ((3) 0 () 0 () () (c values c (void))) - #"0: nothing\n1: the loneliest number\n2: company\n3: a crowd\n" - #"") -((for/fold - ((sum 0)) - ((n (in-query pgc "select n from the_numbers"))) - (+ sum n)) - ((3) 0 () 0 () () (c values c 6)) - #"" - #"") -((begin - (with-handlers - ((exn:fail? (lambda (e) (printf "~a~n" (exn-message e))))) - (query-value pgc "select NoSuchField from NoSuchTable")) - (query-value pgc "select 'okay to proceed!'")) - ((3) 0 () 0 () () (c values c (u . "okay to proceed!"))) - #"query-value: relation \"nosuchtable\" does not exist\n SQLSTATE: 42P01\n" - #"") -((query-value pgc "select d from the_numbers where n = $1" 2) - ((3) 0 () 0 () () (c values c (u . "company"))) - #"" - #"") -((query-list pgc "select n from the_numbers where n > $1 and n < $2" 0 3) - ((3) 0 () 0 () () (c values c (c 1 c 2))) - #"" - #"") -((define get-less-than-pst - (prepare pgc "select n from the_numbers where n < $1")) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-list pgc get-less-than-pst 1) - ((3) 0 () 0 () () (c values c (c 0))) - #"" - #"") -((query-list pgc (bind-prepared-statement get-less-than-pst '(2))) - ((3) 0 () 0 () () (c values c (c 0 c 1))) - #"" - #"") -((void) ((3) 0 () 0 () () (c values c (void))) #"" #"") -((define pool - (connection-pool - (lambda () - (displayln "connecting!") - (sqlite3-connect #:database 'memory)))) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((define c1 (connection-pool-lease pool)) - ((3) 0 () 0 () () (c values c (void))) - #"connecting!\n" - #"") -((define c2 (connection-pool-lease pool)) - ((3) 0 () 0 () () (c values c (void))) - #"connecting!\n" - #"") -((disconnect c1) ((3) 0 () 0 () () (c values c (void))) #"" #"") -((define c3 (connection-pool-lease pool)) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((define c - (virtual-connection - (lambda () (printf "connecting!\n") (dsn-connect 'db-scribble-env)))) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((connected? c) ((3) 0 () 0 () () (c values c #f)) #"" #"") -((query-value c "select 1") - ((3) 0 () 0 () () (c values c 1)) - #"connecting!\n" - #"") -((connected? c) ((3) 0 () 0 () () (c values c #t)) #"" #"") -((void (thread (lambda () (displayln (query-value c "select 2"))))) - ((3) 0 () 0 () () (c values c (void))) - #"connecting!\n2\n" - #"") -((disconnect c) ((3) 0 () 0 () () (c values c (void))) #"" #"") -((connected? c) ((3) 0 () 0 () () (c values c #f)) #"" #"") -((query-value c "select 3") - ((3) 0 () 0 () () (c values c 3)) - #"connecting!\n" - #"") -((prepare c "select 2 + $1") - ((3) - 0 - () - 0 - () - () - (c exn c "prepare: cannot prepare statement with virtual connection")) - #"" - #"") -((query-value c "select 2 + $1" 2) ((3) 0 () 0 () () (c values c 4)) #"" #"") -((define pst (virtual-statement "select 2 + $1")) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-value c pst 3) ((3) 0 () 0 () () (c values c 5)) #"" #"") -((begin (set! c #f) (set! pst #f)) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((define c pgc) ((3) 0 () 0 () () (c values c (void))) #"" #"") -((query-exec pgc "insert into the_numbers values (42, 'the answer')") - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-exec pgc "delete from the_numbers where n = $1" 42) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-rows pgc "select * from the_numbers where n = $1" 2) - ((3) 0 () 0 () () (c values c (c (v! 2 (u . "company"))))) - #"" - #"") -((query-rows c "select 17") - ((3) 0 () 0 () () (c values c (c (v! 17)))) - #"" - #"") -((query-list c "select n from the_numbers where n < 2") - ((3) 0 () 0 () () (c values c (c 0 c 1))) - #"" - #"") -((query-list c "select 'hello'") - ((3) 0 () 0 () () (c values c (c (u . "hello")))) - #"" - #"") -((query-row pgc "select * from the_numbers where n = $1" 2) - ((3) 0 () 0 () () (c values c (v! 2 (u . "company")))) - #"" - #"") -((query-row pgc "select min(n), max(n) from the_numbers") - ((3) 0 () 0 () () (c values c (v! 0 3))) - #"" - #"") -((query-maybe-row pgc "select * from the_numbers where n = $1" 100) - ((3) 0 () 0 () () (c values c #f)) - #"" - #"") -((query-maybe-row c "select 17") - ((3) 0 () 0 () () (c values c (v! 17))) - #"" - #"") -((query-value pgc "select timestamp 'epoch'") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") - . - deserialize-info:sql-timestamp-v0)) - 0 - () - () - (c values c (0 1970 1 1 0 0 0 0 #f))) - #"" - #"") -((query-value pgc "select d from the_numbers where n = $1" 3) - ((3) 0 () 0 () () (c values c (u . "a crowd"))) - #"" - #"") -((query-maybe-value pgc "select d from the_numbers where n = $1" 100) - ((3) 0 () 0 () () (c values c #f)) - #"" - #"") -((query-maybe-value c "select count(*) from the_numbers") - ((3) 0 () 0 () () (c values c 4)) - #"" - #"") -((for/list ((n (in-query pgc "select n from the_numbers where n < 2"))) n) - ((3) 0 () 0 () () (c values c (c 0 c 1))) - #"" - #"") -((call-with-transaction - pgc - (lambda () - (for - (((n d) - (in-query pgc "select * from the_numbers where n < $1" 4 #:fetch 1))) - (printf "~a: ~a\n" n d)))) - ((3) 0 () 0 () () (c values c (void))) - #"0: nothing\n1: the loneliest number\n2: company\n3: a crowd\n" - #"") -((for ((n (in-query pgc "select * from the_numbers"))) (displayln n)) - ((3) - 0 - () - 0 - () - () - (c - exn - c - "in-query: query returned wrong number of columns\n statement: \"select * from the_numbers\"\n expected: 1\n got: 2")) - #"" - #"") -((define vehicles-result - (rows-result - '(((name . "type")) ((name . "maker")) ((name . "model"))) - `(#("car" "honda" "civic") - #("car" "ford" "focus") - #("car" "ford" "pinto") - #("bike" "giant" "boulder") - #("bike" "schwinn" ,sql-null)))) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((group-rows vehicles-result #:group '(#("type"))) - ((3) - 2 - (((lib "db/private/generic/interfaces.rkt") - . - deserialize-info:rows-result-v0) - ((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) - 1 - ("ford") - () - (c - values - c - (0 - (c - (c (c name . "type")) - c - (c - (c name . "grouped") - c - (c grouped c (c (c name . "maker")) c (c (c name . "model"))))) - (c - (v! - "car" - (c (v! "honda" "civic") c (v! (? . 0) "focus") c (v! (? . 0) "pinto"))) - c - (v! "bike" (c (v! "giant" "boulder") c (v! "schwinn" (1)))))))) - #"" - #"") -((group-rows - vehicles-result - #:group - '(#("type") #("maker")) - #:group-mode - '(list)) - ((3) - 1 - (((lib "db/private/generic/interfaces.rkt") - . - deserialize-info:rows-result-v0)) - 1 - ((c name . "grouped")) - () - (c - values - c - (0 - (c - (c (c name . "type")) - c - (c - (? . 0) - c - (c - grouped - c - (c (c name . "maker")) - c - (c (? . 0) c (c grouped c (c (c name . "model"))))))) - (c - (v! - "car" - (c (v! "honda" (c "civic")) c (v! "ford" (c "focus" c "pinto")))) - c - (v! "bike" (c (v! "giant" (c "boulder")) c (v! "schwinn" ()))))))) - #"" - #"") -((rows->dict vehicles-result #:key "model" #:value '#("type" "maker")) - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) - 3 - ("car" "ford" "bike") - () - (c - values - c - (h - - - (equal) - ((0) v! (? . 2) "schwinn") - ("civic" v! (? . 0) "honda") - ("pinto" v! (? . 0) (? . 1)) - ("focus" v! (? . 0) (? . 1)) - ("boulder" v! (? . 2) "giant")))) - #"" - #"") -((rows->dict - vehicles-result - #:key - "maker" - #:value - "model" - #:value-mode - '(list)) - ((3) - 0 - () - 0 - () - () - (c - values - c - (h - - - (equal) - ("ford" c "focus" c "pinto") - ("honda" c "civic") - ("giant" c "boulder") - ("schwinn")))) - #"" - #"") -((let* ((get-name-pst (prepare pgc "select d from the_numbers where n = $1")) - (get-name2 (bind-prepared-statement get-name-pst (list 2))) - (get-name3 (bind-prepared-statement get-name-pst (list 3)))) - (list (query-value pgc get-name2) (query-value pgc get-name3))) - ((3) 0 () 0 () () (c values c (c (u . "company") c (u . "a crowd")))) - #"" - #"") -((define pst - (virtual-statement - (lambda (dbsys) - (case (dbsystem-name dbsys) - ((postgresql) "select n from the_numbers where n < $1") - ((sqlite3) "select n from the_numbers where n < ?") - (else (error "unknown system")))))) - ((3) 0 () 0 () () (c values c (void))) - #"" - #"") -((query-list pgc pst 3) ((3) 0 () 0 () () (c values c (c 0 c 1 c 2))) #"" #"") -((query-list pgc pst 3) ((3) 0 () 0 () () (c values c (c 0 c 1 c 2))) #"" #"") -((with-handlers - ((exn:fail:sql? exn:fail:sql-info)) - (query pgc "select * from nosuchtable")) - ((3) - 0 - () - 0 - () - () - (c - values - c - (c - (c severity u . "ERROR") - c - (c code u . "42P01") - c - (c message u . "relation \"nosuchtable\" does not exist") - c - (c position u . "15") - c - (c file u . "parse_relation.c") - c - (c line u . "857") - c - (c routine u . "parserOpenTable")))) - #"" - #"") -((query-value pgc "select count(*) from the_numbers") - ((3) 0 () 0 () () (c values c 4)) - #"" - #"") -((query-value pgc "select false") ((3) 0 () 0 () () (c values c #f)) #"" #"") -((query-value pgc "select 1 + $1" 2) ((3) 0 () 0 () () (c values c 3)) #"" #"") -((query-value pgc "select inet '127.0.0.1'") - ((3) - 0 - () - 0 - () - () - (c exn c "query-value: unsupported type\n type: inet\n typeid: 869")) - #"" - #"") -((query-value pgc "select cast(inet '127.0.0.1' as varchar)") - ((3) 0 () 0 () () (c values c (u . "127.0.0.1/32"))) - #"" - #"") -((query-value pgc "select real '+Infinity'") - ((3) 0 () 0 () () (c values c +inf.0)) - #"" - #"") -((query-value pgc "select numeric '12345678901234567890'") - ((3) 0 () 0 () () (c values c 12345678901234567890)) - #"" - #"") -((query-value pgc "select 1 in (1, 2, 3)") - ((3) 0 () 0 () () (c values c #t)) - #"" - #"") -((query-value - pgc - "select 1 = any ($1::integer[])" - (list->pg-array (list 1 2 3))) - ((3) 0 () 0 () () (c values c #t)) - #"" - #"") -((query-value pgc "select 1 = any ($1)" (list 1 2 3)) - ((3) 0 () 0 () () (c values c #t)) - #"" - #"") -((query-value pgc "select $1::integer = any ($2)" 1 (list 1 2 3)) - ((3) 0 () 0 () () (c values c #t)) - #"" - #"") -((query-value pgc "select $1 = any ($2)" 1 (list 1 2 3)) - ((3) - 0 - () - 0 - () - () - (c - exn - c - "query-value: cannot convert given value to SQL type\n given: 1\n type: string\n dialect: PostgreSQL")) - #"" - #"") -((query-value c "select NULL") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) - 0 - () - () - (c values c (0))) - #"" - #"") -((sql-null->false "apple") ((3) 0 () 0 () () (c values c "apple")) #"" #"") -((sql-null->false sql-null) ((3) 0 () 0 () () (c values c #f)) #"" #"") -((sql-null->false #f) ((3) 0 () 0 () () (c values c #f)) #"" #"") -((false->sql-null "apple") ((3) 0 () 0 () () (c values c "apple")) #"" #"") -((false->sql-null #f) - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) - 0 - () - () - (c values c (0))) - #"" - #"") -((query-value pgc "select date '25-dec-1980'") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-date-v0)) - 0 - () - () - (c values c (0 1980 12 25))) - #"" - #"") -((query-value pgc "select time '7:30'") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-time-v0)) - 0 - () - () - (c values c (0 7 30 0 0 #f))) - #"" - #"") -((query-value pgc "select timestamp 'epoch'") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") - . - deserialize-info:sql-timestamp-v0)) - 0 - () - () - (c values c (0 1970 1 1 0 0 0 0 #f))) - #"" - #"") -((query-value pgc "select timestamp with time zone 'epoch'") - ((3) - 1 - (((lib "db/private/generic/sql-data.rkt") - . - deserialize-info:sql-timestamp-v0)) - 0 - () - () - (c values c (0 1969 12 31 19 0 0 0 -18000))) - #"" - #"") -((sql-bits->list (string->sql-bits "1011")) - ((3) 0 () 0 () () (c values c (c #t c #f c #t c #t))) - #"" - #"") -((sql-bits->string (query-value pgc "select B'010110111'")) - ((3) 0 () 0 () () (c values c (u . "010110111"))) - #"" - #"") -((sql-datetime->srfi-date (query-value pgc "select time '7:30'")) - ((3) - 1 - (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) - 0 - () - () - (c values c (0 0 0 30 7 0 0 0 0))) - #"" - #"") -((sql-datetime->srfi-date (query-value pgc "select date '25-dec-1980'")) - ((3) - 1 - (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) - 0 - () - () - (c values c (0 0 0 0 0 25 12 1980 0))) - #"" - #"") -((sql-datetime->srfi-date (query-value pgc "select timestamp 'epoch'")) - ((3) - 1 - (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) - 0 - () - () - (c values c (0 0 0 0 0 1 1 1970 0))) - #"" - #"") diff --git a/collects/db/scribblings/log-for-connect.rktd b/collects/db/scribblings/log-for-connect.rktd new file mode 100644 index 0000000000..8a3a82171e --- /dev/null +++ b/collects/db/scribblings/log-for-connect.rktd @@ -0,0 +1,82 @@ +;; This file was created by make-log-based-eval +((require racket/class db db/util/postgresql db/util/datetime) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((begin + (define pgc (dsn-connect 'db-scribble-env)) + (query-exec + pgc + "create temporary table the_numbers (n integer, d varchar(20))") + (query-exec pgc "insert into the_numbers values (0, 'nothing')") + (query-exec + pgc + "insert into the_numbers values (1, 'the loneliest number')") + (query-exec pgc "insert into the_numbers values (2, 'company')") + (query-exec pgc "insert into the_numbers values (3, 'a crowd')")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((define pool + (connection-pool + (lambda () + (displayln "connecting!") + (sqlite3-connect #:database 'memory)))) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((define c1 (connection-pool-lease pool)) + ((3) 0 () 0 () () (c values c (void))) + #"connecting!\n" + #"") +((define c2 (connection-pool-lease pool)) + ((3) 0 () 0 () () (c values c (void))) + #"connecting!\n" + #"") +((disconnect c1) ((3) 0 () 0 () () (c values c (void))) #"" #"") +((define c3 (connection-pool-lease pool)) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((define c + (virtual-connection + (lambda () (printf "connecting!\n") (dsn-connect 'db-scribble-env)))) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((connected? c) ((3) 0 () 0 () () (c values c #f)) #"" #"") +((query-value c "select 1") + ((3) 0 () 0 () () (c values c 1)) + #"connecting!\n" + #"") +((connected? c) ((3) 0 () 0 () () (c values c #t)) #"" #"") +((void (thread (lambda () (displayln (query-value c "select 2"))))) + ((3) 0 () 0 () () (c values c (void))) + #"connecting!\n2\n" + #"") +((disconnect c) ((3) 0 () 0 () () (c values c (void))) #"" #"") +((connected? c) ((3) 0 () 0 () () (c values c #f)) #"" #"") +((query-value c "select 3") + ((3) 0 () 0 () () (c values c 3)) + #"connecting!\n" + #"") +((prepare c "select 2 + $1") + ((3) + 0 + () + 0 + () + () + (c exn c "prepare: cannot prepare statement with virtual connection")) + #"" + #"") +((query-value c "select 2 + $1" 2) ((3) 0 () 0 () () (c values c 4)) #"" #"") +((define pst (virtual-statement "select 2 + $1")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-value c pst 3) ((3) 0 () 0 () () (c values c 5)) #"" #"") +((begin (set! c #f) (set! pst #f)) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") diff --git a/collects/db/scribblings/log-for-query.rktd b/collects/db/scribblings/log-for-query.rktd new file mode 100644 index 0000000000..e79a0be26c --- /dev/null +++ b/collects/db/scribblings/log-for-query.rktd @@ -0,0 +1,282 @@ +;; This file was created by make-log-based-eval +((require racket/class db db/util/postgresql db/util/datetime) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((begin + (define pgc (dsn-connect 'db-scribble-env)) + (query-exec + pgc + "create temporary table the_numbers (n integer, d varchar(20))") + (query-exec pgc "insert into the_numbers values (0, 'nothing')") + (query-exec + pgc + "insert into the_numbers values (1, 'the loneliest number')") + (query-exec pgc "insert into the_numbers values (2, 'company')") + (query-exec pgc "insert into the_numbers values (3, 'a crowd')")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((define c pgc) ((3) 0 () 0 () () (c values c (void))) #"" #"") +((query-exec pgc "insert into the_numbers values (42, 'the answer')") + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-exec pgc "delete from the_numbers where n = $1" 42) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-rows pgc "select * from the_numbers where n = $1" 2) + ((3) 0 () 0 () () (c values c (c (v! 2 (u . "company"))))) + #"" + #"") +((query-rows c "select 17") + ((3) 0 () 0 () () (c values c (c (v! 17)))) + #"" + #"") +((query-list c "select n from the_numbers where n < 2") + ((3) 0 () 0 () () (c values c (c 0 c 1))) + #"" + #"") +((query-list c "select 'hello'") + ((3) 0 () 0 () () (c values c (c (u . "hello")))) + #"" + #"") +((query-row pgc "select * from the_numbers where n = $1" 2) + ((3) 0 () 0 () () (c values c (v! 2 (u . "company")))) + #"" + #"") +((query-row pgc "select min(n), max(n) from the_numbers") + ((3) 0 () 0 () () (c values c (v! 0 3))) + #"" + #"") +((query-maybe-row pgc "select * from the_numbers where n = $1" 100) + ((3) 0 () 0 () () (c values c #f)) + #"" + #"") +((query-maybe-row c "select 17") + ((3) 0 () 0 () () (c values c (v! 17))) + #"" + #"") +((query-value pgc "select timestamp 'epoch'") + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") + . + deserialize-info:sql-timestamp-v0)) + 0 + () + () + (c values c (0 1970 1 1 0 0 0 0 #f))) + #"" + #"") +((query-value pgc "select d from the_numbers where n = $1" 3) + ((3) 0 () 0 () () (c values c (u . "a crowd"))) + #"" + #"") +((query-maybe-value pgc "select d from the_numbers where n = $1" 100) + ((3) 0 () 0 () () (c values c #f)) + #"" + #"") +((query-maybe-value c "select count(*) from the_numbers") + ((3) 0 () 0 () () (c values c 4)) + #"" + #"") +((for/list ((n (in-query pgc "select n from the_numbers where n < 2"))) n) + ((3) 0 () 0 () () (c values c (c 0 c 1))) + #"" + #"") +((call-with-transaction + pgc + (lambda () + (for + (((n d) + (in-query pgc "select * from the_numbers where n < $1" 4 #:fetch 1))) + (printf "~a: ~a\n" n d)))) + ((3) 0 () 0 () () (c values c (void))) + #"0: nothing\n1: the loneliest number\n2: company\n3: a crowd\n" + #"") +((for ((n (in-query pgc "select * from the_numbers"))) (displayln n)) + ((3) + 0 + () + 0 + () + () + (c + exn + c + "in-query: query returned wrong number of columns\n statement: \"select * from the_numbers\"\n expected: 1\n got: 2")) + #"" + #"") +((define vehicles-result + (rows-result + '(((name . "type")) ((name . "maker")) ((name . "model"))) + `(#("car" "honda" "civic") + #("car" "ford" "focus") + #("car" "ford" "pinto") + #("bike" "giant" "boulder") + #("bike" "schwinn" ,sql-null)))) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((group-rows vehicles-result #:group '(#("type"))) + ((3) + 2 + (((lib "db/private/generic/interfaces.rkt") + . + deserialize-info:rows-result-v0) + ((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) + 1 + ("ford") + () + (c + values + c + (0 + (c + (c (c name . "type")) + c + (c + (c name . "grouped") + c + (c grouped c (c (c name . "maker")) c (c (c name . "model"))))) + (c + (v! + "car" + (c (v! "honda" "civic") c (v! (? . 0) "focus") c (v! (? . 0) "pinto"))) + c + (v! "bike" (c (v! "giant" "boulder") c (v! "schwinn" (1)))))))) + #"" + #"") +((group-rows + vehicles-result + #:group + '(#("type") #("maker")) + #:group-mode + '(list)) + ((3) + 1 + (((lib "db/private/generic/interfaces.rkt") + . + deserialize-info:rows-result-v0)) + 1 + ((c name . "grouped")) + () + (c + values + c + (0 + (c + (c (c name . "type")) + c + (c + (? . 0) + c + (c + grouped + c + (c (c name . "maker")) + c + (c (? . 0) c (c grouped c (c (c name . "model"))))))) + (c + (v! + "car" + (c (v! "honda" (c "civic")) c (v! "ford" (c "focus" c "pinto")))) + c + (v! "bike" (c (v! "giant" (c "boulder")) c (v! "schwinn" ()))))))) + #"" + #"") +((rows->dict vehicles-result #:key "model" #:value '#("type" "maker")) + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) + 3 + ("car" "ford" "bike") + () + (c + values + c + (h + - + (equal) + ((0) v! (? . 2) "schwinn") + ("civic" v! (? . 0) "honda") + ("pinto" v! (? . 0) (? . 1)) + ("focus" v! (? . 0) (? . 1)) + ("boulder" v! (? . 2) "giant")))) + #"" + #"") +((rows->dict + vehicles-result + #:key + "maker" + #:value + "model" + #:value-mode + '(list)) + ((3) + 0 + () + 0 + () + () + (c + values + c + (h + - + (equal) + ("ford" c "focus" c "pinto") + ("honda" c "civic") + ("giant" c "boulder") + ("schwinn")))) + #"" + #"") +((let* ((get-name-pst (prepare pgc "select d from the_numbers where n = $1")) + (get-name2 (bind-prepared-statement get-name-pst (list 2))) + (get-name3 (bind-prepared-statement get-name-pst (list 3)))) + (list (query-value pgc get-name2) (query-value pgc get-name3))) + ((3) 0 () 0 () () (c values c (c (u . "company") c (u . "a crowd")))) + #"" + #"") +((define pst + (virtual-statement + (lambda (dbsys) + (case (dbsystem-name dbsys) + ((postgresql) "select n from the_numbers where n < $1") + ((sqlite3) "select n from the_numbers where n < ?") + (else (error "unknown system")))))) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-list pgc pst 3) ((3) 0 () 0 () () (c values c (c 0 c 1 c 2))) #"" #"") +((query-list pgc pst 3) ((3) 0 () 0 () () (c values c (c 0 c 1 c 2))) #"" #"") +((with-handlers + ((exn:fail:sql? exn:fail:sql-info)) + (query pgc "select * from nosuchtable")) + ((3) + 0 + () + 0 + () + () + (c + values + c + (c + (c severity u . "ERROR") + c + (c code u . "42P01") + c + (c message u . "relation \"nosuchtable\" does not exist") + c + (c position u . "15") + c + (c file u . "parse_relation.c") + c + (c line u . "857") + c + (c routine u . "parserOpenTable")))) + #"" + #"") diff --git a/collects/db/scribblings/log-for-sql-types.rktd b/collects/db/scribblings/log-for-sql-types.rktd new file mode 100644 index 0000000000..cdf92400f0 --- /dev/null +++ b/collects/db/scribblings/log-for-sql-types.rktd @@ -0,0 +1,155 @@ +;; This file was created by make-log-based-eval +((require racket/class db db/util/postgresql db/util/datetime) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((begin + (define pgc (dsn-connect 'db-scribble-env)) + (query-exec + pgc + "create temporary table the_numbers (n integer, d varchar(20))") + (query-exec pgc "insert into the_numbers values (0, 'nothing')") + (query-exec + pgc + "insert into the_numbers values (1, 'the loneliest number')") + (query-exec pgc "insert into the_numbers values (2, 'company')") + (query-exec pgc "insert into the_numbers values (3, 'a crowd')")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-value pgc "select count(*) from the_numbers") + ((3) 0 () 0 () () (c values c 4)) + #"" + #"") +((query-value pgc "select false") ((3) 0 () 0 () () (c values c #f)) #"" #"") +((query-value pgc "select 1 + $1" 2) ((3) 0 () 0 () () (c values c 3)) #"" #"") +((query-value pgc "select inet '127.0.0.1'") + ((3) + 0 + () + 0 + () + () + (c exn c "query-value: unsupported type\n type: inet\n typeid: 869")) + #"" + #"") +((query-value pgc "select cast(inet '127.0.0.1' as varchar)") + ((3) 0 () 0 () () (c values c (u . "127.0.0.1/32"))) + #"" + #"") +((query-value pgc "select real '+Infinity'") + ((3) 0 () 0 () () (c values c +inf.0)) + #"" + #"") +((query-value pgc "select numeric '12345678901234567890'") + ((3) 0 () 0 () () (c values c 12345678901234567890)) + #"" + #"") +((query-value pgc "select 1 in (1, 2, 3)") + ((3) 0 () 0 () () (c values c #t)) + #"" + #"") +((query-value + pgc + "select 1 = any ($1::integer[])" + (list->pg-array (list 1 2 3))) + ((3) 0 () 0 () () (c values c #t)) + #"" + #"") +((query-value pgc "select 1 = any ($1)" (list 1 2 3)) + ((3) 0 () 0 () () (c values c #t)) + #"" + #"") +((query-value pgc "select $1::integer = any ($2)" 1 (list 1 2 3)) + ((3) 0 () 0 () () (c values c #t)) + #"" + #"") +((query-value pgc "select $1 = any ($2)" 1 (list 1 2 3)) + ((3) + 0 + () + 0 + () + () + (c + exn + c + "query-value: cannot convert given value to SQL type\n given: 1\n type: string\n dialect: PostgreSQL")) + #"" + #"") +((query-value c "select NULL") + ((3) + 0 + () + 0 + () + () + (c exn c "c: undefined;\n cannot reference undefined identifier")) + #"" + #"") +((sql-null->false "apple") ((3) 0 () 0 () () (c values c "apple")) #"" #"") +((sql-null->false sql-null) ((3) 0 () 0 () () (c values c #f)) #"" #"") +((sql-null->false #f) ((3) 0 () 0 () () (c values c #f)) #"" #"") +((false->sql-null "apple") ((3) 0 () 0 () () (c values c "apple")) #"" #"") +((false->sql-null #f) + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-null-v0)) + 0 + () + () + (c values c (0))) + #"" + #"") +((query-value pgc "select date '25-dec-1980'") + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-date-v0)) + 0 + () + () + (c values c (0 1980 12 25))) + #"" + #"") +((query-value pgc "select time '7:30'") + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") . deserialize-info:sql-time-v0)) + 0 + () + () + (c values c (0 7 30 0 0 #f))) + #"" + #"") +((query-value pgc "select timestamp 'epoch'") + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") + . + deserialize-info:sql-timestamp-v0)) + 0 + () + () + (c values c (0 1970 1 1 0 0 0 0 #f))) + #"" + #"") +((query-value pgc "select timestamp with time zone 'epoch'") + ((3) + 1 + (((lib "db/private/generic/sql-data.rkt") + . + deserialize-info:sql-timestamp-v0)) + 0 + () + () + (c values c (0 1969 12 31 19 0 0 0 -18000))) + #"" + #"") +((sql-bits->list (string->sql-bits "1011")) + ((3) 0 () 0 () () (c values c (c #t c #f c #t c #t))) + #"" + #"") +((sql-bits->string (query-value pgc "select B'010110111'")) + ((3) 0 () 0 () () (c values c (u . "010110111"))) + #"" + #"") diff --git a/collects/db/scribblings/log-for-using-db.rktd b/collects/db/scribblings/log-for-using-db.rktd new file mode 100644 index 0000000000..98905077f9 --- /dev/null +++ b/collects/db/scribblings/log-for-using-db.rktd @@ -0,0 +1,172 @@ +;; This file was created by make-log-based-eval +((require racket/class db db/util/postgresql db/util/datetime) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((require db) ((3) 0 () 0 () () (c values c (void))) #"" #"") +((define pgc (dsn-connect 'db-scribble-env)) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-exec + pgc + "create temporary table the_numbers (n integer, d varchar(20))") + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-exec pgc "insert into the_numbers values (0, 'nothing')") + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-exec pgc "insert into the_numbers values (1, 'the loneliest number')") + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-exec pgc "insert into the_numbers values (2, 'company')") + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query pgc "insert into the_numbers values (3, 'a crowd')") + ((3) + 1 + (((lib "db/private/generic/interfaces.rkt") + . + deserialize-info:simple-result-v0)) + 0 + () + () + (c values c (0 (c (c command u . "INSERT 0 1"))))) + #"" + #"") +((query pgc "select n, d from the_numbers where n % 2 = 0") + ((3) + 1 + (((lib "db/private/generic/interfaces.rkt") + . + deserialize-info:rows-result-v0)) + 0 + () + () + (c + values + c + (0 + (c + (c + (c name u . "n") + c + (c typeid . 23) + c + (c type-size . 4) + c + (c type-mod . -1)) + c + (c + (c name u . "d") + c + (c typeid . 1043) + c + (c type-size . -1) + c + (c type-mod . 24))) + (c (v! 0 (u . "nothing")) c (v! 2 (u . "company")))))) + #"" + #"") +((query-rows pgc "select n, d from the_numbers where n % 2 = 0") + ((3) + 0 + () + 0 + () + () + (c values c (c (v! 0 (u . "nothing")) c (v! 2 (u . "company"))))) + #"" + #"") +((query-row pgc "select * from the_numbers where n = 0") + ((3) 0 () 0 () () (c values c (v! 0 (u . "nothing")))) + #"" + #"") +((query-list pgc "select d from the_numbers order by n") + ((3) + 0 + () + 0 + () + () + (c + values + c + (c + (u . "nothing") + c + (u . "the loneliest number") + c + (u . "company") + c + (u . "a crowd")))) + #"" + #"") +((query-value pgc "select count(*) from the_numbers") + ((3) 0 () 0 () () (c values c 4)) + #"" + #"") +((query-value pgc "select d from the_numbers where n = 5") + ((3) + 0 + () + 0 + () + () + (c + exn + c + "query-value: query returned wrong number of rows\n statement: \"select d from the_numbers where n = 5\"\n expected: 1\n got: 0")) + #"" + #"") +((query-maybe-value pgc "select d from the_numbers where n = 5") + ((3) 0 () 0 () () (c values c #f)) + #"" + #"") +((for + (((n d) (in-query pgc "select * from the_numbers where n < 4"))) + (printf "~a: ~a\n" n d)) + ((3) 0 () 0 () () (c values c (void))) + #"0: nothing\n1: the loneliest number\n2: company\n3: a crowd\n" + #"") +((for/fold + ((sum 0)) + ((n (in-query pgc "select n from the_numbers"))) + (+ sum n)) + ((3) 0 () 0 () () (c values c 6)) + #"" + #"") +((begin + (with-handlers + ((exn:fail? (lambda (e) (printf "~a~n" (exn-message e))))) + (query-value pgc "select NoSuchField from NoSuchTable")) + (query-value pgc "select 'okay to proceed!'")) + ((3) 0 () 0 () () (c values c (u . "okay to proceed!"))) + #"query-value: relation \"nosuchtable\" does not exist\n SQLSTATE: 42P01\n" + #"") +((query-value pgc "select d from the_numbers where n = $1" 2) + ((3) 0 () 0 () () (c values c (u . "company"))) + #"" + #"") +((query-list pgc "select n from the_numbers where n > $1 and n < $2" 0 3) + ((3) 0 () 0 () () (c values c (c 1 c 2))) + #"" + #"") +((define get-less-than-pst + (prepare pgc "select n from the_numbers where n < $1")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((query-list pgc get-less-than-pst 1) + ((3) 0 () 0 () () (c values c (c 0))) + #"" + #"") +((query-list pgc (bind-prepared-statement get-less-than-pst '(2))) + ((3) 0 () 0 () () (c values c (c 0 c 1))) + #"" + #"") +((void) ((3) 0 () 0 () () (c values c (void))) #"" #"") diff --git a/collects/db/scribblings/log-for-util.rktd b/collects/db/scribblings/log-for-util.rktd new file mode 100644 index 0000000000..eedc717858 --- /dev/null +++ b/collects/db/scribblings/log-for-util.rktd @@ -0,0 +1,49 @@ +;; This file was created by make-log-based-eval +((require racket/class db db/util/postgresql db/util/datetime) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((begin + (define pgc (dsn-connect 'db-scribble-env)) + (query-exec + pgc + "create temporary table the_numbers (n integer, d varchar(20))") + (query-exec pgc "insert into the_numbers values (0, 'nothing')") + (query-exec + pgc + "insert into the_numbers values (1, 'the loneliest number')") + (query-exec pgc "insert into the_numbers values (2, 'company')") + (query-exec pgc "insert into the_numbers values (3, 'a crowd')")) + ((3) 0 () 0 () () (c values c (void))) + #"" + #"") +((sql-datetime->srfi-date (query-value pgc "select time '7:30'")) + ((3) + 1 + (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) + 0 + () + () + (c values c (0 0 0 30 7 0 0 0 0))) + #"" + #"") +((sql-datetime->srfi-date (query-value pgc "select date '25-dec-1980'")) + ((3) + 1 + (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) + 0 + () + () + (c values c (0 0 0 0 0 25 12 1980 0))) + #"" + #"") +((sql-datetime->srfi-date (query-value pgc "select timestamp 'epoch'")) + ((3) + 1 + (((lib "srfi/19/time.rkt") . deserialize-info:tm:date-v0)) + 0 + () + () + (c values c (0 0 0 0 0 1 1 1970 0))) + #"" + #"") diff --git a/collects/db/scribblings/query.scrbl b/collects/db/scribblings/query.scrbl index 272a928d5f..97f280d3a9 100644 --- a/collects/db/scribblings/query.scrbl +++ b/collects/db/scribblings/query.scrbl @@ -3,10 +3,14 @@ scribble/eval scribble/struct racket/sandbox + racket/runtime-path "config.rkt" "tabbing.rkt" (for-label db db/util/geometry db/util/postgresql racket/dict)) +@(define-runtime-path log-file "log-for-query.rktd") +@(define the-eval (make-pg-eval log-file #t)) + @;{ c - misc connection (alias to pgc) myc - MySQL connection (???) slc - SQLite connection (???) @@ -791,3 +795,6 @@ A struct type property for creating new kinds of statements. The property value is applied to the struct instance and a connection, and it must return a @tech{statement}. } + + +@(close-eval the-eval) diff --git a/collects/db/scribblings/sql-types.scrbl b/collects/db/scribblings/sql-types.scrbl index 06b6ed2a62..a1922e1289 100644 --- a/collects/db/scribblings/sql-types.scrbl +++ b/collects/db/scribblings/sql-types.scrbl @@ -3,11 +3,15 @@ scribble/eval scribble/struct racket/sandbox + racket/runtime-path "config.rkt" "tabbing.rkt" (for-label (prefix-in srfi: srfi/19) db db/util/geometry db/util/postgresql)) +@(define-runtime-path log-file "log-for-sql-types.rktd") +@(define the-eval (make-pg-eval log-file #t)) + @title[#:tag "sql-types"]{SQL Types and Conversions} @declare-exporting[db db/base #:use-sources (db/base)] @@ -535,3 +539,6 @@ represented by sql-bits values. (sql-bits->string (query-value pgc "select B'010110111'")) ] } + + +@(close-eval the-eval) diff --git a/collects/db/scribblings/using-db.scrbl b/collects/db/scribblings/using-db.scrbl index 89ed619f1e..927651a20d 100644 --- a/collects/db/scribblings/using-db.scrbl +++ b/collects/db/scribblings/using-db.scrbl @@ -3,9 +3,13 @@ scribble/eval scribble/struct racket/sandbox + racket/runtime-path "config.rkt" (for-label db db/util/testing racket/dict web-server/lang/web)) +@(define-runtime-path log-file "log-for-using-db.rktd") +@(define the-eval (make-pg-eval log-file #f)) + @title[#:tag "using-db"]{Using Database Connections} This section introduces this library's basic features and covers some @@ -39,6 +43,8 @@ configuration (see @secref{creating-connections} for other connection examples): Use @racket[query-exec] method to execute a SQL statement for effect. +@;{ Keep these examples in sync with config.rkt } + @interaction[#:eval the-eval (query-exec pgc "create temporary table the_numbers (n integer, d varchar(20))") @@ -448,3 +454,6 @@ web-server By using a virtual connection backed by a connection pool, a servlet can achieve simplicity, isolation, and performance all at the same time. + + +@(close-eval the-eval) diff --git a/collects/db/scribblings/util.scrbl b/collects/db/scribblings/util.scrbl index 84091adf20..bc19d138b2 100644 --- a/collects/db/scribblings/util.scrbl +++ b/collects/db/scribblings/util.scrbl @@ -3,9 +3,13 @@ scribble/eval scribble/struct racket/sandbox + racket/runtime-path "config.rkt" (for-label db db/util/datetime db/util/geometry db/util/postgresql db/util/testing)) +@(define-runtime-path log-file "log-for-util.rktd") +@(define the-eval (make-pg-eval log-file #t)) + @title[#:tag "util"]{Utilities} The bindings described in this section are provided by the specific @@ -230,3 +234,5 @@ call (see @secref["ffi-concurrency"]). Even so, it may not accurately simulate an ODBC connection that internally uses cursors to fetch data on demand, as each fetch would introduce additional latency. } + +@(close-eval the-eval)