From 4ac8303faedf1ff127dd1610821c9aac0de74fdc Mon Sep 17 00:00:00 2001 From: Kevin Rosenberg Date: Sun, 7 Feb 2010 02:50:17 -0700 Subject: [PATCH] Version 5.0.0: International character sets support First release of CLSQL to formally and consistently support non-ASCII strings with encoding of external formats for SQL strings. UFFI version 1.8.1 is higher is required. This change may introduce some differences in string handling for people who are using non-ASCII encoded characters. Thus, because of the risk of BACKWARD INCOMPATIBILITY, the major version number was incremented with this release. --- ChangeLog | 12 +++++++++++- db-mysql/mysql-sql.lisp | 14 ++++---------- debian/changelog | 6 ++++++ tests/test-i18n.lisp | 4 ++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index d00e9db..0c26481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-02-06 Kevin Rosenberg + * Version 5.0.0: First release of CLSQL to formally and + consistently support non-ASCII strings with encoding of external + formats for SQL strings. UFFI version 1.8.1 is higher is required. + + This change may introduce some differences in string handling for + people who are using non-ASCII encoded characters. Thus, because + of the risk of BACKWARD INCOMPATIBILITY, the major version number + was incremented with this release. + 2010-02-06 Kevin Rosenberg * tests/test-i18n.lisp: Bind UFFI:*DEFAULT-EXTERNAL-FORMAT* for testing multibyte encodings. @@ -14,7 +24,7 @@ testing on postgres. 2010-02-05 Kevin Rosenberg - * clsql-test.asd, tests/{test-i18n,test-init}.lisp: + * clsql-test.asd, tests/{test-i18n,test-init}.lisp: Load test-i18n.lisp and use its tests as long as 'uffi:no-i18n is not present in cl:*features*. This requires UFFI 1.7.2 or above. diff --git a/db-mysql/mysql-sql.lisp b/db-mysql/mysql-sql.lisp index 0ca15cf..4bf3543 100644 --- a/db-mysql/mysql-sql.lisp +++ b/db-mysql/mysql-sql.lisp @@ -6,7 +6,7 @@ ;;;; Purpose: High-level MySQL interface using UFFI ;;;; Date Started: Feb 2002 ;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002-2009 by Kevin M. Rosenberg +;;;; This file, part of CLSQL, is Copyright (c) 2002-2010 by Kevin M. Rosenberg ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License @@ -20,12 +20,6 @@ (in-package #:clsql-mysql) -;; if we have :sb-unicode, UFFI will treat :cstring as a UTF-8 string -(defun expression-length (query-expression) - (length #+sb-unicode (sb-ext:string-to-octets query-expression - :external-format :utf8) - #-sb-unicode query-expression)) - ;;; Field conversion functions (defun result-field-names (res-ptr) @@ -165,7 +159,7 @@ :mysql-ptr mysql-ptr)) (cmd "SET SESSION sql_mode='ANSI'")) (uffi:with-cstring (cmd-cs cmd) - (if (zerop (mysql-real-query mysql-ptr cmd-cs (expression-length cmd))) + (if (zerop (mysql-real-query mysql-ptr cmd-cs (uffi:foreign-encoded-string-octets cmd))) db (progn (warn "Error setting ANSI mode for MySQL.") @@ -183,7 +177,7 @@ (let ((mysql-ptr (database-mysql-ptr database))) (declare (type mysql-mysql-ptr-def mysql-ptr)) (if (zerop (mysql-real-query mysql-ptr sql-native - (expression-length sql-expression))) + (uffi:foreign-encoded-string-octets sql-expression))) t (error 'sql-database-data-error :database database @@ -515,7 +509,7 @@ :message (mysql-error-string mysql-ptr))) (uffi:with-cstring (native-query sql-stmt) - (unless (zerop (mysql-stmt-prepare stmt native-query (expression-length sql-stmt))) + (unless (zerop (mysql-stmt-prepare stmt native-query (uffi:foreign-encoded-string-octets sql-stmt))) (mysql-stmt-close stmt) (error 'sql-database-error :error-id (mysql-errno mysql-ptr) diff --git a/debian/changelog b/debian/changelog index 691689f..758f2ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (5.0.0-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 07 Feb 2010 02:48:20 -0700 + cl-sql (4.3.3-1) unstable; urgency=low * New upstream diff --git a/tests/test-i18n.lisp b/tests/test-i18n.lisp index 4a6cf67..92aa8d0 100644 --- a/tests/test-i18n.lisp +++ b/tests/test-i18n.lisp @@ -23,7 +23,7 @@ ;;; UTF-8 for example can handle these easily. ;; I show this as a 20char string and 27 bytes in utf-8 (deftest :basic/i18n/1 - (let ((uffi:*default-external-format* :utf-8)) + (let ((uffi:*default-foreign-encoding* :utf-8)) (first (query "SELECT 'Iñtërnâtiônàlizætiøn'" :flatp t :field-names nil))) "Iñtërnâtiônàlizætiøn") @@ -31,7 +31,7 @@ ;; the z in this one is even stronger ;; I show this as a 20char string and 28 bytes in utf-8 (deftest :basic/i18n/2 - (let ((uffi:*default-external-format* :utf-8)) + (let ((uffi:*default-foreign-encoding* :utf-8)) (first (query "SELECT 'Iñtërnâtiônàližætiøn'" :flatp t :field-names nil))) "Iñtërnâtiônàližætiøn") -- 2.34.1