Re: [GENERAL] indexes on functions and create or replace function

2008-08-30 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 7:45 PM, Matthew Dennis <[EMAIL PROTECTED]> wrote: > Another question though. Since I could potentially start transaction, drop > indexes/checks, replace function, create indexes/checks, commit tranasaction > could I deal with the case of the constant f

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 8:51 PM, Alvaro Herrera <[EMAIL PROTECTED]>wrote: > There's no way at all in the general case (a function name could be > passed as a parameter, for example). I think Matthew is suggesting to > track dependencies at run time, but that seems a recipe for burnt > fingers and

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 9:09 PM, Christophe <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2008, at 7:04 PM, Matthew Dennis wrote: > >> The plpgsql execute statement, as I understand it, means "take this string >> and execute like a client sent it to you". >>

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 9:01 PM, Christophe <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2008, at 6:51 PM, Alvaro Herrera wrote: > >> Also, you have to keep in mind that we support pluggable languages. The >> function's source code is just an opaque string. >> > > Oh, ouch, right. > > I think that t

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 8:15 PM, Christophe <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2008, at 6:10 PM, Matthew Dennis wrote: > >> I'm not sure I follow. Couldn't you track which statements were prepared >> that called a function and either reprepare (just

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 7:52 PM, Christophe <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2008, at 5:49 PM, Matthew Dennis wrote: > >> Yes, I can see that would indeed be a problem. Are there future plans to >> start tracking such dependencies? It seems like it would b

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 5:32 PM, Christophe <[EMAIL PROTECTED]> wrote: > On Aug 28, 2008, at 3:21 PM, Matthew Dennis wrote: > >> I have no doubt that someone would complain about it, but I think it's >> better than the alternative. >> > > Determining if

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 6:22 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Matthew Dennis" <[EMAIL PROTECTED]> writes: > > On Thu, Aug 28, 2008 at 9:30 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > >> (Changing the behavior of an allegedly IMMUTABLE functi

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 9:30 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > (Changing the behavior of an allegedly IMMUTABLE function has a number > of other pitfalls besides that one, btw.) > I'm interested in knowing what they are - could you point me in the right direction (I've read the docs on im

Re: [GENERAL] indexes on functions and create or replace function

2008-08-28 Thread Matthew Dennis
On Thu, Aug 28, 2008 at 9:30 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > If it did that, you (or someone) would complain about the enormous > overhead imposed on trivial updates of the function. Since determining > whether the function actually did change behavior is Turing-complete, > we can't rea

[GENERAL] indexes on functions and create or replace function

2008-08-27 Thread Matthew Dennis
Given table T(c1 int) and function F(arg int) create an index on T using F(c1). It appears that if you execute "create or replace function F" and provide a different implementation that the index still contains the results from the original implementation, thus if you execute something like "selec

[GENERAL] different results based solely on existence of index (no, seriously)

2008-08-11 Thread Matthew Dennis
In reference to the script below (I know it can be rewritten, that's not the point), I get 3 rows if the referenced index exists but only two rows if it does not. This is observable and repeatable just by dropping/creating the index. Drop the index and two rows are returned. Create the index, th

Re: [GENERAL] array sort for varchar arrays?

2008-07-09 Thread Matthew Dennis
On Wed, Jul 9, 2008 at 12:28 AM, Pavel Stehule <[EMAIL PROTECTED]> wrote: > 2008/7/8 Matthew Dennis <[EMAIL PROTECTED]>: > > I'm likely overlooking something, but I can't seem to find a function to > > sort a varchar array. Something like "select sort(&

[GENERAL] array sort for varchar arrays?

2008-07-08 Thread Matthew Dennis
I'm likely overlooking something, but I can't seem to find a function to sort a varchar array. Something like "select sort('{y,z,x}'::varchar[])" => {'x','y','z'}.

[GENERAL] functions, selects and the planner

2008-06-14 Thread Matthew Dennis
In PostgreSQL 8.3 lets say I have a table: create table t(c1 int, c2 int, ts0 timestamp with time zone, ts1 timestamp with time zone, data varchar); an index: create index t_c1_c2_ts0_idx on t using btree(c1, c2, ts0 desc); and a function: create function f(_ts timestamp(0) with time zone, _c1

[GENERAL] plpgsql functions and the planner

2008-04-26 Thread Matthew Dennis
Do SQL statements inside of plpgsql functions get planned upon every execution, only when the function is first executed/defined, or something else entirely? For example, suppose I have a table foo and a function bar. Function bar executes some SQL statements (select/insert/update) against table

Re: [GENERAL] aggregate hash function

2008-01-30 Thread Matthew Dennis
On Jan 30, 2008 4:40 PM, Vyacheslav Kalinin <[EMAIL PROTECTED]> wrote: > Most implementations of md5 internally consist of 3 functions: md5_init - > which initializes internal context, md5_update - which accepts portions of > data and processes them and md5_final - which finalizes the hash and > r

[GENERAL] aggregate hash function

2008-01-30 Thread Matthew Dennis
I'm in need of an aggregate hash function. Something like "select md5_agg(someTextColumn) from (select someTextColumn from someTable order by someOrderingColumn)". I know that there is an existing MD5 function, but it is not an aggregate. I have thought about writing a "concat" aggregate functio

[GENERAL] insert into t1 (delete from t0 returning *)

2007-12-17 Thread Matthew Dennis
in 8.3beta3 create table t0(c1 int); create table t1(c1 int); insert into t0 values (1); insert into t0 values (2); insert into t0 values (3); If I execute "delete from t0 returning *" it deletes the rows and returns the deleted rows. I could insert all those rows into t1 by doing "insert into

Re: [GENERAL] Creating Aggregate functions in PLpgSQL

2007-12-11 Thread Matthew Dennis
On 12/11/07, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > > Is it possible to create aggregate functions using pl/pgsql? Yes, the sfunc and ffunc can be functions written in plpgsql. If not possible in plpgsql, is there any other way to create these types of > functions? Yes, but I don't k

[GENERAL] aggregate and order by

2007-12-06 Thread Matthew Dennis
I want to create an aggregate that will give the average velocity (sum of distance traveled / sum of elapsed time) from position and timestamps. example: create table data(position integer, pos_time timestamp, trip_id integer); insert into data values(1, "time x", 1); insert into data values(2,

[GENERAL] 8.3 release notes

2007-12-03 Thread Matthew Dennis
The release notes seem to be in two places, with slightly different information. The page Google sends back for most 8.3 queries http://www.postgresql.org/docs/8.3/static/release-8-3.html and the one you get from the PostgreSQL beta program link http://developer.postgresql.org/pgdocs/postgres/rel

Re: [GENERAL] pg_dump (8.1.9) does not output copy statements

2007-09-27 Thread Matthew Dennis
All of them On 9/26/07, Tom Lane <[EMAIL PROTECTED]> wrote: > > Jan de Visser <[EMAIL PROTECTED]> writes: > > In my world two identical pilot errors within a short timeframe are > indicat= > > ive=20 > > of a bad interface. > > Yeah, it's inconsistent. How many people's dump scripts do you want t

[GENERAL] pg_dump (8.1.9) does not output copy statements

2007-09-26 Thread Matthew Dennis
Maybe I'm just missing something but I can't seem to get pg_dump to output copy statements. Regardless of the -d / --inserts flag it always outputs insert statements. The doc says that pg_dump will output copy statements by default and will only output insert statements with the -d / --inserts fl