Re: [HACKERS] [GENERAL] Adding integers ( > 8 bytes) to an inet

2009-09-08 Thread Martin Gainty

Kristian

assuming the max size of 8 byte integer is
http://www.postgresql.org/docs/8.1/static/datatype.html
bigint8 byteslarge-range integer-9223372036854775808 to 9223372036854775807
i dont know if a IPV6 address
 99 99 99 99would 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@postgresql.org

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: krist...@spritelink.net
> To: pgsql-gene...@postgresql.org
> Subject: [GENERAL] 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 LarssonKLL-RIPE
> +46 704 264511  k...@spritelink.net
> 
> -- 
> Sent via pgsql-general mailing list (pgsql-gene...@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

_
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1

Re: [HACKERS] [GENERAL] string_to_array with empty input

2009-04-01 Thread Martin Gainty

Split strings into array elements using provided delimiter



string_to_array('xx~^~yy~^~zz', '~^~') 

output: {xx,yy,zz}


http://www.postgresql.org/docs/8.3/interactive/functions-array.html

?
Martin 
__ 
Disclaimer and confidentiality note 
This message is confidential and may be privileged. If you are not the intended 
recipient, we kindly ask you to  please inform the sender. Any unauthorised 
dissemination or copying hereof is prohibited. This message serves for 
information purposes only and shall not have any legally binding effect. Given 
that e-mails can easily be subject to manipulation, we can not accept any 
liability for the content provided.






> Date: Wed, 1 Apr 2009 15:49:42 -0400
> From: jus...@emproshunts.com
> To: robertmh...@gmail.com
> CC: t...@sss.pgh.pa.us; st...@enterprisedb.com; s...@samason.me.uk; 
> pgsql-gene...@postgresql.org; pgsql-hackers@postgresql.org
> Subject: Re: [HACKERS] [GENERAL] string_to_array with empty input
> 
> If someone can show me a real world example  this logic simplifies the 
> code and has more uses I'll bite
> 
> 
> I just presently can't see how this works better.
> 
> -- 
> Sent via pgsql-general mailing list (pgsql-gene...@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

_
Rediscover Hotmail®: Get e-mail storage that grows with you. 
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage1_042009