Remove columns pg_index.haskeytype and pg_index.indisclustered
Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
I have removed pg_index.haskeytype and pg_index.indisclustered with the
following patch. They were not used.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: src/backend/access/gist/gist.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/gist/gist.c,v
retrieving revision 1.73
diff -c -r1.73 gist.c
*** src/backend/access/gist/gist.c 2001/05/07 00:43:15 1.73
--- src/backend/access/gist/gist.c 2001/05/14 21:50:12
***************
*** 1127,1133 ****
elog(ERROR, "initGISTstate: index %u not found",
RelationGetRelid(index));
itupform = (Form_pg_index) GETSTRUCT(htup);
- giststate->haskeytype = itupform->indhaskeytype;
indexrelid = itupform->indexrelid;
ReleaseSysCache(htup);
--- 1127,1132 ----
Index: src/backend/catalog/index.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/index.c,v
retrieving revision 1.146
diff -c -r1.146 index.c
*** src/backend/catalog/index.c 2001/05/07 00:43:17 1.146
--- src/backend/catalog/index.c 2001/05/14 21:50:13
***************
*** 587,595 ****
indexForm->indexrelid = indexoid;
indexForm->indrelid = heapoid;
indexForm->indproc = indexInfo->ii_FuncOid;
- indexForm->indisclustered = false;
indexForm->indislossy = islossy;
- indexForm->indhaskeytype = true; /* not actually used anymore */
indexForm->indisunique = indexInfo->ii_Unique;
indexForm->indisprimary = primary;
memcpy((char *) &indexForm->indpred, (char *) predText, predLen);
--- 587,593 ----
Index: src/backend/utils/cache/relcache.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/cache/relcache.c,v
retrieving revision 1.132
diff -c -r1.132 relcache.c
*** src/backend/utils/cache/relcache.c 2001/05/14 20:30:20 1.132
--- src/backend/utils/cache/relcache.c 2001/05/14 21:50:15
***************
*** 70,76 ****
static FormData_pg_attribute Desc_pg_attribute[Natts_pg_attribute] = {Schema_pg_attribute};
static FormData_pg_attribute Desc_pg_proc[Natts_pg_proc] = {Schema_pg_proc};
static FormData_pg_attribute Desc_pg_type[Natts_pg_type] = {Schema_pg_type};
- static FormData_pg_attribute Desc_pg_variable[Natts_pg_variable] = {Schema_pg_variable};
static FormData_pg_attribute Desc_pg_log[Natts_pg_log] = {Schema_pg_log};
/*
--- 70,75 ----
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/catversion.h,v
retrieving revision 1.73
diff -c -r1.73 catversion.h
*** src/include/catalog/catversion.h 2001/05/14 20:30:21 1.73
--- src/include/catalog/catversion.h 2001/05/14 21:50:16
***************
*** 53,58 ****
*/
/* yyyymmddN */
! #define CATALOG_VERSION_NO 2001051401
#endif
--- 53,58 ----
*/
/* yyyymmddN */
! #define CATALOG_VERSION_NO 2001051402
#endif
Index: src/include/catalog/pg_index.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_index.h,v
retrieving revision 1.16
diff -c -r1.16 pg_index.h
*** src/include/catalog/pg_index.h 2001/01/24 19:43:21 1.16
--- src/include/catalog/pg_index.h 2001/05/14 21:50:16
***************
*** 48,54 ****
* index */
int2vector indkey;
oidvector indclass;
- bool indisclustered;
bool indislossy; /* do we fetch false tuples (lossy
* compression)? */
bool indhaskeytype; /* does key type != attribute type? */
--- 48,53 ----
***************
*** 70,87 ****
* compiler constants for pg_index
* ----------------
*/
! #define Natts_pg_index 12
#define Anum_pg_index_indexrelid 1
#define Anum_pg_index_indrelid 2
#define Anum_pg_index_indproc 3
#define Anum_pg_index_indkey 4
#define Anum_pg_index_indclass 5
! #define Anum_pg_index_indisclustered 6
! #define Anum_pg_index_indislossy 7
! #define Anum_pg_index_indhaskeytype 8
! #define Anum_pg_index_indisunique 9
! #define Anum_pg_index_indisprimary 10
! #define Anum_pg_index_indreference 11
! #define Anum_pg_index_indpred 12
#endif /* PG_INDEX_H */
--- 69,84 ----
* compiler constants for pg_index
* ----------------
*/
! #define Natts_pg_index 10
#define Anum_pg_index_indexrelid 1
#define Anum_pg_index_indrelid 2
#define Anum_pg_index_indproc 3
#define Anum_pg_index_indkey 4
#define Anum_pg_index_indclass 5
! #define Anum_pg_index_indislossy 6
! #define Anum_pg_index_indisunique 7
! #define Anum_pg_index_indisprimary 8
! #define Anum_pg_index_indreference 9
! #define Anum_pg_index_indpred 10
#endif /* PG_INDEX_H */
Index: src/interfaces/odbc/info.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/info.c,v
retrieving revision 1.46
diff -c -r1.46 info.c
*** src/interfaces/odbc/info.c 2001/05/08 17:12:36 1.46
--- src/interfaces/odbc/info.c 2001/05/14 21:50:20
***************
*** 2009,2016 ****
char *table_name;
char index_name[MAX_INFO_STRING];
short fields_vector[16];
! char isunique[10],
! isclustered[10];
SDWORD index_name_len,
fields_vector_len;
TupleNode *row;
--- 2009,2015 ----
char *table_name;
char index_name[MAX_INFO_STRING];
short fields_vector[16];
! char isunique[10];
SDWORD index_name_len,
fields_vector_len;
TupleNode *row;
***************
*** 2170,2176 ****
indx_stmt = (StatementClass *) hindx_stmt;
sprintf(index_query, "select c.relname, i.indkey, i.indisunique"
! ", i.indisclustered, c.relhasrules"
" from pg_index i, pg_class c, pg_class d"
" where c.oid = i.indexrelid and d.relname = '%s'"
" and d.oid = i.indrelid", table_name);
--- 2169,2175 ----
indx_stmt = (StatementClass *) hindx_stmt;
sprintf(index_query, "select c.relname, i.indkey, i.indisunique"
! ", c.relhasrules"
" from pg_index i, pg_class c, pg_class d"
" where c.oid = i.indexrelid and d.relname = '%s'"
" and d.oid = i.indrelid", table_name);
***************
*** 2178,2184 ****
result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query));
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
-
/*
* "Couldn't execute index query (w/SQLExecDirect) in
* SQLStatistics.";
--- 2177,2182 ----
***************
*** 2226,2245 ****
goto SEEYA;
}
- /* bind the "is clustered" column */
result = SQLBindCol(hindx_stmt, 4, SQL_C_CHAR,
- isclustered, sizeof(isclustered), NULL);
- if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
- {
- stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column
- * in SQLStatistics."; */
- stmt->errornumber = indx_stmt->errornumber;
- SQLFreeStmt(hindx_stmt, SQL_DROP);
- goto SEEYA;
-
- }
-
- result = SQLBindCol(hindx_stmt, 5, SQL_C_CHAR,
relhasrules, MAX_INFO_STRING, NULL);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
--- 2224,2230 ----
***************
*** 2270,2279 ****
sprintf(buf, "%s_idx_fake_oid", table_name);
set_tuplefield_string(&row->tuple[5], buf);
- /*
- * Clustered index? I think non-clustered should be type OTHER
- * not HASHED
- */
set_tuplefield_int2(&row->tuple[6], (Int2) SQL_INDEX_OTHER);
set_tuplefield_int2(&row->tuple[7], (Int2) 1);
--- 2255,2260 ----
***************
*** 2316,2326 ****
set_tuplefield_string(&row->tuple[4], "");
set_tuplefield_string(&row->tuple[5], index_name);
! /*
! * Clustered index? I think non-clustered should be type
! * OTHER not HASHED
! */
! set_tuplefield_int2(&row->tuple[6], (Int2) (atoi(isclustered) ? SQL_INDEX_CLUSTERED : SQL_INDEX_OTHER));
set_tuplefield_int2(&row->tuple[7], (Int2) (i + 1));
if (fields_vector[i] == OID_ATTNUM)
--- 2297,2303 ----
set_tuplefield_string(&row->tuple[4], "");
set_tuplefield_string(&row->tuple[5], index_name);
! set_tuplefield_int2(&row->tuple[6], (Int2) SQL_INDEX_OTHER);
set_tuplefield_int2(&row->tuple[7], (Int2) (i + 1));
if (fields_vector[i] == OID_ATTNUM)
Re: Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: > I have removed pg_index.haskeytype and pg_index.indisclustered with the > following patch. They were not used. haskeytype IS used, by GIST. Kindly revert this entire patch. regards, tom lane
Re: Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Bruce Momjian writes: > > I have removed pg_index.haskeytype and pg_index.indisclustered with the > > following patch. They were not used. > > haskeytype IS used, by GIST. Kindly revert this entire patch. Fixing now. Thanks. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> > Bruce Momjian writes: > > > I have removed pg_index.haskeytype and pg_index.indisclustered with the > > > following patch. They were not used. > > > > haskeytype IS used, by GIST. Kindly revert this entire patch. > > Fixing now. Thanks. Patch applied. Field re-added. (I removed it incorrectly anyway.) What threw me off is that there was a comment saying the field was not used. How does GIST set this field? Does GIST insert directly into pg_index? I don't see this field set anywhere except to 'true'. Here are the references I see from the 7.1.X code: ./backend/access/gist/gist.c: giststate->haskeytype = itupform->indhaskeytype; ./backend/access/gist/gist.c: if (giststate->haskeytype) ./backend/access/gist/gist.c: if (giststate->haskeytype) ./backend/access/gist/gist.c: if (giststate->haskeytype) ./backend/catalog/index.c: indexForm->indhaskeytype = true; /* not actually used anymore */ ./include/access/gist.h: bool haskeytype; ./include/catalog/pg_index.h: * first variable length field. so I moved indislossy, indhaskeytype, ./include/catalog/pg_index.h: bool indhaskeytype; /* does key type != attribute type? */ ./include/catalog/pg_index.h:#define Anum_pg_index_indhaskeytype 8 -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: src/backend/access/gist/gist.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/gist/gist.c,v retrieving revision 1.74 diff -c -r1.74 gist.c *** src/backend/access/gist/gist.c 2001/05/14 21:53:16 1.74 --- src/backend/access/gist/gist.c 2001/05/15 03:36:59 *************** *** 1127,1132 **** --- 1127,1133 ---- elog(ERROR, "initGISTstate: index %u not found", RelationGetRelid(index)); itupform = (Form_pg_index) GETSTRUCT(htup); + giststate->haskeytype = itupform->indhaskeytype; indexrelid = itupform->indexrelid; ReleaseSysCache(htup); Index: src/backend/catalog/index.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/index.c,v retrieving revision 1.148 diff -c -r1.148 index.c *** src/backend/catalog/index.c 2001/05/15 01:12:58 1.148 --- src/backend/catalog/index.c 2001/05/15 03:37:01 *************** *** 589,594 **** --- 589,595 ---- indexForm->indproc = indexInfo->ii_FuncOid; indexForm->indisclustered = false; /* not used */ indexForm->indislossy = islossy; + indexForm->indhaskeytype = true; /* used by GIST */ indexForm->indisunique = indexInfo->ii_Unique; indexForm->indisprimary = primary; memcpy((char *) &indexForm->indpred, (char *) predText, predLen); Index: src/include/catalog/catversion.h =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/catversion.h,v retrieving revision 1.77 diff -c -r1.77 catversion.h *** src/include/catalog/catversion.h 2001/05/15 01:12:59 1.77 --- src/include/catalog/catversion.h 2001/05/15 03:37:02 *************** *** 53,58 **** */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 200105144 #endif --- 53,58 ---- */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 200105145 #endif Index: src/include/catalog/pg_index.h =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_index.h,v retrieving revision 1.18 diff -c -r1.18 pg_index.h *** src/include/catalog/pg_index.h 2001/05/15 01:12:59 1.18 --- src/include/catalog/pg_index.h 2001/05/15 03:37:02 *************** *** 73,79 **** * compiler constants for pg_index * ---------------- */ ! #define Natts_pg_index 11 #define Anum_pg_index_indexrelid 1 #define Anum_pg_index_indrelid 2 #define Anum_pg_index_indproc 3 --- 73,79 ---- * compiler constants for pg_index * ---------------- */ ! #define Natts_pg_index 12 #define Anum_pg_index_indexrelid 1 #define Anum_pg_index_indrelid 2 #define Anum_pg_index_indproc 3 *************** *** 81,89 **** #define Anum_pg_index_indclass 5 #define Anum_pg_index_indisclustered 6 #define Anum_pg_index_indislossy 7 ! #define Anum_pg_index_indisunique 8 ! #define Anum_pg_index_indisprimary 9 ! #define Anum_pg_index_indreference 10 ! #define Anum_pg_index_indpred 11 #endif /* PG_INDEX_H */ --- 81,90 ---- #define Anum_pg_index_indclass 5 #define Anum_pg_index_indisclustered 6 #define Anum_pg_index_indislossy 7 ! #define Anum_pg_index_indhaskeytype 8 ! #define Anum_pg_index_indisunique 9 ! #define Anum_pg_index_indisprimary 10 ! #define Anum_pg_index_indreference 11 ! #define Anum_pg_index_indpred 12 #endif /* PG_INDEX_H */
Re: Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: > How does GIST set this field? I didn't say GIST *set* it, I said GIST *used* it --- and your patch would've changed GIST's behavior. Perhaps the field is not really necessary, but some detailed analysis would be required to establish that. I'm not very clear on what GIST is doing with it. regards, tom lane
Re: Remove columns pg_index.haskeytype and pg_index.indisclustered
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Bruce Momjian writes: > > How does GIST set this field? > > I didn't say GIST *set* it, I said GIST *used* it --- and your patch > would've changed GIST's behavior. > > Perhaps the field is not really necessary, but some detailed analysis > would be required to establish that. I'm not very clear on what GIST > is doing with it. Nor am I. GIST folks? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026