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 1sMd6H-003TzV-K0 for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jun 2024 00:34:57 +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 1sMd6F-007DuD-5t for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jun 2024 00:34:55 +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 1sMd6E-007Du5-PY for pgsql-hackers@lists.postgresql.org; Thu, 27 Jun 2024 00:34:55 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sMd6C-003jxy-6l for pgsql-hackers@postgresql.org; Thu, 27 Jun 2024 00:34:54 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52cdea1387eso5056774e87.0 for ; Wed, 26 Jun 2024 17:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719448491; x=1720053291; 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=VFug6WoMpwqNSpOv168jPmSi10Yw/wvpsxV+B+Lem3I=; b=BMUC41Ia6d0buCFVc3ploYviWDKvMkGbW22AKYrmfNrHihiMg5KmUEqGIIxMimzYBJ 3txOirkzx10KgYYgRH4Xw1v0887DJlq++8+TyeLet+awHLG2qFCMTlxVp1X8EXAGLlon sWOmAMUQJG5SKHpckidcsZ4qLAMvzkJsiDt0CGJBHmdG6JgnUJHGpTmF926cbxgBBCzC VUEqfX8n1pQ2U0JI72mzynZDe1+ZoQ4EyV3ipbrpNE/u39efc/FaWGaLyUL19S5+GN97 kUboE/ftkZZZY1DEXt4Kr4p06xRpDQPSLwTXGsGRywYgAZOcM44aTNWF4p0Bi9ug61U0 G3og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719448491; x=1720053291; 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=VFug6WoMpwqNSpOv168jPmSi10Yw/wvpsxV+B+Lem3I=; b=WPj1LDaiYydZW0YA393VYn8xWz1XezbbbBFLfkhB4nxRehRQOfD6K5TxV9+XjeU0R3 EhD2Nmhp/v3RX1LWVEqpUziD+a9Fwy3pGRhAkxWzsyQFMZQEKvu4hHtI5CVCO5CwpIze 4f+wVP28GUBoSrNVZiTTnhMUrf50js94CsvAv3Kn+OHy7icFdzIWjRawGUikJAFeT0YN EClRY1or7rYeQsyReIfAmidJlZ9mFzEJZXbNVyn5Cwxt4/c9i89hrC3WEGoQWFUev1gn zi5vNV19jMclLL5R6lnbNmrV7QxfgmVhFkLNUM69QlFd/EZGv5hSRViz41F/tcs73GBJ 1AFQ== X-Forwarded-Encrypted: i=1; AJvYcCX5fGDflPiV+1L3dt4tWttUsegvwoZo+E5aLG47j7LCjM3ExBMDLCnzgK6Lwx5MtefOjArcMjwQihHyiJQjibCx5+r2sIXGe/MXj9HY X-Gm-Message-State: AOJu0YwlfNIlM1OXbxyVOaVeHHzTCYz7L6KUKrXefdjOH8b/4vfi5Yip BeWkp4QOElO7kV2tyOR8v11pzLUxByjFMXuu64U15Od7kMNr8zwGkz4BfhRMuiksXw8SBeL0BAQ ZhzxiEpkbUApgtP2glK08EIHZsLs= X-Google-Smtp-Source: AGHT+IEtHRUtJ7jGY1AK5BcTuZO7VYfoJbAV9bSC1qSwvZQTZE7NXLxWR0JULTnotM44uZgrdD8otan1CbfttP4Rero= X-Received: by 2002:a05:6512:2254:b0:52c:e17c:3753 with SMTP id 2adb3069b0e04-52ce18320e6mr9189730e87.5.1719448491031; Wed, 26 Jun 2024 17:34:51 -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: <1642803.1719447063@sss.pgh.pa.us> From: David Rowley Date: Thu, 27 Jun 2024 12:34:37 +1200 Message-ID: Subject: Re: Should we document how column DEFAULT expressions work? To: Tom Lane Cc: "David G. Johnston" , James Coleman , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 27 Jun 2024 at 12:11, Tom Lane wrote: > > David Rowley writes: > > Maybe I'm slow on the uptake, but I've yet to see anything here where > > time literals act in a special way DEFAULT constraints. This is why I > > couldn't understand why we should be adding documentation about this > > under CREATE TABLE. > > It's not that the parsing rules are any different: it's that in > ordinary DML queries, it seldom matters very much whether a > subexpression is evaluated at parse time versus run time. > In CREATE TABLE that difference is very in-your-face, so people > who haven't understood the rules clearly can get burnt. Aha, now I understand. Thanks. So, seems like CREATE TABLE is being targeted or maybe victimised here as it's probably the most common place people learn about their misuse of the timestamp special input values. > However, there are certainly other places where it matters, > such as queries in plpgsql functions. So I understand your > reluctance to go on about it in CREATE TABLE. At the same > time, I see where David J. is coming from. > > Maybe we could have a discussion of this in some single spot, > and link to it from CREATE TABLE and other relevant places? > ISTR there is something about it in the plpgsql doco already. For the special timestamp stuff, that place is probably the special timestamp table in [1]. It looks like the large caution you added in 540849814 might not be enough or perhaps wasn't done soon enough to catch the people who read that part of the manual before the caution was added. Hard to fix if it's the latter without a time machine. :-( I'm open to having some section that fleshes this stuff out a bit more with a few examples with CREATE TABLE and maybe CREATE VIEW that we can link to. Linking seems like a much more sustainable practice than adding special case documentation for non-special case behaviour. David [1] https://www.postgresql.org/docs/devel/datatype-datetime.html