Re: [GENERAL] json-patch support?

2016-10-24 Thread Deven Phillips
27, 2015 at 4:16 PM, Deven Phillips <deven.phill...@gmail.com> wrote: > OK, then I will look into perhaps implementing it as a pl-python or > pl-java function. Thanks for the advice!! > > Deven > > On Fri, Mar 27, 2015 at 2:40 PM, Merlin Moncure <mmonc...@gmail.com> &

Re: [GENERAL] DB Corruption after running out of disk space?

2016-10-14 Thread Deven Phillips
NVM, I guess that I just didn't wait long enough for the re-index operation to complete... We're good now... On Fri, Oct 14, 2016 at 6:45 AM, Deven Phillips <deven.phill...@gmail.com> wrote: > Here's hoping someone can help me... Overnight, our primary database > server (part of a

[GENERAL] DB Corruption after running out of disk space?

2016-10-14 Thread Deven Phillips
! Deven Phillips

Re: [GENERAL] jsonb_set for nested new item?

2016-09-23 Thread Deven Phillips
Thanks for the confirmation. Unfortunately, I will need to handle more complex situations. I will look into creating a recursive subroutine to handle things. On Sep 23, 2016 5:12 PM, "Vitaly Burovoy" <vitaly.buro...@gmail.com> wrote: On 9/23/16, Deven Phillips <deven.phill.

Re: [GENERAL] jsonb_set for nested new item?

2016-09-23 Thread Deven Phillips
Actually, it looks like I have to create all of the parent objects first before it would work... Is that correct? Deven On Fri, Sep 23, 2016 at 10:14 AM, Deven Phillips <deven.phill...@gmail.com> wrote: > Is there a way to set a nested element for which the parent paths do not &g

[GENERAL] jsonb_set for nested new item?

2016-09-23 Thread Deven Phillips
Is there a way to set a nested element for which the parent paths do not yet exist? For example, if I have a JSONB value called 'data': { "foo": "bar" } and run jsonb_set(data, {'boo', 'baz'}, 'newvalue') I would expect the output to be: { "foo": "bar", "boo": { "baz":

Re: [GENERAL] Verifying LISTEN subscriptions?

2016-09-17 Thread Deven Phillips
NVM, a quick search through the output of `\dfS` showed me the `pg_listening_channels()` function, which returns a TEXT[] of currently subscribed channels. Cheers, Deven On Sat, Sep 17, 2016 at 8:45 AM, Deven Phillips <deven.phill...@gmail.com> wrote: > From a connection which has p

[GENERAL] Verifying LISTEN subscriptions?

2016-09-17 Thread Deven Phillips
>From a connection which has previously executed a LISTEN statement, is there a query which I can run which will tell me if it is still listening on those channels? Thanks in advance!! Deven Phillips

[GENERAL] How to insert/update a bunch of JSOB values?

2016-07-11 Thread Deven Phillips
I've tried to use a simple case: UPDATE target AS d SET data=jsonb_set(d.data, n.path, is_valid::JSONB, true) > FROM temp_table n > WHERE d.time_inserted=n.time_inserted AND d.data->>'id'=n.id But this results in just the first update for a given PK being applied. Any assistance would be appreciated!!! Deven Phillips

Re: [GENERAL] Appending key-value to JSONB tree

2016-02-18 Thread Deven Phillips
On Wed, Feb 17, 2016 at 10:47 AM, Deven Phillips <deven.phill...@gmail.com> wrote: > I have a "user" document with a key "tokens" and I would like to write a > stored procedure for adding new token key-value pairs to the "tokens" part > of the tree withou

[GENERAL] Appending key-value to JSONB tree

2016-02-17 Thread Deven Phillips
ail=$1 ) SELECT jsonb_pretty(token) FROM newtoken $$ LANGUAGE SQL; Thanks in advance!!! Deven Phillips

[GENERAL] Question on how to use to_timestamp()

2016-02-13 Thread Deven Phillips
I'm trying to convert a series of ISO8601 strings into TIMESTAMPs for use with a function: CREATE OR REPLACE FUNCTION v1_nexus_vlan_count(id TEXT, start_time TIMESTAMP, end_time TIMESTAMP) RETURNS TEXT AS $$ SELECT jsonb_pretty(jsonb_agg(row_to_json(datapoints))) AS data_array FROM ( SELECT

Re: [GENERAL] Question on how to use to_timestamp()

2016-02-13 Thread Deven Phillips
Thanks all! On Feb 13, 2016 11:06 PM, "Tom Lane" <t...@sss.pgh.pa.us> wrote: > Vitaly Burovoy <vitaly.buro...@gmail.com> writes: > > On 2/13/16, Deven Phillips <deven.phill...@gmail.com> wrote: > >> I'm trying to convert a series of ISO8601 strings

Re: [GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
er.com> wrote: > On 01/08/2016 07:04 AM, Deven Phillips wrote: > >> Hi all, >> >> I installed the newly released PostgreSQL 9.5 this morning and >> compiled the latest mysql_fdw extension from EnterpriseDB. I was able to >> create the SERVER and USER MAPPIN

Re: [GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
to query that table from PostgreSQL.. I tried to add the "OPTIONS" to the IMPORT FOREIGN SCHEMA and got an error that "dbname" is not a valid parameter. Thanks, Deven On Fri, Jan 8, 2016 at 11:38 PM, Deven Phillips <deven.phill...@gmail.com> wrote: > Apparent

Re: [GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
Additional details. The MySQL server I am targeting is running version 5.1.73. Perhaps it's too old of a version to support foreign schema import? Deven On Fri, Jan 8, 2016 at 11:45 PM, Deven Phillips <deven.phill...@gmail.com> wrote: > I DID get a foreign table to work using the

Re: [GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
turns 0 tables and 0 columns to be imported. Deven On Fri, Jan 8, 2016 at 11:50 PM, Deven Phillips <deven.phill...@gmail.com> wrote: > Additional details. The MySQL server I am targeting is running > version 5.1.73. Perhaps it's too old of a version to support foreign schema > import

Re: [GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
to!!! Deven On Sat, Jan 9, 2016 at 12:06 AM, Deven Phillips <deven.phill...@gmail.com> wrote: > I think that I may have found the problem. It looks like the mysql_fdw > uses the following query to gather information about the foreign schema: > > SELECT > t.TABLE_NAME, >

[GENERAL] PostgreSQL 9.5, mysql_fdw, and IMPORT FOREIGN SCHEMA question

2016-01-08 Thread Deven Phillips
Hi all, I installed the newly released PostgreSQL 9.5 this morning and compiled the latest mysql_fdw extension from EnterpriseDB. I was able to create the SERVER and USER MAPPING, but I cannot seem to get IMPORT FOREIGN SCHEMA to do anything. The command executes without error, but none of

Re: [GENERAL] INSERT ... ON CONFLICT DO UPDATE

2015-07-20 Thread Deven Phillips
For this purpose, I have seen it recommended to use a UUID instead of a randomly generated integer. I do this myself for production applications and over millions of records I have yet to log a conflict. Also, as stated above, you could create a plpgsql function which would achieve exactly what

Re: [GENERAL] Muti-table join and roll-up aggregate data into nested JSON?

2015-03-31 Thread Deven Phillips
tables into a single array? Thanks again for the help!! Deven On Mon, Mar 30, 2015 at 10:25 PM, Deven Phillips deven.phill...@gmail.com wrote: I have already attempted a similar approach and I could not find a way to pass the outer value of the VM ID to the inner SELECT. For example: SELECT

[GENERAL] Muti-table join and roll-up aggregate data into nested JSON?

2015-03-30 Thread Deven Phillips
I have a multi-table join which will return 1 row per interface and I would like to aggregate the interfaces as a nested section on the resulting JSON output. Could someone help me to figure out how to accomplish that? Example: SELECT row_to_json(row) AS json FROM ( SELECT

Re: [GENERAL] Foreign Data Wrapper for remote view?

2015-03-30 Thread Deven Phillips
Nevermind, it works exactly as I would have expected and it is the exact speed improvement I needed! Deven On Mon, Mar 30, 2015 at 10:12 AM, Deven Phillips deven.phill...@gmail.com wrote: To prevent multiple foreign table scans during queries, I would like to be able to create an FDW against

[GENERAL] Foreign Data Wrapper for remote view?

2015-03-30 Thread Deven Phillips
To prevent multiple foreign table scans during queries, I would like to be able to create an FDW against a VIEW in a foreign MySQL database. Is this possible? Thanks in advance! Deven

[GENERAL] JSON pretty and selecting nested JSON fields

2015-03-30 Thread Deven Phillips
Hi all, I have a query which selects several rows of data, and contained in one of those rows is some aggregated JSON data. I am using row_to_json() to make the whole output JSON and I am providing true for pretty formatting of the JSON. The problem that I am seeing is that they nested JSON

Re: [GENERAL] JSON pretty and selecting nested JSON fields

2015-03-30 Thread Deven Phillips
}, {vlan: null, vmid: 114778, order: 0, ip_address: 10.137.154.212, is_backend: true, is_gateway: false, is_reserved: false, mac_address: 00:50:56:9e:25:3d}]} On Mon, Mar 30, 2015 at 1:54 PM, Deven Phillips deven.phill...@gmail.com wrote: Hi all, I have a query which

Re: [GENERAL] Muti-table join and roll-up aggregate data into nested JSON?

2015-03-30 Thread Deven Phillips
res; END; $$ LANGUAGE PLPGSQL; On Mon, Mar 30, 2015 at 5:22 PM, Deven Phillips deven.phill...@gmail.com wrote: I'm using PostgreSQL 9.4.1 on Ubuntu 14.10. The function does the following: DROP FUNCTION get_vm_with_interfaces(vm_id BIGINT); CREATE OR REPLACE FUNCTION get_virtual_interfaces

Re: [GENERAL] Muti-table join and roll-up aggregate data into nested JSON?

2015-03-30 Thread Deven Phillips
)), true) FROM ( SELECT DISTINCT * FROM virtual_interfaces WHERE vmid=vm_id) i INTO res; RETURN res; END; $$ LANGUAGE PLPGSQL; Thanks for any help! Deven On Mon, Mar 30, 2015 at 3:25 PM, Merlin Moncure mmonc...@gmail.com wrote: On Mon, Mar 30, 2015 at 6:27 AM, Deven

Re: [GENERAL] Muti-table join and roll-up aggregate data into nested JSON?

2015-03-30 Thread Deven Phillips
at 5:46 PM, Merlin Moncure mmonc...@gmail.com wrote: On Mon, Mar 30, 2015 at 4:22 PM, Deven Phillips deven.phill...@gmail.com wrote: I'm using PostgreSQL 9.4.1 on Ubuntu 14.10. The function does the following: DROP FUNCTION get_vm_with_interfaces(vm_id BIGINT); CREATE OR REPLACE

[GENERAL] json-patch support?

2015-03-27 Thread Deven Phillips
Are there any plans or ideas about implement JSON Patch ( http://jsonpatch.com/) support for PostgreSQL? We deal with some relatively large JSON documents for our in-house application and it is often better to just send a json-patch update rather than the full document. It would be very nice if we

Re: [GENERAL] json-patch support?

2015-03-27 Thread Deven Phillips
PM, Deven Phillips deven.phill...@gmail.com wrote: Are there any plans or ideas about implement JSON Patch (http://jsonpatch.com/) support for PostgreSQL? We deal with some relatively large JSON documents for our in-house application and it is often better to just send a json-patch

[GENERAL] Alias field names in foreign data wrapper?

2015-03-27 Thread Deven Phillips
I am trying out some ideas using FDW, and I have added some FDW tables which access a backend MySQL DB... Unfortunately, I am getting some errors because of fields names with reserved words. I was wondering if there is a way to alias a field name when creating the foreign table? Thanks in

Re: [GENERAL] Alias field names in foreign data wrapper?

2015-03-27 Thread Deven Phillips
DEFAULT CHARSET=latin1 On Fri, Mar 27, 2015 at 5:19 PM, Adrian Klaver adrian.kla...@aklaver.com wrote: On 03/27/2015 01:55 PM, Deven Phillips wrote: Better example of the problem... My FDW table schema is: CREATE FOREIGN TABLE liquorstore_backendipaddress ( id bigint NOT NULL

Re: [GENERAL] Alias field names in foreign data wrapper?

2015-03-27 Thread Deven Phillips
to prepare the MySQL query: Unknown column 'backend_network_id' in 'field list' I still cannot figure out what the problem might be so any help would be GREATLY appreciated. Thanks, Deven On Fri, Mar 27, 2015 at 4:15 PM, Deven Phillips deven.phill...@gmail.com wrote: I am trying out some ideas

Re: [GENERAL] Alias field names in foreign data wrapper?

2015-03-27 Thread Deven Phillips
OK, one of the devs on the GitHub page for that FDW helped me realize that I had accidentally mapped the wrong table! Doh! Deven On Fri, Mar 27, 2015 at 5:31 PM, Adrian Klaver adrian.kla...@aklaver.com wrote: On 03/27/2015 02:20 PM, Deven Phillips wrote: Yes. Here's the MySQL schema