From: Tom Lane <tgl@sss.pgh.pa.us>
To: jj-kim@github.github.io
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15956: Server closed unexpectedly for user-defined base type LIKE char
Date: Tue, 13 Aug 2019 17:48:20 -0400
Message-ID: <5890.1565732900@sss.pgh.pa.us> (raw)
In-Reply-To: <15956-b4aa898fb01fa984@postgresql.org>
References: <15956-b4aa898fb01fa984@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> The following causes the server to close unexpectedly.
> CREATE TYPE char_type;
> CREATE FUNCTION char_type_in(cstring) RETURNS char_type
> LANGUAGE internal IMMUTABLE STRICT AS 'charin';
> CREATE FUNCTION char_type_out(char_type) RETURNS cstring
> LANGUAGE internal IMMUTABLE STRICT AS 'charout';
> CREATE TYPE char_type (
> INPUT = char_type_in,
> OUTPUT = char_type_out,
> LIKE = char
> );
> CREATE TABLE char_table (t char_type);
> INSERT INTO char_table (t)
> VALUES ('t');
This is pilot error, not a server bug: you created a type that's
not compatible with the I/O functions you provided for it.
Admittedly, it's a bit of a gotcha: "LIKE = char" interprets
char as bpchar, a/k/a the SQL CHAR(n) type. But the internal
charin and charout functions are for the single-byte "char"
type. If we didn't have a couple decades worth of backward
compatibility to think about, we'd likely rename the latter
type, since it's a Postgres-ism not standard.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, jj-kim@github.github.io
Subject: Re: BUG #15956: Server closed unexpectedly for user-defined base type LIKE char
In-Reply-To: <5890.1565732900@sss.pgh.pa.us>
References: <15956-b4aa898fb01fa984@postgresql.org> <5890.1565732900@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox