crash on new system views

Started by Bruce Momjianover 27 years ago10 messages
#1Bruce Momjian
maillist@candle.pha.pa.us

This query crashes the backend. pg_rules is a new system view:

BEGIN WORK;
DECLARE c_matches BINARY CURSOR FOR
SELECT count(*)
FROM pg_attrdef t1, pg_rules t2
WHERE t1.adrelid = t2.oid
END WORK;

Partial backtrace is below. It is crashing in the optimizer.

---------------------------------------------------------------------------

#0 0x80e8a5b in datumIsEqual (value1=0, value2=0, type=26, byVal=0, len=4)
at datum.c:216
#1 0x809d8fe in _equalConst (a=0x82daf10, b=0x82e2dd0) at equalfuncs.c:213
#2 0x809e7b7 in equal (a=0x82daf10, b=0x82e2dd0) at equalfuncs.c:668
#3 0x809e909 in equal (a=0x82e3490, b=0x82e3930) at equalfuncs.c:738
#4 0x809d634 in _equalExpr (a=0x82e2550, b=0x82e2d10) at equalfuncs.c:88
#5 0x809e737 in equal (a=0x82e2550, b=0x82e2d10) at equalfuncs.c:644
#6 0x809dab6 in _equalClauseInfo (a=0x82e2710, b=0x82e2cd0)
at equalfuncs.c:289
#7 0x809e7e7 in equal (a=0x82e2710, b=0x82e2cd0) at equalfuncs.c:677
#8 0x809b52a in member (l1=0x82e2cd0, l2=0x82e38f0) at list.c:371
#9 0x809b692 in set_difference (l1=0x82e3970, l2=0x82e38f0) at list.c:476
#10 0x80b0c23 in create_index_path (root=0x82e1290, rel=0x82e1490,
index=0x82e1a90, restriction_clauses=0x82e38f0, is_join_scan=0 '\000')
at pathnode.c:274
#11 0x80a7778 in create_index_paths (root=0x82e1290, rel=0x82e1490,
index=0x82e1a90, clausegroup_list=0x82e3910, join=0 '\000')
at indxpath.c:1381
#12 0x80a65b5 in find_index_paths (root=0x82e1290, rel=0x82e1490,
indices=0x82e38d0, clauseinfo_list=0x82e36f0, joininfo_list=0x0)
at indxpath.c:155
#13 0x80a55cb in find_rel_paths (root=0x82e1290, rels=0x82e3750)
at allpaths.c:124

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)
#2Keith Parks
emkxp01@mtcc.demon.co.uk
In reply to: Bruce Momjian (#1)
Re: [HACKERS] crash on new system views

Bruce Momjian <maillist@candle.pha.pa.us>

This query crashes the backend. pg_rules is a new system view:

BEGIN WORK;
DECLARE c_matches BINARY CURSOR FOR
SELECT count(*)
FROM pg_attrdef t1, pg_rules t2
WHERE t1.adrelid = t2.oid
END WORK;

Partial backtrace is below. It is crashing in the optimizer.

Bruce,

I'm getting the same here when testing your query.

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

postgres=> select oid,usename from pg_user;
oid|usename
---+--------
|postgres
^^^

Thinking about it, a view would not actually have an OID for each
tuple as it's not a real table.

It also crashed without the BEGIN or DECLARE ...

postgres=> SELECT count(*) FROM pg_attrdef t1, pg_rules t2 WHERE
t1.adrelid = t2.oid;
pqReadData() -- backend closed the channel unexpectedly.

As usual I have no idea where to look for the problem!!

Keith.

#3Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Keith Parks (#2)
Re: [HACKERS] crash on new system views

Bruce Momjian <maillist@candle.pha.pa.us>

This query crashes the backend. pg_rules is a new system view:

BEGIN WORK;
DECLARE c_matches BINARY CURSOR FOR
SELECT count(*)
FROM pg_attrdef t1, pg_rules t2
WHERE t1.adrelid = t2.oid
END WORK;

Partial backtrace is below. It is crashing in the optimizer.

Bruce,

I'm getting the same here when testing your query.

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
http://www.op.net/~candle              |  (610) 353-9879(w)
  +  If your life is a hard drive,     |  (610) 853-3000(h)
  +  Christ can be your backup.        |
#4Keith Parks
emkxp01@mtcc.demon.co.uk
In reply to: Bruce Momjian (#3)
Re: [HACKERS] crash on new system views

Bruce Momjian <maillist@candle.pha.pa.us>

Bruce Momjian <maillist@candle.pha.pa.us>

This query crashes the backend. pg_rules is a new system view:

BEGIN WORK;
DECLARE c_matches BINARY CURSOR FOR
SELECT count(*)
FROM pg_attrdef t1, pg_rules t2
WHERE t1.adrelid = t2.oid
END WORK;

Partial backtrace is below. It is crashing in the optimizer.

Bruce,

I'm getting the same here when testing your query.

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

OK, so we shouldn't be able to select a column called oid from
any view?

Keith.

#5Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Keith Parks (#4)
Re: [HACKERS] crash on new system views

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

OK, so we shouldn't be able to select a column called oid from
any view?

That's an interesting question. Do we disallow the query? Comments?

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
http://www.op.net/~candle              |  (610) 353-9879(w)
  +  If your life is a hard drive,     |  (610) 853-3000(h)
  +  Christ can be your backup.        |
#6The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#5)
Re: [HACKERS] crash on new system views

On Tue, 15 Sep 1998, Bruce Momjian wrote:

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

OK, so we shouldn't be able to select a column called oid from
any view?

That's an interesting question. Do we disallow the query? Comments?

It sounds reasonable to me...considering that any other query on a
table which references a field that doesn't exist fails...no?

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org

#7Andreas Zeugswetter
andreas.zeugswetter@telecom.at
In reply to: The Hermit Hacker (#6)
Re: [HACKERS] crash on new system views

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

OK, so we shouldn't be able to select a column called oid from
any view?

That's an interesting question. Do we disallow the query? Comments?

I guess it would be nice if views could show the original oid for all non join or single table views.

Andreas

#8The Hermit Hacker
scrappy@hub.org
In reply to: Andreas Zeugswetter (#7)
Re: [HACKERS] crash on new system views

On Wed, 16 Sep 1998, Andreas Zeugswetter wrote:

The odd (maybe not?) thing is that views appear to have
a NULL oid for all tuples.

This has always been the case. Views don't have oid.

OK, so we shouldn't be able to select a column called oid from
any view?

That's an interesting question. Do we disallow the query? Comments?

I guess it would be nice if views could show the original oid for all
non join or single table views.

IMHO, then the oid should be included as part of the view
definition itself...even on a join operation, having the OID might be
useful...consider a case where you have a join of two tables such that the
select is something like:

select a.oid,a.field,b.field where a.field=b.field;

Having a.oid means that later I can just do:

select * from <view> where oid = <oid#>;

But I think the person setting up the view should be the one
explicitly including the oid value, not the system "guessing"...

#9Andreas Zeugswetter
andreas.zeugswetter@telecom.at
In reply to: The Hermit Hacker (#8)
AW: [HACKERS] crash on new system views

I guess it would be nice if views could show the original oid for all
non join or single table views.

IMHO, then the oid should be included as part of the view
definition itself...even on a join operation, having the OID might be
useful...consider a case where you have a join of two tables such that the
select is something like:

select a.oid,a.field,b.field where a.field=b.field;

Having a.oid means that later I can just do:

select * from <view> where oid = <oid#>;

But I think the person setting up the view should be the one
explicitly including the oid value, not the system "guessing"...

While I perfectly understand your argument, I see a disadvantage, that the above
will show the oid column with the select * while on the original table the oid is hidden.

But besides:
regression=> create view tables as select oid, relname as tabname from pg_class;
ERROR: create: system attribute named "oid"

which is perfectly OK I think.

Andreas

#10Noname
jwieck@debis.com
In reply to: The Hermit Hacker (#8)
Re: [HACKERS] crash on new system views

IMHO, then the oid should be included as part of the view
definition itself...even on a join operation, having the OID might be
useful...consider a case where you have a join of two tables such that the
select is something like:

select a.oid,a.field,b.field where a.field=b.field;

Having a.oid means that later I can just do:

select * from <view> where oid = <oid#>;

But I think the person setting up the view should be the one
explicitly including the oid value, not the system "guessing"...

This is true. Especially if we look a bit ahead for functions
returning tuple sets, it might be possible in the future to
have a view that calls a functions to retrieve the data. But
this time all the data could be computed at runtime and there
is absolutely no OID the system can guess.

So if there should be one in another case, the creator of the
view must specify it. It must have a different name than oid
but I think this forces the creator to choose a name from
which the user can guess which oid it is in a join view.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #