Re: Database->ServerEncoding, ClientEncoding

From: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
To: "'jm(dot)poure(at)freesurf(dot)fr'" <jm(dot)poure(at)freesurf(dot)fr>
Cc: pgadmin-hackers(at)postgresql(dot)org
Subject: Re: Database->ServerEncoding, ClientEncoding
Date: 2002-02-26 08:46:37
Message-ID: FED2B709E3270E4B903EB0175A49BCB1047612@dogbert.vale-housing.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

> -----Original Message-----
> From: Jean-Michel POURE [mailto:jm(dot)poure(at)freesurf(dot)fr]
> Sent: 25 February 2002 21:07
> To: Dave Page
> Cc: pgadmin-hackers(at)postgresql(dot)org
> Subject: Re: [pgadmin-hackers] Database->ServerEncoding,
> ClientEncoding
>
>
> Hi Dave,
>
> 1) We need two client encodings :
> - one for querying system object,
> - another for displaying data.
>
> > DataEncodingID (Long)
> > DataEncodingName (String)
> The encoding used to display data.
> In my example, UTF-8 to export data, Latin1 otherwize.
>
> > SystemEncodingID (Long)
> > SystemEncodingName (String)
> The encoding used to program schema objects, in my case
> Latin1. "System" because this term is used in pgServerExecSQL.
>
> Example : my database is UTF-8:
> - Latin1 objects,
> - Japanese data.
>
> 2) I hacked pgServerExecSQL like this :
> >As I said in my previous message, we can only set it once for each
> database, otherwise it will become unpredictable as you jump
> from window to window.
>
> 'Get the Query Type and set client encoding
> szClientEncoding = "SQL_ASCII"
> SQL_Encoding = ""
>
> If (QryType And qrySystem) = qrySystem Then
> szQueryType = "System"
> szClientEncoding =
> objServer.Databases(Database).SystemEncodingName
> ElseIf (QryType And qryData) = qryData Then
> szQueryType = "Data"
> szClientEncoding = objServer.Databases(Database).DataEncodingName
> ElseIf (QryType And qryUser) = qryUser Then
> szQueryType = "User"
> szClientEncoding = "SQL_ASCII"
> End If
>
> If szClientEncoding <> "" Then
> SQL_Encoding = "SET CLIENT_ENCODING = '" &
> szClientEncoding & "'; "
> End If
>
> RaiseEvent SQLExecute(SQL, Connection)
> objServer.iLogEvent "SQL (" &
> GetDatabase(Connection.ConnectionString) &
> "): " & SQL, etSQL
> Set ExecSQL = Connection.Execute(SQL_Encoding & SQL)
>
> What do you think?

I forgot I added the query types (that was a recent change to support the
session recorder). Something like that will probably do it, yes. From a
sensible user interface point of view, you could select the system encoding
when logging on (that would be server-wide - would that be a problem), and
the data/user encoding from the SQL window, but default to the system
encoding if a different selection has never been made.

Thoughts?

/D

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dave Page 2002-02-26 08:53:36 Renaming Sequences & Indexes...
Previous Message Dave Page 2002-02-26 08:40:48 Re: fake vs real CREATE OR REPLACE VIEW