2011-10-21 15:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbziparc/ziparc.prg
    + added support for HB_UNZIPFILE() lWithPath parameter
    ! fixed HB_UNZIPFILE() after latest patch and added better error checking
    ! fixed setting attribs
    ; Patch by Grigory Filatov, with these changes of mine:
      * deleted changes to existing code and replaced it with optimizated code
      * deleted reformatting of existing code
      ! fixed adding ending pathsep
      * minor simplification
    ! fixed RTE when using progress bar (from Leandro's new patch)
    ; Please test

  - contrib/hbpgsql/tests/hdbctest.prg
    - deleted HDBC/PGSQL tests
This commit is contained in:
Viktor Szakats
2011-10-21 13:49:12 +00:00
parent bc87124922
commit 02dbec40b8
3 changed files with 35 additions and 215 deletions

View File

@@ -16,6 +16,22 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-10-21 15:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbziparc/ziparc.prg
+ added support for HB_UNZIPFILE() lWithPath parameter
! fixed HB_UNZIPFILE() after latest patch and added better error checking
! fixed setting attribs
; Patch by Grigory Filatov, with these changes of mine:
* deleted changes to existing code and replaced it with optimizated code
* deleted reformatting of existing code
! fixed adding ending pathsep
* minor simplification
! fixed RTE when using progress bar (from Leandro's new patch)
; Please test
- contrib/hbpgsql/tests/hdbctest.prg
- deleted HDBC/PGSQL tests
2011-10-21 12:34 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/gtwvt/gtwvt.c
! fixed infinite recursive loops and GPF in WinCE builds caused by

View File

@@ -1,200 +0,0 @@
/*
* $Id$
*/
#include "common.ch"
PROCEDURE Main( cHost, cDatabase, cUser, cPass )
LOCAL oConn, oMeta, oStmt, cSql, n, oRs
oConn := hdbcPGConnection():New( cHost, cDatabase, cUser, cPass )
oMeta := oConn:getMetaData()
? hb_ValToExp( oMeta:getTables() )
IF AScan( oMeta:getTables(), { | a | "test" == a[ 3 ] } ) > 0
? "test table already exist let's drop it"
oStmt := oConn:createStatement()
oStmt:executeUpdate( "DROP TABLE test" )
oStmt:Close()
? "dropped"
ENDIF
? 'Creating test table...'
cSql := 'CREATE TABLE test('
cSql += ' Code integer not null primary key, '
cSql += ' dept Integer, '
cSql += ' Name Varchar(40), '
cSql += ' Sales boolean, '
cSql += ' Tax Float4, '
cSql += ' Salary Double Precision, '
cSql += ' Budget Numeric(12,2), '
cSql += ' Discount Numeric (5,2), '
cSql += ' Creation Date, '
cSql += ' Description text ) '
oStmt := oConn:createStatement()
oStmt:executeUpdate( cSql )
oStmt:Close()
? "created"
? 'Inserting, declared transaction control '
oConn:StartTransaction()
? "Inserting using direct statement..."
#define _NUMROWS_ 10
? Time()
FOR n := 1 TO _NUMROWS_
cSql := "INSERT INTO test(code, dept, name, sales, tax, salary, budget, Discount, Creation, Description) "
cSql += "VALUES( " + str( n ) + ", 2, 'TEST', '" + iif( n % 2 != 0, "y", "n" ) + "', 5, 3000, 1500.2, 7.5, '12-22-2003', 'Short Description ')"
oStmt := oConn:createStatement()
oStmt:executeUpdate( cSql )
oStmt:close()
NEXT
? Time()
/*
? "Creating prepared statement"
? Time()
oStmt := oConn:prepareStatement( "INSERT INTO test(code, dept, name, sales, tax, salary, budget, Discount, Creation, Description) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 )")
FOR n := _NUMROWS_ + 1 TO _NUMROWS_ * 2
oStmt:SetNumber( 1, n )
oStmt:SetNumber( 2, 2 )
oStmt:SetString( 3, "TEST" )
oStmt:SetBoolean( 4, iif( n % 2 != 0, .T., .F. ) )
oStmt:SetNumber( 5, 5 )
oStmt:SetNumber( 6, 3000 )
oStmt:SetNumber( 7, 1500 )
oStmt:SetNumber( 8, 7.5 )
oStmt:SetDate( 9, Date() )
oStmt:SetString( 10, "Short' Description" )
oStmt:executeUpdate()
NEXT
oStmt:close()
? Time()
*/
oConn:Commit()
oStmt := oConn:createStatement()
? "Excecuting query"
oRs := oStmt:executeQuery( "SELECT code, name, description, sales FROM test" )
? "Showing metadata"
? oRs:getMetaData():getColumnCount()
? "Showing results"
? "nRows", oRs:nRows
? "getrow", oRs:getRow()
? "isbeforefirst", oRs:isBeforeFirst()
? "next", oRs:next()
? "isfirst", oRs:isFirst()
? "getrow", oRs:getRow()
? "previous", oRs:previous()
? "getrow", oRs:getRow()
? "first", oRs:first()
? "getrow", oRs:getRow()
? "last", oRs:last()
? "getrow", oRs:getRow()
? "isbeforefirst", oRs:isBeforeFirst()
oRs:beforeFirst()
? "ascending"
DO WHILE oRs:next()
? oRs:getrow(), oRs:getString( "code" ), oRs:getString( "name" ), oRs:getString( "description" ), oRs:getBoolean( "sales" )
ENDDO
? "isafterlast", oRs:isAfterLast()
oRs:AfterLast()
? "descending"
DO WHILE oRs:previous()
? oRs:getrow(), oRs:getString( "code" ), oRs:getString( "name" ), oRs:getString( "description" ), oRs:getBoolean( "sales" )
ENDDO
? "isbeforefirst", oRs:isBeforeFirst()
oRs:Close()
oStmt:Close()
? hb_ValToExp( oConn:getMetaData():getPrimaryKeys( "", "public", "test" ) )
oStmt := oConn:createStatement()
? "Excecuting query"
oRs := oStmt:executeQuery( "SELECT * FROM test" )
oRs:setTableName( "TEST" )
oRs:setPrimaryKeys( { { "code", "N" } } )
oRs:moveToInsertRow()
oRs:updateNumber( 1, 11 )
oRs:updateString( "description", "Inserted" )
oRs:insertRow()
oRs:first()
oRs:updateNumber( 8, 99.99 )
oRs:updateDate( 9, date() )
oRs:updateString( "description", "Updated" )
oRs:updateRow()
oRs:next()
oRs:deleteRow()
oRs:next()
oRs:deleteRow()
oRs:Close()
oRs := oStmt:executeQuery( "SELECT * FROM test order by code" )
DO WHILE oRs:next()
? oRs:getrow(), oRs:getString( "code" ), oRs:getString( "name" ), oRs:getString( "description" ), oRs:getBoolean( "sales" ), oRs:getString( "Creation" )
ENDDO
oRs:close()
oStmt:close()
/*
? "Creating query prepared statement"
oStmt := oConn:prepareStatement( "SELECT code FROM test WHERE name = $1" )
oStmt:SetString( 1, "TEST" )
oStmt:executeQuery()
? oRs:getMetaData():getColumnCount()
? oRs:getMetaData():getColumnName( 1 )
?
DO WHILE oRs:next()
FOR n := 1 TO 1
? oRs:getString( n )
next
ENDDO
oStmt:close()
*/
oConn:Close()
? "Closing..."
RETURN

View File

@@ -421,8 +421,11 @@ FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles,
DEFAULT lWithPath TO .F.
/* TODO: Implement. */
HB_SYMBOL_UNUSED( lWithPath )
IF lWithPath
IF hb_DirCreate( cPath ) != 0
lRetVal := .F.
ENDIF
ENDIF
IF Empty( cPassword )
cPassword := NIL
@@ -446,6 +449,9 @@ FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles,
hb_FNameSplit( cFileName, @cPath )
ENDIF
cPath := hb_DirAddPathSep( cPath )
nRead := 0
nPos := 0
nErr := hb_UnzipFileFirst( hUnzip )
DO WHILE nErr == 0
@@ -455,19 +461,16 @@ FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles,
IF hb_UnzipFileInfo( hUnzip, @cZipName, @dDate, @cTime, , , , @nSize ) == 0
/* NOTE: As opposed to original hbziparch we don't do a second match without path. */
IF !Empty( acFiles )
IF AScan( acFiles, nPos ) > 0 .OR. ;
AScan( acFiles, {| cMask | hb_FileMatch( cZipName, cMask ) } ) > 0
lExtract := .T.
ELSE
lExtract := .F.
ENDIF
ELSE
lExtract := .T.
ENDIF
lExtract := Empty( acFiles ) .OR. ;
AScan( acFiles, nPos ) > 0 .OR. ;
AScan( acFiles, {| cMask | hb_FileMatch( cZipName, cMask ) } ) > 0
IF lExtract
hHandle := FCreate( cPath + cZipName )
IF lExtract .AND. ;
( hHandle := FCreate( cPath + cZipName ) ) != F_ERROR
IF hb_UnzipFileOpen( hUnzip, cPassword ) != UNZ_OK
EXIT
ENDIF
DO WHILE ( nLen := hb_unZipFileRead( hUnzip, @cBuffer, Len( cBuffer ) ) ) > 0
IF hb_isBlock( bProgress )
nRead += nLen
@@ -475,8 +478,9 @@ FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles,
ENDIF
FWrite( hHandle, cBuffer, nLen )
ENDDO
hb_UnzipFileClose( hUnzip )
FClose( hHandle )
hb_FSetDateTime( cZipName, dDate, cTime )
hb_FSetDateTime( cPath + cZipName, dDate, cTime )
IF hb_isBlock( bUpdate )
Eval( bUpdate, cZipName, nPos )
ENDIF