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 1fwMrr-0004lV-Vw for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Sep 2018 07:32:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwMrp-000474-7v for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Sep 2018 07:32:17 +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 1fwMro-00046x-M9 for pgsql-bugs@lists.postgresql.org; Sun, 02 Sep 2018 07:32:16 +0000 Received: from mail.webkr.de ([78.47.173.34]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwMrh-0007Bg-JT for pgsql-bugs@postgresql.org; Sun, 02 Sep 2018 07:32:15 +0000 ARC-Authentication-Results: i=1; rspamd; auth=pass smtp.auth=andre@webkr.de smtp.mailfrom=andre@webkr.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1535873527; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=vpnJsOzulIm2+AWuyZVzPk9o7AEyhyRtLdP7v+2no9Q=; b=RYGFppWR+ZKoL53j16mMTBaaIOc+KorPg9mD5gda0dfSfnnNNBnmjZCXUewv1zZjdMwDoI 6vXVR8UtbsxCDYDiQPyYeCRbXlEdyZxakkTP8EORrAyc/S17m6HJhJwi0d8MAOacMGr03U Kvhabd7mHs5nMMZxD6qhZukuWAElkNY= ARC-Seal: i=1; s=dkim; d=webkr.de; t=1535873527; a=rsa-sha256; cv=none; b=Lz/+vXUaSx6nEMC/I214inFJ8kx9P+aLwSYVDt6A5duMo48pKECF1fRJ1lOCYYRjAc+NmwtcGVIGKHRNJLuAAT7LqJlfu77QxBwttogDpk2IAaqOBIpmY68cSUE5UNoCTkzv6dPJd4dbOBrXgPFBdv78JepRCw7iErSUyHysuYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=webkr.de; s=dkim; t=1535873527; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=vpnJsOzulIm2+AWuyZVzPk9o7AEyhyRtLdP7v+2no9Q=; b=BBSvz3QGoJ+pklMDu24owWXo+xaf4smrMcriO1Ci+kViM/Hfg/taSMSHigGgL9WYCnUkxi qYF9T1vD/tya2N1DxwA4vvgvJl/Lq+4Gxe09r3TTMG3bFUOjnMfCci/DKX2BAGyRcugXXo BkutGnNWBpgoq9d+8/XxG4MvCbI2XKE= Received: from LappyAndre (unknown [223.205.155.49]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: andre@webkr.de) by mail.webkr.de (Postfix) with ESMTPSA id CFE981A0B4C for ; Sun, 2 Sep 2018 09:32:05 +0200 (CEST) From: =?iso-8859-1?Q?Andr=E9_H=E4nsel?= To: Subject: Two constraints with the same name not always allowed Date: Sun, 2 Sep 2018 09:31:52 +0200 Message-ID: <0c1001d4428f$0942b430$1bc81c90$@webkr.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AdRCjui5FRCotRPURSCUYoE33KeqXg== Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi list, calling this a bug might be pedantic, but I noticed this inconsistency: Case 1: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT foo UNIQUE(c); ALTER TABLE t ADD CONSTRAINT foo CHECK(c > 1); -> ERROR: constraint "foo" for relation "t" already exists Case 2: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT foo CHECK(c > 1); ALTER TABLE t ADD CONSTRAINT foo UNIQUE(c); -> Creates two constraints, both called "foo". Case 3: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT t_c_check UNIQUE(c); -- add the UNIQUE with = the same name that the following CHECK will automatically choose ALTER TABLE t ADD CHECK(c > 1); -> Creates the UNIQUE constraint as "t_c_check" and the CHECK as "t_c_check1" Case 4: CREATE TABLE t(c integer); ALTER TABLE t ADD CONSTRAINT t_c_key CHECK(c > 1); ALTER TABLE t ADD UNIQUE(c); -> Creates two constraints, both called "t_c_key". In cases where two constraints with the same name are created, an "ALTER TABLE t DROP CONSTRAINT ..." drops the UNIQUE first. Issuing the ALTER = TABLE a second time then drops the CHECK. Regards, Andr=E9