Remove int16 from libpgeasy examples. Improve error reporting.
This commit is contained in:
parent
936ff27696
commit
ccab6f7402
@ -18,7 +18,6 @@ main(int argc, char **argv)
|
|||||||
float afloat;
|
float afloat;
|
||||||
double adouble;
|
double adouble;
|
||||||
char achar[11],
|
char achar[11],
|
||||||
achar16[17],
|
|
||||||
abpchar[11],
|
abpchar[11],
|
||||||
avarchar[51],
|
avarchar[51],
|
||||||
atext[51];
|
atext[51];
|
||||||
@ -41,7 +40,6 @@ main(int argc, char **argv)
|
|||||||
afloat float4, \
|
afloat float4, \
|
||||||
adouble float8, \
|
adouble float8, \
|
||||||
achar char, \
|
achar char, \
|
||||||
achar16 char(16), \
|
|
||||||
abpchar char(10), \
|
abpchar char(10), \
|
||||||
avarchar varchar(50), \
|
avarchar varchar(50), \
|
||||||
atext text, \
|
atext text, \
|
||||||
@ -58,7 +56,6 @@ main(int argc, char **argv)
|
|||||||
'Betty', \
|
'Betty', \
|
||||||
'Charley', \
|
'Charley', \
|
||||||
'Doug', \
|
'Doug', \
|
||||||
'Ernie', \
|
|
||||||
'now' )", row);
|
'now' )", row);
|
||||||
doquery(query);
|
doquery(query);
|
||||||
|
|
||||||
@ -73,18 +70,16 @@ main(int argc, char **argv)
|
|||||||
&afloat,
|
&afloat,
|
||||||
&adouble,
|
&adouble,
|
||||||
achar,
|
achar,
|
||||||
achar16,
|
|
||||||
abpchar,
|
abpchar,
|
||||||
avarchar,
|
avarchar,
|
||||||
atext,
|
atext,
|
||||||
&aabstime) != END_OF_TUPLES)
|
&aabstime) != END_OF_TUPLES)
|
||||||
printf("int %d\nfloat %f\ndouble %f\nchar %s\nchar16 %s\n\
|
printf("int %d\nfloat %f\ndouble %f\nchar %s\n\
|
||||||
bpchar %s\nvarchar %s\ntext %s\nabstime %s",
|
bpchar %s\nvarchar %s\ntext %s\nabstime %s",
|
||||||
aint,
|
aint,
|
||||||
afloat,
|
afloat,
|
||||||
adouble,
|
adouble,
|
||||||
achar,
|
achar,
|
||||||
achar16,
|
|
||||||
abpchar,
|
abpchar,
|
||||||
avarchar,
|
avarchar,
|
||||||
atext,
|
atext,
|
||||||
|
@ -20,7 +20,6 @@ main(int argc, char **argv)
|
|||||||
float afloat;
|
float afloat;
|
||||||
double adouble;
|
double adouble;
|
||||||
char achar[11],
|
char achar[11],
|
||||||
achar16[17],
|
|
||||||
abpchar[11],
|
abpchar[11],
|
||||||
avarchar[51],
|
avarchar[51],
|
||||||
atext[51];
|
atext[51];
|
||||||
@ -29,7 +28,6 @@ main(int argc, char **argv)
|
|||||||
afloat_null,
|
afloat_null,
|
||||||
adouble_null,
|
adouble_null,
|
||||||
achar_null,
|
achar_null,
|
||||||
achar16_null,
|
|
||||||
abpchar_null,
|
abpchar_null,
|
||||||
avarchar_null,
|
avarchar_null,
|
||||||
atext_null,
|
atext_null,
|
||||||
@ -52,7 +50,6 @@ main(int argc, char **argv)
|
|||||||
afloat float4, \
|
afloat float4, \
|
||||||
adouble float8, \
|
adouble float8, \
|
||||||
achar char, \
|
achar char, \
|
||||||
achar16 char(16), \
|
|
||||||
abpchar char(10), \
|
abpchar char(10), \
|
||||||
avarchar varchar(50), \
|
avarchar varchar(50), \
|
||||||
atext text, \
|
atext text, \
|
||||||
@ -68,8 +65,7 @@ main(int argc, char **argv)
|
|||||||
'', \
|
'', \
|
||||||
'', \
|
'', \
|
||||||
'', \
|
'', \
|
||||||
'', \
|
CURRENT_TIMESTAMP::abstime);");
|
||||||
'');");
|
|
||||||
#else
|
#else
|
||||||
sprintf(query, "INSERT INTO testfetch VALUES ( \
|
sprintf(query, "INSERT INTO testfetch VALUES ( \
|
||||||
NULL, \
|
NULL, \
|
||||||
@ -79,7 +75,6 @@ main(int argc, char **argv)
|
|||||||
NULL, \
|
NULL, \
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, \
|
NULL, \
|
||||||
NULL, \
|
|
||||||
NULL);");
|
NULL);");
|
||||||
#endif
|
#endif
|
||||||
doquery(query);
|
doquery(query);
|
||||||
@ -99,8 +94,6 @@ main(int argc, char **argv)
|
|||||||
&adouble_null,
|
&adouble_null,
|
||||||
achar,
|
achar,
|
||||||
&achar_null,
|
&achar_null,
|
||||||
achar16,
|
|
||||||
&achar16_null,
|
|
||||||
abpchar,
|
abpchar,
|
||||||
&abpchar_null,
|
&abpchar_null,
|
||||||
avarchar,
|
avarchar,
|
||||||
@ -109,30 +102,28 @@ main(int argc, char **argv)
|
|||||||
&atext_null,
|
&atext_null,
|
||||||
&aabstime,
|
&aabstime,
|
||||||
&aabstime_null) != END_OF_TUPLES)
|
&aabstime_null) != END_OF_TUPLES)
|
||||||
printf("int %d\nfloat %f\ndouble %f\nchar %s\nchar16 %s\n\
|
printf("int %d\nfloat %f\ndouble %f\nchar %s\n\
|
||||||
bpchar %s\nvarchar %s\ntext %s\nabstime %s\n",
|
bpchar %s\nvarchar %s\ntext %s\nabstime %s\n",
|
||||||
aint,
|
aint,
|
||||||
afloat,
|
afloat,
|
||||||
adouble,
|
adouble,
|
||||||
achar,
|
achar,
|
||||||
achar16,
|
|
||||||
abpchar,
|
abpchar,
|
||||||
avarchar,
|
avarchar,
|
||||||
atext,
|
atext,
|
||||||
ctime(&aabstime));
|
ctime(&aabstime));
|
||||||
printf("NULL:\nint %d\nfloat %d\ndouble %d\nchar %d\nchar16 %d\n\
|
|
||||||
|
printf("NULL:\nint %d\nfloat %d\ndouble %d\nchar %d\n\
|
||||||
bpchar %d\nvarchar %d\ntext %d\nabstime %d\n",
|
bpchar %d\nvarchar %d\ntext %d\nabstime %d\n",
|
||||||
aint_null,
|
aint_null,
|
||||||
afloat_null,
|
afloat_null,
|
||||||
adouble_null,
|
adouble_null,
|
||||||
achar_null,
|
achar_null,
|
||||||
achar16_null,
|
|
||||||
abpchar_null,
|
abpchar_null,
|
||||||
avarchar_null,
|
avarchar_null,
|
||||||
atext_null,
|
atext_null,
|
||||||
aabstime_null);
|
aabstime_null);
|
||||||
|
|
||||||
|
|
||||||
doquery("CLOSE c_testfetch");
|
doquery("CLOSE c_testfetch");
|
||||||
doquery("COMMIT WORK");
|
doquery("COMMIT WORK");
|
||||||
printf("--- %-d rows inserted so far\n", row);
|
printf("--- %-d rows inserted so far\n", row);
|
||||||
|
@ -92,11 +92,11 @@ doquery(char *query)
|
|||||||
PQresultStatus(res) == PGRES_FATAL_ERROR))
|
PQresultStatus(res) == PGRES_FATAL_ERROR))
|
||||||
{
|
{
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
fprintf(stderr, "query error: %s\n", PQcmdStatus(res));
|
fprintf(stderr, "query error: %s\n", PQresultErrorMessage(res));
|
||||||
else
|
else
|
||||||
fprintf(stderr, "connection error: %s\n", PQerrorMessage(conn));
|
fprintf(stderr, "connection error: %s\n", PQerrorMessage(conn));
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
halt("failed request: %s\n", query);
|
halt("failed query: %s\n", query);
|
||||||
}
|
}
|
||||||
tuple = 0;
|
tuple = 0;
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user