Missing Column names with multi-insert

Поиск
Список
Период
Сортировка
От Liz Frost
Тема Missing Column names with multi-insert
Дата
Msg-id CAMg5y_eBGPnevausBuMsp2d65JhCkwLn+nY_cxEx6RQ_odObXQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Missing Column names with multi-insert  (Andres Freund <andres@anarazel.de>)
Re: Missing Column names with multi-insert  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Missing Column names with multi-insert  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Список pgsql-hackers
Hello all,

I'm working on a foreign data wrapper that uses INSERT, and I noticed some odd behaviour. If I insert just one row, the TupleDesc->attr[0]->attname.data has the column names in it. However, in a multi-row string, all those are empty strings: 

I added this debugging code to BeginForeignInsert in https://bitbucket.org/adunstan/blackhole_fdw on postgres 10.

int i;
  FormData_pg_attribute *attr;
  TupleDesc tupleDesc;

  tupleDesc = slot->tts_tupleDescriptor;

  for (i = 0; i < tupleDesc -> natts; i++) {
    attr = tupleDesc->attrs[i];
    elog(WARNING, "found column '%s'", attr->attname.data);
  }

Now with a single row insert, this works as you'd expect:

liz=# INSERT INTO bhtable (key, value) VALUES ('hello', 'world');
WARNING:  found column 'key'
WARNING:  found column 'value'
INSERT 0 1

But with a multi-row, all the column names are empty:
liz=# INSERT INTO bhtable (key, value) VALUES ('hello', 'world'), ('goodmorning', 'world');
WARNING:  found column ''
WARNING:  found column ''
WARNING:  found column ''
WARNING:  found column ''
INSERT 0 2

It doesn't seem unreasonable to me that this data wouldn't be duplicated, but there's no mention of how I would go about retriving these column names for my individual rows, and most foreign data wrappers I can find are write-only.

Am I missing something obvious? Is this a bug?

Thanks,

Liz


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: automatically assigning catalog toast oids
Следующее
От: Tom Lane
Дата:
Сообщение: Re: speeding up planning with partitions