diff --git a/ChangeLog.txt b/ChangeLog.txt index c63b1ad984..dd4eb39c37 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,7 +7,19 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ -2021-03-31 20:37 UTC+0200 Aleksander Czajczynski (hb fki.pl) +2021-04-10 23:32 UTC+0200 Aleksander Czajczynski (hb fki.pl) + * contrib/hbfbird/firebird.c + + added optional as 7-th parameter of FBCREATEDB( , + , , , [, ] ) + Based on request and example code from Ivanil Marcelino (#240) + + * contrib/hbpgsql/tpostgre.prg + % var assignment readability + + * ChangeLog.txt + ! corrected wrong date in prev entry + +2021-04-02 20:37 UTC+0200 Aleksander Czajczynski (hb fki.pl) * contrib/hbpgsql/tpostgre.prg ! reverted previous commit 2021-04-01 15:55 UTC-0300 as invalid together with a little cleanup plus another minor cleanup diff --git a/contrib/hbfbird/firebird.c b/contrib/hbfbird/firebird.c index 72719b4a54..1e735a0024 100644 --- a/contrib/hbfbird/firebird.c +++ b/contrib/hbfbird/firebird.c @@ -114,7 +114,7 @@ static isc_db_handle hb_FB_db_handle_par( int iParam ) HB_FUNC( FBCREATEDB ) { - if( hb_pcount() == 6 ) + if( hb_pcount() >= 6 ) { isc_db_handle newdb = ( isc_db_handle ) 0; isc_tr_handle trans = ( isc_tr_handle ) 0; @@ -127,10 +127,11 @@ HB_FUNC( FBCREATEDB ) int page = hb_parni( 4 ); const char * charset = hb_parcx( 5 ); unsigned short dialect = ( unsigned short ) hb_parni( 6 ); + const char * collate = hb_parcx( 7 ); hb_snprintf( create_db, sizeof( create_db ), - "CREATE DATABASE '%s' USER '%s' PASSWORD '%s' PAGE_SIZE = %i DEFAULT CHARACTER SET %s", - db_name, user, pass, page, charset ); + "CREATE DATABASE '%s' USER '%s' PASSWORD '%s' PAGE_SIZE = %i DEFAULT CHARACTER SET %s%s%s", + db_name, user, pass, page, charset, ( hb_parclen( 7 ) > 0 ? " COLLATION " : collate ), collate ); if( isc_dsql_execute_immediate( status, &newdb, &trans, 0, create_db, dialect, NULL ) ) hb_retnl( isc_sqlcode( status ) ); diff --git a/contrib/hbpgsql/tpostgre.prg b/contrib/hbpgsql/tpostgre.prg index 6cb3f60304..f1e49fa053 100644 --- a/contrib/hbpgsql/tpostgre.prg +++ b/contrib/hbpgsql/tpostgre.prg @@ -156,7 +156,7 @@ METHOD StartTransaction() CLASS TPQserver LOCAL res := PQexec( ::pDB, "BEGIN" ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -168,7 +168,7 @@ METHOD Commit() CLASS TPQserver LOCAL res := PQexec( ::pDB, "COMMIT" ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -180,7 +180,7 @@ METHOD Rollback() CLASS TPQserver LOCAL res := PQexec( ::pDB, "ROLLBACK" ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -205,7 +205,7 @@ METHOD TableExists( cTable ) CLASS TPQserver " FROM information_schema.tables" + ; " WHERE table_type = 'BASE TABLE' AND table_schema = " + DataToSql( ::Schema ) + " AND table_name = " + DataToSql( Lower( cTable ) ) ) - IF ( ::lError := PQresultStatus( res ) != PGRES_TUPLES_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_TUPLES_OK ) ::cError := PQresultErrorMessage( res ) result := .F. ELSE @@ -225,7 +225,7 @@ METHOD ListTables() CLASS TPQserver " FROM information_schema.tables" + ; " WHERE table_schema = " + DataToSql( ::Schema ) + " AND table_type = 'BASE TABLE'" ) - IF ( ::lError := PQresultStatus( res ) != PGRES_TUPLES_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_TUPLES_OK ) ::cError := PQresultErrorMessage( res ) ELSE FOR i := 1 TO PQlastrec( res ) @@ -251,7 +251,7 @@ METHOD TableStruct( cTable ) CLASS TPQserver " WHERE table_schema = " + DataToSql( ::Schema ) + " AND table_name = " + DataToSql( Lower( cTable ) ) + ; " ORDER BY ordinal_position" ) - IF ( ::lError := PQresultStatus( res ) != PGRES_TUPLES_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_TUPLES_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -400,7 +400,7 @@ METHOD CreateTable( cTable, aStruct ) CLASS TPQserver res := PQexec( ::pDB, cQuery ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -412,7 +412,7 @@ METHOD DeleteTable( cTable ) CLASS TPQserver LOCAL res := PQexec( ::pDB, "DROP TABLE " + ::Schema + "." + cTable ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -696,7 +696,7 @@ METHOD Refresh( lQuery, lMeta ) CLASS TPQquery ::lEof := .F. ENDIF - ELSEIF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + ELSEIF ::lError := ( ::nResultStatus != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ELSE ::cError := "" @@ -858,7 +858,7 @@ METHOD Delete( oRow ) CLASS TPQquery res := PQexecParams( ::pDB, ; "DELETE FROM " + ::Schema + "." + ::Tablename + " WHERE " + cWhere, aParams ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ::rows := 0 ELSE @@ -917,7 +917,7 @@ METHOD Append( oRow ) CLASS TPQquery IF lChanged res := PQexecParams( ::pDB, cQuery, aParams ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ::rows := 0 ELSE @@ -984,7 +984,7 @@ METHOD Update( oRow ) CLASS TPQquery res := PQexecParams( ::pDB, cQuery, aParams ) - IF ( ::lError := PQresultStatus( res ) != PGRES_COMMAND_OK ) + IF ::lError := ( PQresultStatus( res ) != PGRES_COMMAND_OK ) ::cError := PQresultErrorMessage( res ) ::rows := 0 ELSE