PostgreSQL(0.0.39) – new features

Several new API calls have been wrapped and lots of bugs have been fixed.

New API calls – Encoding
Some API calls have been wrapped to get/set information about the current connection client encoding style.

MSKPSQLInterface>>currentClientEncodingString: anID
This method returns a string (e.h. “UTF8”) describing the internal PostgreSQL encoding id “anID”. Its a helper method, which is used by the class PGConn.

This method returns the internal encoding id for the current connection

This method returns a textual representation of the internal encoding id for the current connection

New API calls – Escaping
Some API calls have been wrapped to help creating correct string for sql command.

PGConn>>escapeString: aString
This method returns a correct escaped string

PGConn>>escapeByteArray: aByteArray
This method returns a correct escaped byte array

New API calls – Asynchronous command execution
Some API calls have been wrapped execute multiple SQL-commands with ONE server call.

PGConn>>sendQuery: cmdString
This method sends a SQL command to the server. The SQL command may consist out of several commands

Helper method to manage incoming data from the server

Helper method to check, if the server is still executing some commands

And here an example how to use it …

  | aPGResult sqlCommandString resultCounter result abort|

  sqlCommandString := 'INSERT into weather (city, prcp) values(''Hamburg'',12.6);INSERT into weather (city, prcp) values(''Berlin'',13.2);INSERT into weather (city, prcp) values(''Bremen'',32.1)'.

  dbConnection sendQuery: sqlCommandString.

  resultCounter := 0.

  abort := false.
  [ abort ] whileFalse:[
    dbConnection consumesInput.
    dbConnection isBusy
      ifTrue:[ (Delay forMilliseconds: 100) wait ]
        result :=  dbConnection getResult.
	result isNil
	  ifTrue:[ abort := true	 ]
            resultCounter := resultCounter + 1.
            result clear

   self assert: (resultCounter = 3).
This entry was posted in Smalltalk and tagged . Bookmark the permalink.