2010-02-02 21:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbpgsql/postgres.c
+ Added GC support for all remaining pointer types (result/cancel/FILE).
+ Added RTE when wrong pointer or wrong number of parameter is passed
to functions.
This means that behavior is now INCOMPATIBLE when wrong parameters
are encountered in these functions.
; Destructor functions PQFREECANCEL(), PQCLOSE(), PQCLEAR() marked
as 'deprecated'.
These are not needed, it's enough to assign NIL to their holder
variables on .prg level.
% Cleanups along the way.
; TODO: Fix sloppy parameter checking which only check number of
parameters instead of enforcing expected type.
; Please test.
* contrib/hbpgsql/tests/async.prg
* contrib/hbpgsql/tests/test.prg
* contrib/hbpgsql/tests/cache.prg
* contrib/hbpgsql/tests/stress.prg
% Replaced deprecated destructor functions with '<var> := NIL'.
* utils/hbmk2/hbmk2.prg
* Formatting.
This commit is contained in:
@@ -17,6 +17,31 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-02 21:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbpgsql/postgres.c
|
||||
+ Added GC support for all remaining pointer types (result/cancel/FILE).
|
||||
+ Added RTE when wrong pointer or wrong number of parameter is passed
|
||||
to functions.
|
||||
This means that behavior is now INCOMPATIBLE when wrong parameters
|
||||
are encountered in these functions.
|
||||
; Destructor functions PQFREECANCEL(), PQCLOSE(), PQCLEAR() marked
|
||||
as 'deprecated'.
|
||||
These are not needed, it's enough to assign NIL to their holder
|
||||
variables on .prg level.
|
||||
% Cleanups along the way.
|
||||
; TODO: Fix sloppy parameter checking which only check number of
|
||||
parameters instead of enforcing expected type.
|
||||
; Please test.
|
||||
|
||||
* contrib/hbpgsql/tests/async.prg
|
||||
* contrib/hbpgsql/tests/test.prg
|
||||
* contrib/hbpgsql/tests/cache.prg
|
||||
* contrib/hbpgsql/tests/stress.prg
|
||||
% Replaced deprecated destructor functions with '<var> := NIL'.
|
||||
|
||||
* utils/hbmk2/hbmk2.prg
|
||||
* Formatting.
|
||||
|
||||
2010-02-02 17:58 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/rtl/direct.c
|
||||
! do not strip other attributes when "V" is set - it's neither
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* This sample show howto use asynchronous/nonblocking queries
|
||||
@@ -7,66 +7,63 @@
|
||||
|
||||
Function Main( cServer, cDatabase, cUser, cPass )
|
||||
Local conn
|
||||
|
||||
CLEAR SCREEN
|
||||
|
||||
? "Connect", conn := PQConnect( cDatabase, cServer, cUser, cPass, 5432)
|
||||
|
||||
? "Conection status", PQerrorMessage(conn), PQstatus(conn)
|
||||
|
||||
Query( conn, 'SELECT codigo, descri FROM client limit 100', .f. )
|
||||
Query( conn, 'SELECT codigo, descri FROM fornec limit 100', .f. )
|
||||
Query( conn, 'SELECT pedido, vlrped FROM pedido', .t. )
|
||||
|
||||
PQclose(conn)
|
||||
CLEAR SCREEN
|
||||
|
||||
? "Connect", conn := PQConnect( cDatabase, cServer, cUser, cPass, 5432)
|
||||
|
||||
? "Conection status", PQerrorMessage(conn), PQstatus(conn)
|
||||
|
||||
Query( conn, 'SELECT codigo, descri FROM client limit 100', .f. )
|
||||
Query( conn, 'SELECT codigo, descri FROM fornec limit 100', .f. )
|
||||
Query( conn, 'SELECT pedido, vlrped FROM pedido', .t. )
|
||||
|
||||
conn := NIL
|
||||
|
||||
return nil
|
||||
|
||||
Procedure Query( conn, cQuery, lCancel )
|
||||
Procedure Query( conn, cQuery, lCancel )
|
||||
Local pCancel, cErrMsg := space(30)
|
||||
Local res, x, y, xTime
|
||||
|
||||
|
||||
? "PQSendQuery", PQsendQuery(conn, cQuery)
|
||||
|
||||
xTime := time()
|
||||
CLEAR TYPEAHEAD
|
||||
|
||||
|
||||
do while inkey() != 27
|
||||
DevPos(Row(), 20)
|
||||
DevOut("Processing: " + Elaptime(xtime, time()))
|
||||
|
||||
inkey(1)
|
||||
|
||||
|
||||
if lCancel
|
||||
if .t.
|
||||
pCancel := PQgetCancel(conn)
|
||||
? "Canceled: ", PQcancel( pCancel, @cErrMsg ), cErrMsg
|
||||
PQfreeCancel(pCancel)
|
||||
|
||||
else
|
||||
pCancel := NIL
|
||||
else
|
||||
? PQrequestCancel(conn) // Deprecated
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
if PQconsumeInput(conn)
|
||||
if ! PQisBusy(conn)
|
||||
exit
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
|
||||
endif
|
||||
endif
|
||||
enddo
|
||||
|
||||
if inkey() != 27
|
||||
? "PQgetResult", hb_valtoexp(res := PQgetResult(conn))
|
||||
|
||||
|
||||
for x := 1 to PQlastrec(res)
|
||||
?
|
||||
?
|
||||
for y := 1 to PQfcount(res)
|
||||
?? PQgetvalue(res, x, y), " "
|
||||
next
|
||||
next
|
||||
next
|
||||
|
||||
PQclear(res)
|
||||
else
|
||||
else
|
||||
? "Canceling Query", PQrequestCancel(conn)
|
||||
endif
|
||||
Return
|
||||
|
||||
@@ -570,7 +570,6 @@ Function QuickQuery( cQuery )
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
PQclear(pQuery)
|
||||
Return result
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
? 'Dropping table...'
|
||||
|
||||
res := PQexec(conn, 'DROP TABLE test')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
? 'Creating test table...'
|
||||
cQuery := 'CREATE TABLE test('
|
||||
@@ -44,13 +44,13 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
cQuery += ' Description text ) '
|
||||
|
||||
res := PQexec(conn, cQuery)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec(conn, 'SELECT code, dept, name, sales, salary, creation FROM test')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec(conn, 'BEGIN')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
For i := 1 to 10000
|
||||
@ 15,0 say 'Inserting values....' + str(i)
|
||||
@@ -59,14 +59,14 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
cQuery += 'VALUES( ' + str(i) + ',' + str(i+1) + ", 'DEPARTMENT NAME " + strzero(i) + "', 'y', " + str(300.49+i) + ", '2003-12-28' )"
|
||||
|
||||
res := PQexec(conn, cQuery)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
if mod(i,100) == 0
|
||||
? res := PQexec(conn, 'COMMIT')
|
||||
? PQclear(res)
|
||||
? res := NIL
|
||||
|
||||
? res := PQexec(conn, 'BEGIN')
|
||||
? PQclear(res)
|
||||
? res := NIL
|
||||
endif
|
||||
Next
|
||||
|
||||
@@ -75,14 +75,14 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
|
||||
cQuery := 'DELETE FROM test WHERE code = ' + str(i)
|
||||
res := PQexec(conn, cQuery)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
if mod(i,100) == 0
|
||||
res := PQexec(conn, 'COMMIT')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec(conn, 'BEGIN')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
endif
|
||||
Next
|
||||
|
||||
@@ -91,14 +91,14 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
|
||||
cQuery := 'UPDATE FROM test SET salary = 400 WHERE code = ' + str(i)
|
||||
res := PQexec(conn, cQuery)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
if mod(i,100) == 0
|
||||
res := PQexec(conn, 'COMMIT')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec(conn, 'BEGIN')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
endif
|
||||
Next
|
||||
|
||||
@@ -108,7 +108,7 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
@ 18,0 say 'Sum values....' + PQgetvalue(res, 1, 1)
|
||||
endif
|
||||
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
x := 0
|
||||
For i := 1 to 4000
|
||||
@@ -122,6 +122,6 @@ Function Main( cServer, cDatabase, cUser, cPass )
|
||||
Next
|
||||
|
||||
? "Closing..."
|
||||
PQclose(conn)
|
||||
conn := NIL
|
||||
|
||||
return nil
|
||||
|
||||
@@ -14,7 +14,7 @@ Function main()
|
||||
|
||||
conn := PQsetdbLogin( 'localhost', "5432", NIL, NIL, cDb, cUser, cPass)
|
||||
? PQdb(conn), PQuser(conn), PQpass(conn), PQhost(conn), PQport(conn), PQtty(conn), PQoptions(conn)
|
||||
? PQClose(conn)
|
||||
? conn := NIL
|
||||
|
||||
conn := PQConnect(cDb, 'localhost', cuser, cpass, 5432)
|
||||
|
||||
@@ -40,11 +40,11 @@ Function main()
|
||||
|
||||
res := PQexec('drop table products')
|
||||
? PQresultStatus(res), PQresultErrorMessage(res)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec('create table products ( product_no numeric(10), name varchar(20), price numeric(10,2) )')
|
||||
? PQresultStatus(res), PQresultErrorMessage(res)
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexecParams(conn, 'insert into products(product_no, name, price) values ($1, $2, $3)', {'2', 'bread', '10.95'})
|
||||
? "Oid Row: ", PQoidValue(res), PQoidStatus(res)
|
||||
@@ -52,7 +52,7 @@ Function main()
|
||||
if PQresultStatus(res) != PGRES_COMMAND_OK
|
||||
? PQresultStatus(res), PQresultErrorMessage(res)
|
||||
endif
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
res := PQexec(conn, 'select price, name, product_no as "produto" from products')
|
||||
|
||||
@@ -79,21 +79,21 @@ Function main()
|
||||
|
||||
? PQGetvalue(res,1, 2)
|
||||
|
||||
? PQclear(res)
|
||||
? res := NIL
|
||||
|
||||
? "Large Objects, always should be in a transaction..."
|
||||
|
||||
res := PQexec(conn, 'begin')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
? (x := lo_Import( conn, 'test.prg' ))
|
||||
? lo_Export( conn, x, 'test.new' )
|
||||
? lo_Unlink( conn, x )
|
||||
|
||||
res := PQexec(conn, 'commit')
|
||||
PQclear(res)
|
||||
res := NIL
|
||||
|
||||
PQuntrace( conn )
|
||||
PQclosetrace( pFile )
|
||||
PQClose(conn)
|
||||
return nil
|
||||
conn := NIL
|
||||
return NIL
|
||||
|
||||
@@ -344,9 +344,9 @@ REQUEST hbmk_KEYW
|
||||
|
||||
#ifndef _HBMK_EMBEDDED_
|
||||
|
||||
#define hb_DirCreate( d ) MakeDir( d )
|
||||
#define hb_DirDelete( d ) DirRemove( d )
|
||||
#define hb_CurDrive() CurDrive()
|
||||
#define hb_DirCreate( d ) MakeDir( d )
|
||||
#define hb_DirDelete( d ) DirRemove( d )
|
||||
#define hb_CurDrive() CurDrive()
|
||||
|
||||
PROCEDURE Main( ... )
|
||||
LOCAL aArgsIn := hb_AParams()
|
||||
|
||||
Reference in New Issue
Block a user