Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOrpS-0003sE-PV for pgsql-bugs@arkaria.postgresql.org; Thu, 09 May 2019 22:47:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hOrpQ-00017Z-DO for pgsql-bugs@arkaria.postgresql.org; Thu, 09 May 2019 22:47:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOmBM-0000xp-7q for pgsql-bugs@lists.postgresql.org; Thu, 09 May 2019 16:46:08 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOmBF-0006jg-Rz for pgsql-bugs@lists.postgresql.org; Thu, 09 May 2019 16:46:04 +0000 Received: by mail-ed1-x52b.google.com with SMTP id w37so2637909edw.4 for ; Thu, 09 May 2019 09:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tvsquared.com; s=google; h=from:mime-version:subject:message-id:date:to :content-transfer-encoding; bh=pgcrLicdAriZuh+V/JmRM0hGdYQU1/oyf+lj4EIelzw=; b=KshYKvcD7HOiOvTDn239zTaeZYYbrHzABytluSdj04cAJt3G0Iif0TpDVEz5lU0RFp OcQOsmkAVmfzQiDJLyA+hdb7LI4h+W9TfVQLq+WeGvGzQDgP+Wb/lQdLhMmPX+pPA25Q msfWTzgmoc0XoOIEt5IwfGo9US7ToERvgd+eo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:message-id:date:to :content-transfer-encoding; bh=pgcrLicdAriZuh+V/JmRM0hGdYQU1/oyf+lj4EIelzw=; b=NIuhnPw2c6MB9h2qCJ2adYh1qX2FFphc3sje1Wl0WGjzWOku69HXJi/Q+4G9gA2/cF mXmJwMVZjoyw8o6V2txnDexK6JqLd0ab6itfuYO3v2H05SWdzMHsD+CaGYS4xJIl4Wqt waREdbVJUmfS+WRUMUM61hBqMsxpEr8p9g1FHqSMzR4CWM6Hb2+bsphenB6faCYIh3Xy pMQKrDVCXxj1Nw8eRaQw7Leb6VWerXPCV/Tc2hT4napPbqjg3PnzNjE6lGYon1Wr73Ks a1jrwqpagLu6Qch+F/IqsSpZ3yqvqn2JqMEwi3oTlObN3IfeAXF0jMqGCoy3b3m5HEbH oGhQ== X-Gm-Message-State: APjAAAUEH01IZG0wT4+R+FFJwWRWI8P9F2gY3NXAQT65i9szAy9iuj2u +Kd/iasHEZ55jFgyy4dtPCgEdZzy+5XRL58ui5eh3MHa/0Lr8l0iyWQl93nSDTjxYlcSo+z1qCc JkWdWdJZYH7MxN2CibWqvIu1IVrVomA== X-Google-Smtp-Source: APXvYqxcRPbYjVAUxEjg7BgR4DXY0PP4LzUoMVIj2WjJZxjTCSz652K16l7FZopzs12J7OxUkJA58w== X-Received: by 2002:a17:906:af53:: with SMTP id ly19mr4173427ejb.78.1557420359320; Thu, 09 May 2019 09:45:59 -0700 (PDT) Received: from [192.168.161.221] ([87.246.78.46]) by smtp.gmail.com with ESMTPSA id a61sm702162edf.8.2019.05.09.09.45.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 09:45:58 -0700 (PDT) From: Alan Jackson Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: inconsistent results querying table partitioned by date Message-Id: Date: Thu, 9 May 2019 17:45:55 +0100 To: pgsql-bugs@lists.postgresql.org X-Mailer: Apple Mail (2.3445.104.8) Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Im having a problem with querying a table partitioned by date. Depending on the sequence of operations on a date parameter used in a where= clause, I either get the expected results, or no results. This suggests a bug in the handling of date parameters and partition range = handling. I=E2=80=99ve replicated this down to a single sequence of create table, ins= ert data, query. This issue occurs for me on postgresql 11.2 on a mac, installed via brew. In this case the table is partitioned by an id and then by the date, if it = is partitioned by only the date everything works as expected. However, I am attempting to add partitioning to a fairly large sofware-as-a= -service platform, so making changes to the table definitions or global cod= e changes is not really practical. The sql in question is below. I hope there is something simple I can change in the partition definitions = to work around this. Many Thanks, Alan Jackson Data Architect=20 TVSquared --SQL STARTS HERE --drop table dataid; CREATE TABLE dataid ( id integer not null, datadatetime timestamp without time zone NOT NULL, CONSTRAINT dataid_pkey PRIMARY KEY (id, datadatetime) ) PARTITION BY RANGE (id, datadatetime)=20 ; CREATE TABLE dataid_201902 PARTITION OF dataid FOR VALUES FROM (1, '2019-02= -01 00:00:00') TO (1, '2019-03-01 00:00:00'); CREATE TABLE dataid_default PARTITION OF dataid DEFAULT; insert into dataid values (1,'2019-02-24T00:00:00'); --- returns 1 row as expected select * from dataid where id=3D1 and datadatetime < (('2019-02-26T00:00:0= 0'::timestamp::timestamp at time zone 'America/New_York' ) at time zone 'UT= C' + '2 days'::interval); --- returns no rows select * from dataid where id=3D1 and datadatetime < (('2019-02-26T00:00:0= 0'::timestamp::timestamp at time zone 'America/New_York' + '2 days'::interv= al) at time zone 'UTC'); -- both date expressions evaluate to the same date. select=20 (('2019-02-26T00:00:00'::timestamp::timestamp at time zone 'America/New_Yor= k' ) at time zone 'UTC' + '2 days'::interval) as workingdate, (('2019-02-26T00:00:00'::timestamp::timestamp at time zone 'America/New_Yor= k' + '2 days'::interval) at time zone 'UTC') as notworkingdate; --SQL ENDS HERE --=20 TV Squared Limited is a company registered in Scotland.=C2=A0 Registered nu= mber:=20 SC421072.=C2=A0 Registered office: CodeBase, Argyle House, 3 Lady Lawson St= reet,=20 Edinburgh, EH3 9DR.=20 =C2=A0 TV Squared Inc (File No. 5600204) is an Incorporated=20 company registered in Delaware. Principal office: 1412 Broadway, 22 Fl, New= =20 York, New York, 10018 TV Squared GmbH is a company registered in Munich.=20 Registered number: HRB 236077. Registered office: Oskar-von-Miller-Ring 20,= =20 c/o wework, 80333 Munchen This message is private and confidential.=C2=A0 If=20 you have received this message in error, please notify us and remove it=20 from your system.