X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 574C147635D for ; Fri, 18 Apr 2003 15:11:27 -0400 (EDT) Received: from mighty.grot.org (66-117-150-96.web.lmi.net [66.117.150.96]) by postgresql.org (Postfix) with ESMTP id AA23547634B for ; Fri, 18 Apr 2003 15:11:23 -0400 (EDT) Received: by mighty.grot.org (Postfix, from userid 515) id 0E10D5D26; Fri, 18 Apr 2003 12:11:23 -0700 (PDT) Date: Fri, 18 Apr 2003 12:11:23 -0700 From: Aditya To: pgsql-sql@postgresql.org Subject: converting from bigint to bit to use bitwise operators Message-ID: <20030418191123.GA44801@mighty.grot.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, hits=-3.1 required=5.0 tests=BAYES_20 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/336 X-Sequence-Number: 13037 For historical reasons, I have IPv4 addresses stored as bigint and I would like to convert them to dot-quad (ie. A.B.C.D) in a select. This is how I would normally do it: - remotehost is the IP address as a bigint select ((remotehost::bit varying(32) >> 24) & 11111111) || '.' || ((remotehost::bit varying(32) & 11111100) >> 16) || '.' || ((remotehost::bit varying(32) & 11110000) >> 8) || '.' || ((remotehost::bit varying(32) & 11000000)) as ip, httpquery from weblogs ; however this complains: ERROR: Cannot cast type 'bigint' to 'bit varying' hints? Thanks, Adi