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 1sO4ia-00CD93-6N for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 00:16:28 +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 1sO4iX-00E1bg-Fl for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 00:16:25 +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 1sO4iX-00E1bY-5I for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 00:16:25 +0000 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sO4iU-003wMN-Uf for pgsql-hackers@postgresql.org; Mon, 01 Jul 2024 00:16:24 +0000 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5c4498dcc27so324823eaf.1 for ; Sun, 30 Jun 2024 17:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719792982; x=1720397782; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=sk8FYbkrgyRe7D+jo7cfiihFdJXLpFlwGxxj1Mrw3Pg=; b=YukvlhDyaX+ffGFXfZF0kva4LCpgM3WPCJqZ5K4jkdBh5gQC/v7n/O5s9U9j7Pkonj waOSN6OkWy8CkU2cWF0tO34qD2H8F+xGMTrQkDEYGi1Cw5ZIIT4Jmc812znBODTtnexY 1G5489wGSl/98JZFJmxiyjcS9uMBUKRVnXAM8HgB8854+GccvkAV1j0wCWSfaXxp2hNu 7Sl7s7X3JSz5Cguvi9CCuQ5+qytJ8nw55XvnVrYJkUlECmYPvGeEAOnfi47yrsMeeWfJ FLS0lh37sDipDc5R9UVep1lnqpNO70iSSmiOfw4nWPCtzA70qps+PnLZId3vQAiLbFbK knRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719792982; x=1720397782; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sk8FYbkrgyRe7D+jo7cfiihFdJXLpFlwGxxj1Mrw3Pg=; b=Om7HZm8zXpWgbqzRug4OxJknE51VTahuG00yejHYo4rBNnJ/1L2jFqkmXJ1k3VsQpv n6rkTj/wzREfehzBBlUZ9F00DMzKB2DIhdv202EKRjyIyi9shm5QRynvsFLhLi8XBMue pqdwnpYh2fnHGYKrKvTbFzZ0m40Fz5+Eu+ZXdXkUc2EWpDdHr6rcofwK2frdWPkV8IfT w34u9tForKCiaki3kjyM/qOmeVXRHsDWGk5uA5GqGp0ZoqLWA6ksgnQcf0qxl41gkae5 hBimYoKTHs5lpn0EM/Nw+8B9S4lanm8Mzi4mfn/KQu4pdxQNmC84OflxIchgRC0rG3Py rNsw== X-Forwarded-Encrypted: i=1; AJvYcCXgfk+kLSmqs5TX1c9I9KYb+rmFnN/AaeN9FOsfbdeQUNo20GWPutEMZiJZATrjnrcxolOjMSXBH2YjUF0Q/I30jiMFjZt1cl2aHXEe X-Gm-Message-State: AOJu0Yxi819/+Et4SUQkEcGNngQrZz0d91FZcOizhdmg9UInRrj2dumo L83+jM/m2NZxrzRDQvUTo0Bs67Ueujjhd95zuhk4avHaoKZrFwNF0k2GgCkmuPDTfeCouuz8ItL pg8qby/uWIobv1Iec5s8jMiOS6fk= X-Google-Smtp-Source: AGHT+IE9a/Vmjik+oZZaofrpZ+ACfeguU7aT4lq9grb0xBVZdRMEN+Xc9y9YJbRYP3BBsCAuT3BerfTS3ikVTs80GMA= X-Received: by 2002:a05:6870:2246:b0:254:c512:88c6 with SMTP id 586e51a60fabf-25db35db53amr4160314fac.51.1719792981659; Sun, 30 Jun 2024 17:16:21 -0700 (PDT) MIME-Version: 1.0 References: <1362410.1719349169@sss.pgh.pa.us> <1390099.1719357084@sss.pgh.pa.us> <1642803.1719447063@sss.pgh.pa.us> In-Reply-To: From: "David G. Johnston" Date: Sun, 30 Jun 2024 17:15:43 -0700 Message-ID: Subject: Re: Should we document how column DEFAULT expressions work? To: David Rowley Cc: Peter Eisentraut , Tom Lane , James Coleman , pgsql-hackers Content-Type: multipart/alternative; boundary="000000000000c2564a061c248119" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c2564a061c248119 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 30, 2024 at 4:55=E2=80=AFPM David Rowley = wrote: > > I'd like to know what led someone down the path of doing something > like DEFAULT 'now()'::timestamp in a CREATE TABLE. Could it be a > faulty migration tool that created these and people copy them thinking > it's a legitimate syntax? > > My thought process on this used to be: Provide a text string of the expression that is then stored within the catalog and eval'd during runtime. If the only thing you are providing is a single literal and not some compound expression it isn't that obvious that you are supposed to provide an unquoted expression - which feels like it should be immediately evaluated - versus something that is a constant. Kinda like dynamic SQL. David J. --000000000000c2564a061c248119 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Jun 30, 2024 at 4:55=E2=80=AFPM David Rowley <<= a href=3D"mailto:dgrowleyml@gmail.com">dgrowleyml@gmail.com> wrote:<= /span>

I'd like to know what led someone down the path of doing something
like DEFAULT 'now()'::timestamp in a CREATE TABLE. Could it be a faulty migration tool that created these and people copy them thinking
it's a legitimate syntax?


My thou= ght process on this used=C2=A0to=C2=A0be:=C2=A0 Provide a text string of th= e expression that is then stored within the catalog and eval'd during r= untime.=C2=A0 If the only thing you are providing is a single literal and n= ot some compound expression it isn't that obvious that you are supposed= to provide an unquoted expression - which feels like it should be immediat= ely evaluated - versus something that is a constant.=C2=A0 Kinda like dynam= ic SQL.

David J.

--000000000000c2564a061c248119--