RE: System indexes are never unique indexes( was RE: [HACKERS] mdnblocksis

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Bruce Momjian" <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: System indexes are never unique indexes( was RE: [HACKERS] mdnblocksis
Date: 1999-10-27 09:45:49
Message-ID: 000401bf2060$0d08e820$2801007e@cadzone.tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> >
> > Anyway,I want to change the implementation of mdcreate() to reuse
> > existent files but the uniqueness of table name is preserved by the
> > current implementation narrowly.
> >
> > First of all,I would change pg_type,pg_class.
> > It's OK ?
>
> Sure.
>

I made a patch.
But I'm not sure my solution is right.
Is there a better way ?

Regards.

Hiroshi Inoue
Inoue(at)tpf(dot)co(dot)jp

*** ../../head/pgcurrent/backend/bootstrap/bootscanner.l Tue Sep 14
12:17:34 1999
--- backend/bootstrap/bootscanner.l Tue Oct 26 23:36:08 1999
***************
*** 90,95 ****
--- 90,96 ----
"declare" { return(XDECLARE); }
"build" { return(XBUILD); }
"indices" { return(INDICES); }
+ "unique" { return(UNIQUE); }
"index" { return(INDEX); }
"on" { return(ON); }
"using" { return(USING); }
*** ../../head/pgcurrent/backend/bootstrap/bootparse.y Mon Jul 26 12:44:44
1999
--- backend/bootstrap/bootparse.y Tue Oct 26 23:47:20 1999
***************
*** 80,86 ****
%token <ival> CONST ID
%token OPEN XCLOSE XCREATE INSERT_TUPLE
%token STRING XDEFINE
! %token XDECLARE INDEX ON USING XBUILD INDICES
%token COMMA EQUALS LPAREN RPAREN
%token OBJ_ID XBOOTSTRAP NULLVAL
%start TopLevel
--- 80,86 ----
%token <ival> CONST ID
%token OPEN XCLOSE XCREATE INSERT_TUPLE
%token STRING XDEFINE
! %token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE
%token COMMA EQUALS LPAREN RPAREN
%token OBJ_ID XBOOTSTRAP NULLVAL
%start TopLevel
***************
*** 106,111 ****
--- 106,112 ----
| Boot_CreateStmt
| Boot_InsertStmt
| Boot_DeclareIndexStmt
+ | Boot_DeclareUniqueIndexStmt
| Boot_BuildIndsStmt
;

***************
*** 226,231 ****
--- 227,245 ----
LexIDStr($3),
LexIDStr($7),
$9, NIL, 0, 0, 0, NIL);
+ DO_END;
+ }
+ ;
+
+ Boot_DeclareUniqueIndexStmt:
+ XDECLARE UNIQUE INDEX boot_ident ON boot_ident USING boot_ident
LPAREN boot_index_params RPAREN
+ {
+ DO_START;
+
+ DefineIndex(LexIDStr($6),
+ LexIDStr($4),
+ LexIDStr($8),
+ $10, NIL, 1, 0, 0, NIL);
DO_END;
}
;
*** ../../head/pgcurrent/backend/catalog/genbki.sh.in Mon Jul 26 12:44:44
1999
--- backend/catalog/genbki.sh.in Tue Oct 26 22:03:43 1999
***************
*** 164,169 ****
--- 164,183 ----
print "declare index " data
}

+ /^DECLARE_UNIQUE_INDEX\(/ {
+ # ----
+ # end any prior catalog data insertions before starting a define unique
index
+ # ----
+ if (reln_open == 1) {
+ # print "show";
+ print "close " catalog;
+ reln_open = 0;
+ }
+
+ data = substr($0, 22, length($0) - 22);
+ print "declare unique index " data
+ }
+
/^BUILD_INDICES/ { print "build indices"; }

# ----------------
*** ../../head/pgcurrent/include/postgres.h Mon Oct 25 22:13:13 1999
--- include/postgres.h Tue Oct 26 21:45:27 1999
***************
*** 138,143 ****
--- 138,144 ----
#define DATA(x) extern int errno
#define DESCR(x) extern int errno
#define DECLARE_INDEX(x) extern int errno
+ #define DECLARE_UNIQUE_INDEX(x) extern int errno

#define BUILD_INDICES
#define BOOTSTRAP
*** ../../head/pgcurrent/include/catalog/indexing.h Mon Oct 4 14:25:34
1999
--- include/catalog/indexing.h Tue Oct 26 21:47:24 1999
***************
*** 102,112 ****
DECLARE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
DECLARE_INDEX(pg_proc_proname_narg_type_index on pg_proc using
btree(proname name_ops, pronargs int2_ops, proargtypes oid8_ops));

! DECLARE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops));
! DECLARE_INDEX(pg_type_typname_index on pg_type using btree(typname
name_ops));

! DECLARE_INDEX(pg_class_oid_index on pg_class using btree(oid oid_ops));
! DECLARE_INDEX(pg_class_relname_index on pg_class using btree(relname
name_ops));

DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid
oid_ops));

--- 102,112 ----
DECLARE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
DECLARE_INDEX(pg_proc_proname_narg_type_index on pg_proc using
btree(proname name_ops, pronargs int2_ops, proargtypes oid8_ops));

! DECLARE_UNIQUE_INDEX(pg_type_oid_index on pg_type using btree(oid
oid_ops));
! DECLARE_UNIQUE_INDEX(pg_type_typname_index on pg_type using btree(typname
name_ops));

! DECLARE_UNIQUE_INDEX(pg_class_oid_index on pg_class using btree(oid
oid_ops));
! DECLARE_UNIQUE_INDEX(pg_class_relname_index on pg_class using
btree(relname name_ops));

DECLARE_INDEX(pg_attrdef_adrelid_index on pg_attrdef using btree(adrelid
oid_ops));

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zakkr 1999-10-27 10:37:44 Bug(?) in pg_get_ruledef()
Previous Message Bruce Momjian 1999-10-27 01:24:57 Re: System indexes are never unique indexes( was RE: [HACKERS] mdnblocksis