Store + Encoding Question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Store + Encoding Question

Andres Fortier-2
Hi list,
         I've been playing around to add Spanish character support on
linux. The added behaviour on Locale>>installESLocale is:

copy := locale copy.
copy name: #'es_AR.UTF-8'.
copy defaultStreamEncoder: (StreamEncoder lookupEncoderDirectory: #'utf-8').
copy needsInputMethod: true.
self addLocale: copy platform: #unix.

After reinstalling the locales I can successfully type accented
characters. Now, when I try to connect to store I get "not enough
elements available". After trying to debug it turns out that the problem
starts in: PostgreSQLMessage>>readFrom: aStream for: aConnectionContext
in the first line:

ByteValue size: 1 readFrom: aStream for: aConnectionContext

Now the weird thing begins:
1. I add a breakpoint in that line.
2. Launch the store connection.
3. The debugger opens.
4. Press F9.
5. The client now connects to store (?!)

If I disconnect, remove the breakpoint and try to connect again, I get
the previously mentioned error. Does anybody have a clue on how opening
the debugger can affect on the connection? I'm attaching a stack of the
full error.

Any help would be appreciated.

Thanks in advance,
                  Andrés

optimized [] in Store.DBAccess>>connectTo:
IncompleteNextCountError(GenericException)>>performHandler:
IncompleteNextCountError(GenericException)>>propagatePrivateFrom:
IncompleteNextCountError(GenericException)>>propagateFrom:
IncompleteNextCountError(GenericException)>>propagate
IncompleteNextCountError(GenericException)>>raiseRequest
optimized [] in [] in Stream>>next:into:startingAt:
BlockClosure>>on:do:
EncodedStream(Stream)>>next:into:startingAt:
EncodedStream(Stream)>>next:
ByteValue(FixedSizeValue)>>size:readFrom:for:
ByteValue class(FixedSizeValue class)>>size:readFrom:for:
PostgreSQLMessage class>>readFrom:for:
PostgreSQLMessageReadStream>>nextInTheContextOf:
PostgreSQLMessageReadStream>>next
PostgreSQLStartupMessageFlow>>initiate
PostgreSQLConnection>>startup
PostgreSQLConnection class>>using:
PostgreSQLEXDIConnection>>acquireExternal
PostgreSQLEXDIConnection>>acquireExternal:
PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>acquire:
PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>connect:
optimized [] in Store.DBAccess>>connectTo:
BlockClosure>>on:do:
Store.DBAccess>>connectTo:
optimized [] in Store.MiniRepositoryManager>>connectTo:
BlockClosure>>ensure:
Cursor>>showWhile:
Store.MiniRepositoryManager>>connectTo:
optimized [] in
Store.MiniRepositoryManager>>createConnectOrDisconnectItemFor:
ControllerWithSelectMenu(ControllerWithMenu)>>dispatchMenuSelection:
ControllerWithSelectMenu(ControllerWithMenu)>>processMenu:at:centered:
ControllerWithSelectMenu>>redButtonPressedEvent:
RedButtonPressedEvent>>dispatchTo:
ControllerWithSelectMenu(ControllerWithMenu)>>handleEvent:
EventDispatcher>>dispatch:to:
EventDispatcher>>dispatchEvent:
RedButtonPressedEvent(Event)>>dispatch
RedButtonPressedEvent(Event)>>dispatchForWindowManager:
optimized [] in WindowManager>>safelyDispatchForWindowManager:
BlockClosure>>on:do:
WindowManager>>safelyDispatchForWindowManager:
WindowManager>>processNextEvent
optimized [] in [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in Process class>>forBlock:priority:

--
Saludos,
         Andrés

Reply | Threaded
Open this post in threaded view
|

Re: Store + Encoding Question

Alan Knight-2
The Postgresql connection will by default use #default as its encoding, so it is likely having problems trying to read strings that it doesn't understand. I think you would need to
  - change the stringEncodingName variable of the underlying PostgresqlConnection. Sending #encoding to the PostgresqlEXDIConnection object should do it.
  - Tell postgresql what you think you're using by sending
     SET CLIENT_ENCODING UNICODE
(or UTF-8, but older versions of Postgrseql called it unicode, and I forget exactly how they spell utf-8 now, and unicode should still work)

That doesn't explain the debugger issue though - and I confess mystified on that one.

At 11:05 AM 9/14/2007, Andres Fortier wrote:
Hi list,
        I've been playing around to add Spanish character support on linux. The added behaviour on Locale>>installESLocale is:

copy := locale copy.
copy name: #'es_AR.UTF-8'.
copy defaultStreamEncoder: (StreamEncoder lookupEncoderDirectory: #'utf-8').
copy needsInputMethod: true.
self addLocale: copy platform: #unix.

After reinstalling the locales I can successfully type accented characters. Now, when I try to connect to store I get "not enough elements available". After trying to debug it turns out that the problem starts in: PostgreSQLMessage>>readFrom: aStream for: aConnectionContext in the first line:

ByteValue size: 1 readFrom: aStream for: aConnectionContext

Now the weird thing begins:
1. I add a breakpoint in that line.
2. Launch the store connection.
3. The debugger opens.
4. Press F9.
5. The client now connects to store (?!)

If I disconnect, remove the breakpoint and try to connect again, I get the previously mentioned error. Does anybody have a clue on how opening the debugger can affect on the connection? I'm attaching a stack of the full error.

Any help would be appreciated.

Thanks in advance,
                   Andrés

optimized [] in Store.DBAccess>>connectTo:
IncompleteNextCountError(GenericException)>>performHandler:
IncompleteNextCountError(GenericException)>>propagatePrivateFrom:
IncompleteNextCountError(GenericException)>>propagateFrom:
IncompleteNextCountError(GenericException)>>propagate
IncompleteNextCountError(GenericException)>>raiseRequest
optimized [] in [] in Stream>>next:into:startingAt:
BlockClosure>>on:do:
EncodedStream(Stream)>>next:into:startingAt:
EncodedStream(Stream)>>next:
ByteValue(FixedSizeValue)>>size:readFrom:for:
ByteValue class(FixedSizeValue class)>>size:readFrom:for:
PostgreSQLMessage class>>readFrom:for:
PostgreSQLMessageReadStream>>nextInTheContextOf:
PostgreSQLMessageReadStream>>next
PostgreSQLStartupMessageFlow>>initiate
PostgreSQLConnection>>startup
PostgreSQLConnection class>>using:
PostgreSQLEXDIConnection>>acquireExternal
PostgreSQLEXDIConnection>>acquireExternal:
PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>acquire:
PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>connect:
optimized [] in Store.DBAccess>>connectTo:
BlockClosure>>on:do:
Store.DBAccess>>connectTo:
optimized [] in Store.MiniRepositoryManager>>connectTo:
BlockClosure>>ensure:
Cursor>>showWhile:
Store.MiniRepositoryManager>>connectTo:
optimized [] in Store.MiniRepositoryManager>>createConnectOrDisconnectItemFor:
ControllerWithSelectMenu(ControllerWithMenu)>>dispatchMenuSelection:
ControllerWithSelectMenu(ControllerWithMenu)>>processMenu:at:centered:
ControllerWithSelectMenu>>redButtonPressedEvent:
RedButtonPressedEvent>>dispatchTo:
ControllerWithSelectMenu(ControllerWithMenu)>>handleEvent:
EventDispatcher>>dispatch:to:
EventDispatcher>>dispatchEvent:
RedButtonPressedEvent(Event)>>dispatch
RedButtonPressedEvent(Event)>>dispatchForWindowManager:
optimized [] in WindowManager>>safelyDispatchForWindowManager:
BlockClosure>>on:do:
WindowManager>>safelyDispatchForWindowManager:
WindowManager>>processNextEvent
optimized [] in [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in WindowManager>>newProcess
BlockClosure>>on:do:
optimized [] in Process class>>forBlock:priority:

--
Saludos,
        Andrés

--
Alan Knight [|], Cincom Smalltalk Development
Reply | Threaded
Open this post in threaded view
|

Re: Store + Encoding Question

Andres Fortier-2
Alan,
      thanks for the response! As a quick hack I added the following line:
newConnection stringEncodingName: #'UTF-8'

to change the encoding when the connection is created in
PostgresqlConnection>>using:

| newConnection |

newConnection := self new using: aParameterSet.
self addConnection: newConnection.

newConnection stringEncodingName: #'UTF-8'.

newConnection startup.
^newConnection

(I use the encoding name from the PostgreSQLTest - test33).
Unfortunately I'm getting the same results as before,
weird-debugger-behaviour included. I also try adding a:

newConnection executeQuery: 'set client_encoding to ''UNICODE'';'.

to mimic the test33 in PostgreSQLTest, but without any luck either. I
also tried to run the tests in PostgreSQLTest and they throw the exact
same error. If you have any other idea what it might I'll be glad to try
it out.

Thanks again,
             Andrés



Alan Knight escribió:

> The Postgresql connection will by default use #default as its encoding, so it is likely having problems trying to read strings that it doesn't understand. I think you would need to
>   - change the stringEncodingName variable of the underlying PostgresqlConnection. Sending #encoding to the PostgresqlEXDIConnection object should do it.
>   - Tell postgresql what you think you're using by sending
>      SET CLIENT_ENCODING UNICODE
> (or UTF-8, but older versions of Postgrseql called it unicode, and I forget exactly how they spell utf-8 now, and unicode should still work)
>
> That doesn't explain the debugger issue though - and I confess mystified on that one.
>
> At 11:05 AM 9/14/2007, Andres Fortier wrote:
>> Hi list,
>>        I've been playing around to add Spanish character support on linux. The added behaviour on Locale>>installESLocale is:
>>
>> copy := locale copy.
>> copy name: #'es_AR.UTF-8'.
>> copy defaultStreamEncoder: (StreamEncoder lookupEncoderDirectory: #'utf-8').
>> copy needsInputMethod: true.
>> self addLocale: copy platform: #unix.
>>
>> After reinstalling the locales I can successfully type accented characters. Now, when I try to connect to store I get "not enough elements available". After trying to debug it turns out that the problem starts in: PostgreSQLMessage>>readFrom: aStream for: aConnectionContext in the first line:
>>
>> ByteValue size: 1 readFrom: aStream for: aConnectionContext
>>
>> Now the weird thing begins:
>> 1. I add a breakpoint in that line.
>> 2. Launch the store connection.
>> 3. The debugger opens.
>> 4. Press F9.
>> 5. The client now connects to store (?!)
>>
>> If I disconnect, remove the breakpoint and try to connect again, I get the previously mentioned error. Does anybody have a clue on how opening the debugger can affect on the connection? I'm attaching a stack of the full error.
>>
>> Any help would be appreciated.
>>
>> Thanks in advance,
>>                  Andrés
>>
>> optimized [] in Store.DBAccess>>connectTo:
>> IncompleteNextCountError(GenericException)>>performHandler:
>> IncompleteNextCountError(GenericException)>>propagatePrivateFrom:
>> IncompleteNextCountError(GenericException)>>propagateFrom:
>> IncompleteNextCountError(GenericException)>>propagate
>> IncompleteNextCountError(GenericException)>>raiseRequest
>> optimized [] in [] in Stream>>next:into:startingAt:
>> BlockClosure>>on:do:
>> EncodedStream(Stream)>>next:into:startingAt:
>> EncodedStream(Stream)>>next:
>> ByteValue(FixedSizeValue)>>size:readFrom:for:
>> ByteValue class(FixedSizeValue class)>>size:readFrom:for:
>> PostgreSQLMessage class>>readFrom:for:
>> PostgreSQLMessageReadStream>>nextInTheContextOf:
>> PostgreSQLMessageReadStream>>next
>> PostgreSQLStartupMessageFlow>>initiate
>> PostgreSQLConnection>>startup
>> PostgreSQLConnection class>>using:
>> PostgreSQLEXDIConnection>>acquireExternal
>> PostgreSQLEXDIConnection>>acquireExternal:
>> PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>acquire:
>> PostgreSQLEXDIConnection(ExternalDatabaseConnection)>>connect:
>> optimized [] in Store.DBAccess>>connectTo:
>> BlockClosure>>on:do:
>> Store.DBAccess>>connectTo:
>> optimized [] in Store.MiniRepositoryManager>>connectTo:
>> BlockClosure>>ensure:
>> Cursor>>showWhile:
>> Store.MiniRepositoryManager>>connectTo:
>> optimized [] in Store.MiniRepositoryManager>>createConnectOrDisconnectItemFor:
>> ControllerWithSelectMenu(ControllerWithMenu)>>dispatchMenuSelection:
>> ControllerWithSelectMenu(ControllerWithMenu)>>processMenu:at:centered:
>> ControllerWithSelectMenu>>redButtonPressedEvent:
>> RedButtonPressedEvent>>dispatchTo:
>> ControllerWithSelectMenu(ControllerWithMenu)>>handleEvent:
>> EventDispatcher>>dispatch:to:
>> EventDispatcher>>dispatchEvent:
>> RedButtonPressedEvent(Event)>>dispatch
>> RedButtonPressedEvent(Event)>>dispatchForWindowManager:
>> optimized [] in WindowManager>>safelyDispatchForWindowManager:
>> BlockClosure>>on:do:
>> WindowManager>>safelyDispatchForWindowManager:
>> WindowManager>>processNextEvent
>> optimized [] in [] in WindowManager>>newProcess
>> BlockClosure>>on:do:
>> optimized [] in WindowManager>>newProcess
>> BlockClosure>>on:do:
>> optimized [] in Process class>>forBlock:priority:
>>
>> --
>> Saludos,
>>        Andrés
>
> --
> Alan Knight [|], Cincom Smalltalk Development
> [hidden email]
> [hidden email]
> http://www.cincom.com/smalltalk
>