Re: Variable length custom data types help

Поиск
Список
Период
Сортировка
От Morgan Kita
Тема Re: Variable length custom data types help
Дата
Msg-id 08B420FF5BF7BC42A064212C2EB768801C1092@neutron.verseon.com
обсуждение исходный текст
Ответ на Variable length custom data types help  ("Morgan Kita" <mkita@verseon.com>)
Ответы Re: Variable length custom data types help  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Thank you for your response! That was quite enlightening.

Just to clarify in the example foo structure below where the first
member is the length, and then you say /*rest of structure here*/, by
that do you mean the individual data members of the structure that will
be in my array of strucs? I guess it can't be a pointer to the array as
you said postgres will not know that you are storing pointers. If so
that means you have a bit of wasted overhead right? I think I will just
try creating the pointer as void*, set the first 4 bytes to the length,
and then fill in the rest.

Seriously, that was an extremely helpful post!

Thanks,
Morgan


-----Original Message-----
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Thursday, March 31, 2005 11:17 PM
To: Morgan Kita
Cc: pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Variable length custom data types help

The usual way is to create a structure:

  typedef struct foo {
      int32  total_length;
      /* rest of structure here */
  } foo;

What follows the length is irrelevant to PostgreSQL, so define it
however makes sense in your code.  Just make sure that all data is
in a contiguous chunk of memory that begins with the 4-byte length
(don't embed pointers in the data, because PostgreSQL won't know
anything about them).

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

Предыдущее
От: Ennio-Sr
Дата:
Сообщение: Re: how to ignore accents?
Следующее
От: "Walker, Jed S"
Дата:
Сообщение: plpgsql question - simple I would have thought