Bad behaviour when inserting unspecified variable length datatypes

Поиск
Список
Период
Сортировка
От Dave Blasby
Тема Bad behaviour when inserting unspecified variable length datatypes
Дата
Msg-id 3B8FE657.300C7B03@refractions.net
обсуждение исходный текст
Ответы Re: Bad behaviour when inserting unspecified variable length datatypes  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
It took me a while to figure out what was going on, but I think I've
figured it out.

Lets say you have your own variable length datatype called
'MY_DATATYPE'.

CREATE TABLE test_table (myint integer, mydata MY_DATATYPE);
INSERT INTO test_table VALUES (1);

At this point, I'd expect there to be one row in test table. The myint
column will have the value one, and the mydata column will have the
value NULL.

This doesnt appear to be the case.  It seems that the mydata column will
have a structure that looks like a '-'::TEXT structure (ie. the first 4
bytes are an int representing 5, and the 5th byte is the ASCII '-').

This is really bad because a "SELECT * FROM test_table" will send this
weird structure to MY_DATATYPE's OUTPUT function.  Since this weird
structure isn't really a MY_DATATYPE structure, it causes problems.

This happens even if you explictly set MY_DATATYPE's DEFAULT to NULL.

dave


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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: Escaping strings for inclusion into SQL queries
Следующее
От: Martin Weinberg
Дата:
Сообщение: Why "ERROR: dtoi4: integer out of range" on pg_dump