このページを編集する際は、[[編集に関する方針]]に従ってください。
*概要 [#a77af665]
-対象:8.1.4
-言語:C
-[[postgresql-8.1.4/src/include/access/heapam.h]]にて定義
-[[postgresql-8.1.4/src/backend/access/common/heaptuple.c]]にて定義

-(概要を書いてください。)

*引数 [#fc54d74b]

+tupleDesc : TupleDesc型
+values : Datum型へのポインタ
+isnull : bool型へのポインタ
+data : char型へのポインタ
+infomask : uint16型へのポインタ
+bit : bits8型へのポインタ

*実装 [#u02a6be4]

void
heap_fill_tuple(TupleDesc tupleDesc,
-以下のメンバを持つ構造体。詳細は[[TupleDesc/postgresql-8.1.4]]参照。
-nattsを、intとして定義。
-attrsを、以下のメンバを持つ構造体Form_pg_attributeへのポインタとして定義。
--attrelidを、Oid(unsigned intの別名)として定義。
--attnameを、以下のメンバを持つ構造体NameDataとして定義。
---dataを、サイズNAMEDATALENのchar配列として定義。
---alignmentDummyを、intとして定義。
--atttypidを、Oid(unsigned intの別名)として定義。
--attstattargetを、int4(int32(signed int)の別名)として定義。
--attlenを、int2(int16(signed short)の別名)として定義。
--attnumを、int2(int16(signed short)の別名)として定義。
--attndimsを、int4(int32(signed int)の別名)として定義。
--attcacheoffを、int4(int32(signed int)の別名)として定義。
--atttypmodを、int4(int32(signed int)の別名)として定義。
--attbyvalを、bool(charの別名)として定義。
--attstorageを、charとして定義。
--attalignを、charとして定義。
--attnotnullを、bool(charの別名)として定義。
--atthasdefを、bool(charの別名)として定義。
--attisdroppedを、bool(charの別名)として定義。
--attislocalを、bool(charの別名)として定義。
--attinhcountを、int4(int32(signed int)の別名)として定義。
-constrを、TupleConstrへのポインタとして定義。
--defvalを、以下のメンバを持つ構造体AttrDefaultへのポインタとして定義。
---adnumを、AttrNumber(int16(signed shortの別名)の別名))として定義。
---adbinを、charへのポインタとして定義。
--checkを、以下のメンバを持つ構造体ConstrCheckへのポインタとして定義。
---ccnameを、charへのポインタとして定義。
---ccbinを、charへのポインタとして定義。
--num_defvalを、uint16(unsigned shortの別名)として定義。
--num_checkを、uint16(unsigned shortの別名)として定義。
--has_not_nullを、bool(charの別名)として定義。
-tdtypeidを、Oid(unsigned intの別名)として定義。
-tdtypmodを、int32(signed intの別名)として定義。
-tdhasoidを、bool(charの別名)として定義。

				Datum *values,
-unsigned longの別名。詳細は[[Datum/postgresql-8.1.4]]参照。

				bool *isnull,
-charの別名。詳細は[[bool/postgresql-8.1.4]]参照。

				char *data, 
				uint16 *infomask, 
-unsigned shortの別名。詳細は[[uint16/postgresql-8.1.4]]参照。

				bits8 *bit)
-uint8(unsigned char)の別名。詳細は[[bits8/postgresql-8.1.4]]参照。

{
	bits8	   *bitP;
-uint8(unsigned char)の別名。詳細は[[bits8/postgresql-8.1.4]]参照。

	int			bitmask;
	int			i;
	int			numberOfAttributes = tupleDesc->natts;
	Form_pg_attribute *att = tupleDesc->attrs;
-以下のメンバを持つ構造体へのポインタ。詳細は[[Form_pg_attribute/postgresql-8.1.4]]参照。
--attrelidを、Oid(unsigned intの別名)として定義。
--attnameを、以下のメンバを持つ構造体NameDataとして定義。
---dataを、サイズNAMEDATALENのchar配列として定義。
---alignmentDummyを、intとして定義。
--atttypidを、Oid(unsigned intの別名)として定義。
--attstattargetを、int4(int32(signed int)の別名)として定義。
--attlenを、int2(int16(signed short)の別名)として定義。
--attnumを、int2(int16(signed short)の別名)として定義。
--attndimsを、int4(int32(signed int)の別名)として定義。
--attcacheoffを、int4(int32(signed int)の別名)として定義。
--atttypmodを、int4(int32(signed int)の別名)として定義。
--attbyvalを、bool(charの別名)として定義。
--attstorageを、charとして定義。
--attalignを、charとして定義。
--attnotnullを、bool(charの別名)として定義。
--atthasdefを、bool(charの別名)として定義。
--attisdroppedを、bool(charの別名)として定義。
--attislocalを、bool(charの別名)として定義。
--attinhcountを、int4(int32(signed int)の別名)として定義。


	if (bit != NULL)
	{
		bitP = &bit[-1];
		bitmask = CSIGNBIT;
	}
	else
	{
		/* just to keep compiler quiet */
		bitP = NULL;
		bitmask = 0;
	}

	*infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTENDED);
-定数0x0001の別名。[[HEAP_HASNULL/postgresql-8.1.4]]参照。
-定数0x0002の別名。[[HEAP_HASVARWIDTH/postgresql-8.1.4]]参照。
-定数0x000Cの別名。[[HEAP_HASEXTENDED/postgresql-8.1.4]]参照。


	for (i = 0; i < numberOfAttributes; i++)
	{
		Size		data_length;

		if (bit != NULL)
		{
			if (bitmask != CSIGNBIT)
-定数0x80の別名。[[CSIGNBIT/postgresql-8.1.4]]参照。

				bitmask <<= 1;
			else
			{
				bitP += 1;
				*bitP = 0x0;
				bitmask = 1;
			}

			if (isnull[i])
			{
				*infomask |= HEAP_HASNULL;
-定数0x0001の別名。[[HEAP_HASNULL/postgresql-8.1.4]]参照。

				continue;
			}

			*bitP |= bitmask;
		}

		/* XXX we are aligning the pointer itself, not the offset */
		data = (char *) att_align((long) data, att[i]->attalign);
-以下の値を取得。詳細は[[att_align()/postgresql-8.1.4]]参照。
--att[i]->attalignの値が'i'の場合、data以上であるALIGNOF_INTの倍数のうち最小値を返す。
--att[i]->attalignの値が'c'の場合、dataを(long型にキャストして)そのまま返す。
--att[i]->attalignの値が'd'の場合、data以上であるALIGNOF_DOUBLEの倍数のうち最小値を返す。
--それ以外の場合、data_length以上であるALIGNOF_SHORTの倍数のうち、最小値を返す
。ただし、USE_ASSERT_CHECKING指定してコンパイルしたバイナリの場合、attalignが's'でなければエラーメッセージを出力して終了する。

		if (att[i]->attbyval)
		{
			/* pass-by-value */
			store_att_byval(data, values[i], att[i]->attlen);
-[[store_att_byval()/postgresql-8.1.4]]参照。

			data_length = att[i]->attlen;
		}
		else if (att[i]->attlen == -1)
		{
			/* varlena */
			*infomask |= HEAP_HASVARWIDTH;
-定数0x0002の別名。[[HEAP_HASVARWIDTH/postgresql-8.1.4]]参照。

			if (VARATT_IS_EXTERNAL(values[i]))
-[[VARATT_IS_EXTERNAL()/postgresql-8.1.4]]参照。

				*infomask |= HEAP_HASEXTERNAL;
-[[HEAP_HASEXTERNAL/postgresql-8.1.4]]参照。

			if (VARATT_IS_COMPRESSED(values[i]))
-[[VARATT_IS_COMPRESSED()/postgresql-8.1.4]]参照。

				*infomask |= HEAP_HASCOMPRESSED;
-[[HEAP_HASCOMPRESSED/postgresql-8.1.4]]参照。

			data_length = VARATT_SIZE(DatumGetPointer(values[i]));
-[[VARATT_SIZE()/postgresql-8.1.4]]参照。
-[[DatumGetPointer()/postgresql-8.1.4]]参照。

			memcpy(data, DatumGetPointer(values[i]), data_length);
-[[DatumGetPointer()/postgresql-8.1.4]]参照。

		}
		else if (att[i]->attlen == -2)
		{
			/* cstring */
			*infomask |= HEAP_HASVARWIDTH;
-[[HEAP_HASVARWIDTH/postgresql-8.1.4]]参照。

			data_length = strlen(DatumGetCString(values[i])) + 1;
-[[DatumGetCString()/postgresql-8.1.4]]参照。

			memcpy(data, DatumGetPointer(values[i]), data_length);
-[[DatumGetPointer()/postgresql-8.1.4]]参照。

		}
		else
		{
			/* fixed-length pass-by-reference */
			Assert(att[i]->attlen > 0);
-[[Assert()/postgresql-8.1.4]]参照。

			data_length = att[i]->attlen;
			memcpy(data, DatumGetPointer(values[i]), data_length);
-[[DatumGetPointer()/postgresql-8.1.4]]参照。

		}

		data += data_length;
	}
}

*呼出元 [#mfbc079c]

-(呼出元の関数を書いてください。)

*備考 [#q52e2952]

 * heap_fill_tuple
 *		Load data portion of a tuple from values/isnull arrays
 *
 * We also fill the null bitmap (if any) and set the infomask bits
 * that reflect the tuple's data contents.

*履歴 [#r25afc1f]
-作者:[[testnoda/ページ作者]]
-日付:????/??/??
|更新日|更新者|更新内容|
|2007/4/24|[[testnoda/ページ作者]]|解読を一旦中止([[関数ポインタ①/解読日記]]を参照)|
||||

*コメント [#ef7d3f1a]

#comment


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS