RE: [PROPOSAL]a new data type 'bytea' for ECPG

From: "Matsumura, Ryo" <matsumura(dot)ryo(at)jp(dot)fujitsu(dot)com>
To: 'Michael Meskes' <meskes(at)postgresql(dot)org>
Cc: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: [PROPOSAL]a new data type 'bytea' for ECPG
Date: 2019-02-12 10:36:58
Message-ID: 03040DFF97E6E54E88D3BFEE5F5480F737AA614F@G01JPEXMBYT04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Meskes-san

Thank you for your review.

> There is one thing that I don't understand right now. YOu
> change ecpg_store_input() to handle the bytea data type, yet you also
> change ECPGset_desc() to not use ecpg_store_input() in case of an
> bytea. This looks odd to me. Can you please explain that to me?

I try to explain as follows. I would like to receive your comment.

The current architecture of data copying of descriptor walks through the following path.
The important point is that it walks through two ecpg_store_input().

step 1. ECPGset_desc
Store to descriptor_item with ecpg_store_input().

step 2. ecpg_build_params(setup for tobeinserted)
Store to tobeinserted with ecpg_store_input().

step 3. ecpg_build_params(building stmt->param*)
Set tobeinserted to stmt->paramvalues.

On the other hand, the part of ecpg_build_params(building stmt->param*)
for bytea needs two information that are is_binary and binary_length.
But, data copying with ecpg_store_input() losts them.

There are two ideas to pass the information to part of ecpg_build_params(building stmt->param*).
But they are same in terms of copying data without ecpg_store_input() at least ones.
I selected Idea-1.

Idea-1.

step 1. ECPGset_desc
Set descriptor_item.is_binary.
Memcpy both bytea.length and bytea.array to descriptor_item.data.

step 2. ecpg_build_params(setup for tobeinserted)
Store bytea.array to tobeinserted with ecpg_store_input(bytea route).
Set is_binary(local) from descriptor_item.is_binary.
Set binary_length(local) from descriptor_item.data.

step 3. ecpg_build_params(building stmt->param*)
Set stmt->paramvalues from tobeinserted.
Set stmt->formats from is_binary(local).
Set stmt->lengths from binary_length(local).

Idea-2.

step 1. ECPGset_desc
Set descriptor_item.is_binary.
Set bytea.length to descriptor_item.data_len. (different!)
Set bytea.array to descriptor_item.data. (different!)

step 2. ecpg_build_params(setup for tobeinserted)
Memcpy bytea.array to tobeinserted by using alloc and memcpy whitout store_input. (different!)
Set is_binary(local) from descriptor_item.is_binary.
Set binary_length(local) from descriptor_item.data_len. (different!)

step 3. ecpg_build_params(building stmt->param*)
Set stmt->paramvalues with tobeinserted.
Set stmt->formats from is_binary(local).
Set stmt->lengths from binary_length(local).

Regards
Ryo Matsumura

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-02-12 11:35:10 Re: Protect syscache from bloating with negative cache entries
Previous Message Dean Rasheed 2019-02-12 10:33:33 Re: BUG #15623: Inconsistent use of default for updatable view