Re: Arrays of Records in PL/Perl - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: Arrays of Records in PL/Perl
Date
Msg-id BA84CD41-25A6-46ED-95DD-240BF9F9E35C@kineticode.com
Whole thread Raw
In response to Re: Arrays of Records in PL/Perl  (Alex Hunsaker <badalex@gmail.com>)
List pgsql-hackers
On Jul 12, 2011, at 12:19 PM, Alex Hunsaker wrote:

> All Arrays in 9.0 and lower are strings, regardless of if they are
> comprised of composite types. Its not so much a bug as a limitation.
> Alexey Klyukin fixed this for 9.1 :-)

Oh?
              dump              --------------------------    $VAR1 = {               +              'that' => '5',+
         'this' => '3' +            };              +   (1 row)
 
   Time: 2.016 ms                           dump
----------------------------------------------------   $VAR1 = bless( {                                  +
      'array' => [                     +                                  {                   +
          'that' => '5',    +                                    'this' => '3'     +                                  }
                 +                                ],                    +                     'typeoid' => 16457
      +                   }, 'PostgreSQL::InServer::ARRAY' );+   (1 row)
 

Woo! Thanks!

> [ In 9.1 we could not make them straight perl arrayrefs as we needed
> to keep the string representation for backwards compatibility. What we
> did in 9.1 is overload the arrayref and string operations on blessed
> object so you can treat it as either. ]

Yep, awesome.

Best,

David


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: FOR KEY LOCK foreign keys
Next
From: Robert Haas
Date:
Subject: Re: spinlock contention