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 1sMFE7-001JM6-DB for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2024 23:05:27 +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 1sMFE5-000nv9-6F for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jun 2024 23:05:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sMFE4-000nv1-Sz for pgsql-hackers@lists.postgresql.org; Tue, 25 Jun 2024 23:05:25 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sMFDy-003YRo-Hj for pgsql-hackers@postgresql.org; Tue, 25 Jun 2024 23:05:24 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cdcd26d61so4162394e87.2 for ; Tue, 25 Jun 2024 16:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719356717; x=1719961517; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pATTT31RChrFQZn1hVKLM3N4SEmB875ZQtyKOyn/8ik=; b=ZNASWTyFmSt1hGhJ1hmurSgMPM5pl1dLtdghBZpS9fKRRAUweg+PqjSlEQe4Rnfzrf 7ac3kZf0P9Jz22gPuond68k+9yLgzmabPURzXEgDj5KMucYSQBoFYE9ixn2rvdUHU3Os uxu0XAOZ6/GQnx2vGCMGdYeBpwOi9HqZ55znvdeqCCZDQW5N/5dCYBA23+7VYxazgPc2 YCeHGDxYkWcmYkEqIzdaI2J6fjAXHhUUhwuZ/hubDqQzPybt6eOdcakTNEB4OtdYgDvs KszbLJAMnM3sM8n3irA8o59K7bTGBc+L+Hj36iZlvmQ5yEfCG4oPixPpDpQ/Kh9XIybH puOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719356717; x=1719961517; h=content-transfer-encoding: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=pATTT31RChrFQZn1hVKLM3N4SEmB875ZQtyKOyn/8ik=; b=Kg5jONc+LqXls8NM+fz24OV59clq5yfK8sQs17KQqL39g4WgsYv+6VjKsyT1gsYgeV f9afZGBk0d+rXYYB0X7RB0uuCrS6nIpU0FyGsEelcdWgfsAUyvCXNJcKnSuA6IW8JXYU OdGD66ma/0Dlih6gr9+TQfE08nZgtL9riHh+mB1V+2pu00ROsqaDmhsf9fxv51lrEI6d xNDk/8PziYPbkY7Sti5hFOGAcaf8TBhA7BTgIViY4CkjW7EemxoEFcN4S2PnJWNgoUPi SGb742YDJah9CHbTnGAH85dOaB0SJIwoQROU06I7ZBBFdt7I262HOEZYB4B5HNLtLlir K7YQ== X-Gm-Message-State: AOJu0YzKEKrZzmiz5vKvNVdD03pouAHkZ7/w80aJitlCOFqDYnn4omXM QsDfpUOrVBI/gpWx3FWuq+ffcpiqbj4peUuZzgkNXtXl0fkGhcQb4zMnOhZYgwxcZoLxRQb6r3J HIVFP9vmfA8bj8TSRoIcj22nWQ4c= X-Google-Smtp-Source: AGHT+IFKduZyqgl762eAnQBRzO6yvFzKCDRTN0m1I2Mm/eZOxiKPZUBfCZR7dqB/d9EEmkQ2KMZ6X+7GotyCLLXpw0s= X-Received: by 2002:a05:6512:318a:b0:52c:ec5d:b18b with SMTP id 2adb3069b0e04-52cec5dbd36mr3478552e87.24.1719356716257; Tue, 25 Jun 2024 16:05:16 -0700 (PDT) MIME-Version: 1.0 References: <1362410.1719349169@sss.pgh.pa.us> In-Reply-To: <1362410.1719349169@sss.pgh.pa.us> From: James Coleman Date: Tue, 25 Jun 2024 19:05:04 -0400 Message-ID: Subject: Re: Should we document how column DEFAULT expressions work? To: Tom Lane Cc: pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 25, 2024 at 4:59=E2=80=AFPM Tom Lane wrote: > > James Coleman writes: > > It's possible I'm the only one who's been in this situation, but I've > > multiple times found myself explaining to a user how column DEFAULT > > expressions work: namely how the quoting on an expression following > > the keyword DEFAULT controls whether or not the expression is > > evaluated at the time of the DDL statement or at the time of an > > insertion. > > Uh ... what? I recall something about that with respect to certain > features such as nextval(), but you're making it sound like there > is something generic going on with DEFAULT. Hmm, I guess I'd never considered anything besides cases like nextval() and now(), but I see now that now() must also be special cased (when quoted) since 'date_trunc(day, now())'::timestamp doesn't work but 'now()'::timestamp does. So I guess what I'm asking about would be limited to those cases (I assume there are a few others...but I haven't gone digging through the source yet). Regards, James Coleman