oid8types() borken?

Started by Christopher Oliverover 27 years ago5 messages
#1Christopher Oliver
oliver@fritz.traverse.net

The query generated by \df causes the backend to fail in oid8types.

The simplest illustration I found was:

SELECT oid8types(proargtypes) FROM pg_proc;

It appears that oid8types() originally expected an array of pointers
to oid8, but now it gets the base of an array of oid8. The following
seems to fix things for me in today's snapshot. Any comments?

--- include/utils/builtins.h	1998/09/18 03:25:18	1.1
+++ include/utils/builtins.h	1998/09/18 03:25:47
@@ -358,7 +358,7 @@
 /* regproc.c */
 extern int32 regprocin(char *pro_name_and_oid);
 extern char *regprocout(RegProcedure proid);
-extern text *oid8types(Oid **oidArray); 
+extern text *oid8types(Oid *oidArray); 
 extern Oid	regproctooid(RegProcedure rp);
 /* define macro to replace mixed-case function call - tgl 97/04/27 */
--- backend/utils/adt/regproc.c	1998/09/18 02:25:19	1.1
+++ backend/utils/adt/regproc.c	1998/09/18 03:23:19
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /home/staff/oliver/lab/pgsql/src/backend/utils/adt/regproc.c,v 1.1 1998/09/18 02:25:19 oliver Exp oliver $
+ *	  $Header: /usr/local/cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.26 1998/09/01 04:32:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -211,7 +211,7 @@
  *		int8typeout			- converts int8 type oids to "typname" list
  */
 text *
-oid8types(Oid **oidArray)
+oid8types(Oid *oidArray)
 {
 	HeapTuple	typetup;
 	text	   *result;
@@ -228,7 +228,7 @@
 	result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ);
 	*VARDATA(result) = '\0';

- sp = *oidArray;
+ sp = oidArray;
for (num = 8; num != 0; num--, sp++)
{
if (*sp != InvalidOid)

--
Christopher Oliver Traverse Internet
Systems Coordinator 223 Grandview Pkwy, Suite 108
oliver@traverse.net Traverse City, Michigan, 49684
"What good is a can of worms if you never open it?" -Bob Arning

#2Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Christopher Oliver (#1)
Re: [HACKERS] oid8types() borken?

Fixed. The actual fix is to change:

oid8types(Oid **oidArray)

to:

oid8types(Oid (*oidArray)[])

Can someone explain what this is? This is the old 6.3 code, and forgot
to reverse back this part when I realized my change to **oidArray did
not work.

The query generated by \df causes the backend to fail in oid8types.

The simplest illustration I found was:

SELECT oid8types(proargtypes) FROM pg_proc;

It appears that oid8types() originally expected an array of pointers
to oid8, but now it gets the base of an array of oid8. The following
seems to fix things for me in today's snapshot. Any comments?

--- include/utils/builtins.h	1998/09/18 03:25:18	1.1
+++ include/utils/builtins.h	1998/09/18 03:25:47
@@ -358,7 +358,7 @@
/* regproc.c */
extern int32 regprocin(char *pro_name_and_oid);
extern char *regprocout(RegProcedure proid);
-extern text *oid8types(Oid **oidArray); 
+extern text *oid8types(Oid *oidArray); 
extern Oid	regproctooid(RegProcedure rp);
/* define macro to replace mixed-case function call - tgl 97/04/27 */
--- backend/utils/adt/regproc.c	1998/09/18 02:25:19	1.1
+++ backend/utils/adt/regproc.c	1998/09/18 03:23:19
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- *	  $Header: /home/staff/oliver/lab/pgsql/src/backend/utils/adt/regproc.c,v 1.1 1998/09/18 02:25:19 oliver Exp oliver $
+ *	  $Header: /usr/local/cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.26 1998/09/01 04:32:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -211,7 +211,7 @@
*		int8typeout			- converts int8 type oids to "typname" list
*/
text *
-oid8types(Oid **oidArray)
+oid8types(Oid *oidArray)
{
HeapTuple	typetup;
text	   *result;
@@ -228,7 +228,7 @@
result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ);
*VARDATA(result) = '\0';

- sp = *oidArray;
+ sp = oidArray;
for (num = 8; num != 0; num--, sp++)
{
if (*sp != InvalidOid)

--
Christopher Oliver Traverse Internet
Systems Coordinator 223 Grandview Pkwy, Suite 108
oliver@traverse.net Traverse City, Michigan, 49684
"What good is a can of worms if you never open it?" -Bob Arning

-- 
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.        |
#3Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Bruce Momjian (#2)
Re: [HACKERS] oid8types() borken?

Also, I checked through the example given by the Russian contributor:

create table t0 (a_id int4 not null, a varchar, a_t1_id int4);
insert into t0 values (1, 'at0', 0);
insert into t0 values (2, 'at0', 0);
create index a_id_t0 on t0 (a_id);
create index a_t1_id_t0 on t0 (a_t1_id);
select * from t0 where (a_id = 1 or a_id = 2) and a_t1_id < 1;

This is crashing in optimizer/util/ordering.c at line 57 trying to
compute path_ordering1->ord.merge->left_operator because the merge
field in ord is NULL. No suggestions; this is deeper in the guts
than I'm qualified to hack just now. ;-)

OK, fixed. There were cases where the ordtype was defaulting to
MERGE_ORDER, while it should have been SORTOP_ORDER. Hence, the
mergejoin fields where being reference when they should not have been.

Your supplied query now works.

-- 
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.        |
#4Noname
t-ishii@sra.co.jp
In reply to: Bruce Momjian (#2)
Re: [HACKERS] oid8types() borken?

At 0:47 AM 98.9.18 -0400, Bruce Momjian wrote:

Fixed. The actual fix is to change:

oid8types(Oid **oidArray)

to:

oid8types(Oid (*oidArray)[])

Can someone explain what this is? This is the old 6.3 code, and forgot
to reverse back this part when I realized my change to **oidArray did
not work.

Oid **oidArray and (Oid (*oidArray)[] are quite different.
The latter is a pointer to Oid array. Sample code for a caller might
be:

Oid oids[8];
:
:
oid8types(&oids);

&oids is actually same as oids or &oids[0]. Interesting but just
waste of time IMHO.
You will see oidArray and *oidArray shows same value in oid8types().

Seems just

oid8types(Oid *oidArray)
or
oid8types(Oid oidArray[])

are simpler and more effective.

--
Tatsuo Ishii
t-ishii@sra.co.jp

#5Bruce Momjian
maillist@candle.pha.pa.us
In reply to: Noname (#4)
Re: [HACKERS] oid8types() borken?

At 0:47 AM 98.9.18 -0400, Bruce Momjian wrote:

Fixed. The actual fix is to change:

oid8types(Oid **oidArray)

to:

oid8types(Oid (*oidArray)[])

Can someone explain what this is? This is the old 6.3 code, and forgot
to reverse back this part when I realized my change to **oidArray did
not work.

Oid **oidArray and (Oid (*oidArray)[] are quite different.
The latter is a pointer to Oid array. Sample code for a caller might
be:

Oid oids[8];
:
:
oid8types(&oids);

&oids is actually same as oids or &oids[0]. Interesting but just
waste of time IMHO.

Yes, I have seen people do this, and it is a waste.

You will see oidArray and *oidArray shows same value in oid8types().

Seems just

oid8types(Oid *oidArray)
or
oid8types(Oid oidArray[])

are simpler and more effective.

Ah, I see now, just a confusion of adding meaningless []. I am applying
the cleanup now. Thanks.

-- 
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.        |