mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
Add PGTYPESchar_free() to avoid cross-module problems on Windows.
On Windows, it is sometimes important for corresponding malloc() and free() calls to be made from the same DLL, since some build options can result in multiple allocators being active at the same time. For that reason we already provided PQfreemem(). This commit adds a similar function for freeing string results allocated by the pgtypes library. Author: Takayuki Tsunakawa Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8AD5D6%40G01JPEXMBYT05
This commit is contained in:
parent
7bcda60d41
commit
3bc19d0d26
@ -1919,11 +1919,23 @@ EXEC SQL SELECT started, duration INTO :ts1, :iv1 FROM datetbl WHERE d=:date1;
|
|||||||
PGTYPEStimestamp_add_interval(&ts1, &iv1, &tsout);
|
PGTYPEStimestamp_add_interval(&ts1, &iv1, &tsout);
|
||||||
out = PGTYPEStimestamp_to_asc(&tsout);
|
out = PGTYPEStimestamp_to_asc(&tsout);
|
||||||
printf("Started + duration: %s\n", out);
|
printf("Started + duration: %s\n", out);
|
||||||
free(out);
|
PGTYPESchar_free(out);
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<sect2 id="ecpg-pgtypes-cstrings">
|
||||||
|
<title>Character Strings</title>
|
||||||
|
<para>
|
||||||
|
Some functions such as <function>PGTYPESnumeric_to_asc</function> return
|
||||||
|
a pointer to a freshly allocated character string. These results should be
|
||||||
|
freed with <function>PGTYPESchar_free</function> instead of
|
||||||
|
<function>free</function>. (This is important only on Windows, where
|
||||||
|
memory allocation and release sometimes need to be done by the same
|
||||||
|
library.)
|
||||||
|
</para>
|
||||||
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="ecpg-pgtypes-numeric">
|
<sect2 id="ecpg-pgtypes-numeric">
|
||||||
<title>The numeric Type</title>
|
<title>The numeric Type</title>
|
||||||
<para>
|
<para>
|
||||||
@ -1997,6 +2009,7 @@ char *PGTYPESnumeric_to_asc(numeric *num, int dscale);
|
|||||||
</synopsis>
|
</synopsis>
|
||||||
The numeric value will be printed with <literal>dscale</literal> decimal
|
The numeric value will be printed with <literal>dscale</literal> decimal
|
||||||
digits, with rounding applied if necessary.
|
digits, with rounding applied if necessary.
|
||||||
|
The result must be freed with <function>PGTYPESchar_free()</function>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2384,9 +2397,10 @@ date PGTYPESdate_from_asc(char *str, char **endptr);
|
|||||||
<synopsis>
|
<synopsis>
|
||||||
char *PGTYPESdate_to_asc(date dDate);
|
char *PGTYPESdate_to_asc(date dDate);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
The function receives the date <literal>dDate</> as its only parameter.
|
The function receives the date <literal>dDate</literal> as its only parameter.
|
||||||
It will output the date in the form <literal>1999-01-18</>, i.e., in the
|
It will output the date in the form <literal>1999-01-18</literal>, i.e., in the
|
||||||
<literal>YYYY-MM-DD</> format.
|
<literal>YYYY-MM-DD</literal> format.
|
||||||
|
The result must be freed with <function>PGTYPESchar_free()</function>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2809,6 +2823,7 @@ char *PGTYPEStimestamp_to_asc(timestamp tstamp);
|
|||||||
The function receives the timestamp <literal>tstamp</> as
|
The function receives the timestamp <literal>tstamp</> as
|
||||||
its only argument and returns an allocated string that contains the
|
its only argument and returns an allocated string that contains the
|
||||||
textual representation of the timestamp.
|
textual representation of the timestamp.
|
||||||
|
The result must be freed with <function>PGTYPESchar_free()</function>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -3317,6 +3332,7 @@ char *PGTYPESinterval_to_asc(interval *span);
|
|||||||
The function converts the interval variable that <literal>span</>
|
The function converts the interval variable that <literal>span</>
|
||||||
points to into a C char*. The output looks like this example:
|
points to into a C char*. The output looks like this example:
|
||||||
<literal>@ 1 day 12 hours 59 mins 10 secs</literal>.
|
<literal>@ 1 day 12 hours 59 mins 10 secs</literal>.
|
||||||
|
The result must be freed with <function>PGTYPESchar_free()</function>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -14,7 +14,7 @@ install: all installdirs install-headers
|
|||||||
|
|
||||||
.PHONY: install-headers
|
.PHONY: install-headers
|
||||||
ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
|
ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
|
||||||
pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
|
pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h pgtypes.h \
|
||||||
sqlda.h sqlda-compat.h sqlda-native.h
|
sqlda.h sqlda-compat.h sqlda-native.h
|
||||||
informix_headers = datetime.h decimal.h sqltypes.h
|
informix_headers = datetime.h decimal.h sqltypes.h
|
||||||
|
|
||||||
|
17
src/interfaces/ecpg/include/pgtypes.h
Normal file
17
src/interfaces/ecpg/include/pgtypes.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* src/interfaces/ecpg/include/pgtypes.h */
|
||||||
|
|
||||||
|
#ifndef PGTYPES_H
|
||||||
|
#define PGTYPES_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void PGTYPESchar_free(char *ptr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PGTYPES_H */
|
@ -3,6 +3,7 @@
|
|||||||
#ifndef PGTYPES_DATETIME
|
#ifndef PGTYPES_DATETIME
|
||||||
#define PGTYPES_DATETIME
|
#define PGTYPES_DATETIME
|
||||||
|
|
||||||
|
#include <pgtypes.h>
|
||||||
#include <pgtypes_timestamp.h>
|
#include <pgtypes_timestamp.h>
|
||||||
|
|
||||||
typedef long date;
|
typedef long date;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define PGTYPES_INTERVAL
|
#define PGTYPES_INTERVAL
|
||||||
|
|
||||||
#include <ecpg_config.h>
|
#include <ecpg_config.h>
|
||||||
|
#include <pgtypes.h>
|
||||||
|
|
||||||
#ifndef C_H
|
#ifndef C_H
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef PGTYPES_NUMERIC
|
#ifndef PGTYPES_NUMERIC
|
||||||
#define PGTYPES_NUMERIC
|
#define PGTYPES_NUMERIC
|
||||||
|
|
||||||
|
#include <pgtypes.h>
|
||||||
|
|
||||||
#define NUMERIC_POS 0x0000
|
#define NUMERIC_POS 0x0000
|
||||||
#define NUMERIC_NEG 0x4000
|
#define NUMERIC_NEG 0x4000
|
||||||
#define NUMERIC_NAN 0xC000
|
#define NUMERIC_NAN 0xC000
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifndef PGTYPES_TIMESTAMP
|
#ifndef PGTYPES_TIMESTAMP
|
||||||
#define PGTYPES_TIMESTAMP
|
#define PGTYPES_TIMESTAMP
|
||||||
|
|
||||||
|
#include <pgtypes.h>
|
||||||
/* pgtypes_interval.h includes ecpg_config.h */
|
/* pgtypes_interval.h includes ecpg_config.h */
|
||||||
#include <pgtypes_interval.h>
|
#include <pgtypes_interval.h>
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
#include "pgtypes.h"
|
||||||
|
|
||||||
/* Return value is zero-filled. */
|
/* Return value is zero-filled. */
|
||||||
char *
|
char *
|
||||||
@ -136,3 +137,12 @@ pgtypes_fmt_replace(union un_fmt_comb replace_val, int replace_type, char **outp
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Functions declared in pgtypes.h. */
|
||||||
|
|
||||||
|
/* Just frees memory (mostly needed for Windows) */
|
||||||
|
void
|
||||||
|
PGTYPESchar_free(char *ptr)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
@ -45,3 +45,4 @@ PGTYPEStimestamp_from_asc 42
|
|||||||
PGTYPEStimestamp_sub 43
|
PGTYPEStimestamp_sub 43
|
||||||
PGTYPEStimestamp_sub_interval 44
|
PGTYPEStimestamp_sub_interval 44
|
||||||
PGTYPEStimestamp_to_asc 45
|
PGTYPEStimestamp_to_asc 45
|
||||||
|
PGTYPESchar_free 46
|
||||||
|
@ -113,18 +113,18 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
|
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf ("Date: %s\n", text);
|
printf ("Date: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf ("timestamp: %s\n", text);
|
printf ("timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
|
iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
|
||||||
PGTYPESinterval_copy(iv1, &iv2);
|
PGTYPESinterval_copy(iv1, &iv2);
|
||||||
text = PGTYPESinterval_to_asc(&iv2);
|
text = PGTYPESinterval_to_asc(&iv2);
|
||||||
printf ("interval: %s\n", text);
|
printf ("interval: %s\n", text);
|
||||||
PGTYPESinterval_free(iv1);
|
PGTYPESinterval_free(iv1);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPESdate_mdyjul(mdy, &date2);
|
PGTYPESdate_mdyjul(mdy, &date2);
|
||||||
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
||||||
@ -144,7 +144,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_fmt_asc(date1, fmt, out);
|
PGTYPESdate_fmt_asc(date1, fmt, out);
|
||||||
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
|
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
|
||||||
printf("Above date in format \"%s\" is \"%s\"\n", fmt, out);
|
printf("Above date in format \"%s\" is \"%s\"\n", fmt, out);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
free(out);
|
free(out);
|
||||||
|
|
||||||
out = (char*) malloc(48);
|
out = (char*) malloc(48);
|
||||||
@ -164,7 +164,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc1: %s\n", text);
|
printf("date_defmt_asc1: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmmm. dd. yyyy";
|
fmt = "mmmm. dd. yyyy";
|
||||||
@ -172,7 +172,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc2: %s\n", text);
|
printf("date_defmt_asc2: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc3: %s\n", text);
|
printf("date_defmt_asc3: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -188,7 +188,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc4: %s\n", text);
|
printf("date_defmt_asc4: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "dd-mm-yy";
|
fmt = "dd-mm-yy";
|
||||||
@ -196,7 +196,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc5: %s\n", text);
|
printf("date_defmt_asc5: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmddyy";
|
fmt = "mmddyy";
|
||||||
@ -204,7 +204,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc6: %s\n", text);
|
printf("date_defmt_asc6: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -212,7 +212,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc7: %s\n", text);
|
printf("date_defmt_asc7: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -220,7 +220,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc8: %s\n", text);
|
printf("date_defmt_asc8: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm yy dd.";
|
fmt = "mm yy dd.";
|
||||||
@ -228,7 +228,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc9: %s\n", text);
|
printf("date_defmt_asc9: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yyyy fierj mm dd.";
|
fmt = "yyyy fierj mm dd.";
|
||||||
@ -236,7 +236,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc10: %s\n", text);
|
printf("date_defmt_asc10: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm/dd/yy";
|
fmt = "mm/dd/yy";
|
||||||
@ -244,28 +244,28 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc12: %s\n", text);
|
printf("date_defmt_asc12: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPEStimestamp_current(&ts1);
|
PGTYPEStimestamp_current(&ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
/* can't output this in regression mode */
|
/* can't output this in regression mode */
|
||||||
/* printf("timestamp_current: Now: %s\n", text); */
|
/* printf("timestamp_current: Now: %s\n", text); */
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc1: %s\n", text);
|
printf("timestamp_to_asc1: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc2: %s\n", text);
|
printf("timestamp_to_asc2: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc3: %s\n", text);
|
printf("timestamp_to_asc3: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
/* abc-03:10:35-def-02/11/94-gh */
|
/* abc-03:10:35-def-02/11/94-gh */
|
||||||
/* 12345678901234567890123456789 */
|
/* 12345678901234567890123456789 */
|
||||||
@ -280,161 +280,161 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 2000";
|
in = "Tue Feb 29 17:28:44 +0200 2000";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1900";
|
in = "Tue Feb 29 17:28:44 +0200 1900";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1996";
|
in = "Tue Feb 29 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 31 17:28:44 +0200 1996";
|
in = " Jul 31 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 32 17:28:44 +0200 1996";
|
in = " Jul 32 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1997";
|
in = "Tue Feb 29 17:28:44 +0200 1997";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%";
|
fmt = "%";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "a %";
|
fmt = "a %";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b, %d %H_%M`%S %z %Y";
|
fmt = "%b, %d %H_%M`%S %z %Y";
|
||||||
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
||||||
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "";
|
fmt = "";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
in = "1980-04-12 3:49:44 ";
|
in = "1980-04-12 3:49:44 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
|
printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%B %d, %Y. Time: %I:%M%p";
|
fmt = "%B %d, %Y. Time: %I:%M%p";
|
||||||
in = "July 14, 1988. Time: 9:15am";
|
in = "July 14, 1988. Time: 9:15am";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = "September 6 at 01:30 pm in the year 1983";
|
in = "September 6 at 01:30 pm in the year 1983";
|
||||||
fmt = "%B %d at %I:%M %p in the year %Y";
|
fmt = "%B %d at %I:%M %p in the year %Y";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15am";
|
in = " 1976, July 14. Time: 9:15am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M %p";
|
fmt = "%Y, %B %d. Time: %I:%M %p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15 am";
|
in = " 1976, July 14. Time: 9:15 am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M%p";
|
fmt = "%Y, %B %d. Time: %I:%M%p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, P.M. July 14. Time: 9:15";
|
in = " 1976, P.M. July 14. Time: 9:15";
|
||||||
fmt = "%Y, %P %B %d. Time: %I:%M";
|
fmt = "%Y, %P %B %d. Time: %I:%M";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = "1234567890";
|
in = "1234567890";
|
||||||
fmt = "%s";
|
fmt = "%s";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
{ ECPGtrans(__LINE__, NULL, "rollback");
|
{ ECPGtrans(__LINE__, NULL, "rollback");
|
||||||
#line 365 "dt_test.pgc"
|
#line 365 "dt_test.pgc"
|
||||||
|
@ -110,14 +110,14 @@ main(void)
|
|||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
|
|
||||||
printf("timestamp: %s\n", text);
|
printf("timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = PGTYPESdate_from_timestamp(ts1);
|
date1 = PGTYPESdate_from_timestamp(ts1);
|
||||||
dc = PGTYPESdate_new();
|
dc = PGTYPESdate_new();
|
||||||
*dc = date1;
|
*dc = date1;
|
||||||
text = PGTYPESdate_to_asc(*dc);
|
text = PGTYPESdate_to_asc(*dc);
|
||||||
printf("Date of timestamp: %s\n", text);
|
printf("Date of timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESdate_free(dc);
|
PGTYPESdate_free(dc);
|
||||||
|
|
||||||
for (i = 0; dates[i]; i++)
|
for (i = 0; dates[i]; i++)
|
||||||
@ -132,7 +132,7 @@ main(void)
|
|||||||
i, err ? "-" : text,
|
i, err ? "-" : text,
|
||||||
endptr ? 'N' : 'Y',
|
endptr ? 'N' : 'Y',
|
||||||
err ? 'T' : 'F');
|
err ? 'T' : 'F');
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
for (j = 0; times[j]; j++)
|
for (j = 0; times[j]; j++)
|
||||||
@ -149,7 +149,7 @@ main(void)
|
|||||||
if (i != 19 || (j != 3 && j != 4))
|
if (i != 19 || (j != 3 && j != 4))
|
||||||
printf("TS[%d,%d]: %s\n",
|
printf("TS[%d,%d]: %s\n",
|
||||||
i, j, errno ? "-" : text);
|
i, j, errno ? "-" : text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,13 +173,13 @@ main(void)
|
|||||||
continue;
|
continue;
|
||||||
text = PGTYPESinterval_to_asc(i1);
|
text = PGTYPESinterval_to_asc(i1);
|
||||||
printf("interval[%d]: %s\n", i, text ? text : "-");
|
printf("interval[%d]: %s\n", i, text ? text : "-");
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ic = PGTYPESinterval_new();
|
ic = PGTYPESinterval_new();
|
||||||
PGTYPESinterval_copy(i1, ic);
|
PGTYPESinterval_copy(i1, ic);
|
||||||
text = PGTYPESinterval_to_asc(i1);
|
text = PGTYPESinterval_to_asc(i1);
|
||||||
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
|
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESinterval_free(ic);
|
PGTYPESinterval_free(ic);
|
||||||
PGTYPESinterval_free(i1);
|
PGTYPESinterval_free(i1);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESnumeric_from_int(1407, value1);
|
PGTYPESnumeric_from_int(1407, value1);
|
||||||
text = PGTYPESnumeric_to_asc(value1, -1);
|
text = PGTYPESnumeric_to_asc(value1, -1);
|
||||||
printf("from int = %s\n", text);
|
printf("from int = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value1);
|
PGTYPESnumeric_free(value1);
|
||||||
|
|
||||||
value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
|
value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
|
||||||
@ -87,12 +87,12 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESnumeric_add(value1, value2, res);
|
PGTYPESnumeric_add(value1, value2, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("add = %s\n", text);
|
printf("add = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPESnumeric_sub(res, value2, res);
|
PGTYPESnumeric_sub(res, value2, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("sub = %s\n", text);
|
printf("sub = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value2);
|
PGTYPESnumeric_free(value2);
|
||||||
|
|
||||||
des = PGTYPESnumeric_new();
|
des = PGTYPESnumeric_new();
|
||||||
@ -122,7 +122,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
PGTYPESnumeric_mul(res, des, res);
|
PGTYPESnumeric_mul(res, des, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("mul = %s\n", text);
|
printf("mul = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(des);
|
PGTYPESnumeric_free(des);
|
||||||
|
|
||||||
value2 = PGTYPESnumeric_from_asc("10000", NULL);
|
value2 = PGTYPESnumeric_from_asc("10000", NULL);
|
||||||
@ -139,7 +139,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
|
|||||||
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
|
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
|
||||||
printf("to long(%d) = %ld %ld\n", i, l1, l2);
|
printf("to long(%d) = %ld %ld\n", i, l1, l2);
|
||||||
|
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value1);
|
PGTYPESnumeric_free(value1);
|
||||||
PGTYPESnumeric_free(value2);
|
PGTYPESnumeric_free(value2);
|
||||||
PGTYPESnumeric_free(res);
|
PGTYPESnumeric_free(res);
|
||||||
|
@ -77,21 +77,21 @@ main(void)
|
|||||||
|
|
||||||
text = PGTYPESnumeric_to_asc(num, -1);
|
text = PGTYPESnumeric_to_asc(num, -1);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,1]: %s\n", i, text); free(text);
|
printf("num[%d,1]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 0);
|
text = PGTYPESnumeric_to_asc(num, 0);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,2]: %s\n", i, text); free(text);
|
printf("num[%d,2]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 1);
|
text = PGTYPESnumeric_to_asc(num, 1);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,3]: %s\n", i, text); free(text);
|
printf("num[%d,3]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 2);
|
text = PGTYPESnumeric_to_asc(num, 2);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,4]: %s\n", i, text); free(text);
|
printf("num[%d,4]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
|
|
||||||
nin = PGTYPESnumeric_new();
|
nin = PGTYPESnumeric_new();
|
||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,5]: %s\n", i, text); free(text);
|
printf("num[%d,5]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
|
|
||||||
r = PGTYPESnumeric_to_long(num, &l);
|
r = PGTYPESnumeric_to_long(num, &l);
|
||||||
if (r) check_errno();
|
if (r) check_errno();
|
||||||
@ -103,7 +103,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = PGTYPESnumeric_to_int(num, &k);
|
r = PGTYPESnumeric_to_int(num, &k);
|
||||||
@ -116,7 +116,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != 6)
|
if (i != 6)
|
||||||
@ -147,7 +147,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
PGTYPESdecimal_free(dec);
|
PGTYPESdecimal_free(dec);
|
||||||
@ -173,7 +173,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(a, 10);
|
text = PGTYPESnumeric_to_asc(a, 10);
|
||||||
printf("num[a,%d,%d]: %s\n", i, j, text);
|
printf("num[a,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
|
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
|
||||||
if (r)
|
if (r)
|
||||||
@ -185,7 +185,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(s, 10);
|
text = PGTYPESnumeric_to_asc(s, 10);
|
||||||
printf("num[s,%d,%d]: %s\n", i, j, text);
|
printf("num[s,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
|
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
|
||||||
if (r)
|
if (r)
|
||||||
@ -197,7 +197,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(m, 10);
|
text = PGTYPESnumeric_to_asc(m, 10);
|
||||||
printf("num[m,%d,%d]: %s\n", i, j, text);
|
printf("num[m,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
|
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
|
||||||
if (r)
|
if (r)
|
||||||
@ -209,7 +209,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(d, 10);
|
text = PGTYPESnumeric_to_asc(d, 10);
|
||||||
printf("num[d,%d,%d]: %s\n", i, j, text);
|
printf("num[d,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
PGTYPESnumeric_free(a);
|
PGTYPESnumeric_free(a);
|
||||||
@ -223,7 +223,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(numarr[i], -1);
|
text = PGTYPESnumeric_to_asc(numarr[i], -1);
|
||||||
printf("%d: %s\n", i, text);
|
printf("%d: %s\n", i, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(numarr[i]);
|
PGTYPESnumeric_free(numarr[i]);
|
||||||
}
|
}
|
||||||
free(numarr);
|
free(numarr);
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#ifndef PGTYPES_NUMERIC
|
#ifndef PGTYPES_NUMERIC
|
||||||
#define PGTYPES_NUMERIC
|
#define PGTYPES_NUMERIC
|
||||||
|
|
||||||
|
#include <pgtypes.h>
|
||||||
|
|
||||||
#define NUMERIC_POS 0x0000
|
#define NUMERIC_POS 0x0000
|
||||||
#define NUMERIC_NEG 0x4000
|
#define NUMERIC_NEG 0x4000
|
||||||
#define NUMERIC_NAN 0xC000
|
#define NUMERIC_NAN 0xC000
|
||||||
|
@ -50,6 +50,8 @@ typedef struct sqlda_struct sqlda_t;
|
|||||||
#ifndef PGTYPES_NUMERIC
|
#ifndef PGTYPES_NUMERIC
|
||||||
#define PGTYPES_NUMERIC
|
#define PGTYPES_NUMERIC
|
||||||
|
|
||||||
|
#include <pgtypes.h>
|
||||||
|
|
||||||
#define NUMERIC_POS 0x0000
|
#define NUMERIC_POS 0x0000
|
||||||
#define NUMERIC_NEG 0x4000
|
#define NUMERIC_NEG 0x4000
|
||||||
#define NUMERIC_NAN 0xC000
|
#define NUMERIC_NAN 0xC000
|
||||||
@ -166,7 +168,7 @@ dump_sqlda(sqlda_t *sqlda)
|
|||||||
|
|
||||||
val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
|
val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
|
||||||
printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
|
printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
|
||||||
free(val);
|
PGTYPESchar_free(val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,18 +39,18 @@ main(void)
|
|||||||
|
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf ("Date: %s\n", text);
|
printf ("Date: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf ("timestamp: %s\n", text);
|
printf ("timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
|
iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
|
||||||
PGTYPESinterval_copy(iv1, &iv2);
|
PGTYPESinterval_copy(iv1, &iv2);
|
||||||
text = PGTYPESinterval_to_asc(&iv2);
|
text = PGTYPESinterval_to_asc(&iv2);
|
||||||
printf ("interval: %s\n", text);
|
printf ("interval: %s\n", text);
|
||||||
PGTYPESinterval_free(iv1);
|
PGTYPESinterval_free(iv1);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPESdate_mdyjul(mdy, &date2);
|
PGTYPESdate_mdyjul(mdy, &date2);
|
||||||
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
printf("m: %d, d: %d, y: %d\n", mdy[0], mdy[1], mdy[2]);
|
||||||
@ -70,7 +70,7 @@ main(void)
|
|||||||
PGTYPESdate_fmt_asc(date1, fmt, out);
|
PGTYPESdate_fmt_asc(date1, fmt, out);
|
||||||
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
|
printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
|
||||||
printf("Above date in format \"%s\" is \"%s\"\n", fmt, out);
|
printf("Above date in format \"%s\" is \"%s\"\n", fmt, out);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
free(out);
|
free(out);
|
||||||
|
|
||||||
out = (char*) malloc(48);
|
out = (char*) malloc(48);
|
||||||
@ -90,7 +90,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc1: %s\n", text);
|
printf("date_defmt_asc1: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmmm. dd. yyyy";
|
fmt = "mmmm. dd. yyyy";
|
||||||
@ -98,7 +98,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc2: %s\n", text);
|
printf("date_defmt_asc2: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -106,7 +106,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc3: %s\n", text);
|
printf("date_defmt_asc3: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yy/mm/dd";
|
fmt = "yy/mm/dd";
|
||||||
@ -114,7 +114,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc4: %s\n", text);
|
printf("date_defmt_asc4: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "dd-mm-yy";
|
fmt = "dd-mm-yy";
|
||||||
@ -122,7 +122,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc5: %s\n", text);
|
printf("date_defmt_asc5: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmddyy";
|
fmt = "mmddyy";
|
||||||
@ -130,7 +130,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc6: %s\n", text);
|
printf("date_defmt_asc6: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -138,7 +138,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc7: %s\n", text);
|
printf("date_defmt_asc7: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mmm. dd. yyyy";
|
fmt = "mmm. dd. yyyy";
|
||||||
@ -146,7 +146,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc8: %s\n", text);
|
printf("date_defmt_asc8: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm yy dd.";
|
fmt = "mm yy dd.";
|
||||||
@ -154,7 +154,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc9: %s\n", text);
|
printf("date_defmt_asc9: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "yyyy fierj mm dd.";
|
fmt = "yyyy fierj mm dd.";
|
||||||
@ -162,7 +162,7 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc10: %s\n", text);
|
printf("date_defmt_asc10: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = 0; text = "";
|
date1 = 0; text = "";
|
||||||
fmt = "mm/dd/yy";
|
fmt = "mm/dd/yy";
|
||||||
@ -170,28 +170,28 @@ main(void)
|
|||||||
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
PGTYPESdate_defmt_asc(&date1, fmt, in);
|
||||||
text = PGTYPESdate_to_asc(date1);
|
text = PGTYPESdate_to_asc(date1);
|
||||||
printf("date_defmt_asc12: %s\n", text);
|
printf("date_defmt_asc12: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPEStimestamp_current(&ts1);
|
PGTYPEStimestamp_current(&ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
/* can't output this in regression mode */
|
/* can't output this in regression mode */
|
||||||
/* printf("timestamp_current: Now: %s\n", text); */
|
/* printf("timestamp_current: Now: %s\n", text); */
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc1: %s\n", text);
|
printf("timestamp_to_asc1: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc2: %s\n", text);
|
printf("timestamp_to_asc2: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_to_asc3: %s\n", text);
|
printf("timestamp_to_asc3: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
/* abc-03:10:35-def-02/11/94-gh */
|
/* abc-03:10:35-def-02/11/94-gh */
|
||||||
/* 12345678901234567890123456789 */
|
/* 12345678901234567890123456789 */
|
||||||
@ -206,161 +206,161 @@ main(void)
|
|||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 2000";
|
in = "Tue Feb 29 17:28:44 +0200 2000";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1900";
|
in = "Tue Feb 29 17:28:44 +0200 1900";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1996";
|
in = "Tue Feb 29 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 31 17:28:44 +0200 1996";
|
in = " Jul 31 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b %d %H:%M:%S %z %Y";
|
fmt = "%b %d %H:%M:%S %z %Y";
|
||||||
in = " Jul 32 17:28:44 +0200 1996";
|
in = " Jul 32 17:28:44 +0200 1996";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %d %H:%M:%S %z %Y";
|
fmt = "%a %b %d %H:%M:%S %z %Y";
|
||||||
in = "Tue Feb 29 17:28:44 +0200 1997";
|
in = "Tue Feb 29 17:28:44 +0200 1997";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%";
|
fmt = "%";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "a %";
|
fmt = "a %";
|
||||||
in = "Tue Jul 22 17:28:44 +0200 2003";
|
in = "Tue Jul 22 17:28:44 +0200 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%b, %d %H_%M`%S %z %Y";
|
fmt = "%b, %d %H_%M`%S %z %Y";
|
||||||
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
in = " Jul, 22 17_28 `44 +0200 2003 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
|
||||||
in = "Tue Jul %22 17:28:44 CEST 2003";
|
in = "Tue Jul %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
|
||||||
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
in = "abc\n 19 October %22 17:28:44 CEST 2003";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "";
|
fmt = "";
|
||||||
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
in = "abc\n 18 October %34 17:28:44 CEST 80";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
in = "1980-04-12 3:49:44 ";
|
in = "1980-04-12 3:49:44 ";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
|
printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
fmt = "%B %d, %Y. Time: %I:%M%p";
|
fmt = "%B %d, %Y. Time: %I:%M%p";
|
||||||
in = "July 14, 1988. Time: 9:15am";
|
in = "July 14, 1988. Time: 9:15am";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = "September 6 at 01:30 pm in the year 1983";
|
in = "September 6 at 01:30 pm in the year 1983";
|
||||||
fmt = "%B %d at %I:%M %p in the year %Y";
|
fmt = "%B %d at %I:%M %p in the year %Y";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15am";
|
in = " 1976, July 14. Time: 9:15am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M %p";
|
fmt = "%Y, %B %d. Time: %I:%M %p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, July 14. Time: 9:15 am";
|
in = " 1976, July 14. Time: 9:15 am";
|
||||||
fmt = "%Y, %B %d. Time: %I:%M%p";
|
fmt = "%Y, %B %d. Time: %I:%M%p";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = " 1976, P.M. July 14. Time: 9:15";
|
in = " 1976, P.M. July 14. Time: 9:15";
|
||||||
fmt = "%Y, %P %B %d. Time: %I:%M";
|
fmt = "%Y, %P %B %d. Time: %I:%M";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
in = "1234567890";
|
in = "1234567890";
|
||||||
fmt = "%s";
|
fmt = "%s";
|
||||||
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
|
||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
exec sql rollback;
|
exec sql rollback;
|
||||||
exec sql disconnect;
|
exec sql disconnect;
|
||||||
|
@ -75,14 +75,14 @@ main(void)
|
|||||||
text = PGTYPEStimestamp_to_asc(ts1);
|
text = PGTYPEStimestamp_to_asc(ts1);
|
||||||
|
|
||||||
printf("timestamp: %s\n", text);
|
printf("timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
date1 = PGTYPESdate_from_timestamp(ts1);
|
date1 = PGTYPESdate_from_timestamp(ts1);
|
||||||
dc = PGTYPESdate_new();
|
dc = PGTYPESdate_new();
|
||||||
*dc = date1;
|
*dc = date1;
|
||||||
text = PGTYPESdate_to_asc(*dc);
|
text = PGTYPESdate_to_asc(*dc);
|
||||||
printf("Date of timestamp: %s\n", text);
|
printf("Date of timestamp: %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESdate_free(dc);
|
PGTYPESdate_free(dc);
|
||||||
|
|
||||||
for (i = 0; dates[i]; i++)
|
for (i = 0; dates[i]; i++)
|
||||||
@ -97,7 +97,7 @@ main(void)
|
|||||||
i, err ? "-" : text,
|
i, err ? "-" : text,
|
||||||
endptr ? 'N' : 'Y',
|
endptr ? 'N' : 'Y',
|
||||||
err ? 'T' : 'F');
|
err ? 'T' : 'F');
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
for (j = 0; times[j]; j++)
|
for (j = 0; times[j]; j++)
|
||||||
@ -114,7 +114,7 @@ main(void)
|
|||||||
if (i != 19 || (j != 3 && j != 4))
|
if (i != 19 || (j != 3 && j != 4))
|
||||||
printf("TS[%d,%d]: %s\n",
|
printf("TS[%d,%d]: %s\n",
|
||||||
i, j, errno ? "-" : text);
|
i, j, errno ? "-" : text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,13 +138,13 @@ main(void)
|
|||||||
continue;
|
continue;
|
||||||
text = PGTYPESinterval_to_asc(i1);
|
text = PGTYPESinterval_to_asc(i1);
|
||||||
printf("interval[%d]: %s\n", i, text ? text : "-");
|
printf("interval[%d]: %s\n", i, text ? text : "-");
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
ic = PGTYPESinterval_new();
|
ic = PGTYPESinterval_new();
|
||||||
PGTYPESinterval_copy(i1, ic);
|
PGTYPESinterval_copy(i1, ic);
|
||||||
text = PGTYPESinterval_to_asc(i1);
|
text = PGTYPESinterval_to_asc(i1);
|
||||||
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
|
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESinterval_free(ic);
|
PGTYPESinterval_free(ic);
|
||||||
PGTYPESinterval_free(i1);
|
PGTYPESinterval_free(i1);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ main(void)
|
|||||||
PGTYPESnumeric_from_int(1407, value1);
|
PGTYPESnumeric_from_int(1407, value1);
|
||||||
text = PGTYPESnumeric_to_asc(value1, -1);
|
text = PGTYPESnumeric_to_asc(value1, -1);
|
||||||
printf("from int = %s\n", text);
|
printf("from int = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value1);
|
PGTYPESnumeric_free(value1);
|
||||||
|
|
||||||
value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
|
value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
|
||||||
@ -47,12 +47,12 @@ main(void)
|
|||||||
PGTYPESnumeric_add(value1, value2, res);
|
PGTYPESnumeric_add(value1, value2, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("add = %s\n", text);
|
printf("add = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
|
|
||||||
PGTYPESnumeric_sub(res, value2, res);
|
PGTYPESnumeric_sub(res, value2, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("sub = %s\n", text);
|
printf("sub = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value2);
|
PGTYPESnumeric_free(value2);
|
||||||
|
|
||||||
des = PGTYPESnumeric_new();
|
des = PGTYPESnumeric_new();
|
||||||
@ -68,7 +68,7 @@ main(void)
|
|||||||
PGTYPESnumeric_mul(res, des, res);
|
PGTYPESnumeric_mul(res, des, res);
|
||||||
text = PGTYPESnumeric_to_asc(res, -1);
|
text = PGTYPESnumeric_to_asc(res, -1);
|
||||||
printf("mul = %s\n", text);
|
printf("mul = %s\n", text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(des);
|
PGTYPESnumeric_free(des);
|
||||||
|
|
||||||
value2 = PGTYPESnumeric_from_asc("10000", NULL);
|
value2 = PGTYPESnumeric_from_asc("10000", NULL);
|
||||||
@ -85,7 +85,7 @@ main(void)
|
|||||||
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
|
i = PGTYPESnumeric_to_long(value1, &l1) | PGTYPESnumeric_to_long(value2, &l2);
|
||||||
printf("to long(%d) = %ld %ld\n", i, l1, l2);
|
printf("to long(%d) = %ld %ld\n", i, l1, l2);
|
||||||
|
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(value1);
|
PGTYPESnumeric_free(value1);
|
||||||
PGTYPESnumeric_free(value2);
|
PGTYPESnumeric_free(value2);
|
||||||
PGTYPESnumeric_free(res);
|
PGTYPESnumeric_free(res);
|
||||||
|
@ -59,21 +59,21 @@ main(void)
|
|||||||
|
|
||||||
text = PGTYPESnumeric_to_asc(num, -1);
|
text = PGTYPESnumeric_to_asc(num, -1);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,1]: %s\n", i, text); free(text);
|
printf("num[%d,1]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 0);
|
text = PGTYPESnumeric_to_asc(num, 0);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,2]: %s\n", i, text); free(text);
|
printf("num[%d,2]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 1);
|
text = PGTYPESnumeric_to_asc(num, 1);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,3]: %s\n", i, text); free(text);
|
printf("num[%d,3]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
text = PGTYPESnumeric_to_asc(num, 2);
|
text = PGTYPESnumeric_to_asc(num, 2);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,4]: %s\n", i, text); free(text);
|
printf("num[%d,4]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
|
|
||||||
nin = PGTYPESnumeric_new();
|
nin = PGTYPESnumeric_new();
|
||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
if (!text) check_errno();
|
if (!text) check_errno();
|
||||||
printf("num[%d,5]: %s\n", i, text); free(text);
|
printf("num[%d,5]: %s\n", i, text); PGTYPESchar_free(text);
|
||||||
|
|
||||||
r = PGTYPESnumeric_to_long(num, &l);
|
r = PGTYPESnumeric_to_long(num, &l);
|
||||||
if (r) check_errno();
|
if (r) check_errno();
|
||||||
@ -85,7 +85,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = PGTYPESnumeric_to_int(num, &k);
|
r = PGTYPESnumeric_to_int(num, &k);
|
||||||
@ -98,7 +98,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != 6)
|
if (i != 6)
|
||||||
@ -129,7 +129,7 @@ main(void)
|
|||||||
text = PGTYPESnumeric_to_asc(nin, 2);
|
text = PGTYPESnumeric_to_asc(nin, 2);
|
||||||
q = PGTYPESnumeric_cmp(num, nin);
|
q = PGTYPESnumeric_cmp(num, nin);
|
||||||
printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
PGTYPESdecimal_free(dec);
|
PGTYPESdecimal_free(dec);
|
||||||
@ -155,7 +155,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(a, 10);
|
text = PGTYPESnumeric_to_asc(a, 10);
|
||||||
printf("num[a,%d,%d]: %s\n", i, j, text);
|
printf("num[a,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
|
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
|
||||||
if (r)
|
if (r)
|
||||||
@ -167,7 +167,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(s, 10);
|
text = PGTYPESnumeric_to_asc(s, 10);
|
||||||
printf("num[s,%d,%d]: %s\n", i, j, text);
|
printf("num[s,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
|
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
|
||||||
if (r)
|
if (r)
|
||||||
@ -179,7 +179,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(m, 10);
|
text = PGTYPESnumeric_to_asc(m, 10);
|
||||||
printf("num[m,%d,%d]: %s\n", i, j, text);
|
printf("num[m,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
|
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
|
||||||
if (r)
|
if (r)
|
||||||
@ -191,7 +191,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(d, 10);
|
text = PGTYPESnumeric_to_asc(d, 10);
|
||||||
printf("num[d,%d,%d]: %s\n", i, j, text);
|
printf("num[d,%d,%d]: %s\n", i, j, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
PGTYPESnumeric_free(a);
|
PGTYPESnumeric_free(a);
|
||||||
@ -205,7 +205,7 @@ main(void)
|
|||||||
{
|
{
|
||||||
text = PGTYPESnumeric_to_asc(numarr[i], -1);
|
text = PGTYPESnumeric_to_asc(numarr[i], -1);
|
||||||
printf("%d: %s\n", i, text);
|
printf("%d: %s\n", i, text);
|
||||||
free(text);
|
PGTYPESchar_free(text);
|
||||||
PGTYPESnumeric_free(numarr[i]);
|
PGTYPESnumeric_free(numarr[i]);
|
||||||
}
|
}
|
||||||
free(numarr);
|
free(numarr);
|
||||||
|
@ -53,7 +53,7 @@ dump_sqlda(sqlda_t *sqlda)
|
|||||||
|
|
||||||
val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
|
val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
|
||||||
printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
|
printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
|
||||||
free(val);
|
PGTYPESchar_free(val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user