converters/test-vector.ss
#lang scheme

(require 
 (prefix-in psql: "psql.ss")
 (prefix-in vector: "vector.ss")
 (prefix-in general: "general.ss")
 "engine.ss")

; to generate this table, I used psql and for instance:
; SELECT encode(numeric_send(15.0::numeric(7,5)),'hex');
; thanks to a tip from RhodiumToad

(define casts
  `())

(require "codec-check.ss")

(general:set-info! (get-engine))
;(numeric:set-info! (get-engine))

(define (apply-values l) (apply values l))

(define (introspect)
  (let-values ([(input output) (psql:generate)])
    (let loop ([oids (send (get-engine) get-oids)])
      (if (null? oids) (void)
          (let ([oid (car oids)])
            (display (format "select oid,typlen from pg_type where typelem = ~a;" oid) output)
            ((compose 
              (λ (parent-oid length)
                (vector:set-info!
                 (string->number parent-oid)
                 oid
                 (if (equal? length "-1") #f
                     (string->number length))
                 (get-engine))
                (display (format "oid ~s poid ~s len ~s~n" oid parent-oid length)))
              apply-values) (read input))
            (loop (cdr oids)))))
    (close-input-port input)
    (close-output-port output)))