1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-25 12:03:53 +03:00

Started adding date and timestamp.

This commit is contained in:
Michael Meskes
2003-03-20 15:56:50 +00:00
parent 26a6378e84
commit 2e6f97560a
22 changed files with 3674 additions and 50 deletions

View File

@@ -1,4 +1,4 @@
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.34 2003/03/16 10:42:54 meskes Exp $
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/test/Makefile,v 1.35 2003/03/20 15:56:50 meskes Exp $
subdir = src/interfaces/ecpg/test
top_builddir = ../../../..
@@ -8,7 +8,7 @@ override CPPFLAGS := -I$(srcdir)/../include $(CPPFLAGS) -g
ECPG = ../preproc/ecpg -I$(srcdir)/../include
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test
TESTS = test1 test2 test3 test4 perftest dyntest dyntest2 test_notice test_code100 test_init testdynalloc num_test dt_test
all: $(TESTS)

View File

@@ -0,0 +1,51 @@
#include <stdio.h>
#include <pgtypes_date.h>
#include <pgtypes_timestamp.h>
int
main()
{
exec sql begin declare section;
date date1;
timestamp ts1;
char *text;
exec sql end declare section;
#if 0
Date date2;
short int mdy[3] = { 4, 19, 1998 };
#endif
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
ECPGdebug(1, dbgs);
exec sql whenever sqlerror do sqlprint();
exec sql connect to mm;
exec sql create table date_test (d date, ts timestamp);
exec sql insert into date_test(d, ts) values ('Mon Jan 17 1966', '2000-7-12 17:34:29');
exec sql select * into :date1, :ts1 from date_test;
text = PGTYPESdate_dtoa(date1);
printf ("Date: %s\n", text);
ts1 = PGTYPEStimestamp_atot("2000-7-12 17:34:29", NULL);
text = PGTYPEStimestamp_ttoa(ts1);
printf ("timestamp: %s\n", text);
#if 0
PGTYPESdate_mdyjul(mdy, &date2);
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
/* reset */
mdy[0] = mdy[1] = mdy[2] = 0;
PGTYPESdate_julmdy(date2, mdy);
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
#endif
exec sql rollback;
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}

View File

@@ -8,6 +8,7 @@ main()
NumericVar *value1, *value2, *res;
exec sql begin declare section;
decimal(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
numeric num;
exec sql end declare section;
double d;
FILE *dbgs;
@@ -52,6 +53,13 @@ main()
text = PGTYPESnumeric_ntoa(res);
PGTYPESnumeric_ntod(res, &d);
printf("div = %s %e\n", text, d);
exec sql rollback;
exec sql disconnect;
if (dbgs != NULL)
fclose(dbgs);
return (0);
}