Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 5249D1952586 for ; Mon, 6 Feb 2012 23:29:16 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rubk3-0003D3-NG for pgsql-sql@postgresql.org; Tue, 07 Feb 2012 03:29:16 +0000 Received: by iacb35 with SMTP id b35so9439305iac.19 for ; Mon, 06 Feb 2012 19:29:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=+vrpuBX+7eZhadhBtL39+OwrS4dlxtdjtDRsJg1H8cU=; b=dGF4joMDCdh8VF9xdfsRJT5hJSYgoH48f/mWLEcCQCpjWF3ky8nFvZzDxS5ZjX8FUt zJBz91eU79jjLuVSAhJAh7SLMse26fGp4l6Bfkp0EBfiS+yVWS7KEVtXHwVBoRbsDeLj RKusINsYWnHMVtClqfrsVEy2z6Bem/jP4pWSE= Received: by 10.50.140.105 with SMTP id rf9mr13642490igb.24.1328585341460; Mon, 06 Feb 2012 19:29:01 -0800 (PST) Received: from tucker.localnet (c-24-17-164-54.hsd1.wa.comcast.net. [24.17.164.54]) by mx.google.com with ESMTPS id z22sm30649256ibg.5.2012.02.06.19.28.58 (version=SSLv3 cipher=OTHER); Mon, 06 Feb 2012 19:29:00 -0800 (PST) From: Adrian Klaver To: zoulx1982 Subject: Re: type cast about int to bit Date: Mon, 6 Feb 2012 19:28:55 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.32-38-generic; KDE/4.4.5; i686; ; ) Cc: pgsql-sql@postgresql.org References: <201202061719.12213.adrian.klaver@gmail.com> <18656bf8.13415.13551499b55.Coremail.zoulx1982@163.com> <706e3124.7b69.13555b11cc6.Coremail.zoulx1982@163.com> In-Reply-To: <706e3124.7b69.13555b11cc6.Coremail.zoulx1982@163.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201202061928.56405.adrian.klaver@gmail.com> X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201202/20 X-Sequence-Number: 36313 On Monday, February 06, 2012 6:42:45 pm zoulx1982 wrote: > you mean there is no cast function for int to varchar ? > i see sure it is. > That is why I said my guess:) If you want to see what is actually going on take a look at: http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/varbit.c;h=adb08369ed28ab6b52aa2cd5213bcd5b4d8de7ad;hb=HEAD The ERROR though is coming further up, in the parser , if I am following correctly. This because as you have found out there is no direct cast from integer to varbit. Why that is for someone else to answer, as I don't know. Though a little playing around got this, not pretty but it seems to work: test(5432)aklaver=>SELECT 10::bit(3)::varbit(3); varbit -------- 010 (1 row) test(5432)aklaver=>SELECT 10::bit(3)::varbit(4); varbit -------- 010 (1 row) test(5432)aklaver=>SELECT 10::bit(4)::varbit(4); varbit -------- 1010 (1 row) test(5432)aklaver=>SELECT 10::bit(4)::varbit(3); varbit -------- 101 -- Adrian Klaver adrian.klaver@gmail.com