X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8B06CD1B4AD for ; Fri, 9 Jan 2004 18:46:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 57608-05 for ; Fri, 9 Jan 2004 14:46:03 -0400 (AST) Received: from curie.credativ.org (credativ.com [217.160.209.18]) by svr1.postgresql.org (Postfix) with ESMTP id B61D8D1B481 for ; Fri, 9 Jan 2004 14:46:02 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by curie.credativ.org (Postfix) with ESMTP id E33BC56243 for ; Fri, 9 Jan 2004 19:46:02 +0100 (CET) Received: from colt.pezone.net (dsl-213-023-254-001.arcor-ip.net [213.23.254.1]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by curie.credativ.org (Postfix) with ESMTP id 46BC75623C for ; Fri, 9 Jan 2004 19:46:02 +0100 (CET) From: Peter Eisentraut To: pgsql-hackers@postgresql.org Subject: Encoding problems in PostgreSQL with XML data Date: Fri, 9 Jan 2004 19:46:01 +0100 User-Agent: KMail/1.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401091946.01930.peter_e@gmx.net> X-Virus-Scanned: by AMaViS at credativ.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/211 X-Sequence-Number: 48935 This is not directly related to current development, but it is something that might need a low-level solution. I've been thinking for some time about how to enchance the current "XML support" (e.g., contrib/xml). The central problem I have is this: How do we deal with the fact that an XML datum carries its own encoding information? Here's a scenario: It is desirable to have validity checking on XML input, be it a special XML data type or some functions that take XML data. Say we define a data type that stores XML documents and rejects documents that are not well-formed. I want to insert something in psql: CREATE TABLE test ( description text, content xml ); INSERT INTO test VALUES ('test document', 'blah...'); Now an XML parser will assume this document to be in UTF-8, and say at the client it is. What if client_encoding=UNICODE but server_encoding=LATIN1? Do we expect some layer to rewrite the declaration to contain the correct encoding information? Or can the xml type bypass encoding conversion? What about reading it back out of the database with yet another client encoding? Rewriting the declaration seems like a workable solution, but it would break the transparency of the client/server encoding conversion. Also, some people might dislike that their documents are being changed as they are stored. Any ideas?