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 1rrlCW-002YI7-R8 for pgsql-general@arkaria.postgresql.org; Tue, 02 Apr 2024 20:57:49 +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 1rrlCW-00C48V-2D for pgsql-general@arkaria.postgresql.org; Tue, 02 Apr 2024 20:57:48 +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 1rrlCV-00C48M-KT for pgsql-general@lists.postgresql.org; Tue, 02 Apr 2024 20:57:47 +0000 Received: from mout-u-107.mailbox.org ([2001:67c:2050:101:465::107]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrlCQ-000FKQ-DO for pgsql-general@lists.postgresql.org; Tue, 02 Apr 2024 20:57:46 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4V8Kvj2ZVjz9sTq; Tue, 2 Apr 2024 22:57:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1712091457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+egy6DPymiNVvePoFVZveRxEpD7Ng+yb0r+d1OS6vdU=; b=xPn0O1Q9BzEDtsVntwNvp8kid6E/N4zOCTvWEMDNMv7TVHqUCj2vi6jSd85oTbbOGLUXlf 0t7T8S9VxlTWCxen35pcG630qncA/JvQYRXFj92KPfL5vqjXwjVtQY5mBKzwlbn+M++vFO 1fL0APAm4qr7F/Ry7JMCm7n/E+weNrY1caZzBbRF9XB3sMVMpE8YqtN/8FuT0X8M2HdNni xcf9+nbh8s6Ri5UB1MDEebBM6yFvdzwlr69N5KdYnENjIR8HyhErd63MpdZwjMr2oEkNUF pD1erKAGpqXelP6vFkyEDBEEk6XsxIl2LcmnAKv4XU4/mRZxdYsPsiPq0c6eQw== Date: Tue, 2 Apr 2024 22:57:35 +0200 From: Erik Wienhold To: sud Cc: Greg Sabino Mullane , pgsql-general Subject: Re: Timestamp conversion Error in dynamic sql script Message-ID: <6oywkrrg5bzvnmorg7l3kdvzc2ipejm2xx3o5qaam57chuacic@iu4pe64gjqoj> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-04-02 22:08 +0200, sud wrote: > On Tue, Apr 2, 2024 at 7:46 PM Greg Sabino Mullane > wrote: > > Now this block seems to be failing near the "LIKE" operator. Isn't it > allowed to add the check constraints along with the CREATE TABLE statement? > > [...] > > EXECUTE format(' > CREATE TABLE parent_table_%s ( > CHECK (partition_key >= ''%s'' AND partition_key < ''%s'' ) > * ) LIKE (parent_table including all);',* > TO_CHAR(start_date + make_interval(days=>i),'YYYY_MM_DD'), > (start_date + make_interval(days=>i))::timestamptz , > (start_date + make_interval(days=>i))::timestamptz > ); > > [...] > > *SQL Error [42601]: ERROR: syntax error at or near "LIKE"Where: PL/pgSQL > function inline_code_block line 8 at EXECUTE* > *Error position: * The LIKE clause goes inside the parenthesis along with the column and constraint definitions, i.e.: CREATE TABLE parent_table_yyyy_mm_dd ( LIKE parent_table, CHECK (...) ); -- Erik