Re: [GENERAL] recasting to timestamp from varchar

2013-01-04 Thread Chris Angelico
On Sat, Jan 5, 2013 at 4:28 AM, Kirk Wythers wrote: > > I am trying to re-cast a column as a timestamp> > > ALTER TABLE sixty_min ALTER COLUMN time2 TYPE timestamp; > ERROR: column "time2" cannot be cast to type timestamp without time zone > > The column time2 is currently a varchar. I actually d

Re: [GENERAL] Linux Distribution Preferences?

2013-01-13 Thread Chris Angelico
On Mon, Jan 14, 2013 at 11:07 AM, Chris Ernst wrote: > I've seen the opinion of "avoid Ubuntu like the plague" expressed many > times, but it is never followed up with any solid reasoning. Can you (or > anyone else) give specific details on exactly why you believe Ubuntu should > be avoided? I s

Re: [GENERAL] INSERT... WHERE

2013-01-13 Thread Chris Angelico
On Mon, Jan 14, 2013 at 3:37 PM, Robert James wrote: > Thanks. But how do I do that where I have many literals? Something like: > > INSERT INTO seltest (id, a, b) SELECT (1,2,3),(4,5,6),(7,8,9) WHERE b > IN (SELECT ...) You can use WITH clauses in crazy ways with PostgreSQL. I haven't actually t

Re: [GENERAL] Linux Distribution Preferences?

2013-01-13 Thread Chris Angelico
On Mon, Jan 14, 2013 at 2:46 PM, Scott Marlowe wrote: > Most importantly, if you've got LOTS of talent for one distro or > another, you're probably best off exploiting it. If 95% of all the > developers and ops crew run Ubuntu or Debian, stick to one of them. > If they favor Fedora / RHEL stick t

Re: [GENERAL] INSERT... WHERE

2013-01-14 Thread Chris Angelico
On Tue, Jan 15, 2013 at 5:26 AM, Robert James wrote: > On 1/13/13, Chris Angelico wrote: >> On Mon, Jan 14, 2013 at 3:37 PM, Robert James >> wrote: >>> Thanks. But how do I do that where I have many literals? Something like: >>> >>> INSERT INTO seltes

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-15 Thread Chris Angelico
On Tue, Jan 15, 2013 at 4:55 AM, Brian Sutherland wrote: > I'm guessing that it's some kind of race condition, but I wouldn't know > where to start looking. Look for a recursive import (A imports B, B imports A) or multiple threads trying to import simultaneously - Python sometimes has issues wit

Re: [GENERAL] noobie question

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 3:47 AM, Steve Clark wrote: > Say I have a table that has 2 columns like > create table "foo" ( > id integer not null, > name text > ); > CREATE UNIQUE INDEX "foo_pkey" on "foo" using btree ( "id" "int4_ops" ); > > with 10 rows of data where id is 1 to 10. > > Now I wan

Re: [GENERAL] noobie question

2013-01-24 Thread Chris Angelico
On Fri, Jan 25, 2013 at 4:45 AM, Steve Clark wrote: > Thanks All, > > This is for a few very small tables, less 100 records each, that a user can > delete and insert records into based on the "id" > which is displayed in a php generated html screen. The tables are rarely > updated and when they ar

Re: [GENERAL] inet/cidr ipv6 operations

2013-01-29 Thread Chris Angelico
On Tue, Jan 29, 2013 at 9:34 PM, George Shuklin wrote: > But IPv6 is differ. Let's assume we wants to get 'next' /64 range. Current > range is inet'2a00:ab00:0:1/64'. We want next. > > Postgres do not allow adding inet + inet, so we need to add natural number. > But 'next' /64 is 'just' 2^64. And

Re: [GENERAL] inet/cidr ipv6 operations

2013-01-29 Thread Chris Angelico
On Wed, Jan 30, 2013 at 2:16 AM, Tom Lane wrote: > Chris Angelico writes: >> Or alternatively, does PostgreSQL have any integer type larger than >> 64-bit bigint? I've become accustomed to using bignums in most of my >> programming; arbitrary-precision integer

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-05 Thread Chris Angelico
On Tue, Feb 5, 2013 at 11:32 PM, Alban Hertroys wrote: > On 5 February 2013 12:41, Andreas Joseph Krogh wrote: >> >> There are lots of things you can do, but when it's the ORM which does it >> you have limited control, and that's the way it should to be (me as >> application-developer having to w

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 12:20 AM, Bèrto ëd Sèra wrote: > Hi Chris, > >> I don't see >> any reason to create a record with a NULL and then replace that NULL >> before committing. Sort out program logic first; then look to the >> database. > > I beg to differ here. Say you have a set of business rule

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-06 Thread Chris Angelico
On Wed, Feb 6, 2013 at 8:01 PM, Jasen Betts wrote: > On 2013-02-06, Bèrto ëd Sèra wrote: >> Hi >> >>> You've hidden nothing from INSERT-RETURNING. >> >> ?? Or from a select, if the final value is what you mean. What we hide >> is the way values are made, clearly not the final value. That bit is >

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-06 Thread Chris Angelico
On Wed, Feb 6, 2013 at 10:36 PM, Bèrto ëd Sèra wrote: > Hi > >> I still don't see how that's any better than a stored procedure that >> directly does the INSERT. You can conceal the code every bit as >> easily. > > Guys I DO NOT write the customers' security guidelines. I get asked to > produce a

[GENERAL] Order of granting with many waiting on one lock

2013-02-10 Thread Chris Angelico
play keepings-off against the other eighteen? Chris Angelico -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Order of granting with many waiting on one lock

2013-02-10 Thread Chris Angelico
On Mon, Feb 11, 2013 at 6:12 PM, Pavan Deolasee wrote: > * Determine where to add myself in the wait queue. > * > * Normally I should go at the end of the queue. Ah! That's perfect. So they'll actually go into perfect strict round-robin, assuming that there are no other locks comin

Re: [GENERAL] Connection limit exceeded for non-superusers when there are plenty of available slots

2013-02-28 Thread Chris Angelico
On Fri, Mar 1, 2013 at 7:38 AM, G B wrote: > SHOW superuser_reserved_connections; > > 480 > > SHOW max_connections; > 500 > > Is there something I'm missing here? Thanks for your help. This leaves just 20 connections for non-root users. Did you intend to set superuser_reserved_connections

Re: [GENERAL] Finding matching words in a word game

2013-03-06 Thread Chris Angelico
ding ~100K words took about 1 second, and the lookup took effectively no time. I don't think there's any need for a heavy database engine here, unless you're working with millions and millions of words :) Chris Angelico -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Problem in "Set search path"

2013-03-21 Thread Chris Angelico
On Thu, Mar 21, 2013 at 11:33 PM, Kalai R wrote: > Hi, > >I am using postgresql 9.0.3. In my application I change often schema > name using set search path. Some times schema name set correctly. But some > time it does not set correctly and it takes the schema previously I set. Is > any pos

Re: [GENERAL] Rewritten rows on unchanged values

2013-03-23 Thread Chris Angelico
On Sat, Mar 23, 2013 at 1:50 AM, Bertrand Janin wrote: > Tom is right, this would be an optimization for a corner case, I noticed this > when running a generated script for a batch update that wasn't given a ton of > attention. The BEFORE UPDATE trigger will work great. If you know the app, just

Re: [GENERAL] Money casting too liberal?

2013-03-28 Thread Chris Angelico
On Fri, Mar 29, 2013 at 10:39 AM, Jasen Betts wrote: > how confusing is 'EST' ? > worse than this: > > set datestyle to 'sql,dmy'; > set time zone 'Australia/Brisbane'; > select '20130101T00Z'::timestamptz; > set time zone 'Australia/Sydney'; > select '20130101T00Z'::timestamptz; > set tim

Re: [GENERAL] procedure to contribute this community

2013-04-07 Thread Chris Angelico
On Mon, Apr 8, 2013 at 4:14 AM, Gavin Flower wrote: > Not to mention that it appears that Postgres runs better on Linux than on > Microsoft. Linux skills are increasingly in demand, while MIcrosoft's > market share is dropping (partly as a result of the Metro fiasco!). > Are you allowed to call

Re: [GENERAL] procedure to contribute this community

2013-04-07 Thread Chris Angelico
On Mon, Apr 8, 2013 at 8:27 AM, Gavin Flower wrote: > On 08/04/13 09:45, Chris Angelico wrote: >> My development >> platform consists of Linux, Xfce, five workspaces... > > On my workstation, I use xfce with 25 virtual workspaces, 8 currently empty, > I've been logged

Re: [GENERAL] What's wrong with postgresql.org domain?

2013-04-18 Thread Chris Angelico
On Thu, Apr 18, 2013 at 6:33 PM, Magnus Hagander wrote: > On Thu, Apr 18, 2013 at 10:31 AM, Eduardo Morras wrote: >> >> >> I get Godaddy's page saying it's free > > Really? > > Whois shows it expires Oct 21 - and surely it will be renewed by then. > and godaddy says it's registered (though no det

Re: [GENERAL] What's wrong with postgresql.org domain?

2013-04-18 Thread Chris Angelico
On Thu, Apr 18, 2013 at 8:32 PM, Eduardo Morrás wrote: > On Thu, 18 Apr 2013 18:40:40 +1000 > Chris Angelico wrote: > >> Works for me. Do a name lookup - what IP address do you get? I get: >> >> postgresql.org. 17973 IN A 217.196.149.50 >&g

Re: [GENERAL] FATAL: database "a/system_data" does not exist

2013-05-10 Thread Chris Angelico
On Fri, May 10, 2013 at 5:13 PM, sumita wrote: > This error is getting logged at an interval of 2 minutes and 10 seconds > 2013-05-10 00:22:50 GMT:[4180]FATAL: database "a/system_data" does not > exist > 2013-05-10 00:25:00 GMT:[4657]FATAL: database "a/system_data" does not > exist > 2013-05-

Re: [GENERAL] Storing Special Characters

2013-05-14 Thread Chris Angelico
On Wed, May 15, 2013 at 8:20 AM, CR Lender wrote: > On 2013-05-14 19:32, Paul Jungwirth wrote: >> The UTF-8 encoding for a pound sign is 0xc2a3, not just 0xa3. You >> might want to make sure your PHP file is correct. > > Just for the record, the Unicode code point for the pound symbol (£) is > act

Re: [GENERAL] Success stories of PostgreSQL implementations in different companies

2013-05-24 Thread Chris Angelico
On Fri, May 24, 2013 at 11:52 PM, wrote: > Thank you all of you for your answers! It helps me a lot because when I'm > trying to convince a client to migrate to PostgreSQL sometimes they think > that because it's free, it only works for small databases for web or desktop > applications with a

Re: [GENERAL] Success stories of PostgreSQL implementations in different companies

2013-05-24 Thread Chris Angelico
On Sat, May 25, 2013 at 12:56 AM, Scott Marlowe wrote: > In addition to the other places mentioned, don't forget that the .info > and .org TLDs run on pgsql. and run quite well too. Oracle tossed a > LOT of FUD when Afilias put in their bid to run the TLD on postgresql. > It was actually quite pat

Re: [GENERAL] Introduction

2013-05-30 Thread Chris Angelico
On Thu, May 30, 2013 at 6:02 AM, Corbett, James wrote: > For those twenty years as a developer I should say that I have been > completely blind, relying upon a screen review application known as JAWS and > a Braille display. > > I’m looking forward to being part of this list. Welcome! One thing I

Re: [GENERAL] Using a CTE for an update

2013-05-31 Thread Chris Angelico
On Sat, Jun 1, 2013 at 7:37 AM, David Salisbury wrote: > > I would think this would be possible. I'm on 9.0.8 > > I have a reference between two tables, and want to populate a field in one > table > with a value that's in the referenced table ( based on the FK reference of > course ). > > with ro

Re: [GENERAL] Migration from DB2 to PostgreSQL

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 11:10 AM, Amit Langote wrote: > If this particular function is to be used repeatedly in a single > query, would the cost of having a wrapper function around the original > function be too large? For example, if this function appears in a > WHERE clause against a table conta

Re: [GENERAL] Migration from DB2 to PostgreSQL

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 11:35 AM, Amit Langote wrote: > On Thu, Jun 20, 2013 at 10:27 AM, Chris Angelico wrote: >> If your wrapper function is written in SQL and is trivial (eg ignore >> the third parameter and pass the other two on), the planner should be >> able to opti

Re: [GENERAL] Migration from DB2 to PostgreSQL

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 12:09 PM, Amit Langote wrote: > Umm, my bad! I almost forgot I could write pure SQL function bodies. > Although, why does following happen? (sorry, a 8.4.2 installation) : > > postgres=# create or replace function gt(n int, m int) returns boolean > as 'select n>m' language

Re: [GENERAL] Migration from DB2 to PostgreSQL

2013-06-19 Thread Chris Angelico
On Thu, Jun 20, 2013 at 12:34 PM, Amit Langote wrote: > On Thu, Jun 20, 2013 at 11:10 AM, Chris Angelico wrote: >> On Thu, Jun 20, 2013 at 12:09 PM, Amit Langote >> wrote: >>> Umm, my bad! I almost forgot I could write pure SQL function bodies. >>> Although,

Re: [GENERAL] coalesce function

2013-06-20 Thread Chris Angelico
On Fri, Jun 21, 2013 at 7:36 AM, David Johnston wrote: > SELECT input > FROM ( SELECT unnest($1) AS input ) src > WHERE input IS NOT NULL AND input <> '' > LIMIT 1; Does this guarantee the order of the results returned? Using LIMIT without ORDER BY is something I'v

[GENERAL] DELETE with LIMIT - workaround?

2013-06-27 Thread Chris Angelico
because it does make good sense to do this in a single pass rather than fetching some kind of unique identifier and then re-locating by that. But is the ctid somehow magical in being actually fast/simple enough to not care about the difference? Chris Angelico -- Sent via pgsql-general mailing list

[GENERAL] IN vs equality (was Re: odd intermittent query hanging issue)

2012-05-19 Thread Chris Angelico
On Sat, May 19, 2012 at 3:09 AM, Steve Crawford wrote: > I also don't understand the "xcrm.channel_id in (1)" instead of > "xcrm.channel_id = 1" unless this is a generated query and there could be > multiple ids in that condition. Side point from this thread. Is there ever any difference between

Re: [GENERAL] Libpq question

2012-05-20 Thread Chris Angelico
ijn mentioned a few, and I mentioned the Pike one, all of which do indeed bypass libpq and talk directly to the server. It is, as I understand it, an open and stable protocol, so it's no different from writing a program that connects to port 25 and talks SMTP rather than dropping to sendmail.

Re: [GENERAL] Libpq question

2012-05-21 Thread Chris Angelico
On Mon, May 21, 2012 at 9:05 PM, John Townsend wrote: > I downloaded PIKE. The "PostgreSQL direct network module for Pike", > pgsql.pike (and the other modules), shows how it was done. > > Many thanks for the tip. I rarely step out of Delphi, so I was unaware of > the power and versatility of Pike

Re: [GENERAL] Postgres process is crashing continously in 9.1.1

2012-05-22 Thread Chris Angelico
On Tue, May 22, 2012 at 4:51 PM, Jayashankar K B wrote: > On writing into this table, a stored procedure is triggered which inserts > into another table. > But crash is happening while writing into this financialtransaction table > once this table has more than 1000 records. What language is th

Re: [GENERAL] Postgres process is crashing continously in 9.1.1

2012-05-22 Thread Chris Angelico
On Tue, May 22, 2012 at 8:23 PM, Jayashankar K B wrote: > But here, the crash is happening right at the insert statement. That is > insert itself is failing. > Unless the insert is successful, stored procedure is not triggered. Hmm. I wonder is it possible that going past ID 999 and into a four-

Re: [GENERAL] Not understanding this behavior of a subselect + volatile function

2012-05-26 Thread Chris Angelico
On Sun, May 27, 2012 at 8:17 AM, Brian Palmer wrote: > There is behavior in the following code that has me confused, and I'd like to > understand it, as it goes against how I thought that MVCC worked in psql: > ... >      select a from t1 into ret where b < 1 for update; >      update t1 set b =

Re: [GENERAL] Not understanding this behavior of a subselect + volatile function

2012-05-26 Thread Chris Angelico
On Sun, May 27, 2012 at 11:36 AM, Brian Palmer wrote: > That's a good link, thanks Chris. I'm not sure it entirely answers what I'm > seeing though. It does explain why the outer select doesn't see the updated > values, but the other thing that I'm seeing is that sometimes the function > will upda

Re: [GENERAL] Interval Division Workaround Suggestions (sub-day intervals only)?

2012-05-29 Thread Chris Angelico
On Wed, May 30, 2012 at 3:50 AM, David Johnston wrote: > Any suggestions on how to obtain the number of “X minute” intervals in “Y” > where “Y” is always less than 24 hours? > > e.g., : ‘05:00:00’::interval / ’00:06:00’::interval => 50 (integer) Turn them into integer seconds: select date_part(

Re: [GENERAL] Change request - log line prefix

2012-05-30 Thread Chris Angelico
On Thu, May 31, 2012 at 2:05 PM, Evan Rempel wrote: > Even when the wrap column is set to a very large value (32k) STATEMENT lines > still wrap according to the line breaks in > the original SQL statement. The problem isn't so much the wrapping, it seems, as that your statements' line breaks are

Re: [GENERAL] Question: How do you manage version control?

2012-06-01 Thread Chris Angelico
On Sat, Jun 2, 2012 at 1:28 AM, Bryan Montgomery wrote: > Hello, > So we've been reviewing our processes and working on improving them. One > area we've been lacking is a procedure to version control our database > functions, table changes, static data etc. > > I'm curious how others do it. Ideall

Re: [GENERAL] SELECT issue with references to different tables

2012-06-02 Thread Chris Angelico
value(refid_persons) over w,first_value(refid_companies) over w FROM pets_reference WINDOW w AS (partition refid_pets order by ownersince desc) I'm sure there's an easier way to do this, but I'm not an expert with window functions. Hope that helps! Chris Angelico --

Re: [GENERAL] New crosslinks in docs

2012-06-09 Thread Chris Angelico
On Sat, Jun 9, 2012 at 6:06 AM, Adrian Klaver wrote: > So when did the links to other versions of the docs get rolled out? > To whomever is responsible, thanks very much. Ooh. Must be pretty recent, I've not seen them before. Seconded - thank you! Web searches often bring up the old versions, gla

Re: [GENERAL] Question about load balance

2012-06-11 Thread Chris Angelico
On Tue, Jun 12, 2012 at 5:17 AM, Condor wrote: > On 2012-06-11 21:03, John R Pierce wrote: >> >> On 06/11/12 2:11 AM, Condor wrote: >>> >>> Yes, I now but these parameters can't be increase forever. It's can but >>> isn't cheep. >>> For that reason I looking some other ways. >> >> why don't you wo

Re: [GENERAL] How to insert record only if primary key does not exist

2012-07-01 Thread Chris Angelico
On Mon, Jul 2, 2012 at 12:19 AM, Craig Ringer wrote: > How to insert record to this table only if primary key does not exist ? > > > You want an operation that's called an UPSERT or MERGE operation. PostgreSQL > doesn't have any native support to do this for you. Doing it right is > surprisingly t

Re: [GENERAL] Where should I start for learn development

2012-07-03 Thread Chris Angelico
On Tue, Jul 3, 2012 at 9:50 PM, AI Rumman wrote: > I have been working with Postgresql for the last 3 years. Before that I > worked with Oracle, Mysql and other databases. > Now, its time to learn the internals of Postgresql system. You'll do far better with some of the essays on the Postgres sit

Re: [GENERAL] Help with sql

2012-07-07 Thread Chris Angelico
On Sat, Jul 7, 2012 at 11:48 PM, Perry Smith wrote: > The database is mostly static. I run through a very lengthy process to > populate the database maybe once a month and then it is 99% read-only. Do you run an ANALYZE on the table after populating it? Postgres needs up-to-date statistics for

Re: [GENERAL] PostgreSQL limitations question

2012-07-13 Thread Chris Angelico
d thus figure out that the airline limits me to X amount of sheet music; but there's no actual limit on sheet music. Does that help? Chris Angelico -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] PostgreSQL limitations question

2012-07-13 Thread Chris Angelico
On Sat, Jul 14, 2012 at 2:40 AM, Mike Christensen wrote: > Wait, are you suggesting Olive Garden doesn't *actually* offer > unlimited breadsticks? I'm not American, and have only been to Olive Garden once (visited your country and tried to cram way way too much into not nearly enough time), so I

[GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-16 Thread Chris Angelico
too). This may be digging too deep into the internals to be dependable for future versions. If so, I'd rather put the extra load on the servers than risk a future upgrade breaking replication subtly. Chris Angelico -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-16 Thread Chris Angelico
On Tue, Jul 17, 2012 at 1:40 AM, Michael Nolan wrote: > I did several weeks of tests on 9.1.3 using mod time and file size > rather than checksumming the files, that did not appear to cause any problems > and it sped up the rsync considerably. (This was about a 40 GB database.) Thanks! Is file s

Re: [GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-16 Thread Chris Angelico
On Tue, Jul 17, 2012 at 1:58 AM, Michael Nolan wrote: > As I understand the docs for rsync, it will use both mod time and file size > if told not to do checksums. Oh, so it does, I misread. Thanks! Time+size it is. ChrisA -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

Re: [GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-16 Thread Chris Angelico
On Tue, Jul 17, 2012 at 4:35 AM, Sergey Konoplev wrote: > On Mon, Jul 16, 2012 at 8:01 PM, Chris Angelico wrote: >> On Tue, Jul 17, 2012 at 1:58 AM, Michael Nolan wrote: >>> As I understand the docs for rsync, it will use both mod time and file size >>> if told not to

Re: [GENERAL] Select Rows With Only One of Two Values

2012-07-20 Thread Chris Angelico
u'll get a list of rows with indicator 0, and then remove from that list any that are also found in the second query. What's left is the rows that have only indicator 0. Chris Angelico -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make change

Re: [GENERAL] Select Rows With Only One of Two Values [RESOLVED]

2012-07-20 Thread Chris Angelico
On Sat, Jul 21, 2012 at 2:21 AM, Rich Shepard wrote: > On Sat, 21 Jul 2012, Chris Angelico wrote: > >> Try this: >> >> SELECT DISTINCT param FROM table WHERE indicator=0 >> EXCEPT >> SELECT DISTINCT param FROM table WHERE indicator=1 > > > Chris, &g

Re: [GENERAL] Select Rows With Only One of Two Values

2012-07-20 Thread Chris Angelico
On Sat, Jul 21, 2012 at 6:52 AM, Alban Hertroys wrote: > I don't think the DISTINCT is necessary there, doesn't EXCEPT already return > a distinct set, just like UNION (hence the existence of UNION ALL)? > > It can also be written as a correlated subquery: Oops, yes. I usually use UNION ALL and

Re: [GENERAL] Pg_ctl promote -- wait for slave to be promoted fully ?

2012-07-20 Thread Chris Angelico
On Sat, Jul 21, 2012 at 5:28 AM, Manoj Govindassamy wrote: > -- Anyway I can query the state of DB to know its status slave or master ?? > So, that i can issue write statements only after I know that the DB is the > new master now Yep. Use pg_is_in_recovery() - it's false on the master, true on s

Re: [GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-26 Thread Chris Angelico
On Fri, Jul 27, 2012 at 9:53 AM, Bruce Momjian wrote: > You might want to look at the hackers list thread I started about the > same topic a week before your post: > > http://archives.postgresql.org/pgsql-hackers/2012-07/msg00416.php > > Basically, you can only use mtime/size if you are re

Re: [GENERAL] Replication/cloning: rsync vs modification dates?

2012-07-26 Thread Chris Angelico
On Fri, Jul 27, 2012 at 9:57 AM, Chris Angelico wrote: > On Fri, Jul 27, 2012 at 9:53 AM, Bruce Momjian wrote: >> You might want to look at the hackers list thread I started about the >> same topic a week before your post: >> >> http://archives.postgresq

Re: [GENERAL] Terminating a rogue connection

2012-07-27 Thread Chris Angelico
On Fri, Jul 27, 2012 at 6:27 PM, Mark Morgan Lloyd wrote: > Assuming a *nix server: if a monitoring program determines that an > established connection appears to be trying to so something inappropriate, > what's the best way of terminating that session rapidly? select pg_terminate_backend(procpi

Re: [GENERAL] Terminating a rogue connection

2012-07-27 Thread Chris Angelico
On Fri, Jul 27, 2012 at 7:09 PM, Mark Morgan Lloyd wrote: > Chris Angelico wrote: >> >> On Fri, Jul 27, 2012 at 6:27 PM, Mark Morgan Lloyd >> wrote: >>> >>> Assuming a *nix server: if a monitoring program determines that an >>> established

Re: [GENERAL] How to don't update sequence on rollback of a transaction

2012-08-02 Thread Chris Angelico
On Fri, Aug 3, 2012 at 1:08 AM, Frank Lanitz wrote: > My understanding of all was that it includes sequences. Obviously, I'm > wrong... but how to do it right? Sequences are fast and lock-free, but don't guarantee absence of gaps. Quite a few things can unexpectedly advance a sequence (including

Re: [GENERAL] strategies for segregating client data when using PostgreSQL in a web app

2012-08-03 Thread Chris Angelico
On Sat, Aug 4, 2012 at 6:05 AM, Menelaos PerdikeasSemantix wrote: > [1] use just one database and schema and logically segregate companies data > by having all tables have a client_id column as part of their primary key. > [2] use multiple database (in the same server instance) and only the public

Re: [GENERAL] Using Insert with case

2012-08-07 Thread Chris Angelico
On Wed, Aug 8, 2012 at 8:26 AM, Bob Pawley wrote: > Hi > > select > case when somevariable = 2 > then (insert into pipe (line) ... > > I am attempting to use the above. However, with or without the enclosing > brackets I get a syntax error on the word into. Utterly untested, but does it work

[GENERAL] Postgres and Upstart

2012-08-10 Thread Chris Angelico
x27;s fully ready? Upstart can recognize this signal (and will promptly SIGCONT it), and use it as an indication of readiness (the "expect stop" stanza). Or maybe it already exists in some other form and I haven't seen it, in which case all I'm asking is: How best can this be

[GENERAL] Understanding autocommit

2012-08-22 Thread Chris Angelico
d implicitly opened as soon as any query is performed, and that transaction remains until committed or rolled back (or until end of session implicit rollback). I'm sure there's something really obvious here, but... how do I find out whether my program's running in autocommit mod

Re: [GENERAL] Can column name aliases be supported?

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 8:19 AM, Gauthier, Dave wrote: > I have a table with a column called "last_name". I have one customer who > likes to articulate queries and updates for this using column name > "last_name" (no problem there) but another who likes to call it "lname" and > yet another who li

Re: [GENERAL] Can column name aliases be supported?

2012-08-22 Thread Chris Angelico
On Thu, Aug 23, 2012 at 2:19 PM, Craig Ringer wrote: > On 08/23/2012 11:56 AM, Chris Angelico wrote: >> >> Here's an out-of-the-box suggestion. >> >> Drop the column altogether and have a single column "name". Trying to >> divide names up never

Re: [GENERAL] run function on server restart

2012-08-24 Thread Chris Angelico
On Sat, Aug 25, 2012 at 8:25 AM, John D. West wrote: > I *think* my independent processes are cleaning up in that they supposedly > abort themselves if they lose db connection, but on restart there is a table > of pid's I'd like to (1) make sure all of the processes are really dead, > killing any

Re: [GENERAL] PQfformat question and retrieving bytea data in C

2012-08-29 Thread Chris Angelico
On Wed, Aug 29, 2012 at 10:30 PM, Jason Armstrong wrote: > I see the following: > 30 5c 33 33 32 5c 30 30 30 5c 30 31 31 5c 30 30 > > But when I look at the same data in the database: > > psql> select encode(substr(data, 0, 16), 'hex') from data_table where > id='xxx'; > encode > ---

Re: [GENERAL] Understanding autocommit

2012-08-29 Thread Chris Angelico
On Wed, Aug 22, 2012 at 6:52 PM, Albe Laurenz wrote: > Chris Angelico wrote: >> I'm looking at these two pages: >> >> http://www.postgresql.org/docs/9.1/static/ecpg-sql-set-autocommit.html >> http://www.postgresql.org/docs/9.1/static/sql-start-transaction.html

Re: [GENERAL] String comparision in PostgreSQL

2012-08-29 Thread Chris Angelico
On Thu, Aug 30, 2012 at 1:56 AM, Nicola Cisternino wrote: > The same query using " LIKE " is completed in 15 ms while > using " ILIKE " the execution time is 453 ms Sounds to me like (pun not intended) there's an index that's being used in one case and not in the other.

Re: [GENERAL] psql & unix env variables

2012-08-30 Thread Chris Angelico
On Thu, Aug 30, 2012 at 4:42 PM, Achilleas Mantzios wrote: > I have found useful the use of variable assignment in psql, e.g. > > #!/bin/sh > > # lets say you have some var with a value, or even populate some var with a > value from > # psql as shown below > somevar=`psql -P pager=off -q -t -c "S

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread Chris Angelico
On Sat, Sep 1, 2012 at 12:07 PM, David Johnston wrote: > These are not equivalent if some values of foo are not-null and you want the > sum of all non-null values while replacing any nulls with zero. So the > decision depends on what and why you are summing. It comes to the same result with SU

[GENERAL] Null-terminated log entries?

2012-09-03 Thread Chris Angelico
is feels clunky. Is there a convenient way to mark log entries for grepping like this? I googled for various things, but "null", "zero", and "log" all have rather a lot of meanings :) Alternatively, this may be a feature request: support %z meaning \0, or perhaps a se

Re: [GENERAL] "Too far out of the mainstream"

2012-09-05 Thread Chris Angelico
On Wed, Sep 5, 2012 at 7:40 PM, Achilleas Mantzios wrote: > (single master, 80+ slaves in 80+ vessels in the 7 seas (80+ = 80 and > growning)) Cool!! How do your nodes communicate with each other? Is it an off-line resynchronization, or do you maintain long-range (satellite?) comms? The system

Re: [GENERAL] Can a view use a schema search_path?

2012-09-17 Thread Chris Angelico
On Mon, Sep 17, 2012 at 7:06 PM, Adam Mackler wrote: > Am I correct in concluding that there's no way to have a single view in the > public schema that selects data from tables in different other schemas > depending on my search_path at the time I execute a query involving that > view? I don't th

Re: [GENERAL] Official C++ API for postgresql?

2012-09-17 Thread Chris Angelico
On Tue, Sep 18, 2012 at 5:56 AM, Adrian Klaver wrote: > I think the confusing part is: > > > "This library works on top of the C-level API library, libpq. It comes with > postgres" > > The it refers to libpq not libpqxx. Sounds to me like a wording change might be in order - perhaps "... libpq, w

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-18 Thread Chris Angelico
On Tue, Sep 18, 2012 at 4:44 PM, Craig Ringer wrote: > On 09/18/2012 07:32 AM, Tom Lane wrote: >> >> It's easier to understand why this is if you realize that SQL has a very >> clear model of a "pipeline" of query execution. > > I just wish they hadn't written it backwards! > > It'd be much less c

Re: [GENERAL] Double types

2012-09-18 Thread Chris Angelico
On Wed, Sep 19, 2012 at 7:25 AM, Hall, Samuel L (Sam) wrote: > > I have an application that writes an Excel Spreadsheet to postgres. For the > values that go in number fields, I check the Excel values for dbnull and set > the parameters to 0, like this: cmd.Parameters(9).Value = 0. Npgsql throws

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 11:15 PM, David Johnston wrote: > I could maybe see something like the following having some value: > > SELECT inverse > FROM data > WHERE x<>0 AND inverse > .5 > MACRO inverse (1/x) > WITH macros AS (SELECT *,1/x AS inverse FROM data) SELECT inverse FROM macros WHERE x<>0

Re: [GENERAL] Using psql -f to load a UTF8 file

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 11:21 AM, Craig Ringer wrote: > I strongly disagree. The BOM provides a useful and standard way to > differentiate UTF-8 encoded text files from the random pile of encodings > that any given file could be. The only reliable way to ascertain the encoding of a hunk of data i

Re: [GENERAL] Using psql -f to load a UTF8 file

2012-09-20 Thread Chris Angelico
On Fri, Sep 21, 2012 at 2:39 PM, John R Pierce wrote: > On 09/20/12 10:27 AM, Alan Millington wrote: >> >> I am using Notepad, which inserts the byte order mark. Following the links >> a bit further, I gather that the version of Notepad that I am using may not >> identify a UTF8 file correctly if

Re: [GENERAL] Question about permissions on database.

2012-09-22 Thread Chris Angelico
On Sun, Sep 23, 2012 at 6:47 AM, Ryan Kelly wrote: > On Sat, Sep 22, 2012 at 11:35:00PM +0300, Condor wrote: >> Hello, >> I wanna ask: is there a short way to giver permission to one user to >> select/insert (all privileges) on whole database ? >> Im create a user and try to give him all permissio

Re: [GENERAL] Thousands of schemas and ANALYZE goes out of memory

2012-10-02 Thread Chris Angelico
On Wed, Oct 3, 2012 at 10:09 AM, Jeff Janes wrote: > On Tue, Oct 2, 2012 at 10:38 AM, Hugo wrote: >>> That might be the problem. I think with 32 bits, you only 2GB of >>> address space available to any given process, and you just allowed >>> shared_buffers to grab all of it. >> >> The address s

Re: [GENERAL] Trajectory of a [Pg] DBA

2012-10-04 Thread Chris Angelico
On Fri, Oct 5, 2012 at 6:44 AM, Thalis Kalfigkopoulos wrote: > Is it an easier and more common entry point to be a part-time DBA e.g. > perform DBA duties as part of being a U**X sysadmin? > > Is it more common to start as a developer and change focus to DBA? > > In particular how does one go abou

Re: [GENERAL] database corruption questions

2012-10-13 Thread Chris Angelico
On Sun, Oct 14, 2012 at 1:13 PM, Craig Ringer wrote: > * Never, ever, ever use cheap SSDs. Use good quality hard drives or (after > proper testing) high end SSDs. Read the SSD reviews periodically posted on > this mailing list if considering using SSDs. Make sure the SSD has a > supercapacitor or

Re: [GENERAL] PostgreSQL training recommendations?

2012-10-17 Thread Chris Angelico
On Thu, Oct 18, 2012 at 12:56 AM, Vincent Veyron wrote: > > I am surprised none of the fine contributors to this thread mentionned > an activity they practice extensively, which is reading this list's > content every day. > > Best training material ever in my opinion. A pay-for magazine you can p

Re: [GENERAL] problem with distinct not distincting...

2012-10-17 Thread Chris Angelico
On Thu, Oct 18, 2012 at 2:32 AM, John Beynon wrote: > I just managed to solve the problem infact. > > The trailing 'e' character on the name was different for one row. All > my tools, (pgadmin and the source data in openoffice) showed the same > 'e' character but psql showed it as different charac

Re: [GENERAL] Improve MMO Game Performance

2012-10-17 Thread Chris Angelico
On Mon, Oct 15, 2012 at 7:16 PM, Albe Laurenz wrote: > - Set fsync=off and hope you don't crash. Ouch. I might consider that for a bulk import operation or something, but not for live usage. There's plenty else can be done without risking data corruption. ChrisA -- Sent via pgsql-general mail

Re: [GENERAL] 9.1/9.2 SERIALIZABLE: expected serialization failure between INSERT and SELECT not encountered

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 3:08 PM, Craig Ringer wrote: > BTW, the issue with the underlying question is that their "name" column is > unique. They expected to get a serialization failure on duplicate insert > into "name", not a unique constraint violation. The question wasn't "why > doesn't this fai

Re: [GENERAL] 9.1/9.2 SERIALIZABLE: expected serialization failure between INSERT and SELECT not encountered

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 11:26 PM, Kevin Grittner wrote: > updating a "last_used" number in a table and > using the result (if it is *is* critical that there are no gaps in > the numbers). Correct me if I'm wrong, but wouldn't: update some_table set last_used=last_used+1 returning last_used simp

Re: [GENERAL] 9.1/9.2 SERIALIZABLE: expected serialization failure between INSERT and SELECT not encountered

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 1:22 AM, Kevin Grittner wrote: > Now, if no records are inserted or deleted by another connection, how > many rows will be deleted by this statement?: > > delete from rc where id = (select min(id) from rc); > > It's a trick question; the answer depends on a race condition.

Re: [GENERAL] obtain the difference between successive rows

2012-10-20 Thread Chris Angelico
On Sun, Oct 21, 2012 at 2:30 AM, Berend Tober wrote: > What about if there is more than one column you want the difference for (... > coincidentally I am writing a article on this topic right now! ...), say a > table which is used to record a metered quantity at not-quite regular > intervals: > ..

  1   2   3   >