Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Richard Huxton
nteed. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Concatenating bytea types...

2013-03-01 Thread Richard Huxton
2, 'hex'); END; $$ LANGUAGE plpgsql; SELECT '\x000b'::bytea AS want_this, decode('000b','hex')AS or_this1, decode('\000\013','escape') AS or_this2; SELECT f_concat_bytea1('\x00', '\x0b&#x

Re: [SQL] Can't get upsert working.

2012-12-04 Thread Richard Huxton
ve, which means it's trying to treat them as a single record-column with three fields. Hence the error message. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Insane behaviour in 8.3.3

2012-06-15 Thread Richard Huxton
k the same options as ssh I daresay you could get it working. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Insane behaviour in 8.3.3

2012-06-14 Thread Richard Huxton
-- (0 rows) dynacom=# -- THIS IS INSANE Perhaps just do an EXPLAIN ANALYSE on both of those. If for some reason one is using the index and the other isn't then it could be down to a corrupted index. Seems unlikely though. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing

Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread Richard Huxton
AS id_a, tb.id AS id_b, ta.d, ta.t FROM ta JOIN tb USING (d,t); ROLLBACK; If the fields were named differently you'd need something like: FROM ta JOIN tb ON (ta.d1, ta.t1) = (tb.d2, tb.t2) -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql

Re: [SQL] the use of $$string$$

2011-11-07 Thread Richard Huxton
quote any of your values in your Python code - it's doing it for you. I'm guessing there are other options beside %s for other data-types (integers,floats,boolean etc). -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] the use of $$string$$

2011-11-04 Thread Richard Huxton
caping apart from single quotes. It's especially useful for function bodies which tend to contain their own string literals. SELECT length($$ab\nde$$); length 6 None of this should matter from an application however, since its database access library should do all the

Re: [SQL] CROSS JOIN ordering

2011-05-12 Thread Richard Huxton
ies do not have any guaranteed order unless you add an ORDER BY clause. None of them, no matter how simple. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Problem with serial counters

2011-03-01 Thread Richard Huxton
. Apart from Vibhor's suggestion (which is the typical way PG does it) you can also set the auto field to DEFAULT: INSERT INTO mytable (rowid, other) VALUES (DEFAULT,'a'), (DEFAULT,'b'); This should work on either system. -- Richard Huxton Archonet Ltd -- Sent via pgsq

Re: [SQL] pattern matching with dates?

2011-01-07 Thread Richard Huxton
7;day' FROM d) = 3; That ends up doing a bitmap index scan for me. Of course, it's entirely possible an index on year+month returns too many rows to be useful. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subs

Re: [SQL] Need help on update.

2010-10-21 Thread Richard Huxton
ble1 SET nm = table2.nm FROM table2 WHERE table1.sn = table2.sn; SELECT * FROM table1; ROLLBACK; Be careful with aliasing the target of the update (table1 in this case). As another poster has discovered, that counts as another table in your join. -- Richard Huxton Archonet Ltd -- Sent v

Re: [SQL] Aggregates (last/first) not behaving

2010-07-22 Thread Richard Huxton
Using the real, windowing versions of first/last in 8.4+ will still require sorting the whole table (AFAICT) so isn't likely to be much improvement over a self-join here. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] grouping subsets

2010-07-22 Thread Richard Huxton
with an outer query that compares mycode=prev_code to get a run length. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Aggregates (last/first) not behaving

2010-07-22 Thread Richard Huxton
uot; and "last value I happened to find". If you want the earliest/latest timestamp from each day, use min() and max(). -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Avoiding cycles in a directed graph

2010-03-16 Thread Richard Huxton
trigger? If you don't expect this to be common, maybe you could fix the concurrency issue by taking a table-wide lock that locks out other writers. Surely SELECT FOR UPDATE on the parents would be sufficient? If there's no overlap between (currently non-cyclic) graphs being altered

Re: [SQL] Avoiding cycles in a directed graph

2010-03-16 Thread Richard Huxton
child" isn't in that set. 4. If there is a cycle, raise an error (which will abort the insert or update) If you have a "before" trigger, then step 4 could return NULL rather than raise an error. That would just skip the insert. Also, step #1 could be done with a CHECK const

Re: [SQL] installing uuid generators

2010-03-16 Thread Richard Huxton
es to go through the issues I had building the lib etc.) I'd be surprised if there wasn't a -contrib or -extras rpm with the relevant files. The community rpms should have them if the "official" Suse ones don't -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql ma

Re: [SQL] installing uuid generators

2010-03-16 Thread Richard Huxton
is being executed? It's also worth checking that the pg_config you are executing is the one associated with postgresql-8.4.2 - make sure your PATH is set appropriately. I'm not sure that it would give this error, but I keep making the mistake of setting my PATH with the three version

Re: [SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread Richard Huxton
You will need to create the function with SECURITY DEFINER permissions, as a user who can read from the table. Make sure the application cannot read from the table and has to use the function. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To

Re: [SQL] kind of RULE on SELECT depending on existence of a WHERE condition

2010-03-01 Thread Richard Huxton
return NOTHING. Is there a way to achieve this? Not quite the way you suggest. You could build a series of views with the WHERE conditions built in to them, and grant permissions on those though. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org

Re: [SQL] Unable to get UPDATE ... FROM syntax correct

2010-02-19 Thread Richard Huxton
On 19/02/10 10:58, Gordon Ross wrote: On 19/02/2010 10:36, "Richard Huxton" wrote: Works here - are you sure you don't have any triggers interfering? Doh ! *blush* Yes, I did, to stop anyone tampering with the audit table ;-) There you go - it worked :-) -- Richard Hu

Re: [SQL] sintax error

2010-02-19 Thread Richard Huxton
of PostgreSQL from the last few years supports "dollar quoting". http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS That lets you do: create or replace function ... as $$ ... IF myvar = 'normal-quoting works here' THEN ... $$ language plpgsql; -- Ric

Re: [SQL] Unable to get UPDATE ... FROM syntax correct

2010-02-19 Thread Richard Huxton
(-1,1), (-2,2), (-3,3); UPDATE audit SET key = extension.number FROM extension WHERE audit.record_id = extension.number; SELECT * FROM audit ORDER BY id; ROLLBACK; CREATE TABLE INSERT 0 3 INSERT 0 3 UPDATE 3 id | record_id | key +---+- 1 | 1 | 1 2 | 2 | 2 3 |

Re: [SQL] Referencing external table in update/insert triggers

2010-02-18 Thread Richard Huxton
r, for this case you can just do an update with an extended where clause: UPDATE t2 ... WHERE t2f1=NEW.d1 AND NEW.t1f4 > t2.t2f4 No need for the IF. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscript

Re: [SQL] 'image' table with relationships to different objects

2010-02-09 Thread Richard Huxton
l.loc_name AS linked_name FROM images i2 JOIN location_images li ON i2.img_id = li.img_id JOIN locations l ON li.loc_id = l.loc_id ... You could do something clever with inheritance on the joining tables, but it's better to keep things simple imho. -- Richard Huxton Archonet Ltd -- Sent via pg

Re: [SQL] slow count(CASE) query

2009-10-30 Thread Richard Huxton
to replace our UNIONs. You'll want a unique constraint on length_codes.code and you should really write a custom trigger to make sure none of the min_length..max_length ranges overlap. In practice, you're probably only setting this table up once so might not bother. -- Ri

Re: [SQL] Table Valued Parameters

2009-10-24 Thread Richard Huxton
E plpgsql; SELECT print_array(ARRAY[ '(1,"abc")'::typ1, '(2,"def")'::typ1 ]); SELECT print_array(ARRAY[ '(1,"abc")', '(2,"def")' ]::typ1[]); ROLLBACK; -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Problem with return type of function ??? (corrected)

2009-10-22 Thread Richard Huxton
number'::regclass; > > plpgsql isn't tremendously good with rowtypes that contain dropped > columns. I thought that only applied to columns dropped after the function was defined. Live and learn. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list

Re: [SQL] Problem with return type of function ???

2009-10-22 Thread Richard Huxton
ial_number > > That seems to be some bug in Postgres ? If you look earlier you should see a line that says something like: "set search_path = rma, ..." Makes it irritating to cut+paste sections of the dump, but it works just fine. -- Richard Huxton Archonet Ltd --

Re: [SQL] Problem with return type of function ???

2009-10-22 Thread Richard Huxton
Denis BUCHER wrote: > Richard Huxton a écrit : >> The other thing you could try is printing out row before returning it: >> RAISE NOTICE 'row = %', row; >> RETURN NEXT ROW; >> It might be you've not got what you were expecting. > > Thanks a

Re: [SQL] Problem with return type of function ???

2009-10-22 Thread Richard Huxton
. ROLLBACK we can change things until we see the problem. The other thing you could try is printing out row before returning it: RAISE NOTICE 'row = %', row; RETURN NEXT ROW; It might be you've not got what you were expecting. -- Richard Huxton Archonet Ltd -- Sent via p

Re: [SQL] Problem with return type of function ???

2009-10-22 Thread Richard Huxton
Denis BUCHER wrote: > Richard Huxton a écrit : >>> ERREUR: wrong record type supplied in RETURN NEXT >>> CONTEXTE : PL/pgSQL function "hds_bw_find_sn_live" line 26 at return next >>> >>> Does someone maybe knows what it could be ? >>>

Re: [SQL] Problem with return type of function ???

2009-10-22 Thread Richard Huxton
PLACE FUNCTION rma.find_sn_live (varchar(30)) RETURNS SETOF >> rma.serial_number This is a different function. Function "hds_bw_find_sn_live" has the wrong type for its "return next". -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pg

Re: [SQL] Function Anomaly?

2009-10-08 Thread Richard Huxton
---+---+-- > (0 rows) You've defined getnote() as returning a single getnote_t value I think you probably want "RETURNS SETOF getnote_t". -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Encryption in the tables of a Postgres 7.3.2 database

2009-09-11 Thread Richard Huxton
t splitting where the files are stored. That might involve setting up symlinks, I can't remember if 7.3 supported tablespaces. If you do put some files on the encrypted filesystem and some on the unencrypted one make sure you don't start PG until both are available. I don't kno

Re: [SQL] trigger failed to identify the partions

2009-09-09 Thread Richard Huxton
two rows. > But to work with hibernate I need the return NEW statement. Hmm - not sure I can see a way around this. Maybe someone else who knows Hibernate can help. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make change

Re: [SQL] trigger failed to identify the partions

2009-09-09 Thread Richard Huxton
p_subdtls_01" does not exist I think you missed the word "column" in the error message (easy to do, you know you are naming tables). You've missed the quotes around the partition-names so it's trying to find a column on a table that matches. dateTable := 'coll_fp_su

Re: [SQL] Problems when copy data from dump file

2009-08-06 Thread Richard Huxton
ext \. Why not just load the dump file into PostgreSQL? Why are you trying to copy+paste if you want the entire dump? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Problems when copy data from dump file

2009-08-06 Thread Richard Huxton
ould be if I just can type the table name. There is a variable called "search_path" which controls what schemas are checked for tables, functions etc. If you have two tables with the same name but different schemas you'll need to use the . format though. SET search_path = public

Re: [SQL] Problems when copy data from dump file

2009-08-04 Thread Richard Huxton
27;t know how you do that, but it should be in the manual. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Problems when copy data from dump file

2009-08-04 Thread Richard Huxton
he end of lines when it's expecting "\n". The postgresql version is 7.4.17. Might want to set aside some time to upgrade in the near future - you're missing four full versions since 2003. At the very least, upgrade to 7.4.25 at your earliest convenience. -- Richard

Re: [SQL] Bit by "commands ignored until end of transaction block" again

2009-07-23 Thread Richard Huxton
Glenn Maynard wrote: On Thu, Jul 23, 2009 at 2:41 AM, Richard Huxton wrote: Ah [cue light-bulb effect], I think I understand. Your function isn't in the database is it? Surely your application knows if it's issuing BEGIN..COMMIT? I'm writing a Python library call. It has no i

Re: [SQL] Bit by "commands ignored until end of transaction block" again

2009-07-22 Thread Richard Huxton
Glenn Maynard wrote: On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxton wrote: - Let me use SAVEPOINT outside of a transaction, You are never outside a transaction. All queries are executed within a transaction. "Transaction block", then, if you insist. I think this is the ro

Re: [SQL] Bit by "commands ignored until end of transaction block" again

2009-07-22 Thread Richard Huxton
ter, I'll probably end up dropping out of the ORM and using some uglier SQL to work around this, but this is so trivial that it's silly to have to do that. I can't do it within the ORM; it doesn't have the vocabulary. The ORM can't control transactions, can't call fu

Re: [SQL] De-duplicating rows

2009-07-17 Thread Richard Huxton
earliest duplicates WHERE email=tgt_email AND create_date > tgt_date; -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Moving text columns, when it actually is large

2009-07-09 Thread Richard Huxton
, transplant the pointer rather than actually copy the data? If they are large-objects (stored via the lo_xxx interface) yes. If not, no. I take it the large blob of xml is one of the fields that you are classifying as common? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql

Re: [SQL] 'cost' and 'rows' for volitile function

2009-06-08 Thread Richard Huxton
Rob Sargent wrote: Richard Huxton wrote: If your functions are all called at the top-level then indeed it doesn't matter. At a low level though, telling the planner function F1 costs 1000 times more than F2 is useful. What scares me about this is that for function such as the one

Re: [SQL] 'cost' and 'rows' for volitile function

2009-06-08 Thread Richard Huxton
Rob Sargent wrote: Richard Huxton wrote: Rob Sargent wrote: pg-admin is showing 'COST 100' and 'ROWS 1000' for my explicitly VOLATILE functions. Thanks for the pointer back to CREATE FUNCTION docs. That would have told me that those value are indeed the defaults.

Re: [SQL] Make the planner smarter about idiosyncratic (or broken) ORM behaviour

2009-05-22 Thread Richard Huxton
Frank Joerdens wrote: On Fri, May 22, 2009 at 10:56 AM, Richard Huxton wrote: [...] Are you sure it wouldn't be easier to hire a Python guru for a couple of days and have him/her hack the ORM to make it less, um, "simplistic"? Not sure. :) Your arguments make eminent sense

Re: [SQL] Make the planner smarter about idiosyncratic (or broken) ORM behaviour

2009-05-22 Thread Richard Huxton
Are you sure it wouldn't be easier to hire a Python guru for a couple of days and have him/her hack the ORM to make it less, um, "simplistic"? There must be an "assemble references into JOINs" point in the code you could rationalise this at. -- Richard Huxton Archonet

Re: [SQL] How do I optimize this?

2009-03-18 Thread Richard Huxton
N D.da=2 THEN 1 ELSE 0 END) AS a2, ... FROM D ) AS b WHERE tkey = You might also want to look at the crosstab functions in the tablefunc contrib module (see appendix F of the manuals). -- Richard Huxton Archonet Ltd - Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make c

Re: [SQL] SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-03-17 Thread Richard Huxton
A single User Session can span across many days. SELECT * FROM session WHERE (start_ts,end_ts) OVERLAPS (, ); > I tried using wildcards in timestamp '07/01/2009 11:%:%" but in vain. I tries googling / searching archives without any success either. I'd have thought OVERLAPS

Re: [SQL] JOIN and aggregate problem

2009-02-23 Thread Richard Huxton
Tarlika Elisabeth Schmitz wrote: > On Fri, 20 Feb 2009 19:06:48 + > Richard Huxton wrote: >> try something like: >> >> SELECT t1.d, t1.s, t1.c, count(*) >> FROM t1 >> LEFT JOIN ( >> SELECT d,s,c FROM t2 WHERE x >> ) AS t2_true USING (d,

Re: [SQL] JOIN and aggregate problem

2009-02-20 Thread Richard Huxton
c FROM t2 WHERE x ) AS t2_true USING (d,s,c) GROUP BY t1.d, t1.s, t1.c; Warning - not tested -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] How to find number of seconds between 2 timestamps

2009-02-17 Thread Richard Huxton
ou don't need to do anything: select extract(epoch from ('2009-02-16 22:15:28.034567-06'::timestamp with time zone - '2009-02-15 22:15:28.034567-06'::timestamp with time zone)); date_part --- 86400 (1 row) HTH -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] count(distinct)

2009-02-06 Thread Richard Huxton
index has. Or at least to skip sorting. Afraid not. Have a search of the archives for discussion on "mvcc visibility indexes" for lots on this. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Is there a bug in PostgreSQL ?

2008-12-10 Thread Richard Huxton
e that returns no rows is using a particular index that the other queries aren't. Have you had any crashes / power failures / disk errors recently? Oh - and what version of PostgreSQL is this? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Richard Huxton
trunc to see what it was choosing between) And in the next one it guesses it has an interval (because that's what the other thing is, I'm guessing). => SELECT '2008-12-09 18:00:00' + '2 hours'::interval; ERROR: invalid input syntax for type interval: "2008

Re: [SQL] inconsistent automatic casting between psql and function

2008-12-09 Thread Richard Huxton
t) and then the comparison fails. That seems reasonable to me - you're unlikely to want to discard information from an equality test. The obvious question is - why are you comparing a date to a timestamp in the first place? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
Tom Lane wrote: > Richard Huxton <[EMAIL PROTECTED]> writes: >> Tom Lane wrote: >>> Richard Huxton <[EMAIL PROTECTED]> writes: >>>> Anyone got anything more elegant? >>> Seems to me that no document should have an empty dup_set. If it's no

Re: [SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
Tom Lane wrote: > Richard Huxton <[EMAIL PROTECTED]> writes: >> Anyone got anything more elegant? > > Seems to me that no document should have an empty dup_set. If it's not > a match to any existing document, then immediately assign a new dup_set > number to it.

Re: [SQL] DIVISION with Group By

2008-12-09 Thread Richard Huxton
hat you're trying to do. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] A DISTINCT problem removing duplicates

2008-12-09 Thread Richard Huxton
native is to separate duplicated and non-duplicated documents and UNION them. That's simple enough to see what's happening but does seem ugly. Anyone got anything more elegant? I'm happy to alter the duplicates table so long as it doesn't make it complicated to update. -- Ri

Re: [SQL] Permission denied for create table

2008-11-24 Thread Richard Huxton
possible, then 7.3.21 at least. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] VACUUM cannot be executed from multi-command string

2008-11-19 Thread Richard Huxton
straint, > without loosing the performance ? Not without seeing the bit of the script causing problems. How/why are you executing vacuum from your function / multi-command string. I don't see why you have a multi-command string in a script. -- Richard Huxton Archonet Ltd -- Sent via pg

Re: [SQL] Left Join Question

2008-11-18 Thread Richard Huxton
n multiple cursors (see plpgsql and refcursor in the manuals) and that's a bit fiddly to use. HTH -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] uuid on windows

2008-11-14 Thread Richard Huxton
s > that the file is not found. The uuid-ossp.so file? Is it in the right directory? Is it readable by the postgres user? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] uuid on windows

2008-11-14 Thread Richard Huxton
don't run Windows routinely, so you'll have to check. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns

2008-11-10 Thread Richard Huxton
Mario Splivalo wrote: > Richard Huxton wrote: >> Mario Splivalo wrote: >>> I have this issue: >>> >>> postgres=# select E'\xc5\x53\x94\x96\x83\x29'; >>> ERROR: invalid byte sequence for encoding "UTF8": 0xc553 >> >>

Re: [SQL] Query optimizing

2008-11-10 Thread Richard Huxton
Richard Huxton wrote: > Do you have an index on (id,dt_modified) for manage_followup? Can you > provide an EXPLAIN ANALYSE for this? > Hi Richard, > > Firstly, thank-you very much for your swift reply. To answer your > question, > I had not been using an index on dt_modfied

Re: [SQL] Query optimizing

2008-11-10 Thread Richard Huxton
nough to figure out that it can It's impossible to say which applies to you without knowing the full query. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Query optimizing

2008-11-10 Thread Richard Huxton
ex on (id,dt_modified) for manage_followup? Can you provide an EXPLAIN ANALYSE for this? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] reliable lock inside stored procedure

2008-11-03 Thread Richard Huxton
n says that savepoints can only be established inside > transactions, but does it fail fatal enough so that the procedure getss > aborted? (more fatal than LOCK does?) I'm not sure I understand what you mean here. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] returning count(*) when it is > 1, else -1

2008-10-17 Thread Richard Huxton
0 THEN total ELSE -1 END AS new_total FROM ( SELECT count(*) AS total FROM test WHERE id=$1 ) AS raw_total -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] pg_dump in windows

2008-09-19 Thread Richard Huxton
to store a password in a (secured - make sure this is true!) file. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] May I have an assistance on CREATE TABLE Command

2008-09-17 Thread Richard Huxton
> > If I do this, I will get the error message "You can not change > region_id other tables are reference to it. > > HOW CAN DO THIS? (AUTOMATIC UPDATE OF FOREIGN KEY) When you define your foreign key mark it "ON UPDATE CASCADE" (there is a similar option for ON DE

Re: [SQL] Pls Hlp: SQL Problem

2008-09-12 Thread Richard Huxton
000* > Why the calculation result has so many decimals ? Because you've cast 100 to numeric, rather than numeric(10,2) or whatever. This means you get the full accuracy on the calculation - it won't ever trim a numeric (that's the whole reason to have the type). -- R

Re: [SQL] Function syntax ?

2008-09-09 Thread Richard Huxton
| time with time zone | time with time zone, time with time zone (4 rows) Also available for other built-in types. Been there ages, used by aggregate funcs iirc. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Identifying which column matches a full text search

2008-07-30 Thread Richard Huxton
Ryan Wallace wrote: Richard Huxton wrote: Failing that, where I've had many (a dozen) different sources but want to search them all I've built a textsearch_blocks table with columns to identify the source and have triggers that keep it up to date. Once you've built the tex

Re: [SQL] order function in aggregate

2008-07-30 Thread Richard Huxton
u only want the first/last value of some set. You want all of them. You could accumulate the values in an array and then sort that with the final-func that create aggregate supports. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Identifying which column matches a full text search

2008-07-29 Thread Richard Huxton
that, where I've had many (a dozen) different sources but want to search them all I've built a textsearch_blocks table with columns to identify the source and have triggers that keep it up to date. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsq

Re: [SQL] postgres time zone settings(time difference in Server and client)

2008-07-25 Thread Richard Huxton
--- 25/07/2008 10:21:58.464055 BST SET timezone='EST'; SELECT clock_timestamp(); clock_timestamp ---- 25/07/2008 04:22:19.584367 EST -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to

Re: [SQL] Select default values

2008-07-24 Thread Richard Huxton
Giorgio Valoti wrote: postgres=# insert into f(a,b) values(default, default) returning *; It seems that you can’t use the same syntax with function calls: select function(default,default); gives a syntax error. Is it expected? Um - there is no default value for a function. -- Richard

Re: [SQL] Generating table rows from arrays

2008-07-17 Thread Richard Huxton
sql, I guess, but I wonder if there are better options nowadays. The smallest function I've seen is Merlin Moncure's here: http://people.planetpostgresql.org/merlin/index.php?/archives/4-fun-with-arrays.html -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsq

Re: [SQL] PERSISTANT PREPARE (another point of view)

2008-07-17 Thread Richard Huxton
CREATE FUNCTION users_at_dotcom(text) RETURNS SETOF users AS $$ SELECT * FROM users WHERE email LIKE '%@' || $1 || '.com'; $$ LANGUAGE SQL; SELECT * FROM users_at_dotcom('archonet'); uid | uname | email -+-----+--- 1 | richar

Re: [SQL] Need a sample Postgre SQL script

2008-07-01 Thread Richard Huxton
FROM metadata; Does that do it for you? Try the SELECT clauses by themselves to check if they're doing the right thing. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Need a sample Postgre SQL script

2008-07-01 Thread Richard Huxton
aticfields VALUES (91); INSERT INTO staticfields VALUES (86); INSERT INTO metadata (value, field, mydate) SELECT value, f, mydate FROM metadata, staticfields; -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscrip

Re: [SQL] Quick select, slow update - help with performance problems

2008-07-01 Thread Richard Huxton
eem to take a long time. Do you have any foreign keys referencing used_diary? Do they have the correct indexes on the referencing tables? Any on-update triggers? -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] Weeks elapsed to Months elapsed conversion

2008-05-30 Thread Richard Huxton
w) => SELECT extract(month from justify_days('1 week'::interval)); date_part --- 0 (1 row) If you just have a number (e.g. 14) then you can just do something like: => SELECT round(14 * 7 / 30); round --- 3 (1 row) -- Richard Huxton Archonet Ltd -- Se

Re: [SQL] how to check if a point is contained in a polygon ?

2008-05-07 Thread Richard Huxton
8,25)' <@ polygon '((-3,10),(8,18),(-3,30),(-10,20))'; SELECT polygon '((-3,10),(8,18),(-3,30),(-10,20))' @> point '(-8,25)'; I'm running 8.3, but it seems to be in 8.2 too. Try \do '<@' from psql to see what operators are available. --

Re: [SQL] Database normalization

2008-05-06 Thread Richard Huxton
foo_id/bar_id then you'll want the foreign-key of course. The one thing I would do is change the names of foo_id, bar_id since they're not identifiers by themselves. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make chan

Re: [SQL] psql: no schema info

2008-04-28 Thread Richard Huxton
've forgotten what your search_path is set to then that can cause confusion. Not a problem I see much of since I very rarely change my search_path. I refer to schema.table by preference. -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.

Re: [SQL] Error in restore the Database in Postgres

2008-04-17 Thread Richard Huxton
.org/projects/mysql2pgsql/ http://pgfoundry.org/projects/my2postgres/ -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Desc Commnad in pgsql?

2008-04-17 Thread Richard Huxton
pose: http://rubyforge.org/projects/ruby-pg/ -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] drop table where tableName like 'backup_2007%' ?

2008-03-31 Thread Richard Huxton
TEXT) IS $$Pattern-matching permission revoker. See grant_all(...) for details. $$; CREATE OR REPLACE FUNCTION util.drop_all_roles(pattern name) RETURNS TEXT AS $$ DECLARE rRECORD; sql TEXT; res TEXT; BEGIN res := 'Dropped: '; FOR r IN SELECT

Re: [SQL] Bit string help, please

2008-03-06 Thread Richard Huxton
[EMAIL PROTECTED] wrote: Thanks for the help again, Richard. I will look into upgrading to 8.3 as I think that will be the best solution. I don't think you'll regret it. There are some excellent improvements in 8.3 -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing l

Re: [SQL] Bit string help, please

2008-03-06 Thread Richard Huxton
ng PostgreSQL 8.2.3.1. I don't know if that matters too much. Ah, sorry - that was an 8.3-only cast. I think your only real option will be to build your query as a string and use EXECUTE to get the bit-varying you want in your function. -- Richard Huxton Archonet Ltd -- Sent via pgs

Re: [SQL] RETURN QUERY generates error

2008-03-06 Thread Richard Huxton
;s not happy - if I create an empty table to go with it, it runs here. If you replace them with RETURN QUERY SELECT '' does that make the error go away? Oh, and are you sure you mean IMMUTABLE? That's only true if hg18.genome is a static table. -- Richard Huxton Archonet Ltd

Re: [SQL] Bit string help, please

2008-03-06 Thread Richard Huxton
achieve this? Try casting from a string: SELECT ('1' || repeat('0', n-1))::bit varying; -- Richard Huxton Archonet Ltd -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-sql

  1   2   3   4   5   6   7   8   9   >