postgresql and strings
Aleksandar Bakic <a_bakic-/[email protected]> Thu, 17 Nov 2005 16:39:30 -0800 (PST)
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
PostgreSQL 7.4.9 documentation states:
Table 8-4. Character Types
Name Description
character varying(n), varchar(n) variable-length with limit
character(n), char(n) fixed-length, blank padded
text variable unlimited length
In file sql/generic-postgresql.lisp, there is this code:
(defmethod database-get-type-specifier ((type (eql 'string)) args database
(db-type (eql :postgresql)))
(declare (ignore database))
(if args
(format nil "CHAR(~A)" (car args))
"VARCHAR"))
as well as
(defun clsql-type->postgresql-type (type)
(cond
((in type :int :integer) "INT4")
((in type :short) "INT2")
((in type :bigint) "INT8")
((in type :float :double :number) "NUMERIC")
((and (consp type) (in (car type) :char :varchar)) "VARCHAR")
(t
(error 'sql-user-error
:message
(format nil "Unknown clsql type ~A." type)))))
Notice that :string is missing, whereas in file fdml.lisp, there is this code:
(defun prepare-sql (sql-stmt types &key (database *default-database*)
(result-types :auto) field-names)
"Prepares a SQL statement for execution. TYPES contains a
list of types corresponding to the input parameters. Returns a
prepared-statement object.
A type can be
:int
:double
:null
(:blob n)
(:string n)
"
(unless (db-type-has-prepared-stmt? (database-type database))
(error 'sql-user-error
:message
(format nil
"Database backend type ~:@(~A~) does not support prepared
statements."
(database-type database))))
(database-prepare sql-stmt types database result-types field-names))
I haven't used prepared statements with arguments, so I can't tell how this
code behaves exactly when (string N) is used (which I use a lot but do not like
the fact that lots of space is used for padding; so I'd switch to varchar(N)).
Overal, the postgresql string support seems broken to me. Does anyone know more
about this?
Thanks,
Alex
PS. I think just "varchar" works, though.
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com