Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qi0S6-004w9v-Pd for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Sep 2023 22:41:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qi0S4-00CxbW-MZ for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Sep 2023 22:41:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qi0S4-00CxbD-8s for pgsql-hackers@lists.postgresql.org; Sun, 17 Sep 2023 22:41:16 +0000 Received: from mout-u-204.mailbox.org ([2001:67c:2050:101:465::204]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qi0Ry-0058qz-CA for pgsql-hackers@lists.postgresql.org; Sun, 17 Sep 2023 22:41:15 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4RpjZQ1flrz9sQT; Mon, 18 Sep 2023 00:41:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1694990462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8QNzCiKFjj3Gk9CHYiWP+JE6aKfk8846q8FdRefWBwE=; b=rgFcc9+bJCD7vEFtObBoA1an4jMZhWUnQzuu3yBn+OmemACRAUZbr9dt3khV+k7d/vtOx/ kGhGLfhWsaCaFdU10y0tBiygvNqssbGNRtDCGBLCoCzd2OKg54XbJNqHRPeoRIBP8E9MmI DuU8goJxVII9IZSMF1INAF3ioUFvM9CWWCLNA14/ZKzbyIV6UQgdxDodiLbqolYAmbd3bD Xg/MbIXFWZi+eeTTd0kHs3cdQ4dYqeKtEj4/QpdzCPXgc4MO7+fp3nfjM/7fAM1Ye9OrnJ jGU8bowb3n6K75N5ehhWwGFTFvQzQurlF7GV7ij6Al7YFd8zne5zLvia8eNFAg== Date: Mon, 18 Sep 2023 00:41:01 +0200 (CEST) From: Erik Wienhold To: "David E. Wheeler" , pgsql-hackers@lists.postgresql.org Message-ID: <1096313951.132571.1694990461053@office.mailbox.org> In-Reply-To: <09F9CAD6-5096-43CC-B6A7-685703E4714D@justatheory.com> References: <09F9CAD6-5096-43CC-B6A7-685703E4714D@justatheory.com> Subject: Re: to_regtype() Raises Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4RpjZQ1flrz9sQT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 18/09/2023 00:13 CEST David E. Wheeler wrote: > The docs for `to_regtype()` say, =E2=80=9Cthis function will return NULL = rather than > throwing an error if the name is not found.=E2=80=9D And it=E2=80=99s tru= e most of the time: > > david=3D# select to_regtype('foo'), to_regtype('clam'); > to_regtype | to_regtype > ------------+------------ > [null] | [null] > > But not others: > > david=3D# select to_regtype('inteval second'); > ERROR: syntax error at or near "second" > LINE 1: select to_regtype('inteval second'); > ^ > CONTEXT: invalid type name "inteval second=E2=80=9D Probably a typo and you meant 'interval second' which works. > I presume this has something to do with not catching errors from the pars= er? > > david=3D# select to_regtype('clam bake'); > ERROR: syntax error at or near "bake" > LINE 1: select to_regtype('clam bake'); > ^ > CONTEXT: invalid type name "clam bake" Double-quoting the type name to treat it as an identifier works: =09test=3D# select to_regtype('"clam bake"'); =09 to_regtype =09------------ =09 =09(1 row) So it's basically a matter of keywords vs. identifiers. -- Erik