Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fw8An-0005Ez-0b for pgsql-general@arkaria.postgresql.org; Sat, 01 Sep 2018 15:50:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fw8Aj-0007ya-6F for pgsql-general@arkaria.postgresql.org; Sat, 01 Sep 2018 15:50:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fw8Ai-0007yR-G7 for pgsql-general@lists.postgresql.org; Sat, 01 Sep 2018 15:50:48 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fw8Aa-0003Nm-On for pgsql-general@lists.postgresql.org; Sat, 01 Sep 2018 15:50:46 +0000 Received: by mail-wm0-x22c.google.com with SMTP id b19-v6so7742361wme.3 for ; Sat, 01 Sep 2018 08:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:subject:date:mime-version:content-language :thread-index; bh=0gsXtNvRdMcvgwPk5cJhQJwBuHFb5Ovj3MtBtx56CMI=; b=oj6P71ncciCuedCpyI//ADLLWfPBizu/6WXyNx+Zs707Xi4rdkYIcTJpDgGTg7J4zx iHRyDbAwPBVzhoDc8oPxnmJC1kzgqBd1Aj7V+l8QA/3vvUEUQ5SqcNRqHb+Ggc3Nehji /BrTiF+qJ4BbMJubRojs/NB2i7Lm/PrPrBqlBRk0NiJS845L70xOjTIvSy633IiBDdJb aqycaG5ZhSlTjz+POaLXK9T+IB1/tTNyb31iMkaGbzRv0RwAEUtyRyMlJF70nPATZII3 P8x5KgfM011OG8S1rxxZZeVBJM8rs/vDsy1OiBXjI2CEfDlw+bdP25WaHnEJCAbhlkcg dI2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:subject:date:mime-version :content-language:thread-index; bh=0gsXtNvRdMcvgwPk5cJhQJwBuHFb5Ovj3MtBtx56CMI=; b=FQz6PGNiLD+reVjFv7jZtteRJqtUZdUnh5F5ByemQT6XZsQu5sBbMV8N9AU6gf/bzL HodVtkg73KyAux62WQFyiWqA6G8P0KYI67BkLNvGqratJzudRlsNJnkqZ64ubjlBF8mT ep3V2yUg16DflVU4hFps5dVJiC0r2ZOAlD74f6LCvFwjvP+NLJznlCdjgDgzGwu4IJMX l9wNAKa99fizEOPPBHd8bgWI7D+lPhkoLh3/5DB1Nrxwo19P2Ppth63aFQzRYvrfm4hd urOnguyBCeH6o8ZyNFd7jzxhpvao+KeG2JDJvPpMe6WKXS/ghocyo33acRhBtvs9CO65 Xf3w== X-Gm-Message-State: APzg51AbjpxNYwbr9qLEHoEwKFXIY+XwUHGlAjpWCEwPMjHwwbm1DLV+ FjLTJsFE/7isg/TWbLUjzQTlyLTQ X-Google-Smtp-Source: ANB0VdbQuu+xT+jQjNcIQl/ZNZHs0qfO14jzFqG28xvBOOk167/VnCDeQEpg1LTelFDsa4rlFO/+HQ== X-Received: by 2002:a1c:af0c:: with SMTP id y12-v6mr876174wme.87.1535817037687; Sat, 01 Sep 2018 08:50:37 -0700 (PDT) Received: from PADOUE (mau78-1-88-184-109-217.fbx.proxad.net. [88.184.109.217]) by smtp.gmail.com with ESMTPSA id a203-v6sm744877wmh.31.2018.09.01.08.50.35 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Sep 2018 08:50:36 -0700 (PDT) Message-ID: <5b8ab54c.1c69fb81.1566e.43f0@mx.google.com> X-Google-Original-Message-ID: <025001d4420b$847af0b0$8d70d210$@lepretre@gmail.com> From: =?iso-8859-1?Q?Olivier_Lepr=EAtre?= To: Subject: TR: redundant constraint_schema Date: Sat, 1 Sep 2018 17:50:31 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0251_01D4421C.4803C0B0" X-Mailer: Microsoft Office Outlook 12.0 Content-Language: fr Thread-Index: AdQ/nvqWfTOoqOe5S7aBsxclgGpFAQBihcMAADht0fA= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_0251_01D4421C.4803C0B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, =20 Please find a question that didn't get an answer in the pgsql-sql & pgsql-hackers lists. I hope I'll get an answer here. =20 Thanks, =20 Olivier =20 =20 De : Olivier Lepr=EAtre [ mailto:o.lepretre@gmail.com]=20 Envoy=E9 : mercredi 29 ao=FBt 2018 15:49 =C0 : 'pgsql-sql@lists.postgresql.org' Objet : redundant constraint_schema =20 Hi, =20 Can someone explain why, when a column is not created (add column if not exists), a redundant constraint is still created from the REFERENCES = part ? =20 =20 I have a patching script that is supposed to add column if not existing = : =20 ALTER TABLE myschem.table1 ADD COLUMN IF NOT EXISTS col1 VARCHAR(254) REFERENCES myschem.table2(col2) =20 When col1 already exists, I expected that nothing would happen. But, = when applying the previous query and then querying : =20 select constraint_name from information_schema.key_column_usage where constraint_schema=3D'myschem' =20 I notice that a new constraint "table1_col2_fkeyxxx" is created each = time the previous ALTER TABLE ADD COLUMN is called (with xxx being a new = number each time) =20 It seems strange to have second part of statement executed (references) = when first part (add column) was not. Would it be possible that this sort of query executes "references" first ? =20 Thanks, =20 Olivier =20 ------=_NextPart_000_0251_01D4421C.4803C0B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi,

 =

Please = find a question that didn't get an answer in the pgsql-sql & = pgsql-hackers lists. I hope I'll get an answer = here.

 =

Thanks,

 =

Olivier

 =

 =

De : Olivier Lepr=EAtre [mailto:o.lepretre@gmail.com]
Envoy=E9 : mercredi 29 ao=FBt 2018 = 15:49
=C0 : = 'pgsql-sql@lists.postgresql.org'
Objet : redundant = constraint_schema

 

Hi,

 =

Can = someone explain why, when a column is not created (add column if not = exists), a redundant constraint is still created from the REFERENCES = part ?

 =

 =

I have a = patching script that is supposed to add column if not existing = :

 =

ALTER = TABLE myschem.table1

  = ;        ADD COLUMN IF NOT EXISTS = col1 VARCHAR(254) REFERENCES = myschem.table2(col2)

 =

When col1 = already exists, I expected that nothing would happen. But, when applying = the previous query and then querying :

 =

select = constraint_name from information_schema.key_column_usage where = constraint_schema=3D'myschem'

 =

I notice = that a new constraint "table1_col2_fkeyxxx" is created each = time the previous ALTER TABLE ADD COLUMN is called (with xxx being a new = number each time)

 =

It seems = strange to have second part of statement executed (references) when = first part (add column) was not. Would it be possible that this sort of = query executes "references" first ?

 =

Thanks,

 =

Olivier

 

------=_NextPart_000_0251_01D4421C.4803C0B0--