Kristian assuming the max size of 8 byte integer is http://www.postgresql.org/docs/8.1/static/datatype.html
i dont know if a IPV6 address 999999 999999 999999 999999 would fit into 9,223,372,036,854,775,807 boundary i think you discovered the bug! if you feel you have a solution try submitting a patch http://wiki.postgresql.org/wiki/Submitting_a_Patch please ping ping pgsql-hackers@xxxxxxxxxxxxxx Good Catch! Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Tue, 8 Sep 2009 15:58:25 +0200 > From: kristian@xxxxxxxxxxxxxx > To: pgsql-general@xxxxxxxxxxxxxx > Subject: Adding integers ( > 8 bytes) to an inet > > Hello! > > I'm having some trouble with the inet data type and its > operators. Right now I'm relying on operations such as > > kll=# SELECT '10.0.0.0/24'::inet + (2^(32-24))::integer; > ?column? > ------------- > 10.0.1.0/24 > (1 row) > > to get the "next" available /24. This works all fine and dandy > for IPv4 since I'll never go beyond what an integer has to offer. > Expanding my application to IPv6 will on the other hand cause me > some trouble since 2^128 won't fit in an integer and not in a > bigint either. I tried numeric; > > kll=> SELECT '2000::/48'::inet + (2^(128-96))::numeric(100); > ERROR: operator does NOT exist: inet + numeric > LINE 1: SELECT '2000::/48'::inet + (2^(128-96))::numeric(100); > ^ > HINT: No operator matches the given name AND argument type(s). You might need TO ADD explicit type casts. > > > And poking in pg_operator / pg_type seems to confirm this: > > nils=# SELECT (SELECT typname FROM pg_type WHERE typelem=oprleft), oprname, (SELECT typname FROM pg_type WHERE typelem=oprright) FROM pg_operator WHERE oprleft=(SELECT typelem FROM pg_type WHERE typname='_inet') AND oprname='+'; > ?column? | oprname | ?column? > ----------+---------+---------- > _inet | + | _int8 > (1 row) > > I could hack together some kluge to loop through, but it all > becomes quite ugly after a while and I would rather see some way > to add a numeric. > > Am I doing it the wrong way? Bug? > What to do? > > Kind regards, > Kristian. > > -- > Kristian Larsson KLL-RIPE > +46 704 264511 kll@xxxxxxxxxxxxxx > > -- > Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general Get back to school stuff for them and cashback for you. Try Bing now. |