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 1sO5D2-00CFDW-Nv for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 00:47:56 +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 1sO5D0-00E7gv-9v for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jul 2024 00:47:54 +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 1sO5D0-00E7gn-0B for pgsql-hackers@lists.postgresql.org; Mon, 01 Jul 2024 00:47:54 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sO5Ct-004O63-I6 for pgsql-hackers@postgresql.org; Mon, 01 Jul 2024 00:47:53 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52ce9ba0cedso4046208e87.2 for ; Sun, 30 Jun 2024 17:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719794866; x=1720399666; 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=uWq0TsqHp/gLm9cg7hEh34ClCbvJJDZoZAUlpIm3/Ys=; b=RVGs8RP1C16wQ4hOB4P3lCaf5H7RqN+o5V70a7xWA7oZLBsTmS0OJjKuCfRam7bjKw QsEIXmy8JvZwWKXQ5tdUMZQEd/eMOrOBarauBJbL6jXFL1OrUfq8EMGEzdSbD85fRPpW I4bVAqY0LOpGTYbjHxf4TxiMMleA3SWlmMmKRg412RnQHtncaRt+sLDrcDugR8YJbFAQ FvAB/oTyZ9Fw9wVzdP6YHa6S0aG6qaS4JNrAwQdDnZebZfEtp+qiA0mWHlNV5AdOoe85 7u2gFbDLTw/5ILYy3EroQrNd+0qH4IoBI8mVk1a9liDD+EegRmQzV5Rrt6zlH1oe2vTy CD8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719794866; x=1720399666; 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=uWq0TsqHp/gLm9cg7hEh34ClCbvJJDZoZAUlpIm3/Ys=; b=ASO4xE9efGwnm2BMMXzWSgYCfmQ6U+sDxfUSfvFg9HymVguthS5biI6uO5IPh8O/kL /kc+Mi88SiBAcfbQSRo6oOPj9jZqcX30cHqDrHfjvmY39tzIOgzOk9SVBXGzXucVEaug B93s8GO39H6y/CzdJ9jXP+Z2FBB9YmlF+ftlZgNRwx9bjB9wIvNJZQlZDLMqko1G6EQG Btlmgkt+dcky7jNNDhhu+rIu+oUFDvmtupJNEB1wLdLDACUYkJnfurU+s51d4Mdj+lJl mhP8zcJxV4CKqu0jYzwLZKdNdTxEY3gQVYkXIh/miuuvARaGFx2vcHL0JhDUMm/FaSZ4 /T5A== X-Forwarded-Encrypted: i=1; AJvYcCWWQtrUJh9RRP44ZsdfaAfxDYwEGPv/yPSTbVQU1kqcB/jON9UqgaqmqPdMJDD6etq/FAI5W+LPButW7bCzDsogMFIZRl8UhMCkCkct X-Gm-Message-State: AOJu0Yw03WYM7iubMcPPNjqEO4gTNCC7HHat2x0zRkEm2BQAMxdO9F/T bJJ6+vhhNhHEZsoqUktkHFGbRlBeH0j60/K2+pw33xyzZ4q4ZjWc4QbOTC3VL/5+vBMVIPste8d Jmcy7epiCeIeoIbsEq0Ma7+AmUGA= X-Google-Smtp-Source: AGHT+IGLLNUCNwi/hD+89x3KwwQuWA9NZoi2j6bJ1eQpkwcrL1ovlO4uE4Ofal8biaVq1DH03P+6QGbQL3u/aI2YGyY= X-Received: by 2002:a05:6512:2814:b0:52c:db0e:6c4a with SMTP id 2adb3069b0e04-52e8264bc06mr3606109e87.2.1719794866127; Sun, 30 Jun 2024 17:47:46 -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 Rowley Date: Mon, 1 Jul 2024 12:47:31 +1200 Message-ID: Subject: Re: Should we document how column DEFAULT expressions work? To: "David G. Johnston" Cc: Peter Eisentraut , Tom Lane , James Coleman , 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 Mon, 1 Jul 2024 at 12:16, David G. Johnston wrote: > > 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 expr= ession that is then stored within the catalog and eval'd during runtime. I= f the only thing you are providing is a single literal and not some compoun= d expression it isn't that obvious that you are supposed to provide an unqu= oted expression - which feels like it should be immediately evaluated - ver= sus something that is a constant. Kinda like dynamic SQL. Thanks for sharing that. Any idea where that thinking came from? Maybe it was born from the fact that nothing complains when you do: 'now()'::timestamp? A quick test evaluation of that with a SELECT statement might trick someone into thinking it'll work. I wonder if there's anything else like this that might help fool people into thinking this is some valid way of getting delayed evaluation. David