What is the correct way to get the content of a varchar field in pgsql's source code

Поиск
Список
Период
Сортировка
От Felix.徐
Тема What is the correct way to get the content of a varchar field in pgsql's source code
Дата
Msg-id CAPmhLM1th8j9Pve9GwwnD4WP-CcR9ymgoyNSRB8w7rf1RMSE3A@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Hi all,
I've learnt from the source code to open a table and scan it, like this:

Relation qma = try_relation_open(qmappersta, AccessShareLock);
  if(qma!=NULL){
    HeapScanDesc scan= heap_beginscan(qma,SnapshotNow,0,NULL);
  HeapTuple tup;
TupleDesc tupDesc= RelationGetDescr(qma);
    Datum   *values;
  bool *nulls;
    int value1;
    char value2;
    while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL){
        heap_deform_tuple(tup,tupDesc,values, nulls);
        /* int values can be retrieved easily */
        value1=values[0];
        /* how to retrieve the content of a varchar field here? */
        /* What I've tried: */
        value2=VARDATA_ANY(values[2]);
        /* But value2 seems to be incorrect
           if the original data is "abcd", then I will get "abcd2" here(in most cases, a "2" is appended to the data...), I'm wondering  how to get the data properly...
           I've also tried VARDATA macro and encountered with the same problem.
        */
    }
  }

Thanks!

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

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: [HACKERS] using rpmbuild with PostgreSQL 9.2.6 source code
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: using rpmbuild with PostgreSQL 9.2.6 source code