mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
*** empty log message ***
This commit is contained in:
@ -1,12 +1,19 @@
|
||||
exec sql include sqlca;
|
||||
|
||||
exec sql whenever sqlerror do PrintAndStop(msg);
|
||||
exec sql whenever sqlwarning do warn();
|
||||
|
||||
void PrintAndStop(msg)
|
||||
void Finish(msg)
|
||||
{
|
||||
fprintf(stderr, "Error in statement '%s':\n", msg);
|
||||
sqlprint();
|
||||
|
||||
/* finish transaction */
|
||||
exec sql rollback;
|
||||
|
||||
/* and remove test table */
|
||||
exec sql drop table meskes;
|
||||
exec sql commit;
|
||||
|
||||
exec sql disconnect;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -14,3 +21,6 @@ void warn(void)
|
||||
{
|
||||
fprintf(stderr, "Warning: At least one column was truncated\n");
|
||||
}
|
||||
|
||||
exec sql whenever sqlerror do Finish(msg);
|
||||
exec sql whenever sqlwarning do warn();
|
||||
|
@ -38,6 +38,12 @@ exec sql end declare section;
|
||||
|
||||
exec sql create unique index number2 on perftest2(number);
|
||||
|
||||
exec sql commit;
|
||||
|
||||
exec sql set autocommit to on;
|
||||
|
||||
exec sql begin transaction;
|
||||
|
||||
gettimeofday(&tvs, NULL);
|
||||
|
||||
for (i = 0;i < 1407; i++)
|
||||
@ -49,14 +55,16 @@ exec sql end declare section;
|
||||
sprintf(text, "%ld", i);
|
||||
exec sql insert into perftest1(number, ascii) values (:i, :text);
|
||||
exec sql insert into perftest2(number, next_number) values (:i, :i+1);
|
||||
|
||||
exec sql commit;
|
||||
}
|
||||
|
||||
exec sql commit;
|
||||
|
||||
gettimeofday(&tve, NULL);
|
||||
|
||||
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "insert");
|
||||
|
||||
exec sql begin transaction;
|
||||
|
||||
gettimeofday(&tvs, NULL);
|
||||
|
||||
for (i = 0;i < 1407; i++)
|
||||
@ -66,14 +74,16 @@ exec sql end declare section;
|
||||
exec sql end declare section;
|
||||
|
||||
exec sql select ascii into :text from perftest1 where number = :i;
|
||||
|
||||
exec sql commit;
|
||||
}
|
||||
|
||||
exec sql commit;
|
||||
|
||||
gettimeofday(&tve, NULL);
|
||||
|
||||
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "selection&projection");
|
||||
|
||||
exec sql begin transaction;
|
||||
|
||||
gettimeofday(&tvs, NULL);
|
||||
|
||||
for (i = 0;i < 1407; i++)
|
||||
@ -83,14 +93,16 @@ exec sql end declare section;
|
||||
exec sql end declare section;
|
||||
|
||||
exec sql select perftest1.ascii into :text from perftest1, perftest2 where perftest1.number = perftest2.number and perftest2.number = :i;
|
||||
|
||||
exec sql commit;
|
||||
}
|
||||
|
||||
exec sql commit;
|
||||
|
||||
gettimeofday(&tve, NULL);
|
||||
|
||||
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "join");
|
||||
|
||||
exec sql begin transaction;
|
||||
|
||||
gettimeofday(&tvs, NULL);
|
||||
|
||||
exec sql update perftest2 set next_number = next_number + 1;
|
||||
@ -101,6 +113,8 @@ exec sql end declare section;
|
||||
|
||||
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "update");
|
||||
|
||||
exec sql begin transaction;
|
||||
|
||||
gettimeofday(&tvs, NULL);
|
||||
|
||||
exec sql delete from perftest2;
|
||||
@ -111,6 +125,8 @@ exec sql end declare section;
|
||||
|
||||
print_result(tve.tv_sec - tvs.tv_sec, tve.tv_usec - tvs.tv_usec, "delete");
|
||||
|
||||
exec sql set autocommit = off;
|
||||
|
||||
exec sql drop index number2;
|
||||
|
||||
exec sql drop table perftest2;
|
||||
|
@ -1,4 +1,19 @@
|
||||
exec sql include header_test;
|
||||
exec sql include sqlca;
|
||||
|
||||
exec sql whenever sqlerror do PrintAndStop(msg);
|
||||
exec sql whenever sqlwarning do warn();
|
||||
|
||||
void PrintAndStop(msg)
|
||||
{
|
||||
fprintf(stderr, "Error in statement '%s':\n", msg);
|
||||
sqlprint();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void warn(void)
|
||||
{
|
||||
fprintf(stderr, "Warning: At least one column was truncated\n");
|
||||
}
|
||||
|
||||
exec sql include sqlca;
|
||||
|
||||
|
@ -62,7 +62,7 @@ exec sql end declare section;
|
||||
|
||||
while (1) {
|
||||
strcpy(msg, "fetch");
|
||||
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
|
||||
exec sql fetch from cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
@ -81,7 +81,7 @@ exec sql end declare section;
|
||||
strcpy(msg, "close");
|
||||
exec sql close cur;
|
||||
|
||||
/* and now the same query with prepare */
|
||||
/* and now a same query with prepare */
|
||||
exec sql prepare MM from :query;
|
||||
exec sql declare prep cursor for MM;
|
||||
|
||||
|
@ -54,7 +54,7 @@ exec sql end declare section;
|
||||
|
||||
while (1) {
|
||||
strcpy(msg, "fetch");
|
||||
exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
|
||||
exec sql fetch cur into :personal:ind_personal, :married:ind_married, :children:ind_children;
|
||||
printf("%8.8s", personal.name.arr);
|
||||
if (ind_personal.ind_birth.born >= 0)
|
||||
printf(", born %d", personal.birth.born);
|
||||
@ -73,7 +73,7 @@ exec sql end declare section;
|
||||
strcpy(msg, "close");
|
||||
exec sql close cur;
|
||||
|
||||
/* and now the same query with prepare */
|
||||
/* and now a query with prepare */
|
||||
exec sql prepare MM from "select name, born, age, married, children from meskes where name = ?";
|
||||
exec sql declare prep cursor for MM;
|
||||
|
||||
|
Reference in New Issue
Block a user