Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Simon Riggs
On Fri, 2005-03-18 at 23:21 +, Brian O'Reilly wrote: > The following bug has been logged online: > > Bug reference: 1552 > Logged by: Brian O'Reilly > Email address: [EMAIL PROTECTED] > PostgreSQL version: 8.0.1 > Operating system: Linux 2.6.11 > Description:massiv

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Tom Lane
Bruce Momjian writes: > OK, here are the TODO items I have created: > * Add support for ANSI time INTERVAL syntax, INTERVAL '1 2:03:04' DAY TO > SECOND > * Add support for ANSI date INTERVAL syntax, INTERVAL '1-2' YEAR TO MONTH That example might better read, say, * Add support for ANSI

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Tom Lane wrote: > Bruce Momjian writes: > > OK, here are the TODO items I have created: > > > * Add support for ANSI time INTERVAL syntax, INTERVAL '1 2:03:04' DAY TO > > SECOND > > * Add support for ANSI date INTERVAL syntax, INTERVAL '1-2' YEAR TO MONTH > > That example might better read,

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Tom Lane
Bruce Momjian writes: > Tom Lane wrote: >> * Add support for ANSI date INTERVAL syntax, INTERVAL '2005-3' YEAR TO MONTH > Uh, I thought about that, but we are talking about an interval here, not > a year, so 2005 years seems like a strange number of years to span. Oh, right. Never mind ...

[BUGS] Precision and scale of numeric column reported as value -1

2005-03-23 Thread Sergio Lob
Bug to report - For a numeric in a table defined by: CREATE TABLE SERG (F01NUM NUMERIC) ; , the precision and scale reported by ResultSetMetaData.getScale() and ResultSetMetaData.getPrecision() are value -1 Attached is a simple java program (Repro1.java) that repros the problem. Before running re

Re: [BUGS] [GENERAL] contrib module intagg crashing the backend

2005-03-23 Thread Tom Lane
I wrote: > Grumble ... I seem to have managed to promote intagg from > broken-on-64bit-platforms to broken-on-every-platform ... > will look into a fix tomorrow. Ron's problem is essentially a double-free bug. In this patch: 2005-01-27 16:35 tgl * contrib/intagg/: int_aggregate.c, int_

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Keith Browne
Simon Riggs wrote: The EXPLAINs you've enclosed are for SELECTs, yet your bug report describes INSERTs as being the things that are slow. [You may find better performance from using COPY] Simon, Brian and I are working together on this problem. We're starting with an empty database, creating four t

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Andrew - Supernews
On 2005-03-23, Keith Browne <[EMAIL PROTECTED]> wrote: > One other thing which puzzled me: as a test, I tried modifying our > script to spit out raw SQL statements instead of connecting to the > database and performing the inserts itself. Normally, our script > populates two tables in one pass,

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
> "Bruce" == Bruce Momjian writes: Bruce> OK, here are the TODO items I have created: Bruce> * Add support for ANSI time INTERVAL syntax, INTERVAL '1 Bruce> 2:03:04' DAY TO SECOND Bruce> * Add support for ANSI date INTERVAL Bruce> syntax, INTERVAL '1-2' YEAR TO MONT

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Bruce> * Interpret INTERVAL '1:30' MINUTE TO SECOND as '1 Bruce> minute 30 seconds' This seems redundant; it's just another example of the ANSI day-time interval syntax... -roy ---(end of broadcast)--- TIP 3: if posting/read

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
Bruce> Is this sufficient? Also support for ANSI interval data types is incomplete in the parser, in that it doesn't recognize the precision field. eg CREATE TABLE foo (a INTERVAL MONTH(3)); fails to parse. -roy ---(end of broadcast)-

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Tom Lane
Andrew - Supernews <[EMAIL PROTECTED]> writes: > Changing the order so that the referenced table is fully populated, or at > least populated with more than a handful of pages of rows, before doing > _any_ insert on a referencing table in the same session will avoid the > misplan of the FK trigger q

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > Bruce>* Interpret INTERVAL '1:30' MINUTE TO SECOND as '1 > Bruce> minute 30 seconds' > > This seems redundant; it's just another example of the ANSI day-time > interval syntax... The reason I added it is that usually people think of the PG syntax as '1 hour 30 s

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Bruce> The reason I added it is that usually people think of the Bruce> PG syntax as '1 hour 30 seconds'. The '1:30' is a kind of Bruce> subtle because both PG and ANSI support that syntax and we Bruce> need to handle that. The tricky part is that we can't say Bruce> by looki

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Keith Browne
Tom Lane wrote: I'm still looking for an example that demonstrates why this is a common problem that we need to worry about. ISTM that if an FK reference is hit when there are still zero entries in the referenced table, that insertion will fail anyway, and so people wouldn't try to load data in su

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Oliver Jowett
Sergio Lob wrote: Bug to report - For a numeric in a table defined by: CREATE TABLE SERG (F01NUM NUMERIC) ; , the precision and scale reported by ResultSetMetaData.getScale() and ResultSetMetaData.getPrecision() are value -1 What should they return instead in this case? -O -

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > "Bruce" == Bruce Momjian writes: > > Bruce> OK, here are the TODO items I have created: > > Bruce> * Add support for ANSI time INTERVAL syntax, INTERVAL '1 > Bruce> 2:03:04' DAY TO SECOND > > Bruce> * Add support for ANSI date INTERVAL > Bruce>

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > Bruce> Is this sufficient? > > Also support for ANSI interval data types is incomplete in the parser, > in that it doesn't recognize the precision field. > > eg CREATE TABLE foo (a INTERVAL MONTH(3)); > > fails to parse. Added to TODO: o Support precision, C

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Sergio Lob
Precision is the number of total digits in the number. Scale is the number of fractional digits. For instance, a column defined as NUMERIC(10,3) should return precision=10, scale=3. The error only occurs for a column defined as NUMERIC (without precision or scale specified). Presumably, there

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
Bruce> Seems that is implentation-dependent so I added "round' or Bruce> error" to the TODO item. Ah, OK. "A guide to the SQL standard" claims it's an exception, but I haven't checked the actual standard. Bruce> Uh, I think this already works fine for PG syntax, and I Bruce> assu

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Alvaro Herrera
On Wed, Mar 23, 2005 at 04:13:22PM -0500, Sergio Lob wrote: > Precision is the number of total digits in the number. Scale is the > number of fractional digits. > For instance, a column defined as NUMERIC(10,3) should return > precision=10, scale=3. The error only occurs for a column defined as

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Andrew - Supernews
On 2005-03-23, Tom Lane <[EMAIL PROTECTED]> wrote: > Andrew - Supernews <[EMAIL PROTECTED]> writes: >> Changing the order so that the referenced table is fully populated, or at >> least populated with more than a handful of pages of rows, before doing >> _any_ insert on a referencing table in the s

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Stephan Szabo
On Wed, 23 Mar 2005, Sergio Lob wrote: > Precision is the number of total digits in the number. Scale is the > number of fractional digits. > For instance, a column defined as NUMERIC(10,3) should return > precision=10, scale=3. The error only occurs for a column defined as > NUMERIC (without

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Oliver Jowett
Sergio Lob wrote: Precision is the number of total digits in the number. Scale is the number of fractional digits. For instance, a column defined as NUMERIC(10,3) should return precision=10, scale=3. Yes, I understand that. The error only occurs for a column defined as NUMERIC (without precis

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > Bruce> The reason I added it is that usually people think of the > Bruce> PG syntax as '1 hour 30 seconds'. The '1:30' is a kind of > Bruce> subtle because both PG and ANSI support that syntax and we > Bruce> need to handle that. The tricky part is that we c

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Bruce> This is going to be a backward compatibility problem, but Bruce> to support ANSI syntax we are going to need to do this. Given the existence of the INTERVAL '1' MONTH etc syntax is completely undocumented, I doubt it's a major problem. (Actually, INTERVAL '1' and INTERVAL '1:30' a

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > Bruce> Seems that is implentation-dependent so I added "round' or > Bruce> error" to the TODO item. > > Ah, OK. "A guide to the SQL standard" claims it's an exception, but I > haven't checked the actual standard. Here is an email stating it is implementation defined:

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
Bruce> Here is an email stating it is implementation defined: Bruce> http://archives.postgresql.org/pgsql-bugs/2005-03/msg00162.php Hmm, looks like I'm mistaken, then. In fact the "whether to truncate or round" bit suggests you should do one or the other, rather than raise an except

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > Bruce> This is going to be a backward compatibility problem, but > Bruce> to support ANSI syntax we are going to need to do this. > > Given the existence of the INTERVAL '1' MONTH etc syntax is completely > undocumented, I doubt it's a major problem. > > (Actually,

Re: [BUGS] BUG #1552: massive performance hit between 7.4 and 8.0.1

2005-03-23 Thread Tom Lane
Keith Browne <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> I'm still looking for an example that demonstrates why this is a common >> problem that we need to worry about. > We're filling pairs of tables with rows having nearly a one-to-one > mapping; very rarely, the second table will have mul

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Bruce Momjian writes: > o Interpret syntax that isn't uniquely ANSI or PG, like '1:30' or > '1' as ANSI syntax, e.g. interpret '1:30' MINUTE TO SECOND as > '1 minute 30 seconds' > This is going to be a backward compatibility problem, but to support > ANSI syntax we are

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> That would eliminate the backward-compatibility problem Tom> pretty well (since the constraints aren't documented and Tom> hence aren't being used now), while not posing a big problem Tom> for ISO cases (since if there's no constraint there are no Tom> ambiguous cases, I be

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Roy> The 'constraint' (interval type descriptor or whatever it's Roy> really called) is mandatory in standard SQL, I think, so Roy> there's no ambiguity anyway, unless anyone is using this Roy> undocumented syntax at the moment... Incidentally, this was the ratinale behind my earli

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Roy> I have no objection to allowing things like Roy>'1 hour 10 minutes' DAY TO SECOND Roy> but I'm just wondering whether the hybrid syntax is an Roy> unnecessary complication. And furthermore, if you really want to allow constrained postgres syntax interval literals (and I

Re: [BUGS] Precision and scale of numeric column reported as value

2005-03-23 Thread Tom Lane
Oliver Jowett <[EMAIL PROTECTED]> writes: > There appears to be no default, which is why we currently return -1. The spec's notion of a "default precision and scale" is that every numeric column has a specific precision and scale --- ie, is physically fixed-width --- and everything you store into

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> We should do that *only* when an ISO (not ANSI) Just to clarify, is that a distinction or just a clarification? (ie are ANSI and ISO SQL different?) -roy ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > Bruce> Here is an email stating it is implementation defined: > > Bruce>http://archives.postgresql.org/pgsql-bugs/2005-03/msg00162.php > > Hmm, looks like I'm mistaken, then. In fact the "whether to truncate > or round" bit suggests you should do one or the other,

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Tom Lane
Bruce Momjian writes: > ... I don't think we are > going to have to change any internal representations. In order to support the spec *exactly*, we would have to. For instance we cannot presently tell the difference between '13 months' and '1 year 1 month' ... they both end up stored as '13 mont

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
Bruce> o Interpret INTERVAL '1 year' MONTH as I'm still not convinced that allowing this doesn't just create unnecessary confusion. How about: o Decide whether constructs such as INTERVAL '1 year' MONTH should be allowed, and if so what they should mean, eg perhaps CAST (INTERVAL

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month

2005-03-23 Thread Roy Badami
Tom> In order to support the spec *exactly*, we would have to. Tom> For instance we cannot presently tell the difference between Tom> '13 months' and '1 year 1 month' ... they both end up stored Tom> as '13 months'. I can't say that I find this very important, Tom> but it does

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > Roy> The 'constraint' (interval type descriptor or whatever it's > Roy> really called) is mandatory in standard SQL, True. ( is what SQL99 calls it.) > I have no objection to allowing things like >'1 hour 10 minutes' DAY TO SECOND > but I'm ju

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > Tom> In order to support the spec *exactly*, we would have to. > Tom> For instance we cannot presently tell the difference between > Tom> '13 months' and '1 year 1 month' ... they both end up stored > Tom> as '13 months'. I can't say that I find this very imp

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > Tom> We should do that *only* when an ISO (not ANSI) > Just to clarify, is that a distinction or just a clarification? (ie > are ANSI and ISO SQL different?) There is no "ANSI SQL". Only ISO SQL. ANSI never issued their own spec to my knowledge ... u

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > Which is where my comment about EXTRACT comes in. They can both be > stored as 13 months, but EXTRACT (MONTH FROM ...) should return 1 > month or 13 months as appropriate. Surely this isn't a problem, you > know the type of the interval? EXTRACT doesn't h

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month

2005-03-23 Thread Roy Badami
Bruce> What happens if you store '13 months' into an interval Bruce> column that is YEAR TO MONTH? Does extract MONTH return 1 Bruce> or 13? In standard SQL the MONTH field of INTERVAL YEAR TO MONTH can't contain a value greater than 11. Though I don't immediately see how yo

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> In the context of interval literals it's probably Tom> unnecessary, but that's not the only thing to worry about. Tom> In particular we have to consider the behavior of the input Tom> and output routines for cases like COPY. I think it would be Tom> really bad to reject '

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Peter Eisentraut
Tom Lane wrote: > There is no "ANSI SQL". Only ISO SQL. ANSI never issued their own > spec to my knowledge ... unlike, say, C, where I believe ANSI C was > in fact issued by ANSI. There is an ANSI SQL standard ANSI X3.135. At least my copy of SQL 1999 carries a combined ANSI/ISO label. Nevert

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > Tom> In particular we have to consider the behavior of the input > Tom> and output routines for cases like COPY. > Hmm, but COPY is non-standard, so I'd be happy that it insisted on > postgres interval syntax. It's not different from INSERT INTO f

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> It's not different from Tom> INSERT INTO foo VALUES('1 year 1 month'); Tom> Nothing nonstandard about that that I can see. Oh, does ISO allow a cast from a string to an interval? Yes, I think it probably does. And with the interpretation of the string is dependent on the ISO

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> Yes. The ISO design for the datatype is pretty brain-dead if Tom> you ask me --- the basic meaning of a data literal shouldn't Tom> be so dependent on context. Arguably it's not, because the interval qualifier is an intrinsic (and mandatory) part of the literal syntax, so the fu

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > That convinces me that you have to figure out what to do with > CAST ('1 year 1 month' AS INTERVAL MONTH) > It _still_ doesn't completely convince me that you need to (or even > want to) support hybrid interval syntax. > Though given you have to support

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Tom Lane
Roy Badami <[EMAIL PROTECTED]> writes: > Tom> Yes. The ISO design for the datatype is pretty brain-dead if > Tom> you ask me --- the basic meaning of a data literal shouldn't > Tom> be so dependent on context. > Arguably it's not, because the interval qualifier is an intrinsic (and >

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Roy Badami
> "Bruce" == Bruce Momjian writes: >> You also need to make EXTRACT do the right thing. >> >> eg EXTRACT (MONTH FROM INTERVAL '1-1' YEAR TO MONTH) => 1 >> >> but >> >> EXTRACT (MONTH FROM INTERVAL '13' MONTH) => 13 >> >> Ditto for day-time intervals, o

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Roy Badami
Tom> As you point out, the ISO spec doesn't actually say that that Tom> string literal has to be the external textual representation Tom> ... but it's surely pretty bizarre that it's not a good Tom> candidate to be the textual representation. Yes, I'm convicned. Particularly after

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Bruce Momjian
Tom Lane wrote: > Roy Badami <[EMAIL PROTECTED]> writes: > > Tom> We should do that *only* when an ISO (not ANSI) > > Just to clarify, is that a distinction or just a clarification? (ie > > are ANSI and ISO SQL different?) > > There is no "ANSI SQL". Only ISO SQL. ANSI never issued their ow

Re: [BUGS] BUG #1517: SQL interval syntax is accepted by the parser,

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > Roy> The 'constraint' (interval type descriptor or whatever it's > Roy> really called) is mandatory in standard SQL, I think, so > Roy> there's no ambiguity anyway, unless anyone is using this > Roy> undocumented syntax at the moment... > > Incidentally, this wa

Re: [BUGS] BUG #1518: Conversions to (undocumented) SQL year-month and

2005-03-23 Thread Bruce Momjian
Roy Badami wrote: > > "Bruce" == Bruce Momjian writes: > > >> You also need to make EXTRACT do the right thing. > >> > >> eg EXTRACT (MONTH FROM INTERVAL '1-1' YEAR TO MONTH) => 1 > >> > >> but > >> > >> EXTRACT (MONTH FROM INTERVAL '13' MONTH) => 13 > >>