[GENERAL] Determining the type (array, object, or scalar) of a JSON value

2013-06-12 Thread Andrew Tipton
Hi all, I recently wanted to declare a CHECK constraint to ensure that a JSON value was an object with keys that were scalars (not nested objects or arrays). This proved to be more difficult than I had expected. In the end, I had to write a json_typeof() function in pl/pgsql. It's a simple funct

[GENERAL] Get data type aliases

2013-06-12 Thread Rebecca Clarke
Hi all. I have a function that has an attribute with datatype of character varying. In the pg_type table the oid of the data type points to type varchar Is there somewhere that identifies the alias for each type? E.g. int4 = integer varchar = character varying. and so on. I can do an if statem

Re: [GENERAL] Determining the type (array, object, or scalar) of a JSON value

2013-06-12 Thread Merlin Moncure
On Wed, Jun 12, 2013 at 9:02 AM, Andrew Tipton wrote: > Hi all, > > I recently wanted to declare a CHECK constraint to ensure that a JSON value > was an object with keys that were scalars (not nested objects or arrays). > This proved to be more difficult than I had expected. In the end, I had to

[GENERAL] Pass-by-reference UDTs and volatility

2013-06-12 Thread Stephen Scheck
Hello, I am working on an extension which defines a number of user-defined functions which will operate on a common, custom data type to perform a pipeline of transformations (the data type is the IN/OUT parameter for all of the functions), eventually being supplied to a sink function which takes

Re: [GENERAL] Get data type aliases

2013-06-12 Thread Alvaro Herrera
Rebecca Clarke escribió: > Hi all. > > I have a function that has an attribute with datatype of character varying. > In the pg_type table the oid of the data type points to type varchar > > Is there somewhere that identifies the alias for each type? Cast the type name to regtype. That outputs t

Re: [GENERAL] Pass-by-reference UDTs and volatility

2013-06-12 Thread Tom Lane
Stephen Scheck writes: > "Never modify the contents of a pass-by-reference input value. If you do so > you are likely to corrupt on-disk data, since the pointer you are given > might point directly into a disk buffer. The sole exception to this rule is > explained in Section 35.10." > If the UDTs

Re: [GENERAL] Pass-by-reference UDTs and volatility

2013-06-12 Thread Stephen Scheck
Hmm, that might work - so allocate the values in a transaction-scoped memory context? But how would the hash table keys themselves be deleted? Is there some callback API to hook transaction completion? On Wed, Jun 12, 2013 at 1:07 PM, Tom Lane wrote: > Stephen Scheck writes: > > "Never modify

Re: [GENERAL] Pass-by-reference UDTs and volatility

2013-06-12 Thread Tom Lane
Stephen Scheck writes: > But how would the hash table keys themselves be deleted? Is there some > callback API to hook transaction completion? See RegisterXactCallback and RegisterSubXactCallback. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@

[GENERAL] Get multiple columns with counts from one table.

2013-06-12 Thread chuydb
Hi, >From two columns in my table I want to get a unified count for the values in these columns. As an example, two columns are: Table: reports | type| place | - | one | home| | two

Re: [GENERAL] Get multiple columns with counts from one table.

2013-06-12 Thread Alban Hertroys
On Jun 13, 2013, at 24:09, chuydb wrote: > Hi, > From two columns in my table I want to get a unified count for the values in > these columns. > As an example, two columns are: > > Table: reports > | type| place | > - > |

Re: [GENERAL] Get multiple columns with counts from one table.

2013-06-12 Thread Sergey Konoplev
On Wed, Jun 12, 2013 at 3:09 PM, chuydb wrote: > Im trying to get something like this: (one column with my types grouped > together and multiple columns with the count vales for each place) > I get: > | type| home| school | work| > cafe|

Re: [GENERAL] Get multiple columns with counts from one table.

2013-06-12 Thread chuydb
Thanks for your quick answer...! Ill try this out to see if I can get it working. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Get-multiple-columns-with-counts-from-one-table-tp5758977p5758981.html Sent from the PostgreSQL - general mailing list archive at Nabble.com

Re: [GENERAL] Explicit LOAD and dynamic library loading

2013-06-12 Thread Tom Lane
Stephen Scheck writes: > However, whenever I run one of the UDTs defined in bar, I get this error > message: > dev=# SELECT * FROM test1 WHERE (info(bar_dat)).some_prop = 10; > ERROR: could not load library > "/vol/data/home/postgres/pg-builds/9.2.4/lib/bar.so": > /vol/data/home/postgres/pg-buil

Re: [GENERAL] Explicit LOAD and dynamic library loading

2013-06-12 Thread Stephen Scheck
Tom, Not sure what you mean by "oid" system: [postgres@dev1 lib]$ uname -a Linux dev1 2.6.35.14-106.fc14.x86_64 #1 SMP Wed Nov 23 13:07:52 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux [postgres@dev1 lib]$ ldd bar.so linux-vdso.so.1 => (0x7fff1c7ff000) libc.so.6 => /lib64/libc.so.