Skip site navigation (1) Skip section navigation (2)

Bad behaviour when inserting unspecified variable length datatypes

From: Dave Blasby <dblasby(at)refractions(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Bad behaviour when inserting unspecified variable length datatypes
Date: 2001-08-31 19:32:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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

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.



pgsql-hackers by date

Next:From: Martin WeinbergDate: 2001-08-31 20:04:31
Subject: Why "ERROR: dtoi4: integer out of range" on pg_dump
Previous:From: Barry LindDate: 2001-08-31 17:03:04
Subject: Re: Escaping strings for inclusion into SQL queries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group