* contrib/hbblat/tests/blatcmd.prg
* contrib/hbblat/tests/blattest.prg
* contrib/hbbz2/tests/test.prg
* contrib/hbcomm/tests/test.prg
* contrib/hbcups/tests/test.prg
* contrib/hbexpat/tests/test.prg
* contrib/hbexpat/tests/tohash.prg
* contrib/hbfbird/tests/simple.prg
* contrib/hbfbird/tests/stress.prg
* contrib/hbfbird/tests/test.prg
* contrib/hbfimage/tests/fitest.prg
* contrib/hbgs/tests/testgs.prg
* contrib/hbhpdf/tests/harupdf.prg
* contrib/hblzf/tests/test.prg
* contrib/hbmagic/tests/hbmagit.prg
* contrib/hbmemio/tests/test.prg
* contrib/hbmxml/tests/custom.prg
* contrib/hbmxml/tests/reminder.prg
* contrib/hbmxml/tests/testmxml.prg
* contrib/hbmysql/tests/test.prg
* contrib/hbmzip/tests/myunzip.prg
* contrib/hbmzip/tests/myzip.prg
* contrib/hbodbc/tests/odbccall.prg
* contrib/hbodbc/tests/odbcdemo.prg
* contrib/hbodbc/tests/testodbc.prg
* contrib/hbpgsql/tests/async.prg
* contrib/hbpgsql/tests/cache.prg
* contrib/hbpgsql/tests/dbf2pg.prg
* contrib/hbpgsql/tests/simple.prg
* contrib/hbpgsql/tests/stress.prg
* contrib/hbpgsql/tests/test.prg
* contrib/hbsms/tests/send.prg
* contrib/hbsqlit3/tests/authoriz.prg
* contrib/hbsqlit3/tests/backup.prg
* contrib/hbsqlit3/tests/blob.prg
* contrib/hbsqlit3/tests/hdbctest.prg
* contrib/hbsqlit3/tests/hooks.prg
* contrib/hbsqlit3/tests/metadata.prg
* contrib/hbsqlit3/tests/pack.prg
* contrib/hbsqlit3/tests/sl3_test.prg
* contrib/hbssl/tests/bio.prg
* contrib/hbssl/tests/crypt.prg
* contrib/hbssl/tests/digest.prg
* contrib/hbssl/tests/encode.prg
* contrib/hbssl/tests/pem.prg
* contrib/hbssl/tests/test.prg
* contrib/hbtip/tests/base64.prg
* contrib/hbtip/tests/dbtohtml.prg
* contrib/hbtip/tests/dnldftp.prg
* contrib/hbtip/tests/ftpadv.prg
* contrib/hbtip/tests/gmail.prg
* contrib/hbtip/tests/httpadv.prg
* contrib/hbtip/tests/loadhtml.prg
* contrib/hbtip/tests/test01.prg
* contrib/hbtip/tests/tipmail.prg
* contrib/hbtip/tests/tipmime.prg
* contrib/hbtip/tests/tipmmail.prg
* contrib/hbtip/tests/tiptest.prg
* contrib/hbtip/tests/tiptime.prg
* contrib/hbtip/tests/upld_ftp.prg
* contrib/hbtpathy/tests/testtp.prg
* contrib/hbunix/tests/testdmn.prg
* contrib/hbunix/tests/testpid.prg
* contrib/hbxdiff/tests/test.prg
* contrib/hbxdiff/tests/test2.prg
* contrib/hbxdiff/tests/test3.prg
* contrib/rddsql/tests/arrayrdd.prg
* contrib/sddsqlt3/tests/test1.prg
* contrib/xhb/tests/compress.prg
* contrib/xhb/tests/dll.prg
* contrib/xhb/tests/testcp.prg
* contrib/xhb/tests/xml1.prg
+ added #require directives, so the tests can now
be run as scripts. It will require a dynamically
built hbrun and contrib dlls. To make them, use:
HB_BUILD_CONTRIB_DYN=yes and rebuild Harbour.
* minor cleanups along the way
; RDDSQL fails in RDDSETDEFAULT().
* contrib/gtwvg/toolbar.prg
! fixed yet another != (disguised as <>) operator on string
109 lines
2.7 KiB
Plaintext
109 lines
2.7 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* VERY IMPORTANT: Don't use this querys as sample, they are used for stress tests !!!
|
|
*/
|
|
|
|
#require "hbpgsql"
|
|
|
|
#include "postgres.ch"
|
|
|
|
PROCEDURE Main( cServer, cDatabase, cUser, cPass )
|
|
LOCAL conn, res, i, x
|
|
|
|
LOCAL cQuery
|
|
|
|
CLS
|
|
|
|
? "Connecting...."
|
|
conn := PQconnectDB( "dbname = " + cDatabase + " host = " + cServer + " user = " + cUser + " password = " + cPass + " port = 5432" )
|
|
|
|
? PQstatus( conn ), PQerrormessage( conn )
|
|
|
|
IF PQstatus( conn ) != CONNECTION_OK
|
|
QUIT
|
|
ENDIF
|
|
|
|
? "Dropping table..."
|
|
|
|
PQexec( conn, "DROP TABLE test" )
|
|
|
|
? "Creating test table..."
|
|
cQuery := "CREATE TABLE test("
|
|
cQuery += " Code integer not null primary key, "
|
|
cQuery += " dept Integer, "
|
|
cQuery += " Name Varchar(40), "
|
|
cQuery += " Sales boolean, "
|
|
cQuery += " Tax Float4, "
|
|
cQuery += " Salary Double Precision, "
|
|
cQuery += " Budget Numeric(12,2), "
|
|
cQuery += " Discount Numeric(5,2), "
|
|
cQuery += " Creation Date, "
|
|
cQuery += " Description text ) "
|
|
|
|
PQexec( conn, cQuery )
|
|
PQexec( conn, "SELECT code, dept, name, sales, salary, creation FROM test" )
|
|
PQexec( conn, "BEGIN" )
|
|
|
|
FOR i := 1 TO 10000
|
|
@ 15, 0 SAY "Inserting values...." + Str( i )
|
|
|
|
cQuery := "INSERT INTO test(code, dept, name, sales, salary, creation) " +;
|
|
"VALUES( " + Str( i ) + "," + Str( i + 1 ) + ", 'DEPARTMENT NAME " + StrZero( i ) + "', 'y', " + Str( 300.49 + i ) + ", '2003-12-28' )"
|
|
|
|
PQexec( conn, cQuery )
|
|
|
|
IF Mod( i, 100 ) == 0
|
|
? PQexec( conn, "COMMIT" )
|
|
? PQexec( conn, "BEGIN" )
|
|
ENDIF
|
|
NEXT
|
|
|
|
FOR i := 5000 TO 7000
|
|
@ 16, 0 SAY "Deleting values...." + Str( i )
|
|
|
|
cQuery := "DELETE FROM test WHERE code = " + Str( i )
|
|
PQexec( conn, cQuery )
|
|
|
|
IF Mod( i, 100 ) == 0
|
|
PQexec( conn, "COMMIT" )
|
|
PQexec( conn, "BEGIN" )
|
|
ENDIF
|
|
NEXT
|
|
|
|
FOR i := 2000 TO 3000
|
|
@ 17, 0 SAY "Updating values...." + Str( i )
|
|
|
|
cQuery := "UPDATE FROM test SET salary = 400 WHERE code = " + str( i )
|
|
PQexec( conn, cQuery )
|
|
|
|
IF Mod( i, 100 ) == 0
|
|
PQexec( conn, "COMMIT" )
|
|
PQexec( conn, "BEGIN" )
|
|
ENDIF
|
|
NEXT
|
|
|
|
res := PQexec( conn, "SELECT sum(salary) as sum_salary FROM test WHERE code between 1 and 4000" )
|
|
|
|
IF PQresultStatus( res ) == PGRES_TUPLES_OK
|
|
@ 18, 0 SAY "Sum values...." + PQgetvalue( res, 1, 1 )
|
|
ENDIF
|
|
|
|
x := 0
|
|
FOR i := 1 TO 4000
|
|
res := PQexec( conn, "SELECT salary FROM test WHERE code = " + Str( i ) )
|
|
|
|
IF PQresultStatus( res ) == PGRES_TUPLES_OK
|
|
x += Val( PQgetvalue( res, 1, 1 ) )
|
|
|
|
@ 19, 0 SAY "Sum values...." + Str( x )
|
|
ENDIF
|
|
NEXT
|
|
|
|
? "Closing..."
|
|
conn := NIL
|
|
|
|
RETURN
|