Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 38B5665017F for ; Mon, 8 Sep 2008 03:19:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 51256-02 for ; Mon, 8 Sep 2008 03:19:08 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by postgresql.org (Postfix) with ESMTP id B2D466501C3 for ; Mon, 8 Sep 2008 03:14:45 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id i26so77950wxd.28 for ; Sun, 07 Sep 2008 23:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=UnHr/KFlN2bEoIQT9wu4Kbt4i6+GVrDGWPKonO4xo3Y=; b=unz4va92a9kECmwtAnVaAuRLr3/LQwt8Zf26pce9rNCE1yH4XnLoKq5lDgHTVgcv94 Q7n68FPCf0fp6xStGkBrJUoYHlu765OSq5lKzosXkMthnAaZav3Er5Lwu8z5V/E0GOTy Vau6Of2zoS8RsD1eSIplJEcEM7C7DwR2csm+8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=QbTDfg0shwKvgcUhJW7vjUcKAEzu+4k1OegUTlJzLogf0oRaRPvJYOVdpmtB85uXk2 5t42uoqtWpFR8d2U0nN8oHCjTEL1Z7HmAhjYHaZLDx9KTZDttkZXnnWQH3d8x5bxJ40I TNRRa79d4wEBSLXZRPDz3zJdmhDaFEK2Cv5JY= Received: by 10.70.18.11 with SMTP id 11mr18587806wxr.73.1220854484012; Sun, 07 Sep 2008 23:14:44 -0700 (PDT) Received: by 10.70.49.17 with HTTP; Sun, 7 Sep 2008 23:14:43 -0700 (PDT) Message-ID: Date: Sun, 7 Sep 2008 23:14:43 -0700 From: "Ryan Bradetich" To: "Tom Lane" , "Jaime Casanova" Subject: Re: [PgFoundry] Unsigned Data Types [1 of 2] Cc: pgsql-patches In-Reply-To: <14575.1220803638@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3073cc9b0809061341q5c747488i85491e4c8e2420ba@mail.gmail.com> <3073cc9b0809062330o62fd74dax74b1730cedc0fbb9@mail.gmail.com> <8731.1220773267@sss.pgh.pa.us> <3073cc9b0809070713s1df16d8dlb3be457b3584ba5c@mail.gmail.com> <14575.1220803638@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/87 X-Sequence-Number: 7102 Hello Jamie and Tom. Thank you very much for the feedback and reviews. I will attempt to answer all the questions I found in this thread in this one email. If I miss any questions, let me know and I will answer it :) Jamie: Thanks for the feedback on missing comments. I will go back and add more comments to the code. Jamie: Thanks for the patches. I have applied the Makefile patch to my local tree. I am still reviewing the regressions.diffs patch. I definitely see the issue now, I am still reviewing to see/understand if your solution is the proper fix. I am reviewing the main PostgreSQL regression tests to understand how the COPY is handled. Jamie: This patch is targeted for as a PGFoundry module. I wanted it reviewed by the PostgreSQL community for two reasons: 1. To make the data type is correct (i.e. the bugs you and Tom identified, etc). 2. To go through the community review process so other people can have faith/trust the module is correct. After the community is happy with the uint data type, I will commit it to the PGFoundry repository. Jamie: The uint1 is an unsigned 8-bit value. It is the unsigned variant of the "char" type. The uint8 type (which I did not provide support for in this patch would be the unsigned variant of the int8 (64-bit type). Jamie and Tom: Tom, you were correct. The -255::uint1 is being promoted to the int4 data type. Here is the sample c program I used to verify this: #include #include #include #include #include int main() { PGconn *conn; PGresult *res; char query[255]; conn = PQconnectdb("host=127.0.0.1 dbname=test user=rbrad"); assert(PQstatus(conn) == CONNECTION_OK); res = PQexec(conn, "SELECT -255::uint1;"); assert(PQresultStatus(res) == PGRES_TUPLES_OK); snprintf(query, 255, "SELECT %d::regtype", PQftype(res, 0)); PQclear(res); res = PQexec(conn, query); assert(PQresultStatus(res) == PGRES_TUPLES_OK); printf("Result Type: %s\n", PQgetvalue(res, 0, 0)); PQclear(res); PQfinish(conn); return 0; } Output: Result Type: integer On Sun, Sep 7, 2008 at 9:07 AM, Tom Lane wrote: > Ah. The scalarltsel/scalargtsel stuff has always been a bit bogus for > cross-type comparisons; it assumes it will know both or neither of the > two datatypes. So you can get away with using those functions for > uint > uint (although they won't be very bright about it); but using > them for uint > int fails outright. > If you read the comments around that stuff it leaves quite a lot to be > desired, but I don't really have better ideas at the moment. The best > near-term solution for the uint module is probably not to rely on > scalarltsel/scalargtsel for uint comparisons, but to make its own > selectivity functions that know the uint types plus whatever standard > types you want to have comparisons with. Ok. Looks like I need to review these functions and develop new functions specific for the unsigned type. I will work on this tomorrow night and submit an updated patch. Thanks again for the feedback and reviews! - Ryan