On Wednesday 25 February 2004 19:18, Richard Huxton wrote:
> Large table representing non-overlapping blocks:
>
> blocks(id int4, min varchar, max varchar)
>
> SELECT * FROM blocks WHERE 'ABCDE' BETWEEN min AND max;
>
> The estimator gets the wrong plan because
On Wednesday 25 February 2004 20:56, Joe Conway wrote:
> Richard Huxton wrote:
> > That's not quite the same though, because it means I need to split
> > ABCAA..ABDBB into ABCAA..ABCZZ and ABDAA..ABDZZ but it's close enough
> > unless someone is feeling clever this
On Wednesday 25 February 2004 21:32, Tom Lane wrote:
> Richard Huxton <[EMAIL PROTECTED]> writes:
> > Large table representing non-overlapping blocks:
> > blocks(id int4, min varchar, max varchar)
> >
> > SELECT * FROM blocks WHERE 'ABCDE' BETWEEN min AN
e possible in some cases, but I'm not
sure how difficult it is to do in all cases.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
;ORDER BY pr_min DESC LIMIT 1)
Aha! I was trying something like that, but couldn't get it quite right and it
was getting too late for me to see clearly.
Thanks Tom, I'll have a play with this later today.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
he replication options available -
you may be able to adapt contrib/dbmirror, or perhaps erserver/rservimp on
gborg.postgresql.org
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregist
onal functions/operators iirc).
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
olumn.
...
(
SELECT x.field2
FROM tableB AS x
WHERE x.field1 = tableB.field1 - 1
)
...
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
tion.
Yes - a wrapper function is the standard solution. I don't think you need to
do this in 7.4 though.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
su
r(10));
> insert into someOthertest (value) values ('100');
> insert into test (value) values ('10');
> insert into test (value) values ('20');
>
> select currval() should returns 2 (the last value of the test table
> sequence)
Not really - what
g will convert back/fore quite neatly. Alternatively, you might prefer
'base64' - on average a less compact format I'd guess.
I don't know whether the ECPG interface lets you pass "raw" binary back and
fore or not, but hopefully someone else will.
--
Richard H
ee a $2 constraint so why am i getting the error msg?
Firstly, $2 will be the automatically created name for this new constraint.
Secondly || doesn't mean OR - it joins strings.
Try something like (untested):
ALTER TABLE genus ADD CONSTRAINT valid_gender CHECK (gender IN
('masculine'
ease if it is not possible please say.
You're best doing this in the application really.
However, if you only want to work with text, search the mailing list archives
using keywords like:
text concat aggregate
and you should see an example solution where you build your own aggregate
.x
Might be worth a quick look in the -bugs list archives and see if anything
looks like your problem.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
of your problems are down to quoting issues and misleading error
statements.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
ke there you were using transact-sql (if I remember its name
correctly) rather than sql.
The syntax is different (plpgsql bares a startling resemblance to the Oracle
approach), the purpose of each is the same.
--
Richard Huxton
Archonet Ltd
-
if there is any way to do this in one of the later SQL standards?
The CREATE INDEX thing is a bit of a hack, and I certainly wouldn't have
thought of it either.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
rs,
> irrespective of the values of c1 ranging from 100 to 10 million
You could write such a coding so long as you don't mind having ten-thousand
characters in your character-set. Of course, character does not equal byte
like this, but that's true in the various unicode syste
lts I think I should be getting. Is there
> any kind of debug setting, or if not that, a way to output text (i.e.
> printf) from plpgsql?
RAISE NOTICE ''var1 = %, var2 = %'', var1, var2;
Note - you need this format, you can't mix and match expressions etc.
--
R
dump, a specific table/query?
Do you need to provide values for this update/insert, or is it fixed (updating
timestamps sort of thing).
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desir
the procedural language pl/sh - I think that is what you
need.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
E a.other_acc = OLD.acc;
Your second example just ignored the OLD.acc altogether in the join, so of
course you got an unconstraind join of 213 x 213.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
why this
won't work in your case?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
n (other than as NEW.col1, NEW.col2, NEW.col3
etc).
You can however use TG_NAME or TG_RELNAME to see what trigger/table called
you. I find that's helpful.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
the
question please do assist.
Martin - you'll need to explain exactly what you want. Can you show what
outputs you would like given the above data?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lis
| 5
SELECT
d.divisions_name,
s.pd_geo,
COUNT(s.pd_geo)
FROM
ser_divisions d,
ser s
WHERE
d.divisions_id = s.ser_divisions
GROUP BY
d.divisions_name, s.pd_geo
ORDER BY
d.divisions_name, s.pd_geo
;
It's called a join, and any good SQL book should cover it.
--
Richard Huxton
Please ignore - testing a previously misconfigured email client
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
that in Postgres SQL Server.
You could use unicode (e.g. UTF-8) encoding. I don't see what it gains you
though. What do you hope to achieve by storing numerical data as characters?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)--
This is called a join. Any book on databases/SQL should discuss this sort of
stuff.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
bytea,'UTF-8')
> ERROR: No such encoding as 'UTF-8'
I think you're using the encode() function wrongly. The second parameter is
supposed to be something like "base64" or "hex". I'm not sure it makes sense
to try and cast an integer
it will get back compared to how many it
actually gets back.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 8: explain analyze is your friend
for PostgreSQL.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
nt OIDs that table will use 4
bytes less for every row, and so be a bit faster.
I believe in the next version, the default setting will be not to have
OIDs and you will have to specify "WITH OIDS" if you do want them.
HTH
--
Richard Huxton
Archonet Ltd
---(end
to do?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
also deleted the a table row.
You'll need to show the table definitions (with foreign keys etc) and
also trigger definitions (use "\d table_a" in psql or "pg_dump
--schema-only -t tablename")
--
Richard Huxton
Archonet Ltd
---
the
source folder. Haven't used them myself, so can't say more. Worth
checking the mailing list archives though, since there has been
discussion of this.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 7: don't for
ut only for those columns that
have active='y'. For the columns that have active='f' I don't care if num is
unique or not. I'm asking this because num will be doubled some times.
Non-standard but elegant:
CREATE UNIQUE INDEX my_partially_unique_index ON rekl
archives (this list and general would be a good
start) for plenty of discussion on these.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unreg
me serial message_id
column that should act as a clue.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
t any of my PL/SQL functions (or yours) are so brilliant
> that they need trade secret protection.
Some of mine are so ugly, I wish they were hidden away mind you ;-)
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you
ur current connection.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
datatype inside your function. Clearly
PostgreSQL needs to know what type is being returned while parsing the
function, so you can't have a "dynamic type" (if such an idea has any
meaning at all).
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
this. I'd guess you
dropped/recreated the function after defining the trigger, yes?
The solution in older versions is to put the CREATE FUNCTION and CREATE
TRIGGER in the same file so that you drop/recreate both together.
HTH
--
Richard Huxton
Archonet Ltd
---(end of
views? At least for simple views of the kind 'CREATE VIEW v AS SELECT a,b,c FROM t'?
If you're running 7.4 you can look in the information schema, in
view_column_usage - that will tell you which table-columns a view uses.
--
Richard Huxton
Archonet Ltd
---
t myself on occasion. The '==' operator
doesn't exist in plpgsql, you should use '=' when comparing and ':=' for
assignment.
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
ght well interfere (though
I admit I haven't looked in detail)
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
h a clever idea involving a
join against a set-returning function, but I'm not sure about
guaranteeing the order of the join vs the returned set (and it's getting
late here). Any ideas people?
Maybe one of those is some use
--
Richard Huxton
Archonet Ltd
---
igh key to t1).
So there's no connection between column "code" in any of the tables? I'm
confused as to the correlation between t0 and t1. I'm also not clear
what t2.code is supposed to be.
Could you give a short (5 rows each) example of the contents of the
tables and th
nd usually given is to do two updates:
UPDATE story SET id = -id;
UPDATE story SET id = -id + 1500;
The real solution would be to check unique constraints at the end of
statement, but I assume this is a tricky change or it would have been
done by now.
--
Richard Huxton
Arch
about it's type-matching, which is why you need to
have two entries for the function.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 8: explain analyze is your friend
te field1/2/3 then this
won't work.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
bid. However, writing a perl script or plsql
function to do this for you shouldn't be difficult.
Screams out plpgsql to me - it's good at automating what is basically
cut & paste of values.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
co,clo1,nl,l1,m1;
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
as
IF NOT((...)=false)
is a good one. Handling of NULLs causes a great deal of pain to
inexperienced and experienced developers alike. You might be interested
in the archives at http://www.dbdebunk.com/ which IIRC contains some
articles arguing against nulls at all in a relational system.
--
Ri
data to an already partially normalised database.
How can newtable contain data if you don't have any keys for it?
Perhaps a fuller example, with the schemas of the tables in question
would help.
--
Richard Huxton
Archonet Ltd
---(end of broa
lls.
The key point of argument, and where the problem is with your (13 <
NULL)::BOOL point is this:
IT IS NOT MY PROBLEM !!! it is an EXAMPLE WHY WE CAN NOT PROHIBIT NULLS !!!
Umm - who is suggesting prohibiting nulls? I've re-read the entire
thread and can't find any such suggesti
the money_ref in old_money and then INSERT...SELECT to make sure you get
the reference right in new_money.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
extreme. Might make a good project for
someone learning more about PG's code.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's dataty
s.
IF OLD.CreateTime <> NEW.CreateTime THEN
...
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
t want to provide a value you'll need to
set a DEFAULT.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
rep
"ERROR:*" > import_errors
Try something like: ... psql cli_post 2>import_errors
STDOUT is file-handle 1, STDERR is file-handle 2. You might also want to
read up on the "tee" utility.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)
ook in the contrib/ folder of the source distribution
(or the equivalent in your packaged installation for "dblink". Haven't
used it myself, but it can certainly do what you want here.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)-
| | |
100473 | | | text1| |
Don't forget the provided crosstab functions (in contrib/). If you don't
want that, you could aggregate your results:
SELECT content_object_id, MAX(xpos), MAX(ypos), ...
FROM (
) AS raw
GROUP BY content_object_id;
--
Rich
| | |
100473 | | | text1| |
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unreg
mented with an index, so I'm guessing
the FK code assumes there is an index there to check against.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
ybe an alternative todo?
* Allow multiple unique constraints to share an index where one is a
superset of the others' columns.
That way you can mark it unique without having the overhead of multiple
indexes.
--
Richard Huxton
Archonet Ltd
---(end o
presumably that's already implied.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
d) WHERE trans_type='CHQ';
Actually, since we can have a "unique index with where" this second form
should be do-able shouldn't it?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 5: Have you checked our exte
ust
Or, since you're on 7.2 probably
local all trust
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
o's set-returning-functions article on techdocs.
http://techdocs.postgresql.org/guides/SetReturningFunctions
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
T
SELECT lsttable();
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 8: explain analyze is your friend
Key (typnum)=(43) is not present in table "types".
I don't kown why.
Before your "insert into" add:
RAISE NOTICE ''cletype = %'', cletype;
This will show what value cletype has. Presumably it's 43 and you don't
have an equivalent row in &
opriate table you can use CREATE TYPE to create a
structure.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
ry but 150 in the second
then it might decide a sequential scan is quicker.
Post the outputs of explain analyse and we can compare them.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list ar
ichardh=# SELECT '2004-02-29'::date + '1 year'::interval;
?column?
-
2005-02-28 00:00:00
(1 row)
richardh=# SELECT '2004-02-29'::date + '4 years'::interval;
?column?
-
2008-02-29 00:00:00
(1 row)
-
-- TYPE: line_type
CREATE TYPE public.line_type AS
(
line text
);
CREATE FUNCTION public.show_users()
RETURNS SETOF user_type AS
user_rec line_type%ROWTYPE;
--
Richard Huxton
Archonet Ltd
Org
Subject: Re: [SQL] Ordering a record returned from a stored procedure -
date issue
I have the code working except for the date part of the where clause. Can
anyone point out how
yield_date = ''''10/18/2004''''
can be translated so the 10/18/2004 is comin
t;name" (look carefully at the error message).
If you quote the name when you create it, ALWAYS quote it. If you never
quote names then you won't have any problems.
It might be that the webmin module quoted the column-name for you
without your knowledge. You'll need to consult
one of the PK
columns?
CREATE TABLE SUPPLY
(
ITEM_FK integer NOT NULL,
CONTACT_FK integer NOT NULL,
COST numeric (7,2),
PRIMARY KEY (ITEM_FK,CONTACT_FK)
);
The primary-key index can be used for ITEM_FK but not CONTACT_FK, so you
might want an index on that column.
--
Richard Huxton
Archonet
254"
2004-11-10 11:22:47 FATAL: missing or erroneous pg_hba.conf file
2004-11-10 11:22:47 HINT: See server log for details.
Configuration file pg_hba.conf
hostall all 192.168.2.1/254 md5
You don't have 254 bits in in IP address. Did you mean /32?
--
Rich
for a network howto on CIDR subnet formats.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster
quot; in the "Localization" chapter of the manuals)
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
contains four
accented characters, with accents as follows: A` E` D- O/
Actually, this doesn't display properly in my usual terminal (konsole
under KDE) but does under xterm.
--
Richard Huxton
Archonet Ltd
CREATE TABLE foo (t text);
-- DELETE FROM foo;
COPY foo FROM STDIN;
AAA
à à à Ã
a while.
The only thing is, you need to remember to call nextval() every time you
connect.
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 8: explain analyze is your friend
Achilleus Mantzios wrote:
O Richard Huxton έγραψε στις Nov 17, 2004 :
Riccardo G. Facchini wrote:
hi all,
is there a way to determine the session id on a database session?
I would need to have a unique number whenever a session is started, and
have this available as a function or view result
to
also change my_session_id to another value.
No - other sessions will see different values. Test it and see.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscrib
ned to him? :-)
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
oints" in version 8.0 though, which
lets you trap errors and rollback to a named (saved) point in your function.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
rrect procedure (although ask yourself if you should have
nulls rather than just empty strings).
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings
the source distribution (.tar.gz or .bz2) - the one you'd use to
compile PostgreSQL from scratch. Untar it, and you'll see src/tutorial
directories.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 9: the planner will i
tus").
HTH
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
; row.
Maybe someone smarter than me can come up with a non-procedural
solution. Personally, I've got a nagging feeling that this sort of
"connectedness" problem is NP, so scaling could be a problem for you.
--
Richard Huxton
Archonet Ltd
---(end of broa
?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 8: explain analyze is your friend
."
4. Issue "UPDATE..."
5. Issue "INSERT..."
6. etc
Until you issue COMMIT/ROLLBACK the transaction remains open.
If you had an error at step 3, then 4,5 would fail because the
transaction would be aborted (but waiting for you to issue ROLLBACK).
uot;C"
sorting, so dump your database, re-initdb with --locale=C and restore
the dump.
There's a whole chapter on localisation in the manuals. Make sure you
are clear on the difference between encoding and locale.
--
Richard Huxton
Archonet Ltd
---(e
hould be
straightforward enough to write some support functions and just use a
text type, but that'd use a lot more storage.
Of course, another table is the accepted way of doing this relationally.
Are there any particular features you need, or are you just porting an
application fr
summarise, and if so by what?
Can you explain how you would do this by hand.
Could you provide the actual table definition?
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
er_score DESC, t1.part ASC;
Write a small plpgsql function to process the table in that order and
update "full" accordingly. Actually, I'd add a SERIAL primary key and
have a separate table for "full" - that way you can just delete the
sorting values and replace them in one
relations from beeing seen.
Obviously, everyone needs access to the system tables and at present
there is no system in place to restrict access to viewing all their
contents.
--
Richard Huxton
Archonet Ltd
---(end of broadcast)---
TIP 3: if
alias for this account is
[EMAIL PROTECTED] Both may be listed because I frequently get emails
in duplicate.
Any help would be greatly appreciated.
Try the web interface from http://www.postgresql.org/lists.html - you
can unsubscribe/get a password reminder from there.
--
Richard Huxton
Arc
301 - 400 of 859 matches
Mail list logo