Re: [SQL] [HACKERS] [GENERAL] Bug with sequence

2002-11-21 Thread Rod Taylor
On Thu, 2002-11-21 at 15:09, scott.marlowe wrote: > On 21 Nov 2002, Rod Taylor wrote: > > > On Thu, 2002-11-21 at 14:11, Bruce Momjian wrote: > > > Of course, those would be SQL purists who _don't_ understand > > > concurrency issues. ;-) > > > >

Re: [SQL] [HACKERS] [GENERAL] Bug with sequence

2002-11-26 Thread Rod Taylor
On Thu, 2002-11-21 at 14:11, Bruce Momjian wrote: > Of course, those would be SQL purists who _don't_ understand > concurrency issues. ;-) Or they're the kind that locks the entire table for any given insert. -- Rod Taylor <[EMAIL PROTECTED]> --

Re: [SQL] [PERFORM] 7.3.1 index use / performance

2003-01-07 Thread Rod Taylor
nts shown by Tom. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] [HACKERS] Please include hier-patch in next PostgreSQL version

2003-01-29 Thread Rod Taylor
have to handle such kind of hierarchical > data. Yes, very useful -- but use the SQL 99 syntax for recursive queries and not the wonky Oracle version. It's more flexible. Looking forward to the patch ;) -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc sign

Re: [SQL] Denormalizing during select

2003-03-01 Thread Rod Taylor
to do it with an aggregate -- but the best I've been able to come up with is a Set Returning Function. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Denormalizing during select

2003-03-01 Thread Rod Taylor
to do it with an aggregate -- but the best I've been able to come up with is a Set Returning Function. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Atomicity of UPDATE, interchanging values in unique column

2003-03-08 Thread Rod Taylor
anyway? The first is what you want. PostgreSQL needs some work in the evaluation of unique indexes to properly support it. Namely, when it sees a conflict when inserting into the index, it needs to record the fact, and revisit the conflict at the end of the command. Lots of work... -- Ro

Re: [SQL] Atomicity of UPDATE, interchanging values in unique

2003-03-08 Thread Rod Taylor
lete both, and insert values back in again is another :) -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Cursors and backwards scans and SCROLL

2003-03-09 Thread Rod Taylor
ppear after that. Enforcing spec seems like the least confusing mode to operate under, especially given it could break simply by changing the plan -- which happens automagically (seemingly random). -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc

Re: [SQL] Sorting by NULL values

2003-03-05 Thread Rod Taylor
ay to replace the NULLs with > > empty strings? > > Coalesce should work. > > > > > ---(end of broadcast)--- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere&q

Re: [SQL] [PHP] faster output from php and postgres

2003-05-27 Thread Rod Taylor
the order of authors in the > field. If order is required: SELECT custom_aggregate(author) as authors FROM (SELECT author FROM table ORDER BY author) AS tab; The above should give you authors in alphabetical order if custom_aggregate() was written to concatenate text. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Upgrade 7.2.3 -> 7.3 or more

2003-06-01 Thread Rod Taylor
cs/view.php?version=7.3&idoc=1&file=sql-prepare.html -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] generic return for functions

2003-06-01 Thread Rod Taylor
, integer); <- Third argument would be '32'? When PostgreSQL gets named parameters the above probably makes sense to add. A TODO item? -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] (long) What's the problem?

2003-06-08 Thread Rod Taylor
> rposition() is a volatile custom C function. Does the query function as expected when not being EXPLAINed ? Odds are it's a bug in the custom C function. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally

Re: [SQL] Domains and Joins

2003-06-08 Thread Rod Taylor
atched datatypes, which is partially true. It's also a problem in 7.4. I'll see what I can do to fix it. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Column limits in table/ views

2003-06-09 Thread Rod Taylor
should be able to return more columns than that. Both views and tables create a ROW TYPE to represent it, which is where the limitation is. Thus, I would not expect you to be able to create a view. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc D

Re: [SQL] Coalesce/Join/Entries may not exist.

2003-06-10 Thread Rod Taylor
his one? Multiple left outer joins? FROM LEFT OUTER JOIN USING () LEFT OUTER JOIN USING () WHERE ... In your case, SELECT (o.max - coalesce(sum(lr.total), 0)) FROM orders LEFT OUTER JOIN lists ON (orders.id = lists.order_id) LEFT OUTER JOIN list_results ON (lists.id = list_results.l_id) G

Re: [SQL] how to determine array size

2003-06-10 Thread Rod Taylor
d is used by pg_dump. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] how to determine array size

2003-06-10 Thread Rod Taylor
e been added in 7.4. In fact, it's the only way to fetch an accurate CHECK constraint in 7.4. Miscellaneous functions are documented at: http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=functions-misc.html -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://ww

Re: [SQL] comparing querys

2003-06-18 Thread Rod Taylor
Take a look at EXPLAIN and EXPLAIN ANALYSE: http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=sql-explain.html On Wed, 2003-06-18 at 16:23, Lucas Lain wrote: > how can i compare two querys' eficiency??? > > TIA, -- Rod Taylor <[EMAIL PROTECTED]>

Re: [SQL] convert_numeric_to_scalar: unsupported type 354210

2003-06-23 Thread Rod Taylor
#x27;s worth. This has been fixed for 7.4 (the system implicitly coerces the domain to numeric for the index comparison). -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Temporary table performance?

2003-06-26 Thread Rod Taylor
er off just sucking this data into an in-memory data structure, > or can I use a temp table as an easy-to-use alternative? You are probably better off using a cursor. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Change the behaviour of the SERIAL "Type"

2003-06-27 Thread Rod Taylor
o see how close their implementation matches spec -- whether it will make us compatible with them or not. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] ERROR: ExecEvalExpr: unknown expression type 108

2003-06-30 Thread Rod Taylor
:00:00 | 2000-01-01 11:00:00 3 | 2000-01-01 14:00:00 | 2000-01-01 12:00:00 4 | 2000-01-01 15:00:00 | 2000-01-01 14:00:00 5 | 2000-01-01 16:00:00 | 2000-01-01 15:00:00 (5 rows) rbt=# select version(); version -

Re: [SQL] cleaning up useless pl/pgsql functions

2003-06-30 Thread Rod Taylor
e some of them > from my scripts again. DROP PROCEDURAL LANGUAGE plpgsql CASCADE; CREATE PROCEDURAL LANGUAGE plpgsql ... -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] Need help creating a BEFORE DELETE trigger

2003-06-30 Thread Rod Taylor
;t exist anymore. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] CREATE SEQUENCE fails in plpgsql function

2003-07-01 Thread Rod Taylor
uence has quite a bit more. Another alternative is to use setval() on the sequence BUT first pull a FOR UPDATE lock on some blocking row (for concurrency reasons). SELECT * FROM pg_class WHERE relname = 'sequence name' FOR UPDATE; SELECT setval(); This would work equally well with ALT

Re: [SQL] SEQUENCE and PRIMARY KEY

2003-07-02 Thread Rod Taylor
to go about this. The alternative is to teach the bad clients to use DEFAULT rather than NULL when they expect the GENERATOR to create the value for them. -- Rod Taylor <[EMAIL PROTECTED]> PGP Key: http://www.rbt.ca/rbtpub.asc signature.asc Description: This is a digitally signed message part

Re: [SQL] SEQUENCE and PRIMARY KEY

2003-07-03 Thread Rod Taylor
> >A trigger (maybe a rule) is the way to go about this. > > > >The alternative is to teach the bad clients to use DEFAULT rather than > >NULL when they expect the GENERATOR to create the value for them. > > > Hmm, Rod, there really seems a demand for the GENERATOR feature :-) > Do you see any perf

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread Rod Taylor
> Could be a solution?! > The question is - how long could the IN be? I'm not sure about IN specifically, but I know you can do: SELECT * FROM table WHERE col = '<1GB long file>'; It tends not to be friendly for Ram though :) signature.asc Description: This is a digitally signed message part

Re: [SQL] max length of sql select statement ?

2003-07-09 Thread Rod Taylor
> Maybe we can disuss that problem here again?! What exactly means > "max_expr_depth"? Thanks for any help If I'm not mistaken, max_expr_depth is used to catch runaway recursion (view a is select * from b, view b is select * from a). It's a tunable in postgresql.conf. Toss a couple of 0's behind

Re: [SQL] max length of sql select statement ?

2003-07-09 Thread Rod Taylor
On Wed, 2003-07-09 at 15:51, markus brosch wrote: > On Wed, 2003-07-09 at 17:45, Rod Taylor wrote: > > > Nobody a better idea? Why is the join of a temporary table (the IN > > > paramters) and the original table so slow? Any tricks here? > > > > Did you inde

Re: [SQL] Table Partitioning and Rules

2003-07-17 Thread Rod Taylor
On Thu, 2003-07-17 at 19:03, Josh Berkus wrote: > Girish, > > > > Essentially Im trying to store a persons information in a table in the > > > database. Since we could have millions of people, with duplicates! Ive > > > decided we need to partition the table into segments where all people with > >

Re: [SQL] Why their is a limit in Postgresql (psql) Parameters..?

2003-07-21 Thread Rod Taylor
> The reason why it's not bigger is that there hasn't been enough people saying > "I need more parameters". That and a general speed penalty to all users of all functions. Make (whatever) the limitation is affect only those using a large number of parameters and you will find the limit set to a

Re: [SQL] silly NULL question

2003-07-24 Thread Rod Taylor
> Would return the row. Now with an upgrade to PostgreSQL 7.3 (yes, I know > there are many changes and we're working through them right now) the same > query returns nothing. Dropping the "AND parent_id = NULL" returns the row > as expected. NULL is similar to UNKNOWN. So, NULL = NULL is the s

Re: [SQL] function returning setof performance question

2003-07-29 Thread Rod Taylor
> The performance hit is tiny, we're talking less than 1/2 a second, > but when I've done this sort of thing in Oracle I've seen a performance > increase, not a decrease. Thats just plain strange (never tried on Oracle). Why in the world would adding the overhead of a function call (with no ot

Re: [SQL] ALTER TABLE ... DROP CONSTRAINT

2003-07-30 Thread Rod Taylor
I think you can do some constraints in 7.2, but 7.3 will allow dropping them all in that fashion. On Wed, 2003-07-30 at 11:52, Elielson Fontanezi wrote: > Hi all! > > Who can tell me what postgres version supports ALTER TABLE... DROP > CONSTRAINT without > the need of droping the table to re

Re: [SQL] Does a the block of code within a stored procedure constitute

2003-07-31 Thread Rod Taylor
> What I need to know is whether or not this is multi-user safe, i.e., will > the block of code in the procedure execute as a transaction so that if > more than one clerk creates an expense report for the same employee > simultaneously is it possible or impossible that value of the > employee.expen

Re: [SQL] join optimization problem

2003-07-31 Thread Rod Taylor
How about this? It should spit out the same number, but be quite a bit quicker at it. Untested of course... select t.thread_id, t.forum_id, t.thread_title, t.thread_owner, t.thread_owner_id, t.date_created,

Re: [SQL] select query that would join two databases

2003-07-31 Thread Rod Taylor
Take a look at the dblink() contrib module. PostgreSQL does not currently support inter-database joins BUT it does offer Schemas which is often enough. Take each of your source databases and toss them into two different schemas of the same database. On Wed, 2003-07-30 at 07:28, Keith H.K. Lam (U

Re: [SQL] What day is it - when it isn't NOW()?

2003-08-01 Thread Rod Taylor
'2003-08-04' is ambiguous. It could be a text string, a date, something else. So cast it. SELECT to_char('2003-08-04'::date, 'Day'); > SELECT to_char(now(), 'Day'); returns Friday as I'd hoped. > But how do I return the day of the week for a specific date other > than now()? I'm looking for s

Re: [SQL] join optimization problem

2003-08-03 Thread Rod Taylor
> thanks for that - I tried it out, fixed the minor typos and it ran at almost > the same speed! Any other ideas? Could you post an explain analyze for both queries? There is always an application change. Add a trigger onto msg that will bump the date and count on msg_sum when a msg is

Re: [SQL] length of recordset read through a cursor

2003-08-09 Thread Rod Taylor
Yes, a move takes less time, but can still a significant amount of time. Do you need to know exactly what to expect? Run ANALYZE recently? A cheat I've used before is to parse the EXPLAIN (not EXPLAIN ANALYZE) output for the expected number of records involved. If that number was less than 2000

Re: [SQL] Insert a description while creating a table

2003-08-14 Thread Rod Taylor
On Wed, 2003-08-13 at 07:56, [EMAIL PROTECTED] wrote: > Hi, > > I want to insert descriptions at the columns of my tables but without > using the command COMMENT ON. I want to do it together with the table > creation. Is that possible? > > I wanna do something like this: > > create table test

Re: [SQL] Porting from PL/SQL to PLPGSQL

2003-08-14 Thread Rod Taylor
> we are facing a few problems with PL/SQL Code.. > > 1)In Exceptions ORACLE have something called WHEN OTHERS THEN cluase.I > can't find a replacement for that in > PostGreSQL. What does it do? > 2 Oracle have a function USERENV to get the user session > informati

Re: [SQL] Do it exist?

2003-08-16 Thread Rod Taylor
> In another language I would do: > find first Order where Order.Order_num = "". > if avaialble Order then it_exists = true. > > In PostgreSQL ?: > SELECT DISTINCT Order_num from Order_header where Order_num = ''; > > Is this close? If so, how to raise flage that row exists? >

Re: [SQL] Reverse pattern match.

2003-08-18 Thread Rod Taylor
On Mon, 2003-08-18 at 03:05, Moonstruck wrote: > I want to create a table of regular expression patterns (for assessing > phone numbers), something like: > CREATE TABLE CallType ( pattern varchar primary key, > typevarchar, > rateint4); > INS

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Rod Taylor
> Thanks, Stephan. I was really hoping that the IN(valuelist) was going to > be changed at the same time, because it really is unusable for anything > over a couple of thousand values. Changed to do what? I suppose that the ability to combine several index scans via a bitmap would help to linear

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Rod Taylor
Ensure your IN list is unique. You might find better times by through an indexed temp table. On Wed, 2003-08-20 at 16:32, Mike Winter wrote: > I'm sure many on this list are sick of hearing about this problem, but it > was on the fix list for 7.4, but doesn't appear to have been changed. > > You

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Rod Taylor
On Wed, 2003-08-20 at 17:41, Stephan Szabo wrote: > On Wed, 20 Aug 2003, Rod Taylor wrote: > > > > Thanks, Stephan. I was really hoping that the IN(valuelist) was going to > > > be changed at the same time, because it really is unusable for anything > > >

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-22 Thread Rod Taylor
> What is measured by the \timing option? The figures reported > are slightly larger than those loged when the log_duration parameter > is true. The time of the psql client. It will include round trip activity including network overhead. signature.asc Description: This is a digitally sign

Re: [SQL] MINUS & ROWNUM in PostGres

2003-09-04 Thread Rod Taylor
> 1)Do we have a replacement in PostGres for MINUS operator of Oracle . I believe MINUS is non-standard word for EXCEPT, correct? > 2 Also I need to find an alternative for ROWNUM in oracle.. If you are looking for a unique identifier, try using the OID. signature.asc Descript

Re: [SQL] Porting from Oracl to Postgres

2003-09-05 Thread Rod Taylor
On Fri, 2003-09-05 at 00:24, Jomon Skariah wrote: > > Hi, > > Thanks for your replys. > > We are facing another problem now. > > we need to find an alternative for Oracle's ADD_MONTHS in PostGres.. Guessing based on the name that it adds a quantity of months to a timestamp. How about an SQL I

Re: [SQL] SQL subqueries newbie help

2003-09-06 Thread Rod Taylor
> I'd like to write a query which returns following information regarding > each item: item, date of very first event, very last event. > Is this possible? I think I can write several SELECT queries and > procces them by an application or possibly write some procedure, but > what is better soluti

Re: [SQL] Why table has drop, but the foreign key still there?

2003-08-14 Thread Rod Taylor
> insert into state (state_code,state) values ('GU','Guam'); > drop table whitepage; > delete from state where state_code = 'GU'; > ERROR: Relation "whitepage" does not exist Old version of PostgreSQL? Effort went into cleaning up inter-object dependencies in 7.3. I don't recall having that pa

Re: [SQL] SQL subqueries newbie help

2003-09-07 Thread Rod Taylor
On Sun, 2003-09-07 at 07:42, Alexei Chetroi wrote: > On Sat, Sep 06, 2003 at 01:21:36PM -0400, Rod Taylor wrote: > > > I'd like to write a query which returns following information regarding > > > each item: item, date of very first event, very last event. > > &g

Re: [SQL] MINUS & ROWNUM in PostGres

2003-09-08 Thread Rod Taylor
On Mon, 2003-09-08 at 09:44, Jomon Skariah wrote: > Hi, > > Do we have any replacement for REPLACE() of Oracle in PostGres? What does replace() do? String replacement? http://www.postgresql.org/docs/7.3/interactive/functions-string.html replace(string text, from text, to text) signature.asc

Re: [SQL] MINUS & ROWNUM in PostGres

2003-09-09 Thread Rod Taylor
> The problem is we are using PostGres 7.1.In this version REPLACE() is not > available. It sounded like you were just starting to work on the change over. I highly suggest upgrading to 7.3 at the very least, 7.4 if you're going to be a few months prior to going to production. A ton of good work

Re: [SQL] Q: select query

2003-09-13 Thread Rod Taylor
> in other words, all but the first row of a group. Interesting question. The below should work and be quick so long as there is a UNIQUE(col1, col2) constraint. SELECT col1 , col2 FROM j WHERE col2 != (SELECT col2 FROM j AS jsub WHERE col1 = j.col1

Re: [SQL] A simple way to Create type ...?

2003-09-16 Thread Rod Taylor
> I guess, ideally it'd be > create type AddressType AS varchar(50) ; > but it does not work. Only one keyword off. SQL calls this a domain. They're limited in 7.3, but much improved (not yet perfect) for 7.4. http://www.postgresql.org/docs/7.3/interactive/sql-createdomain.html signature.asc

Re: [SQL] Creating Index

2003-10-01 Thread Rod Taylor
>-> Seq Scan on table1 (cost=0.00..20.00 rows=1000 width=0) (actual Run VACUUM ANALYZE, then repost your EXPLAIN ANALYZE results please. signature.asc Description: This is a digitally signed message part

Re: [SQL] [PERFORM] sql performance and cache

2003-10-14 Thread Rod Taylor
> > Perhaps you are confusing it with the MySQL query cache? > Is there plan on developing one (query cache)? For the most part, prepared queries and cursors give you a greater advantage due to their versatility -- both of which we do have. In the cases where an actual cache is useful, the clien

Re: [SQL] How can I produce the following desired result?

2003-10-14 Thread Rod Taylor
On Tue, 2003-10-14 at 22:09, aicean wrote: > How can I produce the following desired result? I'm not sure I understand the problem, but you might want to try a subselect in the FROM. SELECT FROM table JOIN (SELECT goodid FROM table WHERE ) AS tab USING (good

Re: [SQL] see a current query

2003-10-22 Thread Rod Taylor
On Wed, 2003-10-22 at 05:26, sad wrote: > Hello > > i'am logged in as superuser (pgsql) > trying to > SELECT * FROM pg_stat_activity; > and seeing NULLs instead of current_query column& You need to change the stats settings in postgresql.conf. By default the current query is not enabled as it d

Re: [SQL] naming conventions constraint

2003-10-24 Thread Rod Taylor
rbt=# create table bob_is(your_uncle integer, constraint "bob_is#your_uncle" check(true)); CREATE TABLE rbt=# \d bob_is Table "public.bob_is" Column | Type | Modifiers +-+--- your_uncle | integer | Check constraints: "bob_is#your_uncle" CHECK true Yo

Re: [SQL] Table versions

2003-10-29 Thread Rod Taylor
> What I did next, is put a trigger on pg_attribute that should, in theory, > on insert and update, fire up a function that will increment a version System tables do not use the same process for row insertion / updates as the rest of the system. You're trigger will rarely be fired. signature.asc

Re: [SQL] A tricky sql-query...

2003-11-02 Thread Rod Taylor
On Sun, 2003-11-02 at 19:42, Mark Stosberg wrote: > On 2003-10-22, Timo <[EMAIL PROTECTED]> wrote: > > > > You can't have any recursion in an pure sql-query, can you? > > It depends on how you think of recursion, I'd say. You join on the same > table a number of times, by giving it a different ali

Re: [SQL] DateDiff in PostgreSQL

2003-11-07 Thread Rod Taylor
> ie, a function that returns difference of two dates(timestamp) in days > or months or year.. > > The - operator for timestamp retuns the intervel in days only. rbt=# select extract('days' from current_timestamp - '2003-01-01'::timestamp); date_part --- 310 (1 row)

Re: [SQL] transaction processing after error in statement

2003-11-10 Thread Rod Taylor
> be recovered either. When committing a transaction the effects of all > operations that did not fail will be made permanent. This is how > transaction processing is described in the literature. I would be interested in reading that (URLs please) as I didn't see anything in the spec that was inte

Re: [SQL] transaction processing after error in statement

2003-11-10 Thread Rod Taylor
> Although i am not aware of the roots of this discussion but would like > to > comment at this point . > > When we work with sequences an aborted transaction does have > a permanent effect on the last value of sequence. Is this behaviour > not a violation of above defination of transaction ? I

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Rod Taylor
> Suppose by example that one have a table1 with a primary key over three > field (a, b, c): .. > are the indexes over (a) and (a, b) redundant (and so useless)? Yes, they are redundant not not necessarily useless. In short, an index with 3 keys will be larger than an index with 1 key, as such

Re: [SQL] rules and return values question

2003-11-28 Thread Rod Taylor
> tables but it introduces too much overhead. In any case, we need the return > value (or an exception) from the function but there does not seem a way to > return it. Can't you use erreport() to return an exception message? ---(end of broadcast)-

Re: [SQL] Sometimes referential integrity seems not to work

2004-02-02 Thread Rod Taylor
> TRUNCATE cannot be used inside of a transaction, and since 7.3 it checks > for foreign keys. So I guess Enio is getting but ignoring the error In 7.4 truncate is transaction safe. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe comma

Re: [SQL] column alias and group by/having/order

2004-02-13 Thread Rod Taylor
> select val1+val2 as val > from some_table > group by val having val>1; > ERROR: Attribute "val" not found > > Is it a bug or a feature? It's a mis-feature that group by accepts aliases of the select list. Having is proper. ---(end of broadcast)--

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
Most of the queries are going to be for the other values (in which case you've wasted an index scan) which is minor, but in the event there is a single 239 you're still taking a big hit. That is an awful lot of work to handle the non-existant case only. -- Rod Taylor Build

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
On Thu, 2004-02-12 at 23:25, Tom Lane wrote: > Rod Taylor <[EMAIL PROTECTED]> writes: > > Statistics say there are 10 values. Statistics list the 10 most common > > values (all of them). Given this, would it not be reasonable to assume > > that 239 is a recent additi

Re: [SQL] 7.4 - FK constraint performance

2004-02-15 Thread Rod Taylor
. Statistics list the 10 most common values (all of them). Given this, would it not be reasonable to assume that 239 is a recent addition (if there at all) to the table and not very common? -- Rod Taylor Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL PGP Key: http://www.rbt.

Re: [SQL] ORDER BY TIMESTAMP_column ASC, NULL first

2004-02-15 Thread Rod Taylor
On Thu, 2004-02-12 at 05:06, Fredrik Wendt wrote: > Hi! > > I read posts telling me that NULL values are considered greater than > non-null values. Fine. Is there a way to explicitly reverse this? ORDER BY column IS NOT NULL, column ASC; ---(end of broadcast)

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Rod Taylor
> and then you can foreach across the input: > > foreach($fields as $f){ > if (!$_POST[$f]){ > $_POST[$f]='DEFAULT'; > } else { > $_POST[$f] = "'".$_POST[$f]."'"; > } > } Default in quotes isn't going to work, and please tell me you escape those things with pg_escape_string() at som

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Rod Taylor
> Note that the ' marks aren't part of the string, they are the delimiter of > the string, and I always run every server with magic_quotes_gpc on. > > anything else? :-) Good point. I looked at the single quotes of the second line and somehow the DEFAULT got quoted as well ;) -

Re: [SQL] Compiling pl/pgsql functions

2004-02-20 Thread Rod Taylor
logic, or lack thereof, but accounting needs to use both sets of information to do their work. Otherwise, having each group relegated to their own schema with semi-public views is a nice way to pass information from department to department for small companies. Sure beats the spreadsheets on the centr

Re: [SQL] Newbie Query question

2004-03-26 Thread Rod Taylor
> However, this query does not give me the result I expected. It appears that > the database engine first calculates the cartesian product of the tables A > and B and then evaluates the query. Hence, I get multiple matches for Yup.. WHERE filters the results of the join. > Is there any way to do

Re: [SQL] partial unique constraint

2004-04-06 Thread Rod Taylor
On Tue, 2004-04-06 at 10:29, Robert Treat wrote: > Trying to come up with the proper syntax to meet the following criteria: > > create table foo (bar integer, baz boolean UNIQUE (bar, baz = true)); Tt takes 2 steps. CREATE TABLE ... CREATE UNIQUE INDEX ... (bar) WHERE baz = true;

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-08 Thread Rod Taylor
On Thu, 2004-04-08 at 19:33, Greg Stark wrote: > Jeff Boes <[EMAIL PROTECTED]> writes: > > > I headed off in the direction of groups of SELECTs and UNIONs, and quit when I > > got to something like four levels of "SELECT ... AS FOO" ... > > four? wimp, that's nothing! > > ok, seriously I think t

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-09 Thread Rod Taylor
On Fri, 2004-04-09 at 18:43, Greg Stark wrote: > Josh Berkus <[EMAIL PROTECTED]> writes: > > > Rod, > > > > > Something along the lines of the below would accomplish what you want > > > according to spec. ROW_NUMBER() is a spec defined function. (6.10 of > > > SQL200N) > > > > Great leaping litt

Re: [SQL] Can someone tell me why this statement is failing?

2004-04-20 Thread Rod Taylor
> Can anyone tell me why this SQL statement is not > matching with the row from the table below? I think > I'm going mad! Indeed. The row is NOT in that range. 1082377320 is > 1082375100 not <= it ---(end of broadcast)--- TIP 3: if posting/reading

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Rod Taylor
On Thu, 2004-04-22 at 01:18, Peter Eisentraut wrote: > Kemin Zhou wrote: > > IN chapter 33 Extending SQL > > 33.7.5 Writing Code > > when run pg_config --includedir-server > > I got /usr/local/pgsql/include/server but my machine does have this > > directory > > make install-all-headers > > It's

Re: [SQL] Server Side C programming Environment Set up

2004-04-22 Thread Rod Taylor
On Thu, 2004-04-22 at 10:11, Peter Eisentraut wrote: > Am Donnerstag, 22. April 2004 15:58 schrieb Rod Taylor: > > > make install-all-headers > > > > > > It's explained in the installation instructions. > > > > That doesn't happen on most

Re: [SQL] problem with slow select

2004-04-26 Thread Rod Taylor
On Wed, 2004-04-21 at 11:00, francescosaf wrote: > hi > > I have two tables: Please send results of EXPLAIN ANALYZE for the query in question. Thanks ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate

Re: [SQL] Check a value in array

2004-04-29 Thread Rod Taylor
On Thu, 2004-04-29 at 13:37, Marco Lazzeri wrote: > Hi all. > > I have to check if a value is in an array. > > I've got a date array in a table and I would like to perform queries > like: > > SELECT * FROM table WHERE date IN dates_array; If you're using 7.4 or later, try: SELECT * FRO

Re: [SQL] Procedure failing after upgrade

2004-05-05 Thread Rod Taylor
On Tue, 2004-05-04 at 09:32, patkins wrote: > All, > > I just upgraded to the latest version from 7.2.x and now a procedure is failing. > > Please tell me what I'm doing wrong! Please include the actual error message produced. That said, I'm getting an interesting error. It appears as if the int

Re: [SQL] most efficient way to manage ordering

2004-06-01 Thread Rod Taylor
> Ideally, I'd like to figure out a single SQL query that can be run > afterwards to clean up the dsply_order to make sure that each number occurs > only one time and that there are no gaps. Well... by far the easiest way to approach this is not to clean up the gaps. Removing gaps will only make t

Re: [SQL] Last insert id

2004-06-15 Thread Rod Taylor
On Tue, 2004-06-15 at 03:05, Andrei Bintintan wrote: > "Is it safe to use "select max(table1_id) from table1" after the insert?" > > Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT). No, this is not safe outside of the serializable isolation. rbt=# begin; BEGIN rbt=# se

Re: [SQL] Queries across multiple database

2004-06-30 Thread Rod Taylor
On Wed, 2004-06-30 at 18:54, Garth Thompson wrote: > I am in the process of migrating the databases for an application from mysql > to postgres. The application is uses several different databases. From > what I have read, postgres still does not support queries across multiple > databases. If t

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-12 Thread Rod Taylor
On Mon, 2004-07-12 at 08:29, SZŰCS Gábor wrote: > Dear Fellow Countymen, > > I fear none of your answers are acceptable for me. Also, from Csaba's > answer, this sounds to me more like a bug in pg_dump v7.3. It is a bug (or a missing feature) that should be solved with v7.5 for restoring to 7.5 o

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread Rod Taylor
> Checked, and So do you say, this problem persists in dbs dumped from 7.4 to > 7.4 too? i.e. upgrading to 7.4 (which we tested for quite some time now) > won't help? There may have been some minor fiddling to make it easier, but I wouldn't call it fixed by any means. > trying dump confirmed thi

Re: [SQL] Constraint->function dependency and dump in 7.3

2004-07-13 Thread Rod Taylor
On Tue, 2004-07-13 at 13:42, SZŰCS Gábor wrote: > Dear Rod, > > Thanks. It'll be a pain to have two versions between the prod and devel > servers, but I'll forward this info to the chief. You can make this part easier on yourself. Dump the structure from production and migrate it to devel (fix t

Re: [SQL] Query plan discrepancies

2004-07-16 Thread Rod Taylor
Have you run ANALYZE recently? Please send back EXPLAIN ANALYZE for the below query. > EXPLAIN from DB 2 (doesn't come back): >QUERY PLAN >

Re: [SQL] date_format in postresql

2004-07-20 Thread Rod Taylor
On Tue, 2004-07-20 at 20:55, azah azah wrote: > Hi, > I want convert from mysql to postresql, > in mysql, query to database using the code as below: > > date_format(submittime, "%W %M %e, %Y - %r") to_char(submittime, 'format string') http://www.postgresql.org/docs/7.4/static/functions-formattin

Re: [SQL] date_format in postresql

2004-07-21 Thread Rod Taylor
Which version of PostgreSQL are you using? select version(); > On Tue, 20 Jul 2004 22:39:38 -0400, Rod Taylor <[EMAIL PROTECTED]> wrote: > > On Tue, 2004-07-20 at 20:55, azah azah wrote: > > > Hi, > > > I want convert from mysql to postresql, > &

  1   2   >