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 1scX78-008DRl-2T for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2024 21:25:34 +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 1scX76-006BvU-5p for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2024 21:25:32 +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 1scX75-006BvM-Nw for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2024 21:25:31 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1scX6z-003wRx-Il for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2024 21:25:30 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-7094641d4e6so1241845a34.3 for ; Fri, 09 Aug 2024 14:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723238724; x=1723843524; darn=lists.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=NlnypL5Xl+gHMZuwZAer1D+o3lKoTNUCmr/ppSeJBPA=; b=SQ6Ioc+JETMbWU+A9CXBFHYyEkWw8LELzqnekgDEbEo1L1eUkGbISgHw/tWlwkDB8o HtLhlGY6KNvJVLfRA6zBbCT2qpOBKebOjInVNAUqsR/xTX/q6gEMJ8AwvfZBg/c31yi6 5S3KPQpnn1lzJ2lJxZfUJ0wmb5RaLWnsdhFZedcPcqIawX2rbGdZ4eusWwOiCYQw+S0T +c9LPipFnmsSqkdvfcOarhKh4xJHUroqIvKjM7n8D8qk0FyPysx3OwIET1RtEDB4GSEo ikJmsSPN0RKQ83JaJ9Qfv5E5SL4EOhhkRa9hPPXsRVWDRodJZUrB5m+KbF6NXif83IcV 3DXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723238724; x=1723843524; 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=NlnypL5Xl+gHMZuwZAer1D+o3lKoTNUCmr/ppSeJBPA=; b=glHYrLVqeK1//o0NPvSnh6IV0v3nNJaY5wg9Ud6YM8tuzsz8b17Bez+YeyhPaOmh1o JUvXN95qS8WruAcQVR17uS2fzzavzgjg3zEi3simrGWcRyuehb6wwwUJLyMQ8Ko7DLcQ DGWkkp5nmylF3pp3DbteN4o9FM9XOXyupMUmp8suYgtlo0oA3rdT4zO/uY/Ixw2JH5/4 68YAXBeXNb0ZmDMQF/Xdv6Csi4aNlySvTQShiYP2IMQaKg62gyhwcCi47/uc4RZx/KKh R5owaguuqnvWxLyJMi0pUn2VaQW50sP6l3eIME/t3Uj5tuq+neX/OHlAIkpWxPql8C68 wzyA== X-Gm-Message-State: AOJu0YxY+grnD0ksI4mhrTA1hBbb8R5+nSv2NKqe9vBGIX5FDDIeLP7c mVc6ONNOhEnLTSl/HoIxnLHeE+x4DDQhpBY2KWIsT1H1eVHxl79fG4HZj6UE1jd6aYl3jEXQTay yA7UeoLLxcG0sv+nbRFKo9Nj23BQ= X-Google-Smtp-Source: AGHT+IEc76NHXvNy8ZSZEiCpx9biFe7kXcnMp9PYVF5WAkZv5yCuQlqyJ+q+Dzj9YWusUl0Cn3Kbr1a1sQkBSRECqZw= X-Received: by 2002:a05:6358:41a1:b0:1aa:c71e:2b2c with SMTP id e5c5f4694b2df-1b176f25712mr333745155d.11.1723238724239; Fri, 09 Aug 2024 14:25:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Fri, 9 Aug 2024 14:24:46 -0700 Message-ID: Subject: Re: Insert works but fails for merge To: yudhi s Cc: pgsql-general Content-Type: multipart/alternative; boundary="00000000000005892d061f46c89a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000005892d061f46c89a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Aug 9, 2024 at 2:14=E2=80=AFPM yudhi s wrote: > > Why so? > Because you stuck a CTE in between the column list of the insert - where types are known - and the values command - where types are unknown since you didn't specify them. As the row comes out of the CTE every column must have a known type, and so in the absence of context they get typed as text. David J. --00000000000005892d061f46c89a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Aug 9, 2024 at 2:14=E2=80=AFPM yudhi s <learnerdatabase99@gmail.com>= wrote:

Why = so?

Because you stuck a CTE in be= tween the column list of the insert - where types are known - and the value= s command - where types are unknown since you didn't specify them.=C2= =A0 As the=C2=A0row comes out of the CTE every column must have a known typ= e, and so in the absence of context they get typed as text.

David J.

--00000000000005892d061f46c89a--