Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxenI-0005Ay-M7 for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Aug 2019 21:57:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxemG-0000AY-Qq for pgsql-bugs@arkaria.postgresql.org; Tue, 13 Aug 2019 21:56:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxemG-00008f-Fn for pgsql-bugs@lists.postgresql.org; Tue, 13 Aug 2019 21:56:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hxemE-00014i-79 for pgsql-bugs@lists.postgresql.org; Tue, 13 Aug 2019 21:56:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x7DLmKvP005891; Tue, 13 Aug 2019 17:48:20 -0400 From: Tom Lane 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 In-reply-to: <15956-b4aa898fb01fa984@postgresql.org> References: <15956-b4aa898fb01fa984@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 13 Aug 2019 21:35:03 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5889.1565732900.1@sss.pgh.pa.us> Date: Tue, 13 Aug 2019 17:48:20 -0400 Message-ID: <5890.1565732900@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form 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