Re: [GENERAL] Populating missing dates in postgresql data

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 3:41 AM, Vincent Veyron vv.li...@wanadoo.fr wrote: On Thu, 26 Mar 2015 00:25:09 + Lavrenz, Steven M slavr...@purdue.edu wrote: I have a second table (TABLE B) with all of the object_ids and channels that are supposed to be reporting in each day. For cases where a

Re: [GENERAL] Building JSON objects

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 12:30 PM, Eli Murray ejmur...@illinimedia.com wrote: Thanks to you all for the replies. Adrian, your solution is working for me without errors but it's not actually inserting anything. I'll keep fiddling with it and see if I can get what I want but I'm confident now

Re: [GENERAL] Building JSON objects

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 11:31 AM, Jan de Visser j...@de-visser.net wrote: On March 27, 2015 01:12:52 PM Eli Murray wrote: ERROR: syntax error at or near json_build_object LINE 1: insert into json(data) json_build_object(SELECT DISTINCT dep... You may want to review the syntax of the

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

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 1:55 PM, Deven Phillips deven.phill...@gmail.com wrote: Better example of the problem... My FDW table schema is: CREATE FOREIGN TABLE liquorstore_backendipaddress ( id bigint NOT NULL, backend_network_id bigint, backend_virtual_interface_id bigint,

Re: [GENERAL] Index corruption

2015-03-24 Thread David G. Johnston
On Tuesday, March 24, 2015, Bankim Bhavsar ban...@nimblestorage.com wrote: Hello postgres experts, We are running a test that periodically abruptly kills postgres process(equivalent to kill -9) and restarts it. After running this test for 24 hrs or so, we see duplicate primary key entries

Re: [GENERAL] Populating missing dates in postgresql data

2015-03-25 Thread David G. Johnston
On Wed, Mar 25, 2015 at 5:25 PM, Lavrenz, Steven M slavr...@purdue.edu wrote: Alright everyone, this is a doozy of a problem. I am new to Postgres so I appreciate patience/understanding. I have a database of hardware objects, each of which has several different “channels”. Once per day, these

Re: [GENERAL] Populating missing dates in postgresql data

2015-03-25 Thread David G. Johnston
On Wed, Mar 25, 2015 at 8:57 PM, Mitu Verma mitu.ve...@ericsson.com wrote: Hi, We have a customer complaining about the time taken by one of the application scripts while deleting older data from the log tables. During the deletion, customer reported that he often sees the below error

Re: [GENERAL] Autovacuum query

2015-03-25 Thread David G. Johnston
On Wed, Mar 25, 2015 at 8:58 PM, Mitu Verma mitu.ve...@ericsson.com wrote: Correcting the subject ​And this is why it is considered good form to do compose new message instead of replying to an existing one. Injecting your new topic into an existing unrelated mail thread is mildly annoying.

Re: [GENERAL] what is parse unnamed?

2015-01-29 Thread David G Johnston
rummandba wrote Hi All, I am facing some slow sqls in my database as follows: 2015-01-29 18:57:19.777 CST [29024][user@user] 10.6.48.226(59246): [1-1] LOG: duration: 3409.729 ms parse unnamed : 2015-01-29 18:57:19.782 CST [29140][user@user] 10.6.48.227(36662): [1-1] LOG: duration:

Re: [GENERAL] HTTP user authentication against PostgreSQL

2015-01-29 Thread David G Johnston
Jeremy Palmer-2 wrote I'm setting up an apache server and was wondering if it is possible to setup HTTP user authentication against PostgreSQL authentication? I see http://www.giuseppetanzilli.it/mod_auth_pgsql2/, but that requires a custom username table. I want to be able to leverage the

Re: [GENERAL] Why doesn't `RAISE EXCEPTION` provide error context?

2015-04-02 Thread David G. Johnston
On Thursday, April 2, 2015, Pavel Stehule pavel.steh...@gmail.com wrote: 2015-04-02 9:13 GMT+02:00 David G. Johnston david.g.johns...@gmail.com javascript:_e(%7B%7D,'cvml','david.g.johns...@gmail.com');: Adding raw content present on Nabble that gets filtered by the mailing list

Re: [GENERAL] Why doesn't `RAISE EXCEPTION` provide error context?

2015-04-02 Thread David G. Johnston
Adding raw content present on Nabble that gets filtered by the mailing list. On Wednesday, April 1, 2015, Taytay tay...@youneedabudget.com wrote: We make heavy use of `GET STACKED DIAGNOSTICS` to determine where errors happened. However, I am trying to use RAISE EXCEPTION to report errors,

Re: [GENERAL] The case of PostgreSQL on NFS Server (II)

2015-04-02 Thread David G. Johnston
On Thu, Apr 2, 2015 at 1:01 PM, Octavi Fors oct...@live.unc.edu wrote: I don't see how to migrate the databases from my desktop directory determined in a) to my NAS. Could someone please provide the steps to accomplish that? ALTER DATABASE name SET TABLESPACE new_tablespace ​You are solely

Re: [GENERAL] The case of PostgreSQL on NFS Server (II)

2015-04-02 Thread David G. Johnston
On Thu, Apr 2, 2015 at 5:09 PM, Octavi Fors oct...@live.unc.edu wrote: Thanks John for your extensive and helpful response. I have a NAS box. But I would worry about responsiveness. What is better, IMO, is an external SATA connected DAS box. DAS is Direct Attached Storage. Many PCs have a

Re: [GENERAL] ERROR: out of memory

2015-04-02 Thread David G. Johnston
On Thursday, April 2, 2015, Melvin Davidson melvin6...@gmail.com wrote: Well right of the bat, if your master shared_buffers = 7GB and 3 slaves shared_buffers = 10GB, that is 37GB total, which means you are guaranteed to exceed the 30GB physical limit on your machine. I don't get why you are

Re: [GENERAL] ERROR: out of memory

2015-04-02 Thread David G. Johnston
On Thu, Apr 2, 2015 at 5:24 PM, Dzmitry Nikitsin dzmitry.nikit...@gmail.com wrote: Hey folks, I have 4 postgresql servers 9.3.6(on master I use 9.3.5) configured with streaming replication - with 1 maser(30GB RAM, processor - Intel Xeon E5-2680 v2) and 3 slaves(61 Intel Xeon E5-2670 v2),

Re: [GENERAL] Using array_agg in pgr_kdisjkstrpath() error

2015-04-10 Thread David G. Johnston
On Thursday, April 9, 2015, Marc-André Goderre magode...@cgq.qc.ca wrote: Hello all, I hope someone will can help me. Then, where's the difference between the result of (select array_agg(end_id::integer)::integer[] as id from n2) AND '{28411,25582}' There isn't...though technically the

Re: [GENERAL] Limiting user from changing its own attributes

2015-04-11 Thread David G. Johnston
On Friday, April 10, 2015, Sameer Kumar sameer.ku...@ashnik.com wrote: On Sat, Apr 11, 2015 at 12:57 AM David G. Johnston david.g.johns...@gmail.com javascript:_e(%7B%7D,'cvml','david.g.johns...@gmail.com'); wrote: On Fri, Apr 10, 2015 at 9:01 AM, Sameer Kumar sameer.ku...@ashnik.com

Re: [GENERAL] bigserial continuity safety

2015-04-13 Thread David G. Johnston
On Mon, Apr 13, 2015 at 3:05 PM, Pawel Veselov pawel.vese...@gmail.com wrote: Hi. If I have a table created as: CREATE TABLE xq_agr ( idBIGSERIAL PRIMARY KEY, node text not null ); and that multiple applications insert into. The applications never

Re: [GENERAL] Help with slow table update

2015-04-13 Thread David G. Johnston
On Mon, Apr 13, 2015 at 5:01 PM, Pawel Veselov pawel.vese...@gmail.com wrote: r_agrio_hourly - good, r_agrio_total - bad. Update on r_agrio_hourly (cost=0.42..970.32 rows=250 width=329) (actual time=2.248..2.248 rows=0 loops=1) - Index Scan using u_r_agrio_hourly on r_agrio_hourly

[GENERAL] With Update From ... vs. Update ... From (With)

2015-04-13 Thread David G. Johnston
Hello! Is there any non-functional difference between these two forms of Update? WITH name AS ( SELECT ) UPDATE tbl SET ... FROM name WHERE tbl.id = name.id and UPDATE tbl SET ... FROM ( WITH qry AS ( SELECT ) SELECT * FROM qry ) AS name WHERE tbl.id = name.id They both better give the same

Re: [GENERAL] bigserial continuity safety

2015-04-13 Thread David G. Johnston
On Mon, Apr 13, 2015 at 7:01 PM, Jim Nasby jim.na...@bluetreble.com wrote: On 4/13/15 7:45 PM, David G. Johnston wrote: On Mon, Apr 13, 2015 at 3:05 PM, Pawel Veselov pawel.vese...@gmail.com mailto:pawel.vese...@gmail.comwrote: Hi. If I have a table created as: CREATE TABLE

Re: [GENERAL] Cast SRF returning record to a table type?

2015-04-20 Thread David G. Johnston
On Mon, Apr 20, 2015 at 7:57 AM, Merlin Moncure mmonc...@gmail.com wrote: On Sat, Apr 18, 2015 at 5:37 PM, Jim Nasby jim.na...@bluetreble.com wrote: On 4/18/15 12:47 AM, David G. Johnston wrote: If you could find a way to pass a value of type some_table into the function - instead

Re: [GENERAL] Cast SRF returning record to a table type?

2015-04-20 Thread David G. Johnston
On Mon, Apr 20, 2015 at 9:40 AM, David G. Johnston david.g.johns...@gmail.com wrote: On Mon, Apr 20, 2015 at 7:57 AM, Merlin Moncure mmonc...@gmail.com wrote: On Sat, Apr 18, 2015 at 5:37 PM, Jim Nasby jim.na...@bluetreble.com wrote: On 4/18/15 12:47 AM, David G. Johnston wrote

Re: [GENERAL] delete is getting hung when there is a huge data in table

2015-05-02 Thread David G. Johnston
On Saturday, May 2, 2015, Mitu Verma mitu.ve...@ericsson.com wrote: still this delete operation is not working and not a single row has been deleted from the table. Because of MVCC other sessions are not able to see partial deletions...and as you aluded to knowing the data itself is not

Re: [GENERAL] Errors using JDBC batchUpdate with plpgsql function

2015-05-03 Thread David G. Johnston
On Sun, May 3, 2015 at 2:33 PM, Nanker Phelge n.phelg...@gmail.com wrote: inner ex 2 =A result was returned when none was expected. ​I don't know what is or is not allowed by JDBC but it is reasonable to assume that you cannot create batches of SELECT statements. The intent of batching is to

Re: [GENERAL] Unexpected function behaviour with NULL and/or default NULL parameters

2015-05-06 Thread David G. Johnston
On Wednesday, May 6, 2015, Gunnar Nick Bluth gunnar.bl...@pro-open.de wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, I'm experiencing odd behaviour with a function I wrote yesterday. Background: function is supposed to deliver some terms and conditions from a table; when the

Re: [GENERAL] Unexpected function behaviour with NULL and/or default NULL parameters

2015-05-06 Thread David G. Johnston
Wednesday, May 6, 2015, Gunnar Nick Bluth gunnar.bl...@pro-open.de wrote: -BEGIN PGP SIGNED MESSAGE- CREATE OR REPLACE FUNCTION public.get_current_tac(userid bigint, sessionid uuid, locale character varying, OUT current_tac json) RETURNS json LANGUAGE sql IMMUTABLE STRICT

Re: [GENERAL] detached query?

2015-05-06 Thread David G. Johnston
On Wed, May 6, 2015 at 3:37 PM, Yves Dorfsman y...@zioup.com wrote: On 9.3, is there any way to start a query, detach from the server and have the query keep going (long query that updates tables, but nothing is returned)? ​No. Sessions require an external client to maintain its

Re: [GENERAL] Limiting user from changing its own attributes

2015-05-04 Thread David G. Johnston
On Mon, May 4, 2015 at 10:23 PM, Sameer Kumar sameer.ku...@ashnik.com wrote: Sorry about the long silence on this. On Mon, Apr 13, 2015 at 3:34 PM David G. Johnston david.g.johns...@gmail.com wrote: On Sun, Apr 12, 2015 at 10:23 PM, Sameer Kumar sameer.ku...@ashnik.com wrote: On Mon

Re: [GENERAL] Grouping By Similarity (using pg_trgm)?

2015-05-14 Thread David G. Johnston
On Thu, May 14, 2015 at 1:09 PM, Cory Tucker cory.tuc...@gmail.com wrote: That produces pretty much the same results as the CROSS JOIN I was using before. Because each my_value in the table are different, if I group on just their value then I will always have the full result set and a bunch

Re: [GENERAL] Grouping By Similarity (using pg_trgm)?

2015-05-14 Thread David G. Johnston
On Thu, May 14, 2015 at 11:58 AM, Cory Tucker cory.tuc...@gmail.com wrote: [pg version 9.3 or 9.4] Suppose I have a simple table: create table data ( my_value TEXT NOT NULL ); CREATE INDEX idx_my_value ON data USING gin(my_value gin_trgm_ops); Now I would like to essentially do

Re: [GENERAL] SELECT INTO and ON COMMIT

2015-05-13 Thread David G. Johnston
On Wed, May 13, 2015 at 4:38 PM, Bruce Momjian br...@momjian.us wrote: On Wed, May 13, 2015 at 05:29:36PM -0600, Yves Dorfsman wrote: Is there any way to add an ON COMMIT clause to a SELECT INTO TEMP TABLE? Well CREATE TABLE has a ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } clause,

Re: [GENERAL] Why is there no object create date is the catalogs?

2015-05-12 Thread David G. Johnston
On Tue, May 12, 2015 at 6:33 PM, Melvin Davidson melvin6...@gmail.com wrote: I thank everyone for their feedback regarding the omission of object creation date from the catalog. I do respect the various reasons for not including it, but I feel it is my duty to draw out this issue a bit

Re: [GENERAL] Dry run through input function for a given built-in data type

2015-05-13 Thread David G. Johnston
On Tue, May 12, 2015 at 11:23 PM, Fabio Ugo Venchiarutti fa...@vuole.me wrote: Is there any cleaner way to, say, only run the validation part of a type input function ​ [...]​ ​This pre-supposes that said type input function has a distinct validation phase as opposed to simply performing its

Re: [GENERAL] Limiting user from changing its own attributes

2015-04-13 Thread David G. Johnston
On Sun, Apr 12, 2015 at 10:23 PM, Sameer Kumar sameer.ku...@ashnik.com wrote: On Mon, Apr 13, 2015 at 1:03 PM Jim Nasby jim.na...@bluetreble.com wrote: No. I suspect the community would support at least a hook for GUC changes, if not a full-on permissions system. A hook would make it

Re: [GENERAL] On using doubles as primary keys

2015-04-17 Thread David G. Johnston
On Fri, Apr 17, 2015 at 8:45 AM, Melvin Davidson melvin6...@gmail.com wrote: ​ On Fri, Apr 17, 2015 at 11:34 AM, Kynn Jones kyn...@gmail.com wrote: One consideration that is complication the choice of primary key is wanting to have the ability to store chunks of the data table (not the

Re: [GENERAL] Cast SRF returning record to a table type?

2015-04-17 Thread David G. Johnston
On Friday, April 17, 2015, Jim Nasby jim.na...@bluetreble.com wrote: On 4/17/15 7:39 PM, David G. Johnston wrote: On Friday, April 17, 2015, Jim Nasby jim.na...@bluetreble.com mailto:jim.na...@bluetreble.com wrote: I'm working on a function that will return a set of test data

Re: [GENERAL] [SQL] function to send email with query results

2015-04-17 Thread David G. Johnston
On Friday, April 17, 2015, Suresh Raja suresh.raja...@gmail.com wrote: Hi all: I'm looking to write a function to send email with result of a query. Is it possible to send email with in a function. Any help is appreciated. Yes...though neither the neither the sql nor the plpgsql languages

Re: [GENERAL] Cast SRF returning record to a table type?

2015-04-17 Thread David G. Johnston
On Friday, April 17, 2015, Jim Nasby jim.na...@bluetreble.com wrote: I'm working on a function that will return a set of test data, for unit testing database stuff. It does a few things, but ultimately returns SETOF record that's essentially: RETURN QUERY EXECUTE 'SELECT * FROM ' ||

Re: [GENERAL] Problems with casting

2015-04-07 Thread David G. Johnston
On Tue, Apr 7, 2015 at 3:09 PM, Jim Nasby jim.na...@bluetreble.com wrote: On 4/7/15 4:35 PM, Tom Lane wrote: Jim Nasby jim.na...@bluetreble.com writes: On 4/7/15 4:17 PM, Tom Lane wrote: I suspect that that's only the tip of the iceberg. Remember the mess we had with implicit casts to

Re: [GENERAL] Overlap function for hstore?

2015-04-03 Thread David G. Johnston
On Fri, Apr 3, 2015 at 5:37 PM, Stefan Keller sfkel...@gmail.com wrote: Hi, I'd like to get an overlap function similar to '' but for key-value pairs of hstore! This underfits: postgres=# select hstore_to_array('a=1,b=2,c=3'::hstore) hstore_to_array('a=2,d=4,b=2'::hstore) ...because

Re: [GENERAL] now() vs 'epoch'::timestamp

2015-04-02 Thread David G. Johnston
On Thu, Apr 2, 2015 at 10:27 AM, James Cloos cl...@jhcloos.com wrote: SC == Steve Crawford scrawf...@pinpointresearch.com writes: SC Very convoluted calculation as others have noted. As to why it is SC off, you are casting one part of the statement to an integer thus SC truncating the

Re: [GENERAL] Consistent state for pg_dump and pg_dumpall

2015-05-20 Thread David G. Johnston
Yes. The entire dump is performed within a single transaction. On Wed, May 20, 2015 at 9:24 AM, Michael Nolan htf...@gmail.com wrote: The documentation for pg_dump says that dump files are created in a consistent state. Is that true across multiple tables in the same pg_dump command?

Re: [GENERAL] pg_start_backup does not actually allow for consistent, file-level backup

2015-06-08 Thread David G. Johnston
On Mon, Jun 8, 2015 at 9:26 AM, otheus uibk otheus.u...@gmail.com wrote: On Mon, Jun 8, 2015 at 3:13 PM, otheus uibk otheus.u...@gmail.com wrote: Thank you, all. The manual for 9.4 is indeed clearer on this point than the 9.1 version. Just to nit-pick, I see nowhere in either version of

Re: [GENERAL] Problem when temp_tablespace get full?

2015-06-03 Thread David G. Johnston
On Wed, Jun 3, 2015 at 11:14 AM, Daniel Begin jfd...@hotmail.com wrote: A query ​OK...​ But ma question is: What append the temp_tablespace drive get full? ​The query, probably... There is also a temp_tablespaces parameter, which determines the placement of temporary tables and indexes,

Re: [GENERAL] user constructed where clause

2015-06-09 Thread David G. Johnston
On Tue, Jun 9, 2015 at 4:48 AM, Yelai, Ramkumar IN BLR STS ramkumar.ye...@siemens.com wrote: Now, the requirement is if user provides filter information based on every column from the web UI, this filter will let the user construct the “where clause” and provide to postgresql. In a month

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thursday, June 18, 2015, Sven Geggus li...@fuchsschwanzdomain.de wrote: Hello, I supose this is simple, but I did not find a solution in the documentation. I would like to be able to do something like this: select myfunc('foo','bar'); or select myfunc(foo, bar) from foobartable; or

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thursday, June 18, 2015, Chris Travers chris.trav...@gmail.com wrote: Select (myfunc('foo','bar')).*; This should be avoided. Use lateral instead,or a cte a/o offset 0. My_func is evaluated twice (once per column) if called this way Or Select * from myfunc('foo','bar'); This is ok

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thu, Jun 18, 2015 at 9:32 AM, Sven Geggus li...@fuchsschwanzdomain.de wrote: David G. Johnston david.g.johns...@gmail.com wrote: Look at the returns table (col1 type, col2 type) form. If I got this right returns table is not what I want as I need to select from my function as a virtual

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thu, Jun 18, 2015 at 9:52 AM, Sven Geggus li...@fuchsschwanzdomain.de wrote: Raymond O'Donnell r...@iol.ie wrote: mydb= select myfunc('foo','bar'); You need to do: select * from myfunc('foo','bar'); This has been a misguided example. Reality should more likely look like this:

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thu, Jun 18, 2015 at 10:31 AM, Sven Geggus li...@fuchsschwanzdomain.de wrote: David G. Johnston david.g.johns...@gmail.com wrote: WITH exec_func AS ( SELECT myfunc(col1,col2) FROM mytable ) SELECT (exec_func.myfunc).* FROM exec_func; This relies on the fact that currently a CTE

Re: [GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread David G. Johnston
On Sat, Jun 20, 2015 at 10:56 AM, Tom Lane t...@sss.pgh.pa.us wrote: David G. Johnston david.g.johns...@gmail.com writes: I know this could be written quite easily in sql but was wondering if it is possible in pl/pgsql. CREATE FUNCTION test_func() RETURNS text LANGUAGE 'plpgsql

[GENERAL] Trying to avoid a simple temporary variable declaration in a pl/pgsql function

2015-06-20 Thread David G. Johnston
I know this could be written quite easily in sql but was wondering if it is possible in pl/pgsql. CREATE FUNCTION test_func() RETURNS text LANGUAGE 'plpgsql' AS $$ BEGIN SELECT 'text_to_return' INTO what_goes_here?; --with or without a cast RETURN what_goes_here?; END; $$; The goal is to return

Re: [GENERAL] Correct place for feature requests

2015-06-25 Thread David G. Johnston
On Thu, Jun 25, 2015 at 3:29 PM, John R Pierce pie...@hogranch.com wrote: On 6/25/2015 11:59 AM, Алексей Бережняк wrote: I think that PostgreSQL is great RDBMS, but one important (for me) feature that it missing is case-insensitive identifier quotes ([table].[column]) like in Microsoft SQL

Re: [GENERAL] INSERT a real number in a column based on other columns OLD INSERTs

2015-06-24 Thread David G. Johnston
On Wed, Jun 24, 2015 at 5:52 PM, Adrian Klaver adrian.kla...@aklaver.com wrote: On 06/23/2015 11:20 PM, litu16 wrote: So, this is what I have made so far... *CREATE OR REPLACE FUNCTION timelog() RETURNS trigger AS $BODY$ DECLARE t_ix real; n int;

Re: [GENERAL] PL/pgSQL: How to return two columns and multiple rows

2015-06-18 Thread David G. Johnston
On Thu, Jun 18, 2015 at 12:00 PM, Sven Geggus li...@fuchsschwanzdomain.de wrote: David G. Johnston david.g.johns...@gmail.com wrote: Assuming you are on 9.3+ what you want to use is LATERAL OK, how is such a query supposed to look like? assuming select myfunc(col1,col2) from mytable works

Re: [GENERAL] Foreign data wrappers and indexes on remote side

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 12:09 PM, Filip Rembiałkowski filip.rembialkow...@gmail.com wrote: Hi. Is there any way to take use of indexes on foreign tables? Currently (at least with tds_fdw, that I was testing) the planner just does a dumb full sequential scan in all cases. That is SELECT

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 11:38 AM, Tim Smith randomdev4+postg...@gmail.com wrote: Adrian, Ok, let's start fresh. app_security.validateSession() calls app_security.cleanSessionTable(). app_security.cleanSessionTable(), when called on its, own, does not cause me any issues. It operates as

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 9:38 AM, Tim Smith randomdev4+postg...@gmail.com wrote: I have a function that validates a web session is still active, so my code looks something like this : BEGIN perform app_security.cleanSessionTable(p_forcedTimeout,p_sessionTimeout); SAVEPOINT

Re: [GENERAL] Functions, savepoints, autocommit = I am confused !

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 10:48 AM, Tim Smith randomdev4+postg...@gmail.com wrote: Hi David, I should have perhaps made clear this was a saved function, so my understanding is ROLLBACK can't be used as its implicit. ​I am pretty certain ROLLBACK cannot be used but the ROLLBACK TO SAVEPOINT

Re: [GENERAL] checking for NULLS in aggregate

2015-06-24 Thread David G. Johnston
On Wed, Jun 24, 2015 at 12:54 PM, Seb splu...@gmail.com wrote: Hello, I've defined a function to calculate standard deviation of angular values: CREATE AGGREGATE public.stddev(angle_vectors) ( SFUNC=array_append, STYPE=angle_vectors[], FINALFUNC=angle_vectors_stddev_yamartino );

Re: [GENERAL] Foreign data wrappers and indexes on remote side

2015-06-26 Thread David G. Johnston
On Fri, Jun 26, 2015 at 3:31 PM, Filip Rembiałkowski filip.rembialkow...@gmail.com wrote: Is WHERE clause push-down implemented in any known fdw? ​ Google: ​​postgresql fdw where clause push down https://wiki.postgresql.org/wiki/SQL/MED#Open_questions ​postgresql_fdw

Re: [GENERAL] How to convert a text variable into a timestamp in postgreSQL?

2015-06-26 Thread David G. Johnston
On Friday, June 26, 2015, litu16 litumelen...@gmail.com wrote: I know how to convert a text to timestamp in postgreSQL using *SELECT to_timestamp('05 Dec 2000', 'DD Mon ')* but how can I convert a text variable (inside a function) to timestamp?? Generally, just try casting it.

Re: [GENERAL] Question about CONSTRAINT TRIGGER

2015-06-26 Thread David G. Johnston
On Friday, June 26, 2015, ZM Yang zmp...@gmail.com wrote: Hi folks, I'm confused about the usage of CONSTRAINT TRIGGER. More specifically, the documentation says that the name of another table referenced by the constraint can be specified in a FROM clause: The (possibly schema-qualified)

Re: [GENERAL] use null or 0 in foreign key column, to mean no value?

2015-06-26 Thread David G. Johnston
On Friday, June 26, 2015, Robert Nikander rob.nikan...@gmail.com wrote: So… is this bad DB design to use null to mean that an item has no color? Should I instead put a special row in `colors`, maybe with id = 0, to represent the “no color” value? Or is there some way to make an index work

Re: [GENERAL] Random order by but first 3

2015-06-11 Thread David G. Johnston
On Thu, Jun 11, 2015 at 12:35 PM, Arup Rakshit arupraks...@rocketmail.com wrote: Hi, Suppose I have a column t1 for a table. Now t1 holds some numerice value for each row. Say R1 to R5 records has values for the column t1 as : t1(2,5,8,10,32) I want the result to be printed as (10, 32, 8,

Re: [GENERAL] support for ltree

2015-06-12 Thread David G. Johnston
On Friday, June 12, 2015, Michael Shapiro mshapir...@gmail.com wrote: Hi Melvin, Thanks for this response. It still leave my question unanswered. I should rephrase it -- will ltree become a native datatype in Postgres (as opposed to remaining an extension). Are there any plans to make ltree

Re: [GENERAL] Suggested (or existing) way to parse currency into numeric?

2015-06-12 Thread David G. Johnston
On Fri, Jun 12, 2015 at 12:57 PM, Adrian Klaver adrian.kla...@aklaver.com wrote: On 06/12/2015 09:46 AM, David G. Johnston wrote: Version 9.3 CREATE TABLE t ( field numeric NULL ); SELECT * FROM json_populate_record(null::t, '{ field: $18,665 }'::json); Error: invalid input syntax for type

Re: [GENERAL] Suggested (or existing) way to parse currency into numeric?

2015-06-12 Thread David G. Johnston
​I wrote that type off as something I would never code into my own schema so basically forgot about its usability in other situations. Though if you do not want to use the money type in a table you could do: test= select '$18,665'::money::numeric; numeric -- 18665.00 (1 row)

[GENERAL] Suggested (or existing) way to parse currency into numeric?

2015-06-12 Thread David G. Johnston
Version 9.3 CREATE TABLE t ( field numeric NULL ); SELECT * FROM json_populate_record(null::t, '{ field: $18,665 }'::json); Error: invalid input syntax for type numeric: $18,665 I can accept the type of field being something like numeric_cleaned which has a custom input function that would strip

Re: [GENERAL] support for ltree

2015-06-12 Thread David G. Johnston
On Friday, June 12, 2015, Michael Shapiro mshapir...@gmail.com wrote: The reason I am asking is that, although ltree seems to have been a contributed module since at least 8.3, how can one know if it will always be part of subsequent versions of Postgres? Whether contrib, core, or an

Re: [GENERAL] Efficient sorting the results of a join, without denormalization

2015-05-30 Thread David G. Johnston
On Saturday, May 30, 2015, Glen M. Witherington g...@fea.st wrote: Sorry about the horrendous subject, let me explain by example: Let's take this schema: ``` CREATE TABLE a ( id bigserial PRIMARY KEY, created_at timestamp with time zone NOT NULL DEFAULT NOW() ); CREATE TABLE b(

[GENERAL] Unusual sorting requirement (mixed enum/non-enum) - need thoughts

2015-07-03 Thread David G. Johnston
CREATE TYPE enum_type AS ENUM ('X-One','A-Two'); SELECT * FROM (VALUES ('Not Enum'::text, 1::int, 'Uno'::text), ('Not Enum', 2, 'Dos'), ('Enum', 4, 'X-One'), ('Enum', 3, 'A-Two')) val (flag, id, val) ; I need to write an ORDER BY clause that will result in the output of: 1, 2, 4, 3 Basically,

Re: [GENERAL] Unusual sorting requirement (mixed enum/non-enum) - need thoughts

2015-07-03 Thread David G. Johnston
On Fri, Jul 3, 2015 at 11:27 AM, David G. Johnston david.g.johns...@gmail.com wrote: CREATE TYPE enum_type AS ENUM ('X-One','A-Two'); SELECT * FROM (VALUES ('Not Enum'::text, 1::int, 'Uno'::text), ('Not Enum', 2, 'Dos'), ('Enum', 4, 'X-One'), ('Enum', 3, 'A-Two')) val (flag, id, val

Re: [GENERAL] record from plpgsql function performance

2015-07-02 Thread David G. Johnston
On Thursday, July 2, 2015, Alexander Shereshevsky shereshev...@gmail.com wrote: Hello, I have some simple function. The returned data set is generated based on view (dynamic - can be changed on daily basis). So the function was defined this way: 1. returns setof some_view as ... 2.

Re: [GENERAL] Average New Users Per DOW

2015-07-06 Thread David G. Johnston
Please follow list conventions and either respond inline or bottom-post. On Mon, Jul 6, 2015 at 3:30 PM, Robert DiFalco robert.difa...@gmail.com wrote: Paul, I'm sure I'm missing something but it seems like your approach will not work. It's because the LEFT OUTER JOIN is on the numeric day of

Re: [GENERAL] Average New Users Per DOW

2015-07-06 Thread David G. Johnston
On Mon, Jul 6, 2015 at 4:40 PM, Robert DiFalco robert.difa...@gmail.com wrote: ​I am fairly certain this does not give you the correct results. Specifically, the minimum value for each cDate is going to be 1 since count(*) counts NULLs. count(u) should probably work. ​ Yes you are right, I

Re: [GENERAL] PgBouncer error - psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket /var/run/postgresql/.s.PGSQL

2015-07-06 Thread David G. Johnston
Cursory observations below... On Mon, Jul 6, 2015 at 11:04 AM, Ali Aktar aktar...@gmail.com wrote: Hi Guys; Can I please get some assistance: I have postgres server running on the localhost: -bash-4.2$ telnet localhost 5432 Trying ::1... Connected to localhost. Escape character is '^]'.

Re: [GENERAL] Average New Users Per DOW

2015-07-06 Thread David G. Johnston
On Mon, Jul 6, 2015 at 2:04 PM, Robert DiFalco robert.difa...@gmail.com wrote: Wouldn't I have to generate a series based on the date range (by day) and then group by DOW _after_ that? ​You are correct.​ WITH userdays (dow, user_count) AS ( existing_query, more or less ) ​, day_counts (dow,

Re: [GENERAL] Average New Users Per DOW

2015-07-06 Thread David G. Johnston
On Mon, Jul 6, 2015 at 6:16 PM, Michael Nolan htf...@gmail.com wrote: But you can see it wont give correct results since (for example) Monday's with no new users will not be counted in the average as 0. One way to handle this is to union your query with one that has a generate_series (0,6)

Re: [GENERAL] PG and undo logging

2015-05-23 Thread David G. Johnston
On Sat, May 23, 2015 at 1:34 PM, Ravi Krishna sravikrish...@gmail.com wrote: Is it true that PG does not log undo information, only redo. If true, then how does it bring a database back to consistent state during crash recovery. Just curious. ​What does undo mean? David J.​

Re: [GENERAL] [NOVICE] Constraint exclusion in partitions

2015-05-23 Thread David G. Johnston
On Saturday, May 23, 2015, Daniel Begin jfd...@hotmail.com wrote: I am working with postgresql 9.3 and I understand from the documentation that constraint_exclusion is set to “partition” by default. Looking at my postgres.conf file, the concerned line is “#constraint_exclusion = partition”.

Re: [GENERAL] PG and undo logging

2015-05-23 Thread David G. Johnston
On Saturday, May 23, 2015, Ravi Krishna sravikrish...@gmail.com wrote: undo means that reading the WAL logs and able to rollback a row back to its original state before the update. Typically it is used to rollback a long running transaction which got aborted due to a crash. Here is an

Re: [GENERAL] About COPY command (and probably file fdw too)

2015-05-21 Thread David G. Johnston
On Thu, May 21, 2015 at 1:33 PM, Nicolas Paris nipari...@gmail.com wrote: Hi, To me this would be great. Why not the ability to restrict lines too COPY stafflist (userid, username, staffid) FROM 'myfile.txt' WITH (FORMAT text, DELIMITER E'\t', COLUMNS (1, 2, 7), LINES(2:1000,2000:3000),

Re: [GENERAL] date with month and year

2015-05-21 Thread David G. Johnston
On Thu, May 21, 2015 at 2:10 PM, Paul Jungwirth p...@illuminatedcomputing.com wrote: Anyway, I agree that you have to store the time zone *somewhere*, and I suppose that's the reason Joshua remarked that you really shouldn't use WITHOUT TIME ZONE. And often a time has one perspective that is

Re: [GENERAL] FW: Constraint exclusion in partitions

2015-05-22 Thread David G. Johnston
On Fri, May 22, 2015 at 10:21 AM, Daniel Begin jfd...@hotmail.com wrote: But how constraint exclusion would react with the following queries … b- Select * from parent_table where id between 2345 and 6789; -- using a range of ids ​Not sure... ​ These are constants but I'm not sure how

Re: [GENERAL] Replicate over pgbouncer?

2015-05-21 Thread David G. Johnston
On Thursday, May 21, 2015, Andomar ando...@aule.net wrote: Hi, Today I installed pgbouncer. I added a second installation as a hot standby. Before starting the standby, I configured recovery.conf to connect to pgbouncer. This results in an error message: Pooler Error: Unsupported

Re: [GENERAL] date with month and year

2015-05-21 Thread David G. Johnston
On Thursday, May 21, 2015, Daniel Torres nobeea...@gmail.com wrote: I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I've made

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-22 Thread David G. Johnston
On Sat, Aug 22, 2015 at 7:33 PM, Melvin Davidson melvin6...@gmail.com wrote: John, I believe you and I think alike. The truth is, I was brought on as a consultant to help this client, so I do not have the authority to fire the developers. Rather, I am trying to help them fix the absolute

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-22 Thread David G. Johnston
On Saturday, August 22, 2015, Melvin Davidson melvin6...@gmail.com wrote: The correct way to escape a quote is to double quote it: 'Mr. M''vey' That is a matter of opinion. However, the real problem is the enclosed backslashes, which is beyond our control at this point. Therefore, the best

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 9:15 AM, Ray Cote rgac...@appropriatesolutions.com wrote: On Sat, Aug 22, 2015 at 11:46 AM, Karsten Hilbert karsten.hilb...@gmx.net wrote: 1. Prefix ALL literals with an Escape EG: SELECT E'This is a \'quoted literal \''; SELECT E'This is an unquoted

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 9:27 AM, Melvin Davidson melvin6...@gmail.com wrote: 9. 1) What happens if someone mis-types the account-id? To correct that, you also need to correct the FK field in the other dozen tables. 2) What happens when your company starts a new project (or buys a

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 10:32 AM, Melvin Davidson melvin6...@gmail.com wrote: What then if it is discovered that the keyed in value was mis-typed? That is why SQL has UPDATE and DELETE statements. If a primary key is incorrect, it can be fixed, be it one method of another. ​Yes, a DBA can

Re: [GENERAL] plpgsql question: select into multiple variables ?

2015-06-29 Thread David G. Johnston
On Mon, Jun 29, 2015 at 4:27 PM, Tom Lane t...@sss.pgh.pa.us wrote: Adrian Klaver adrian.kla...@aklaver.com writes: On 06/29/2015 12:07 PM, Day, David wrote: What is wrong with my usage of the plpgsql select into concept I have a function to look into a calendar table to find the first

Re: [GENERAL] Inconsistent behaviour calling pg_try_advisory_xact_lock with sub-query and when JOIN'ing

2015-08-07 Thread David G. Johnston
On Fri, Aug 7, 2015 at 1:51 PM, Andreas Joseph Krogh andr...@visena.com wrote: På fredag 07. august 2015 kl. 20:55:28, skrev Tom Lane t...@sss.pgh.pa.us : Andreas Joseph Krogh andr...@visena.com writes: The following query returns and locks 1 row as expected (only one row in pg_locks with

Re: [GENERAL] Foreign Keys as first class citizens at design time?

2015-08-13 Thread David G. Johnston
On Thu, Aug 13, 2015 at 7:26 PM, Stephen Feyrer stephen.fey...@btinternet.com wrote: When we design databases, invariably, normally we design the queries at the same time. ​Well this may be true to an extent well implemented models have the ability to answer questions (queries) the original

Re: [GENERAL] Schema Help Needed To Get Unstuck

2015-07-23 Thread David G. Johnston
On Thu, Jul 23, 2015 at 3:06 PM, Rich Shepard rshep...@appl-ecosys.com wrote: While designing the schema for a new application have become high-centered and stuck relating some many-to-many tables. Fresh eyes and suggestions are needed on how to create many-to-many association tables among

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-25 Thread David G. Johnston
On Tue, Aug 25, 2015 at 11:40 AM, Melvin Davidson melvin6...@gmail.com wrote: Consider: SELECT c.registration_no, c.car_make, p.part_no FROM car c JOIN parts p ON ( p.registration_no = c.registration_no) WHERE registration_no = some_var; versus: SELECT

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-25 Thread David G. Johnston
On Tue, Aug 25, 2015 at 12:09 PM, Rob Sargent robjsarg...@gmail.com wrote: On 08/25/2015 09:40 AM, Melvin Davidson wrote: Adrian, Stop being so technical. When we/I speak of natural keys, we are talking about the column that would NATURALly lend itself as the primary key. No one ever said

<    1   2   3   4   5   6   7   8   9   10   >