バージョンごとのドキュメント一覧

36.6. pgtypes ライブラリ #

<title>pgtypes Library</title>

The pgtypes library maps <productname>PostgreSQL</productname> database types to C equivalents that can be used in C programs. It also offers functions to do basic calculations with those types within C, i.e., without the help of the <productname>PostgreSQL</productname> server. See the following example: pgtypesライブラリはPostgreSQLデータベースの型をCプログラムで使用できるようにC言語に対応させます。 また、これらの型を使用したCの基本的な計算を行う関数も提供します。 この計算には、PostgreSQLサーバを使用しません。 以下の例を参照してください。

EXEC SQL BEGIN DECLARE SECTION;
   date date1;
   timestamp ts1, tsout;
   interval iv1;
   char *out;
EXEC SQL END DECLARE SECTION;

PGTYPESdate_today(&date1);
EXEC SQL SELECT started, duration INTO :ts1, :iv1 FROM datetbl WHERE d=:date1;
PGTYPEStimestamp_add_interval(&ts1, &iv1, &tsout);
out = PGTYPEStimestamp_to_asc(&tsout);
printf("Started + duration: %s\n", out);
PGTYPESchar_free(out);

36.6.1. 文字列 #

<title>Character Strings</title>

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.) PGTYPESnumeric_to_ascのような一部の関数は新たに割り当てられた文字列へのポインタを返します。 この結果はfreeの代わりにPGTYPESchar_freeで解放することが必要です。 (これはWindows上でのみ重要です。Windowsではメモリの割り当てと解放は同じライブラリで実施されることが必要な場合があります。)

36.6.2. numeric 型 #

<title>The numeric Type</title>

The numeric type offers to do calculations with arbitrary precision. See <xref linkend="datatype-numeric"/> for the equivalent type in the <productname>PostgreSQL</productname> server. Because of the arbitrary precision this variable needs to be able to expand and shrink dynamically. That's why you can only create numeric variables on the heap, by means of the <function>PGTYPESnumeric_new</function> and <function>PGTYPESnumeric_free</function> functions. The decimal type, which is similar but limited in precision, can be created on the stack as well as on the heap. numeric 型では任意の精度での計算機能を提供します。 PostgreSQLサーバにおける対応する型については8.1を参照してください。 任意の精度を持つために、この変数は動的に拡張、縮小できなければなりません。 これが、PGTYPESnumeric_newPGTYPESnumeric_free関数では、ヒープ領域上にのみしか numeric 変数を作成できない理由です。 decimal 型も似ていますが精度が限定されていますので、ヒープ領域以外にスタック領域上でも作成可能です。

The following functions can be used to work with the numeric type: 以下の関数は numeric 型で使用することができます:

PGTYPESnumeric_new #

Request a pointer to a newly allocated numeric variable. 新規割当ての numeric 型へのポインタを要求します。

numeric *PGTYPESnumeric_new(void);

PGTYPESnumeric_free #

Free a numeric type, release all of its memory. numeric 型を解放し、そのメモリをすべて解放します。

void PGTYPESnumeric_free(numeric *var);

PGTYPESnumeric_from_asc #

Parse a numeric type from its string notation. 文字列表記から numeric 型に変換します。

numeric *PGTYPESnumeric_from_asc(char *str, char **endptr);

Valid formats are for example: <literal>-2</literal>, <literal>.794</literal>, <literal>+3.44</literal>, <literal>592.49E07</literal> or <literal>-32.84e-4</literal>. If the value could be parsed successfully, a valid pointer is returned, else the NULL pointer. At the moment ECPG always parses the complete string and so it currently does not support to store the address of the first invalid character in <literal>*endptr</literal>. You can safely set <literal>endptr</literal> to NULL. 有効な書式の例を示します。 -2.794+3.44592.49E07-32.84e-4。 値への変換に成功した場合、有効なポインタが返されます。 失敗した場合は NULL ポインタが返されます。 現在ECPGは文字列全体を解析しますので、現時点では*endptr内に最初の無効な文字のアドレスを格納することをサポートしません。 このためendptrを安全に NULL にすることができます。

PGTYPESnumeric_to_asc #

Returns a pointer to a string allocated by <function>malloc</function> that contains the string representation of the numeric type <literal>num</literal>. numeric 型numの文字列表現を持つ、mallocで割り当てられた文字列へのポインタを返します。

char *PGTYPESnumeric_to_asc(numeric *num, int dscale);

The numeric value will be printed with <literal>dscale</literal> decimal digits, with rounding applied if necessary. The result must be freed with <function>PGTYPESchar_free()</function>. numeric の値は、必要に応じて四捨五入され、dscale 桁の十進数で出力されます。 結果はPGTYPESchar_free()で解放しなければなりません。

PGTYPESnumeric_add #

Add two numeric variables into a third one. 2つの numeric 変数を加算し、3番目の numeric 変数に格納します。

int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result);

The function adds the variables <literal>var1</literal> and <literal>var2</literal> into the result variable <literal>result</literal>. The function returns 0 on success and -1 in case of error. この関数は変数var1と変数var2を加算し、その結果をresultに格納します。 成功時0を、エラー時-1を返します。

PGTYPESnumeric_sub #

Subtract two numeric variables and return the result in a third one. 2つの numeric 型変数を減算し、3番目の numeric 型変数に結果を格納します。

int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result);

The function subtracts the variable <literal>var2</literal> from the variable <literal>var1</literal>. The result of the operation is stored in the variable <literal>result</literal>. The function returns 0 on success and -1 in case of error. この関数は変数var1から変数var2を差し引きます。 演算結果を変数resultに格納します。 成功時0を、エラー時-1を返します。

PGTYPESnumeric_mul #

Multiply two numeric variables and return the result in a third one. 2つの numeric 型変数を乗算し、3番目の numeric 型変数に結果を格納します。

int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result);

The function multiplies the variables <literal>var1</literal> and <literal>var2</literal>. The result of the operation is stored in the variable <literal>result</literal>. The function returns 0 on success and -1 in case of error. この関数は変数var1と変数var2を掛け合わせます。 演算結果を変数resultに格納します。 成功時0を、エラー時-1を返します。

PGTYPESnumeric_div #

Divide two numeric variables and return the result in a third one. 2つの numeric 型変数で除算し、3番目の numeric 型変数に結果を格納します。

int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result);

The function divides the variables <literal>var1</literal> by <literal>var2</literal>. The result of the operation is stored in the variable <literal>result</literal>. The function returns 0 on success and -1 in case of error. この関数は変数var1を変数var2で割ります。 演算結果を変数resultに格納します。 成功時0を、エラー時-1を返します。

PGTYPESnumeric_cmp #

Compare two numeric variables. 2つのnumeric型変数を比較します。

int PGTYPESnumeric_cmp(numeric *var1, numeric *var2)

This function compares two numeric variables. In case of error, <literal>INT_MAX</literal> is returned. On success, the function returns one of three possible results: この関数は2つのnumeric型変数を比較します。 エラーの場合INT_MAXが返ります。 成功時、この関数は以下のいずれかを返します:

  • 1, if <literal>var1</literal> is bigger than <literal>var2</literal> var1var2より大きければ1。

  • -1, if <literal>var1</literal> is smaller than <literal>var2</literal> var1var2より小さければ-1。

  • 0, if <literal>var1</literal> and <literal>var2</literal> are equal var1var2と等しければ0。

PGTYPESnumeric_from_int #

Convert an int variable to a numeric variable. int型変数をnumeric型変数に変換します。

int PGTYPESnumeric_from_int(signed int int_val, numeric *var);

This function accepts a variable of type signed int and stores it in the numeric variable <literal>var</literal>. Upon success, 0 is returned and -1 in case of a failure. この関数はsigned int型の変数を受付け、numeric型変数var内に格納します。 成功時0、失敗時-1が返ります。

PGTYPESnumeric_from_long #

Convert a long int variable to a numeric variable. long int型変数をnumeric型変数に変換します。

int PGTYPESnumeric_from_long(signed long int long_val, numeric *var);

This function accepts a variable of type signed long int and stores it in the numeric variable <literal>var</literal>. Upon success, 0 is returned and -1 in case of a failure. この関数は符号付long int型の変数を受付け、numeric 型変数var内に格納します。 成功時0、失敗時-1が返ります。

PGTYPESnumeric_copy #

Copy over one numeric variable into another one. numeric 型変数を他の numeric 型変数にコピーします。

int PGTYPESnumeric_copy(numeric *src, numeric *dst);

This function copies over the value of the variable that <literal>src</literal> points to into the variable that <literal>dst</literal> points to. It returns 0 on success and -1 if an error occurs. この関数は、srcが指し示す変数の値をdstが指し示す変数にコピーします。 成功時0、失敗時-1が返ります。

PGTYPESnumeric_from_double #

Convert a variable of type double to a numeric. double型の変数を numeric 型変数に変換します。

int  PGTYPESnumeric_from_double(double d, numeric *dst);

This function accepts a variable of type double and stores the result in the variable that <literal>dst</literal> points to. It returns 0 on success and -1 if an error occurs. この関数はdouble型の変数を受付け、変換結果をdstが指し示す変数内に格納します。 成功時0、失敗時-1が返ります。

PGTYPESnumeric_to_double #

Convert a variable of type numeric to double. numeric 型変数をdouble型に変換します。

int PGTYPESnumeric_to_double(numeric *nv, double *dp)

The function converts the numeric value from the variable that <literal>nv</literal> points to into the double variable that <literal>dp</literal> points to. It returns 0 on success and -1 if an error occurs, including overflow. On overflow, the global variable <literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal> additionally. この関数はnvが指し示す numeric 型変数の値をdpが指し示すdouble型変数に変換します。 成功時0、オーバーフローを含むエラーが発生した時-1が返ります。 オーバーフローが発生した場合はさらに、グローバル変数errnoPGTYPES_NUM_OVERFLOWに設定されます。

PGTYPESnumeric_to_int #

Convert a variable of type numeric to int. numeric 型変数をint型に変換します。

int PGTYPESnumeric_to_int(numeric *nv, int *ip);

The function converts the numeric value from the variable that <literal>nv</literal> points to into the integer variable that <literal>ip</literal> points to. It returns 0 on success and -1 if an error occurs, including overflow. On overflow, the global variable <literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal> additionally. この関数はnvが指し示す numeric 型変数の値をipが指し示す整数型変数に変換します。 成功時0、オーバーフローを含むエラーが発生した時-1が返ります。 オーバーフローが発生した場合はさらに、グローバル変数errnoPGTYPES_NUM_OVERFLOWに設定されます。

PGTYPESnumeric_to_long #

Convert a variable of type numeric to long. numeric 型変数をlong型に変換します。

int PGTYPESnumeric_to_long(numeric *nv, long *lp);

The function converts the numeric value from the variable that <literal>nv</literal> points to into the long integer variable that <literal>lp</literal> points to. It returns 0 on success and -1 if an error occurs, including overflow. On overflow, the global variable <literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal> additionally. この関数はnvが指し示す numeric 型変数の値をlpが指し示すlong変数に変換します。 成功時0、オーバーフローを含むエラーが発生した時-1が返ります。 オーバーフローが発生した場合はさらに、グローバル変数errnoPGTYPES_NUM_OVERFLOWに設定されます。

PGTYPESnumeric_to_decimal #

Convert a variable of type numeric to decimal. numeric 型変数を decimal 型に変換します。

int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst);

The function converts the numeric value from the variable that <literal>src</literal> points to into the decimal variable that <literal>dst</literal> points to. It returns 0 on success and -1 if an error occurs, including overflow. On overflow, the global variable <literal>errno</literal> will be set to <literal>PGTYPES_NUM_OVERFLOW</literal> additionally. この関数はsrcが指し示す numeric 型変数の値をdstが指し示す decimal 型変数に変換します。 成功時0、オーバーフローを含むエラーが発生した時-1が返ります。 オーバーフローが発生した場合はさらに、グローバル変数errnoPGTYPES_NUM_OVERFLOWに設定されます。

PGTYPESnumeric_from_decimal #

Convert a variable of type decimal to numeric. decimal 型変数を numeric 型に変換します。

int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst);

The function converts the decimal value from the variable that <literal>src</literal> points to into the numeric variable that <literal>dst</literal> points to. It returns 0 on success and -1 if an error occurs. Since the decimal type is implemented as a limited version of the numeric type, overflow cannot occur with this conversion. この関数はsrcが指し示す decimal 型変数の値をdstが指し示す numeric 型変数に変換します。 成功時0、エラーが発生した時-1が返ります。 decimal 型は制限付の numeric 型として実装されていますので、この変換ではオーバーフローは起きません。

36.6.3. 日付型 #

<title>The date Type</title>

The date type in C enables your programs to deal with data of the SQL type date. See <xref linkend="datatype-datetime"/> for the equivalent type in the <productname>PostgreSQL</productname> server. Cの日付型を使用して、プログラムからSQLの日付型を取り扱うことができます。 PostgreSQLサーバにおける対応する型については8.5を参照してください。

The following functions can be used to work with the date type: 日付型を操作するために以下の関数を使用することができます:

PGTYPESdate_from_timestamp #

Extract the date part from a timestamp. タイムスタンプから日付部分を取り出します。

date PGTYPESdate_from_timestamp(timestamp dt);

The function receives a timestamp as its only argument and returns the extracted date part from this timestamp. この関数は唯一の引数としてタイムスタンプを受付け、そこから日付部分を取り出します。

PGTYPESdate_from_asc #

Parse a date from its textual representation. テキスト表現から日付型に変換します。

date PGTYPESdate_from_asc(char *str, char **endptr);

The function receives a C char* string <literal>str</literal> and a pointer to a C char* string <literal>endptr</literal>. At the moment ECPG always parses the complete string and so it currently does not support to store the address of the first invalid character in <literal>*endptr</literal>. You can safely set <literal>endptr</literal> to NULL. この関数はCのchar*型文字列strとCのchar*型文字列endptrへのポインタを受付けます。 現在ECPGは文字列全体を解析しますので、現時点では*endptrに最初の無効な文字のアドレスを格納することをサポートしません。 このためendptrを安全にNULLにすることができます。

Note that the function always assumes MDY-formatted dates and there is currently no variable to change that within ECPG. この関数が常にMDY書式の日付を前提としている点に注意してください。 現在ECPGにはこれを変更するための変数がありません。

<xref linkend="ecpg-pgtypesdate-from-asc-table"/> shows the allowed input formats. 表 36.2に許される入力書式を示します。

表36.2 有効なPGTYPESdate_from_ascの入力書式

<title>Valid Input Formats for <function>PGTYPESdate_from_asc</function></title>
入力結果
January 8, 1999January 8, 1999
1999-01-08January 8, 1999
1/8/1999January 8, 1999
1/18/1999January 18, 1999
01/02/03February 1, 2003
1999-Jan-08January 8, 1999
Jan-08-1999January 8, 1999
08-Jan-1999January 8, 1999
99-Jan-08January 8, 1999
08-Jan-99January 8, 1999
08-Jan-06January 8, 2006
Jan-08-99January 8, 1999
19990108ISO 8601; January 8, 1999
990108ISO 8601; January 8, 1999
1999.008年と年内日数
J2451187Jユリウス日
January 8, 99 BC紀元前99年

PGTYPESdate_to_asc #

Return the textual representation of a date variable. 日付型変数のテキスト表現を返します。

char *PGTYPESdate_to_asc(date dDate);

The function receives the date <literal>dDate</literal> as its only parameter. It will output the date in the form <literal>1999-01-18</literal>, i.e., in the <literal>YYYY-MM-DD</literal> format. The result must be freed with <function>PGTYPESchar_free()</function>. この関数は唯一の引数として日付型dDateを受付けます。 この関数は1999-01-18、つまりYYYY-MM-DD書式で日付を出力します。 結果はPGTYPESchar_free()で解放しなければなりません。

PGTYPESdate_julmdy #

Extract the values for the day, the month and the year from a variable of type date. 日付型の変数から、日、月、年の値を取り出します。

void PGTYPESdate_julmdy(date d, int *mdy);

almost same description as for rjulmdy() The function receives the date <literal>d</literal> and a pointer to an array of 3 integer values <literal>mdy</literal>. The variable name indicates the sequential order: <literal>mdy[0]</literal> will be set to contain the number of the month, <literal>mdy[1]</literal> will be set to the value of the day and <literal>mdy[2]</literal> will contain the year. この関数は日付型のdと、3つの整数値を持つ配列mdyへのポインタを受付けます。 この変数名はその並びを表し、mdy[0]には月数、mdy[1]には日数が、mdy[2]には年が入ります。

PGTYPESdate_mdyjul #

Create a date value from an array of 3 integers that specify the day, the month and the year of the date. 日付の日、月、年を指定した3つの整数からなる配列から日付値を作成します。

void PGTYPESdate_mdyjul(int *mdy, date *jdate);

The function receives the array of the 3 integers (<literal>mdy</literal>) as its first argument and as its second argument a pointer to a variable of type date that should hold the result of the operation. この関数は、1番目の引数として3つの整数からなる配列(mdy)、2番目の引数として処理結果を格納する日付型の変数へのポインタを受付けます。

PGTYPESdate_dayofweek #

Return a number representing the day of the week for a date value. 日付値から週内日数を表す数を返します。

int PGTYPESdate_dayofweek(date d);

The function receives the date variable <literal>d</literal> as its only argument and returns an integer that indicates the day of the week for this date. この関数は唯一の引数としてdate型変数dを受付け、その日付の週内日数を表す整数を返します。

  • 0 - Sunday 0 - 日曜

  • 1 - Monday 1 - 月曜

  • 2 - Tuesday 2 - 火曜

  • 3 - Wednesday 3 - 水曜

  • 4 - Thursday 4 - 木曜

  • 5 - Friday 5 - 金曜

  • 6 - Saturday 6 - 土曜

PGTYPESdate_today #

Get the current date. 現在の日付を取得します。

void PGTYPESdate_today(date *d);

The function receives a pointer to a date variable (<literal>d</literal>) that it sets to the current date. この関数は現在の日付に設定されるdate型変数(d)を指し示すポインタを受付けます。

PGTYPESdate_fmt_asc #

Convert a variable of type date to its textual representation using a format mask. date型変数を書式マスクを使用したテキスト表現に変換します。

int PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf);

The function receives the date to convert (<literal>dDate</literal>), the format mask (<literal>fmtstring</literal>) and the string that will hold the textual representation of the date (<literal>outbuf</literal>). この関数は変換対象のdate型(dDate)、書式マスク(fmtstring)、日付のテキスト表現を格納するための文字列(outbuf)を受付けます。

On success, 0 is returned and a negative value if an error occurred. 成功時に0、エラーが発生した場合は負の値が返ります。

The following literals are the field specifiers you can use: 以下のリテラルを使用して、フィールドを指定することができます。

  • <literal>dd</literal> - The number of the day of the month. dd - 月内の日数。

  • <literal>mm</literal> - The number of the month of the year. mm - 年内の月数。

  • <literal>yy</literal> - The number of the year as a two digit number. yy - 二桁表記の年数

  • <literal>yyyy</literal> - The number of the year as a four digit number. yyyy - 四桁表記の年数

  • <literal>ddd</literal> - The name of the day (abbreviated). ddd - 曜日の名前(省略形)

  • <literal>mmm</literal> - The name of the month (abbreviated). mmm - 月の名前(省略形)

All other characters are copied 1:1 to the output string. 他の文字はすべて出力文字列にそのままコピーされます。

<xref linkend="ecpg-pgtypesdate-fmt-asc-example-table"/> indicates a few possible formats. This will give you an idea of how to use this function. All output lines are based on the same date: November 23, 1959. 表 36.3にいくつかの可能性のある書式を示します。 この関数の使用方法に関するアイディアを提供しています。 出力行はすべて同じ日付、1959年11月23日に基づいています。

表36.3 有効なPGTYPESdate_fmt_ascの入力書式

<title>Valid Input Formats for <function>PGTYPESdate_fmt_asc</function></title>
書式結果
mmddyy112359
ddmmyy231159
yymmdd591123
yy/mm/dd59/11/23
yy mm dd59 11 23
yy.mm.dd59.11.23
.mm.yyyy.dd..11.1959.23.
mmm. dd, yyyyNov. 23, 1959
mmm dd yyyyNov 23 1959
yyyy dd mm1959 23 11
ddd, mmm. dd, yyyyMon, Nov. 23, 1959
(ddd) mmm. dd, yyyy(Mon) Nov. 23, 1959

PGTYPESdate_defmt_asc #

Use a format mask to convert a C <type>char*</type> string to a value of type date. 書式マスクを使用してCのchar*文字列からdate型の値に変換します。

int PGTYPESdate_defmt_asc(date *d, char *fmt, char *str);

same description as rdefmtdate The function receives a pointer to the date value that should hold the result of the operation (<literal>d</literal>), the format mask to use for parsing the date (<literal>fmt</literal>) and the C char* string containing the textual representation of the date (<literal>str</literal>). The textual representation is expected to match the format mask. However you do not need to have a 1:1 mapping of the string to the format mask. The function only analyzes the sequential order and looks for the literals <literal>yy</literal> or <literal>yyyy</literal> that indicate the position of the year, <literal>mm</literal> to indicate the position of the month and <literal>dd</literal> to indicate the position of the day. この関数は、処理結果を格納するための日付型へのポインタ(d)、日付を解析するための書式マスク(fmt)、日付のテキスト表現を含むCのchar*文字列(str)を受付けます。 テキスト表現は書式マスクに合った表現であることが仮定されています。 しかし、文字列と書式マスクを1:1に対応付けする必要はありません。 この関数は並んだ順番に解析し、年の位置を表すyyまたはyyyyを、月の位置を表すmmを、日の位置を表すddを検索します。

<xref linkend="ecpg-rdefmtdate-example-table"/> indicates a few possible formats. This will give you an idea of how to use this function. 表 36.4はいくつかの可能性のある書式を示します。 これはこの関数の使用方法に関するアイディアを提供します。

表36.4 有効なrdefmtdateの入力書式

<title>Valid Input Formats for <function>rdefmtdate</function></title>
書式文字列結果
ddmmyy21-2-541954-02-21
ddmmyy2-12-541954-12-02
ddmmyy201119541954-11-20
ddmmyy1304641964-04-13
mmm.dd.yyyyMAR-12-19671967-03-12
yy/mm/dd1954, February 3rd1954-02-03
mmm.dd.yyyy0412691969-04-12
yy/mm/ddIn the year 2525, in the month of July, mankind will be alive on the 28th day2525-07-28
dd-mm-yyI said on the 28th of July in the year 25252525-07-28
mmm.dd.yyyy9/14/581958-09-14
yy/mm/dd47/03/291947-03-29
mmm.dd.yyyyoct 28 19751975-10-28
mmddyyNov 14th, 19851985-11-14

36.6.4. timestamp型 #

<title>The timestamp Type</title>

The timestamp type in C enables your programs to deal with data of the SQL type timestamp. See <xref linkend="datatype-datetime"/> for the equivalent type in the <productname>PostgreSQL</productname> server. Cのタイムスタンプ型を使用してプログラムからSQLのタイムスタンプ型データを扱うことができます。 PostgreSQLにおける対応する型については8.5を参照してください。

The following functions can be used to work with the timestamp type: 以下の関数を使用してタイムスタンプ型を扱うことができます:

PGTYPEStimestamp_from_asc #

Parse a timestamp from its textual representation into a timestamp variable. テキスト表現のタイムスタンプをタイムスタンプ型変数に変換します。

timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr);

The function receives the string to parse (<literal>str</literal>) and a pointer to a C char* (<literal>endptr</literal>). At the moment ECPG always parses the complete string and so it currently does not support to store the address of the first invalid character in <literal>*endptr</literal>. You can safely set <literal>endptr</literal> to NULL. この関数は変換対象の文字列(str)とC char*へのポインタ(endptr)を受付けます。 現在ECPGは文字列全体を解析しますので、現時点では*endptrに最初の無効な文字の場所を格納をすることサポートしません。 このためendptrを安全に NULL にすることができます。

The function returns the parsed timestamp on success. On error, <literal>PGTYPESInvalidTimestamp</literal> is returned and <varname>errno</varname> is set to <literal>PGTYPES_TS_BAD_TIMESTAMP</literal>. See <xref linkend="pgtypesinvalidtimestamp"/> for important notes on this value. この関数は成功時変換後のタイムスタンプを返します。 エラー時、PGTYPESInvalidTimestampが返され、errnoPGTYPES_TS_BAD_TIMESTAMPに設定されます。 この値についての重要な注意書きについてPGTYPESInvalidTimestampを参照してください。

In general, the input string can contain any combination of an allowed date specification, a whitespace character and an allowed time specification. Note that time zones are not supported by ECPG. It can parse them but does not apply any calculation as the <productname>PostgreSQL</productname> server does for example. Timezone specifiers are silently discarded. 通常、入力文字列には許される日付指定の任意の組み合わせ、空白文字、許される時間指定を含むことができます。 時間帯はECPGでサポートされていない点に注意してください。 変換することはできますが、例えばPostgreSQLサーバが行うような計算を行うことはできません。 時間帯指定は警告無しに無視されます。

<xref linkend="ecpg-pgtypestimestamp-from-asc-example-table"/> contains a few examples for input strings. 表 36.5に入力文字列の例をいくつか示します。

表36.5 有効なPGTYPEStimestamp_from_ascの入力書式

<title>Valid Input Formats for <function>PGTYPEStimestamp_from_asc</function></title>
入力結果
1999-01-08 04:05:061999-01-08 04:05:06
January 8 04:05:06 1999 PST1999-01-08 04:05:06
1999-Jan-08 04:05:06.789-81999-01-08 04:05:06.789 (時間帯指定は無視されます。)
J2451187 04:05-08:001999-01-08 04:05:00 (時間帯指定は無視されます。)

PGTYPEStimestamp_to_asc #

Converts a date to a C char* string. date型をC char*文字列に変換します。

char *PGTYPEStimestamp_to_asc(timestamp tstamp);

The function receives the timestamp <literal>tstamp</literal> as its only argument and returns an allocated string that contains the textual representation of the timestamp. The result must be freed with <function>PGTYPESchar_free()</function>. この関数はtimestamp型のtstampを唯一の引数として受付け、timestamp型のテキスト表現を含む割り当てられた文字列を返します。 結果はPGTYPESchar_free()で解放しなければなりません。

PGTYPEStimestamp_current #

Retrieve the current timestamp. 現在のタイムスタンプを取り出します。

void PGTYPEStimestamp_current(timestamp *ts);

The function retrieves the current timestamp and saves it into the timestamp variable that <literal>ts</literal> points to. この関数は現在のタイムスタンプを取り出し、tsが指し示すtimestamp型変数に格納します。

PGTYPEStimestamp_fmt_asc #

Convert a timestamp variable to a C char* using a format mask. 書式マスクを使用してtimestamp型変数をC char*に変換します。

int PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr);

The function receives a pointer to the timestamp to convert as its first argument (<literal>ts</literal>), a pointer to the output buffer (<literal>output</literal>), the maximal length that has been allocated for the output buffer (<literal>str_len</literal>) and the format mask to use for the conversion (<literal>fmtstr</literal>). この関数は、最初の引数として変換対象のtimestamp型 (ts)を、出力バッファのポインタ(output)、出力バッファで割当て可能な最大長 (str_len)、変換に使用する書式マスク(fmtstr)を受付けます。

Upon success, the function returns 0 and a negative value if an error occurred. 成功するとこの関数は0を返します。 エラーが発生した場合は負の値が返ります。

You can use the following format specifiers for the format mask. The format specifiers are the same ones that are used in the <function>strftime</function> function in <productname>libc</productname>. Any non-format specifier will be copied into the output buffer. 書式マスクには以下の書式指定を使用することができます。 書式指定はlibcstrftime関数で使用されるものと同じです。 書式指定以外は出力バッファにコピーされます。 This is from the FreeBSD man page: http://www.freebsd.org/cgi/man.cgi?query=strftime&apropos=0&sektion=3&manpath=FreeBSD+7.0-current&format=html

  • <literal>%A</literal> - is replaced by national representation of the full weekday name. %A - 各言語の曜日名称に置換されます。

  • <literal>%a</literal> - is replaced by national representation of the abbreviated weekday name. %a - 各言語の曜日略称に置換されます。

  • <literal>%B</literal> - is replaced by national representation of the full month name. %B - 各言語の月名称に置換されます。

  • <literal>%b</literal> - is replaced by national representation of the abbreviated month name. %b - 各言語の月略称に置換されます。

  • <literal>%C</literal> - is replaced by (year / 100) as decimal number; single digits are preceded by a zero. %C - 年を100で割った10進数に置換されます。1桁の場合は先頭に0が付与されます。

  • <literal>%c</literal> - is replaced by national representation of time and date. %c - 各言語の日付時刻表現に置換されます。

  • <literal>%D</literal> - is equivalent to <literal>%m/%d/%y</literal>. %D - %m/%d/%yと同じです。

  • <literal>%d</literal> - is replaced by the day of the month as a decimal number (01&ndash;31). %d - 月内の10進日数(01–31)に置換されます。

  • <literal>%E*</literal> <literal>%O*</literal> - POSIX locale extensions. The sequences <literal>%Ec</literal> <literal>%EC</literal> <literal>%Ex</literal> <literal>%EX</literal> <literal>%Ey</literal> <literal>%EY</literal> <literal>%Od</literal> <literal>%Oe</literal> <literal>%OH</literal> <literal>%OI</literal> <literal>%Om</literal> <literal>%OM</literal> <literal>%OS</literal> <literal>%Ou</literal> <literal>%OU</literal> <literal>%OV</literal> <literal>%Ow</literal> <literal>%OW</literal> <literal>%Oy</literal> are supposed to provide alternative representations. %E* %O* - POSIXロケール拡張です。 %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy という並びは別の表現を提供するものと仮定されています。

    Additionally <literal>%OB</literal> implemented to represent alternative months names (used standalone, without day mentioned). さらに、%OBは、(日に関する仕様がない単体で使用される)別の月名を表すものとして実装されています。

  • <literal>%e</literal> - is replaced by the day of month as a decimal number (1&ndash;31); single digits are preceded by a blank. %e - 月内10進日数(1–31)に置換されます。1桁の場合は前に空白が付けられます。

  • <literal>%F</literal> - is equivalent to <literal>%Y-%m-%d</literal>. %F - %Y-%m-%dと同じです。

  • <literal>%G</literal> - is replaced by a year as a decimal number with century. This year is the one that contains the greater part of the week (Monday as the first day of the week). %G - 世紀付の10進数として年に置換されます。 この年は週の部分がより多く含まれます。(月曜が週の最初の日です。)

  • <literal>%g</literal> - is replaced by the same year as in <literal>%G</literal>, but as a decimal number without century (00&ndash;99). %g -%G同様に年に置換されますが、世紀の部分を除く10進数(00–99)になります。

  • <literal>%H</literal> - is replaced by the hour (24-hour clock) as a decimal number (00&ndash;23). %H - 10進の時間(24時間単位)に置換されます(00–23)。

  • <literal>%h</literal> - the same as <literal>%b</literal>. %h - %bと同じです。

  • <literal>%I</literal> - is replaced by the hour (12-hour clock) as a decimal number (01&ndash;12). %I - 10進の時間(12時間単位)に置換されます(01–12)。

  • <literal>%j</literal> - is replaced by the day of the year as a decimal number (001&ndash;366). %j - 10進の年内日数に置換されます(001–366)。

  • <literal>%k</literal> - is replaced by the hour (24-hour clock) as a decimal number (0&ndash;23); single digits are preceded by a blank. %k - 10進の時間(24時間単位)に置換されます(0–23)。1桁の場合は先頭に空白が付けられます。

  • <literal>%l</literal> - is replaced by the hour (12-hour clock) as a decimal number (1&ndash;12); single digits are preceded by a blank. %l - 10進の時間(12時間単位)に置換されます(1–12)。1桁の場合は先頭に空白が付けられます。

  • <literal>%M</literal> - is replaced by the minute as a decimal number (00&ndash;59). %M - 10進の分数に置換されます(00–59)。

  • <literal>%m</literal> - is replaced by the month as a decimal number (01&ndash;12). %m -10進の月数に置換されます(01–12)。

  • <literal>%n</literal> - is replaced by a newline. %n - 改行に置換されます。

  • <literal>%O*</literal> - the same as <literal>%E*</literal>. %O* - %E*と同じです。

  • <literal>%p</literal> - is replaced by national representation of either <quote>ante meridiem</quote> or <quote>post meridiem</quote> as appropriate. %p - 各言語の午前または午後に適切に置換されます。

  • <literal>%R</literal> - is equivalent to <literal>%H:%M</literal>. %R - %H:%Mと同じです。

  • <literal>%r</literal> - is equivalent to <literal>%I:%M:%S %p</literal>. %r - %I:%M:%S %pと同じです。

  • <literal>%S</literal> - is replaced by the second as a decimal number (00&ndash;60). %S - 10進の秒数に置換されます(00–60)。

  • <literal>%s</literal> - is replaced by the number of seconds since the Epoch, UTC. %s - エポック、UTCからの秒数に置換されます。

  • <literal>%T</literal> - is equivalent to <literal>%H:%M:%S</literal> %T - %H:%M:%Sと同じです。

  • <literal>%t</literal> - is replaced by a tab. %t - タブに置換されます。

  • <literal>%U</literal> - is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number (00&ndash;53). %U - 10進の週番号(日曜が週の先頭です)に置換されます(00–53)。

  • <literal>%u</literal> - is replaced by the weekday (Monday as the first day of the week) as a decimal number (1&ndash;7). %u - 10進の週番号(月曜が週の先頭です)に置換されます(1–7)。

  • <literal>%V</literal> - is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (01&ndash;53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is the last week of the previous year, and the next week is week 1. %V - 10進の年内の週番号(月曜が週の先頭です)に置換されます(01–53)。 新しい年で、1月1日を含む週が4日以上存在する場合、その週が1となります。 さもなくば、この週は前年の週となり、次の週が1となります。

  • <literal>%v</literal> - is equivalent to <literal>%e-%b-%Y</literal>. %v - %e-%b-%Yと同じです。

  • <literal>%W</literal> - is replaced by the week number of the year (Monday as the first day of the week) as a decimal number (00&ndash;53). %W - 10進の年内の週番号(月曜が週の先頭です)に置換されます(00–53)。

  • <literal>%w</literal> - is replaced by the weekday (Sunday as the first day of the week) as a decimal number (0&ndash;6). %w - 10進の週内日数(日曜が週の先頭です)に置換されます(0–6)。

  • <literal>%X</literal> - is replaced by national representation of the time. %X - 各言語の時間表現に置換されます。

  • <literal>%x</literal> - is replaced by national representation of the date. %x - 各言語の日付表現に置換されます。

  • <literal>%Y</literal> - is replaced by the year with century as a decimal number. %Y - 10進の世紀付年に置換されます。

  • <literal>%y</literal> - is replaced by the year without century as a decimal number (00&ndash;99). %y - 10進の世紀なし年に置換されます(00–99)。

  • <literal>%Z</literal> - is replaced by the time zone name. %Z - 時間帯名称に置換されます。

  • <literal>%z</literal> - is replaced by the time zone offset from UTC; a leading plus sign stands for east of UTC, a minus sign for west of UTC, hours and minutes follow with two digits each and no delimiter between them (common form for <ulink url="https://tools.ietf.org/html/rfc822">RFC 822</ulink> date headers). %z - UTCからの時間帯オフセットに置換されます。 UTCより東では正符号が先頭に付き、西では負符号が付きます。 それぞれ2桁の時間と分がその後に続きますが、その区切りはありません。(この形式はRFC 822の日付ヘッダでよく使用されます。)

  • <literal>%+</literal> - is replaced by national representation of the date and time. %+ - 各言語の日付時刻表現に置換されます。

  • <literal>%-*</literal> - GNU libc extension. Do not do any padding when performing numerical outputs. %-* - GNU libc拡張です。数値出力を行う際に何も文字を詰めません。

  • $_* - GNU libc extension. Explicitly specify space for padding. $_* - GNU libcの拡張です。明示的に空白文字を使用して文字を詰めます。

  • <literal>%0*</literal> - GNU libc extension. Explicitly specify zero for padding. %0* - GNU libcの拡張です。明示的に0を使用して文字を詰めます。

  • <literal>%%</literal> - is replaced by <literal>%</literal>. %% - %に置換されます。

PGTYPEStimestamp_sub #

Subtract one timestamp from another one and save the result in a variable of type interval. タイムスタンプの減算を行い、その結果をinterval型の変数に格納します。

int PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv);

The function will subtract the timestamp variable that <literal>ts2</literal> points to from the timestamp variable that <literal>ts1</literal> points to and will store the result in the interval variable that <literal>iv</literal> points to. この関数はts1が指し示すタイムスタンプ型変数からts2が指し示すタイムスタンプ型変数を差し引き、ivが指し示すinterval型変数に結果を格納します。

Upon success, the function returns 0 and a negative value if an error occurred. 成功すると、この関数は0を返し、エラーが発生した場合は負の値を返します。

PGTYPEStimestamp_defmt_asc #

Parse a timestamp value from its textual representation using a formatting mask. 書式マスクを使用して、テキスト表現からtimestamp値へ変換します。

int PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d);

The function receives the textual representation of a timestamp in the variable <literal>str</literal> as well as the formatting mask to use in the variable <literal>fmt</literal>. The result will be stored in the variable that <literal>d</literal> points to. この関数はstr変数内に格納されたタイムスタンプのテキスト表現、fmt変数内に格納された使用される書式マスクを受付けます。 結果はdが指し示す変数内に格納されます。

If the formatting mask <literal>fmt</literal> is NULL, the function will fall back to the default formatting mask which is <literal>%Y-%m-%d %H:%M:%S</literal>. 書式マスクfmtが NULL ならば、この関数はデフォルトの書式マスク%Y-%m-%d %H:%M:%Sを使用するようになります。

This is the reverse function to <xref linkend="pgtypestimestampfmtasc"/>. See the documentation there in order to find out about the possible formatting mask entries. これはPGTYPEStimestamp_fmt_asc関数の逆です。 使用できる書式マスク項目についてはその文書を参照してください。

PGTYPEStimestamp_add_interval #

Add an interval variable to a timestamp variable. timestamp型変数にinterval型変数を加算します。

int PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tout);

The function receives a pointer to a timestamp variable <literal>tin</literal> and a pointer to an interval variable <literal>span</literal>. It adds the interval to the timestamp and saves the resulting timestamp in the variable that <literal>tout</literal> points to. この関数はtimestamp型変数tinへのポインタとinterval型変数spanへのポインタを受付けます。 これは、interval値をtimestamp値に加算し、その結果のtimestamp値をtoutが指し示す変数に格納します。

Upon success, the function returns 0 and a negative value if an error occurred. 成功するとこの関数は0を返します。 エラーが発生した場合は負の値を返します。

PGTYPEStimestamp_sub_interval #

Subtract an interval variable from a timestamp variable. timestamp型変数からinterval型変数の値を引きます。

int PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tout);

The function subtracts the interval variable that <literal>span</literal> points to from the timestamp variable that <literal>tin</literal> points to and saves the result into the variable that <literal>tout</literal> points to. この関数はtinが指し示すtimestamp型変数からspanが指し示すinterval型変数を引きます。 結果はtoutが指し示す変数に保存されます。

Upon success, the function returns 0 and a negative value if an error occurred. 成功するとこの関数は0を、エラーが発生した場合は負の値を返します。

36.6.5. interval型 #

<title>The interval Type</title>

The interval type in C enables your programs to deal with data of the SQL type interval. See <xref linkend="datatype-datetime"/> for the equivalent type in the <productname>PostgreSQL</productname> server. Cにおけるinterval型を用いることにより、プログラムからSQLのinterval型のデータを扱うことができます。 PostgreSQLサーバにおける対応する型については8.5を参照してください。

The following functions can be used to work with the interval type: 以下の関数を使用して、interval型を扱うことができます。

PGTYPESinterval_new #

Return a pointer to a newly allocated interval variable. 新しく割り当てたinterval型変数へのポインタを返します。

interval *PGTYPESinterval_new(void);

PGTYPESinterval_free #

Release the memory of a previously allocated interval variable. 以前に割り当てられたinterval型変数のメモリを解放します。

void PGTYPESinterval_free(interval *intvl);

PGTYPESinterval_from_asc #

Parse an interval from its textual representation. テキスト表現からinterval型に変換します。

interval *PGTYPESinterval_from_asc(char *str, char **endptr);

The function parses the input string <literal>str</literal> and returns a pointer to an allocated interval variable. At the moment ECPG always parses the complete string and so it currently does not support to store the address of the first invalid character in <literal>*endptr</literal>. You can safely set <literal>endptr</literal> to NULL. この関数は入力文字列strを変換し、割当てられたinterval型へのポインタを返します。 現在ECPGは文字列全体を解析しますので、現時点では*endptrに最初の無効な文字のアドレスを格納することをサポートしません。 このためendptrを安全に NULL にすることができます。

PGTYPESinterval_to_asc #

Convert a variable of type interval to its textual representation. interval型変数をテキスト表現に変換します。

char *PGTYPESinterval_to_asc(interval *span);

The function converts the interval variable that <literal>span</literal> points to into a C char*. The output looks like this example: <literal>@ 1 day 12 hours 59 mins 10 secs</literal>. The result must be freed with <function>PGTYPESchar_free()</function>. この関数はspanが指し示すinterval型変数をC char*に変換します。 出力は@ 1 day 12 hours 59 mins 10 secsのようになります。 結果はPGTYPESchar_free()で解放しなければなりません。

PGTYPESinterval_copy #

Copy a variable of type interval. interval型変数をコピーします。

int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);

The function copies the interval variable that <literal>intvlsrc</literal> points to into the variable that <literal>intvldest</literal> points to. Note that you need to allocate the memory for the destination variable before. この関数は、intvlsrcが指し示すinterval型変数を intvldestが指し示す変数にコピーします。 事前に格納先の変数用のメモリを割り当てる必要があることに注意してください。

36.6.6. decimal型 #

<title>The decimal Type</title>

The decimal type is similar to the numeric type. However it is limited to a maximum precision of 30 significant digits. In contrast to the numeric type which can be created on the heap only, the decimal type can be created either on the stack or on the heap (by means of the functions <function>PGTYPESdecimal_new</function> and <function>PGTYPESdecimal_free</function>). There are a lot of other functions that deal with the decimal type in the <productname>Informix</productname> compatibility mode described in <xref linkend="ecpg-informix-compat"/>. decimal型はnumeric型に似ています。 しかし、その最大精度は30有効桁に制限されています。 ヒープ上にしか作成できないnumeric型と比べ、decimal型はスタックまたはヒープ上に作成することができます。 (このためにはPGTYPESdecimal_newおよびPGTYPESdecimal_free関数を使用します。) 36.15で説明するInformix互換モードではdecimal型を扱う関数がより多く存在します。

The following functions can be used to work with the decimal type and are not only contained in the <literal>libcompat</literal> library. 以下の関数を使用してdecimal型を扱うことができます。 これらはlibcompatライブラリに含まれるものだけではありません。

PGTYPESdecimal_new #

Request a pointer to a newly allocated decimal variable. 新しく割り当てられたdecimal型変数へのポインタを要求します。

decimal *PGTYPESdecimal_new(void);

PGTYPESdecimal_free #

Free a decimal type, release all of its memory. decimal型を解放し、そのメモリをすべて解放します。

void PGTYPESdecimal_free(decimal *var);

36.6.7. pgtypeslibのerrno値 #

<title>errno Values of pgtypeslib</title>

PGTYPES_NUM_BAD_NUMERIC #

An argument should contain a numeric variable (or point to a numeric variable) but in fact its in-memory representation was invalid. 引数はnumeric型変数(またはnumeric型変数へのポインタ)を含んでいるはずですが、実際のメモリ上の表現は無効でした。

PGTYPES_NUM_OVERFLOW #

An overflow occurred. Since the numeric type can deal with almost arbitrary precision, converting a numeric variable into other types might cause overflow. オーバーフローが発生しました。 numeric型はほぼ任意の精度を扱うことができますので、numeric型変数から他の型への変換ではオーバーフローが発生する可能性があります。

PGTYPES_NUM_UNDERFLOW #

An underflow occurred. Since the numeric type can deal with almost arbitrary precision, converting a numeric variable into other types might cause underflow. アンダーフローが発生しました。 numeric型はほぼ任意の精度を扱うことができますので、numeric型変数から他の型への変換ではアンダーフローが発生する可能性があります。

PGTYPES_NUM_DIVIDE_ZERO #

A division by zero has been attempted. ゼロ除算をしようとしました。

PGTYPES_DATE_BAD_DATE #

An invalid date string was passed to the <function>PGTYPESdate_from_asc</function> function. PGTYPESdate_from_asc関数に無効な日付文字列が渡されました。

PGTYPES_DATE_ERR_EARGS #

Invalid arguments were passed to the <function>PGTYPESdate_defmt_asc</function> function. PGTYPESdate_defmt_asc関数に無効な引数が渡されました。

PGTYPES_DATE_ERR_ENOSHORTDATE #

An invalid token in the input string was found by the <function>PGTYPESdate_defmt_asc</function> function. PGTYPESdate_defmt_asc関数により入力文字列内に無効なトークンが見つかりました。

PGTYPES_INTVL_BAD_INTERVAL #

An invalid interval string was passed to the <function>PGTYPESinterval_from_asc</function> function, or an invalid interval value was passed to the <function>PGTYPESinterval_to_asc</function> function. PGTYPESinterval_from_asc関数に無効な内部文字列が渡されました。 もしくはPGTYPESinterval_to_asc関数に無効な内部値が渡されました。

PGTYPES_DATE_ERR_ENOTDMY #

There was a mismatch in the day/month/year assignment in the <function>PGTYPESdate_defmt_asc</function> function. PGTYPESdate_defmt_asc関数内の日/月/年の代入において不整合がありました。

PGTYPES_DATE_BAD_DAY #

An invalid day of the month value was found by the <function>PGTYPESdate_defmt_asc</function> function. PGTYPESdate_defmt_asc関数により無効な月内日数が見つかりました。

PGTYPES_DATE_BAD_MONTH #

An invalid month value was found by the <function>PGTYPESdate_defmt_asc</function> function. PGTYPESdate_defmt_asc関数によって無効な月値が見つかりました。

PGTYPES_TS_BAD_TIMESTAMP #

An invalid timestamp string pass passed to the <function>PGTYPEStimestamp_from_asc</function> function, or an invalid timestamp value was passed to the <function>PGTYPEStimestamp_to_asc</function> function. PGTYPEStimestamp_from_asc関数に無効なタイムスタンプ文字列が渡されました。 もしくはPGTYPEStimestamp_to_asc関数に無効なtimestamp値が渡されました。

PGTYPES_TS_ERR_EINFTIME #

An infinite timestamp value was encountered in a context that cannot handle it. コンテキスト内で扱うことができない、無限なタイムスタンプ値がありました。

36.6.8. pgtypeslibの特殊な定数 #

<title>Special Constants of pgtypeslib</title>

PGTYPESInvalidTimestamp #

A value of type timestamp representing an invalid time stamp. This is returned by the function <function>PGTYPEStimestamp_from_asc</function> on parse error. Note that due to the internal representation of the <type>timestamp</type> data type, <literal>PGTYPESInvalidTimestamp</literal> is also a valid timestamp at the same time. It is set to <literal>1899-12-31 23:59:59</literal>. In order to detect errors, make sure that your application does not only test for <literal>PGTYPESInvalidTimestamp</literal> but also for <literal>errno != 0</literal> after each call to <function>PGTYPEStimestamp_from_asc</function>. 無効なタイムスタンプを表すtimestamp型の値です。 これは解析エラーの場合にPGTYPEStimestamp_from_asc関数によって返されます。 timestampデータ型の内部表現のため、PGTYPESInvalidTimestampはまた同時に有効なタイムスタンプでもあります。 これは1899-12-31 23:59:59に設定されます。 エラーを検知するためには、PGTYPEStimestamp_from_ascを呼び出す度にその後、PGTYPESInvalidTimestampを試験するだけではなく、errno != 0も試験してください。