Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit697f9f0

Browse files
committed
Add iteration option to thread test program.
1 parentc7fda55 commit697f9f0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

‎src/interfaces/ecpg/test/test_thread.pgc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66

77
#include <pthread.h>
8+
#include <stdlib.h>
89

910
voidins1(void);
1011
voidins2(void);
1112

1213
EXEC SQL BEGIN DECLARE SECTION;
1314
char *dbname;
15+
int iterations = 10;
1416
EXEC SQL END DECLARE SECTION;
1517

1618
int
@@ -22,13 +24,21 @@ EXEC SQL BEGIN DECLARE SECTION;
2224
introws;
2325
EXEC SQL END DECLARE SECTION;
2426

25-
if (argc!= 2)
27+
if (argc< 2 || argc > 3)
2628
{
27-
fprintf(stderr, "Usage: %s dbname\n", argv[0]);
29+
fprintf(stderr, "Usage: %s dbname [iterations]\n", argv[0]);
2830
return 1;
2931
}
3032
dbname = argv[1];
3133

34+
if (argc == 3)
35+
iterations = atoi(argv[2]);
36+
if (iterations % 2 != 0)
37+
{
38+
fprintf(stderr, "iterations must be an even number\n");
39+
return 1;
40+
}
41+
3242
EXEC SQL CONNECT TO:dbname AS test0;
3343

3444
/* DROP might fail */
@@ -47,7 +57,7 @@ EXEC SQL END DECLARE SECTION;
4757
EXEC SQL AT test3 COMMIT WORK;
4858
EXEC SQL DISCONNECT test3;
4959

50-
if (rows ==10)
60+
if (rows ==iterations)
5161
printf("Success.\n");
5262
else
5363
printf("Failure.\n");
@@ -61,7 +71,7 @@ ins1(void)
6171
EXEC SQL WHENEVER sqlerror sqlprint;
6272
EXEC SQL CONNECT TO:dbname AS test1;
6373

64-
for (i = 0; i <5; i++)
74+
for (i = 0; i <iterations / 2; i++)
6575
{
6676
printf("thread 1 : inserting\n");
6777
EXEC SQL AT test1 INSERT INTO test_thread VALUES('thread1');
@@ -82,7 +92,7 @@ ins2(void)
8292
EXEC SQL WHENEVER sqlerror sqlprint;
8393
EXEC SQL CONNECT TO:dbname AS test2;
8494

85-
for (i = 0; i <5; i++)
95+
for (i = 0; i <iterations / 2; i++)
8696
{
8797
printf("thread 2: inserting\n");
8898
EXEC SQL AT test2 INSERT INTO test_thread VALUES('thread2');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp