Re: [GENERAL] json-patch support?

2016-10-24 Thread Deven Phillips
27, 2015 at 4:16 PM, Deven Phillips 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 > wrote: > >> On Fri, Mar 27, 2015 at 1:36 PM, Ar

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 wrote: > Here's hoping someone can help me... Overnight, our primary database > server (part of a master/slave repl

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

2016-10-14 Thread Deven Phillips
in advance! 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" wrote: On 9/23/16, Deven Phillips wrote: > On Fri, Sep 23, 2016 at 10:14 AM, D

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 wrote: > Is there a way to set a nested element for which the parent paths do not > yet exist? > > For example,

[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": "ne

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 wrote: > From a connection which has previously executed a LIS

[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
l changes from the temp table? 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
lps others!!! Deven On Wed, Feb 17, 2016 at 10:47 AM, Deven Phillips 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 without remov

[GENERAL] Appending key-value to JSONB tree

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

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" wrote: > Vitaly Burovoy writes: > > On 2/13/16, Deven Phillips wrote: > >> I'm trying to convert a series of ISO8601 strings into TIMESTAMPs for > use > >> with a function: ... > > > If you

[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 da

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

2016-01-08 Thread Deven Phillips
upposed to!!! Deven On Sat, Jan 9, 2016 at 12:06 AM, Deven Phillips 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, > c.COLUMN_NAME, > CAS

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

2016-01-08 Thread Deven Phillips
= c.TABLE_NAME WHERE t.TABLE_SCHEMA = '%s' When I poked around inside of MySQL that t.TABLE_CATALOG and c.TABLE_CATALOG values are NULL. Trying to compare NULLs in MySQL using an equals sign (=) results in a "FALSE" and thus the "JOIN" does not provide an actual linkage.

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 wrote: > I DID get a foreign table to work using the following: > > CREATE

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

2016-01-08 Thread Deven Phillips
as subsequently able 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 wrote: > Apparently not, though I hav

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

2016-01-08 Thread Deven Phillips
> 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 MAPPING, but I ca

[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 the

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 you

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

2015-03-31 Thread Deven Phillips
blem I am having is that I cannot put the results of multiple tables into a single array_add() call. How can I aggregate multiple joined tables into a single array? Thanks again for the help!! Deven On Mon, Mar 30, 2015 at 10:25 PM, Deven Phillips wrote: > I have already attempted a simi

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

2015-03-30 Thread Deven Phillips
51 Is there some way to make that value available to the inner select? Thanks in advance! Deven On Mon, Mar 30, 2015 at 5:46 PM, Merlin Moncure wrote: > On Mon, Mar 30, 2015 at 4:22 PM, Deven Phillips > wrote: > > I'm using PostgreSQL 9.4.1 on Ubuntu 14.10. > > &g

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

2015-03-30 Thread Deven Phillips
true)), 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 wrote: > On Mon, Mar 30, 2015 at 6:27 AM, Deven Phillips > w

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 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_virtu

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

2015-03-30 Thread Deven Phillips
quot;template_name":"", "self":"https://mysite.mydomain.tld /v3/customer/3mcc/vdc/1241/vm/421ea391-b292-ca2e-9a3a-6da3037748c8", "type":"cc.v3.vm", "interfaces":[ {"vlan": null, "vmid": 114778, "order&

[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] 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 wrote: > To prevent multiple foreign table scans during queries, I would like to be > able to create an FDW against a VIEW in a f

[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] 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 > c.s

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 wrote: > On 03/27/2015 02:20 PM, Deven Phillips wrote: > >> Yes. Here's the MySQL schema: &

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

2015-03-27 Thread Deven Phillips
72184 DEFAULT CHARSET=latin1 On Fri, Mar 27, 2015 at 5:19 PM, Adrian Klaver 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

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

2015-03-27 Thread Deven Phillips
s; ERROR: failed 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 wrote: > I am trying

Re: [GENERAL] json-patch support?

2015-03-27 Thread Deven Phillips
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 wrote: > On Fri, Mar 27, 2015 at 1:36 PM, Arthur Silva wrote: > > On Fri, Mar 27, 2015 at 1:56 PM, Deven Phillips < &

[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 advanc

[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