Olá
Preciso aplicar um patch na versão 7.4.13 do Postgresql  e não
sei como fazer.
Sei que esta versão está ultrapassada, mas não posso mudar.  Compilar
o banco e instalar eu sei fazer,  mais nunca apliquei nenhum patch.
Alguem pode me explicar  como aplico o patch anexo? Desde já agradeço.

Obs: este patch peguei na lista de discussão pgsql-patches do site
postgresql.org.

[]' Wiliam
diff -Nacr postgresql-7.4.13-orig/contrib/Makefile postgresql-7.4.13/contrib/Makefile
*** postgresql-7.4.13-orig/contrib/Makefile	Thu Sep 11 19:15:27 2003
--- postgresql-7.4.13/contrib/Makefile	Thu Oct 12 12:50:21 2006
***************
*** 40,46 ****
  		tsearch		\
  		tsearch2	\
  		userlock	\
! 		vacuumlo
  
  # Missing:
  #		array		\ (removed all but the README)
--- 40,47 ----
  		tsearch		\
  		tsearch2	\
  		userlock	\
! 		vacuumlo \
! 		pg_advise
  
  # Missing:
  #		array		\ (removed all but the README)
diff -Nacr postgresql-7.4.13-orig/contrib/pg_advise/Makefile postgresql-7.4.13/contrib/pg_advise/Makefile
*** postgresql-7.4.13-orig/contrib/pg_advise/Makefile	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/contrib/pg_advise/Makefile	Thu Oct 12 12:49:58 2006
***************
*** 0 ****
--- 1,13 ----
+ subdir = contrib/pg_advise
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+ 
+ PROGRAM = pg_advise
+ OBJS = main.o indexinfo.o
+ 
+ PG_CPPFLAGS = -I$(libpq_srcdir)
+ PG_LIBS = $(libpq)
+ 
+ DOCS = README.pg_advise
+ 
+ include $(top_srcdir)/contrib/contrib-global.mk
diff -Nacr postgresql-7.4.13-orig/contrib/pg_advise/func.sql postgresql-7.4.13/contrib/pg_advise/func.sql
*** postgresql-7.4.13-orig/contrib/pg_advise/func.sql	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/contrib/pg_advise/func.sql	Thu Oct 12 12:49:58 2006
***************
*** 0 ****
--- 1,17 ----
+ create or replace function int2vector_to_string(int2vector) returns varchar as '
+ declare 
+ 	vec alias for $1;
+ 	i integer := 0;
+ 	s varchar := '''';
+ begin
+ 	for i in 0..31 loop
+ 		if vec[i] > 0 then
+ 			if i > 0 then
+ 				s := s || '','';
+ 			end if;
+ 			s := s || vec[i];
+ 		end if;
+ 	end loop;
+ 	return s;
+ end;
+ ' language plpgsql;
diff -Nacr postgresql-7.4.13-orig/contrib/pg_advise/indexinfo.c postgresql-7.4.13/contrib/pg_advise/indexinfo.c
*** postgresql-7.4.13-orig/contrib/pg_advise/indexinfo.c	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/contrib/pg_advise/indexinfo.c	Thu Oct 12 13:10:16 2006
***************
*** 0 ****
--- 1,98 ----
+ /*
+  *  indexinfo.c
+  *  pg_advise
+  *
+  */
+ 
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include "indexinfo.h"
+ 
+ long compute_config_size(IndexConfig conf, int num) {
+   long size = 0;
+   int i; 
+   
+   for (i = 0; i < num; i++)
+     size += conf[i]->size;
+   return size * 4;
+ }
+ 
+ void find_optimal_configuration_greedy(IndexConfig index_conf, int len, long size) {
+   long current_size = 0;
+   double sum_benefit = 0.0;
+   int i = 0;
+ 
+   while(current_size <= size && i < len) {
+     if (current_size + index_conf[i]->size <= size) {
+       index_conf[i]->used = 1;
+       sum_benefit += index_conf[i]->benefit;
+       current_size += index_conf[i]->size;
+       i++;
+     }
+   }
+ }
+ 
+ void find_optimal_configuration_dp(IndexConfig index_conf, int len, long size) {
+   int **cost;
+   int w, i;
+   
+   printf("w = %ld\n", size);
+   cost = (int **)malloc(sizeof(int) * (len + 1));
+   for (i = 0; i < len+1; i++)
+     cost[i] = (int *)malloc(sizeof(int *) * (size * 1));
+   for (w = 0; w <= size; w++)
+     cost[0][w] = 0;
+   for (i = 1; i <= len; i++) {
+     cost[i][0] = 0;
+     for (w = 1; w <= size; w++) {
+       if (index_conf[i-1]->size <= w) {
+ 	if (index_conf[i-1]->benefit + 
+ 	    cost[i-1][w - index_conf[i-1]->size] > cost[i-1][w]) {
+ 	  cost[i][w] = index_conf[i-1]->benefit + 
+ 	    cost[i-1][w - index_conf[i-1]->size];
+ 	}
+ 	else
+ 	  cost[i][w] = cost[i-1][w];
+       }
+       else
+ 	cost[i][w] = cost[i-1][w];
+       
+     }
+   }
+   
+   i = len; w = size;
+   while (i > 0 && w > 0) {
+     if (cost[i][w] == cost[i-1][w]) 
+       i--;
+     else {
+       index_conf[i-1]->used = 1;
+       w -= index_conf[i-1]->size;
+       i--;
+     }
+   }
+   /*
+     for (i = 0; i < len+1; i++)
+     free(cost[i]);
+     free(cost);
+   */
+ }
+ 
+ #if DEBUG
+ void test_optimize() {
+   IndexConfig conf = (IndexInfo **)malloc(3 * sizeof(IndexInfo *));
+   
+   conf[0] = (IndexInfo *)malloc(sizeof(IndexInfo));
+   conf[0]->benefit = 60;
+   conf[0]->size = 1;
+   conf[0]->used = 0;
+   conf[1] = (IndexInfo *)malloc(sizeof(IndexInfo));
+   conf[1]->benefit = 100;
+   conf[1]->size = 2;
+   conf[1]->used = 0;
+   conf[2] = (IndexInfo *)malloc(sizeof(IndexInfo));
+   conf[2]->benefit = 120;
+   conf[2]->size = 3;
+   conf[2]->used = 0;
+   optimize_indexset(conf, 3, 5);
+ }
+ #endif
diff -Nacr postgresql-7.4.13-orig/contrib/pg_advise/indexinfo.h postgresql-7.4.13/contrib/pg_advise/indexinfo.h
*** postgresql-7.4.13-orig/contrib/pg_advise/indexinfo.h	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/contrib/pg_advise/indexinfo.h	Thu Oct 12 13:09:24 2006
***************
*** 0 ****
--- 1,18 ----
+ #ifndef IndexInfo_h_
+ #define IndexInfo_h_
+ 
+ typedef struct {
+   char *table;
+   char *columns;
+   long size;
+   double benefit;
+   short used;
+ } IndexInfo;
+  
+ typedef IndexInfo** IndexConfig;
+ 
+ extern long compute_config_size(IndexConfig conf, int num);
+ extern void find_optimal_configuration_greedy(IndexConfig index_conf, int len, long size);
+ extern void find_optimal_configuration_dp(IndexConfig index_conf, int len, long size);
+ 
+ #endif
diff -Nacr postgresql-7.4.13-orig/contrib/pg_advise/main.c postgresql-7.4.13/contrib/pg_advise/main.c
*** postgresql-7.4.13-orig/contrib/pg_advise/main.c	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/contrib/pg_advise/main.c	Fri Oct 13 18:49:14 2006
***************
*** 0 ****
--- 1,356 ----
+ /*
+  * pg_advise: the frontend to the indexadvisor
+  *
+  * created by: Kai-Uwe Sattler
+  */
+ 
+ #include "libpq-fe.h"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+ 
+ #include "indexinfo.h"
+ 
+ PGconn *init_connection(const char *dbname, const char *host, int port, 
+ 			const char *user, const char *password) {
+   char conn_str[1024];
+   PGconn *conn;
+ 	
+   sprintf(conn_str, "dbname = %s host = %s port = %d user = %s password = %s", 
+ 	  dbname, host, port, user, password);
+   conn = PQconnectdb(conn_str);
+   if (PQstatus(conn) != CONNECTION_OK) {
+     fprintf(stderr, "%s", PQerrorMessage(conn));
+     return NULL;
+   }
+   return conn;
+ }
+ 
+ int prepare_advisor(PGconn *conn) {
+   PGresult *res;
+   
+   res = PQexec(conn, "SET enable_indexadvisor to 1");
+   if (res == NULL) {
+     fprintf(stderr, "%s", PQerrorMessage(conn));
+     return -1;
+   }
+   res = PQexec(conn, "DELETE FROM pg_indexadvisor");
+   if (res == NULL) {
+     fprintf(stderr, "%s", PQerrorMessage(conn));
+     return -1;
+ 	}
+   else
+     PQclear(res);
+   return 0;
+ }
+  
+ int analyse_workload(PGconn *conn, FILE *file) {
+   PGresult *res;
+   char *query = NULL;
+   char line[1024];
+   int lno = 1;
+   
+   fputs("Analyzing queries ", stderr);
+   
+   for(;;) {
+     if (fgets(line, 1024, file) == NULL)
+       break;
+     if (query == NULL) {
+       query = (char *)malloc(10000); 
+       strcpy(query, "EXPLAIN ");
+       strcat(query, line);
+     }
+     else {
+       if (strlen(query) + strlen(line) > 10000) {
+ 	fprintf(stderr, "Query string too long.\n");
+ 	return -1;
+       }
+       strcat(query, line);
+     }
+     if (strchr(query, ';') != NULL) {
+       // printf("query \#%d: %s\n", lno++, query);
+       res = PQexec(conn, query);
+       fputc('.', stderr);
+       if (res == NULL) {
+ 	fprintf(stderr, "%s", PQerrorMessage(conn));
+ 	return -1;
+       }
+       else
+ 	PQclear(res);
+       free(query); 
+       query = NULL;
+     }
+   }
+   fputs(" done.\n", stderr);
+   return 0;
+ }
+ 
+ int read_advisor_output(PGconn *conn, IndexConfig *index_conf) {
+   PGresult *res;
+   int i;
+   int num_indexes = 0;
+   IndexInfo *index;	
+  
+   res = PQexec(conn, "BEGIN");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+     fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return 0;
+   }
+   
+   res = PQexec(conn, "DECLARE myportal CURSOR FOR \
+ SELECT relname, int2vector_to_string(adviseattrs) AS attrids, \
+ MAX(idxsize) AS size, SUM(adviseprofit) AS benefit, \
+ SUM(adviseprofit)/MAX(idxsize) AS gain \
+ FROM pg_indexadvisor, pg_class \
+ WHERE advisetable = pg_class.oid GROUP BY relname, attrids \
+ ORDER BY gain DESC");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+     fprintf(stderr, "error: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return 0;
+   }
+   res = PQexec(conn, "FETCH ALL IN myportal");
+   if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+     fprintf(stderr, "error: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return 0;
+   }
+      
+   *index_conf = (IndexInfo **)malloc(PQntuples(res) * sizeof(IndexInfo *));
+   for (i = 0; i < PQntuples(res); i++) {
+     IndexInfo *index = (IndexInfo *)malloc(sizeof(IndexInfo));
+     
+     index->table = strdup(PQgetvalue(res, i, 0));
+     index->columns = strdup(PQgetvalue(res, i, 1)); 
+     index->size = atol(PQgetvalue(res, i, 2)) * 4;
+     index->benefit = atof(PQgetvalue(res, i, 3));
+     printf("size = %d, benefit = %f\n", index->size, index->benefit);
+     index->used = 0;
+     (*index_conf)[i] = index;
+     num_indexes++;
+   }
+   
+   res = PQexec(conn, "CLOSE myportal");
+   PQclear(res);
+   res = PQexec(conn, "END");
+   PQclear(res);
+   
+   return num_indexes;
+ }
+ 
+ char* get_column_names (PGconn *conn, const char *table, 
+ 			const char *column_ids) {
+   PGresult *res;
+   int i, len;
+   char stmt[500];
+   char *idxdef;
+   char *colnames[32];
+   
+   for (i = 0; i < 32; i++)
+     colnames[i] = NULL;
+   
+   res = PQexec(conn, "BEGIN");
+   if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+     fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return NULL;
+   }
+   
+   sprintf(stmt, "DECLARE myportal CURSOR FOR \
+ SELECT a.attname, a.attnum \
+ FROM pg_class c, pg_attribute a \
+ WHERE c.relname = '%s' AND a.attrelid = c.oid AND a.attnum = ANY (array[%s])",
+ table, column_ids);
+   res = PQexec(conn, stmt);
+   if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+     fprintf(stderr, "error: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return NULL;
+   }
+   res = PQexec(conn, "FETCH ALL IN myportal");
+   if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+     fprintf(stderr, "error: %s", PQerrorMessage(conn));
+     PQclear(res);
+     return NULL;
+   }
+   
+   for (i = 0; i < PQntuples(res); i++) {
+     char *aname = PQgetvalue(res, i, 0);
+     int anum = atol(PQgetvalue(res, i, 1)); 
+     colnames[anum-1] = strdup(aname);
+   }
+   
+   res = PQexec(conn, "CLOSE myportal");
+   PQclear(res);
+   res = PQexec(conn, "END");
+   PQclear(res);
+   
+   len = 0;
+   for (i = 0; i < 32; i++)
+     if (colnames[i]) {
+       len += strlen(colnames[i]);
+       if (i > 0) len += 1;
+     }
+   idxdef = (char *)malloc(len);
+   idxdef[0] = '\0';
+   for (i = 0; i < 32; i++) {
+     if (colnames[i]) {
+       if (strlen(idxdef) > 0) strcat(idxdef, ",");
+       strcat(idxdef, colnames[i]);
+       free(colnames[i]);
+     }
+   }
+   return idxdef;
+ }
+ 
+ void output_recommendation(PGconn *conn, IndexConfig index_conf, int len, 
+ 			   FILE *sqlfile) {
+   int i;
+   long size = 0;
+   for (i = 0; i < len; i++) {
+     IndexInfo *info = index_conf[i];
+     if (! info->used)
+       continue;
+     char *idxdef = get_column_names(conn, info->table, info->columns);
+     printf("%d. %s(%s): size=%dK, profit=%.2f\n", i+1, info->table, idxdef, 
+ 	   info->size * 4, info->benefit);
+     size += info->size;
+     if (sqlfile)
+       fprintf(sqlfile, "create index advidx_%d on %s (%s);\n", i+1, 
+ 	      info->table, idxdef);
+     free(idxdef);
+   }
+   printf("size = %ldKB\n", size * 4);
+ }
+ 
+ void usage() {
+   puts("This is pavdvise 0.1, the PostgreSQL index advisor.\n");
+   puts("Usage:\n\tpadvise [options] [workload file]\n");
+   puts("Options:");
+   puts("\t-d DBNAME   specify database name to connect to");
+   puts("\t-h HOSTNAME database server host or socket directory (default: \"local socket\")");
+   puts("\t-p PORT     database server port");
+   puts("\t-U NAME     database user name");
+   puts("\t-o FILENAME name of output file for create index statements");
+   puts("\t-s SIZE     specify max. size of space used for indexes (in bytes, opt. with G, M or k)");
+ 	
+   exit(-1);
+ }
+ 
+ long strtosize(const char *s) {
+   long size = 0;
+   char l = s[strlen(s) - 1];
+   if (l == 'G' || l == 'M' || l == 'k' || l == 'K') {
+     char *ns = (char *)malloc(strlen(s) - 1);
+     strncpy(ns, s, strlen(s) - 1);
+     size = atol(ns);
+     free(ns);
+   }
+   switch(l) {
+   case 'G':
+     size *= (1024 * 1024);
+     break;
+   case 'M':
+     size *= 1024;
+     break;
+   case 'k':
+   case 'K':
+     break;
+   default:
+     size /= 1024;
+   }
+   printf("poolsize = %ld KB\n", size);
+   return size;
+ }
+ 
+ int main (int argc, char **argv) {
+   char *dbname = NULL, *host = NULL, *user = NULL, *password = NULL;
+   int port = 5432;
+   PGconn *conn;	
+   long pool_size;
+   FILE *workload = stdin, *sqlfile = NULL;
+   IndexConfig index_conf;
+   int i, num_indexes;
+   char *output_filename = NULL;
+ 
+   // check arguments
+   int ch;
+   while ((ch = getopt(argc, argv, "d:h:p:U:s:o:W:")) != -1)
+     switch(ch) {
+     case 'd': /* database name */
+       dbname = optarg;
+       break;
+     case 'h': /* database server host */
+       host = optarg;
+       break;
+     case 'p': /* port */
+       port = atoi(optarg);
+       break;
+     case 'U': /* username */
+       user = optarg;
+       break;
+     case 's': /* index pool size */
+       pool_size = strtosize(optarg);
+       break;
+     case 'o': /* output file */
+       output_filename = optarg;
+       break;
+     case 'W': /* TODO: prompt for password */
+       break;
+     case '?':
+     default:
+       usage();
+     }
+ 		
+   if (dbname == NULL || user == NULL)
+     usage();
+ 		
+   argc -= optind;
+   argv += optind;
+ 
+   if (argc == 1) {
+     workload = fopen(argv[argc-1], "r");
+     fprintf(stderr, "load workload from file '%s'\n", argv[argc-1]);
+     if (workload == NULL) {
+       fprintf(stderr, "cannot open file %s\n", argv[argc-1]);
+       exit(-1);
+     }
+   }
+ 	
+   // connect to the backend
+   conn = init_connection(dbname, host, port, user, password);
+   if (conn == NULL)
+     exit(-1);
+ 
+   if (prepare_advisor(conn) == -1) {
+     fprintf(stderr, "Sorry: this PostgreSQL server doesn't support the index advisor.\n");
+     PQfinish(conn);
+     exit(-1); 
+   }
+ 	
+   analyse_workload(conn, workload);
+   if (workload != stdin)
+     fclose(workload);
+ 		
+   num_indexes = read_advisor_output(conn, &index_conf);
+   if (pool_size > 0 && 
+       compute_config_size(index_conf, num_indexes) > pool_size / 4)
+     find_optimal_configuration_greedy(index_conf, num_indexes, pool_size / 4); 
+   else {
+     for (i = 0; i < num_indexes; i++)
+       index_conf[i]->used = 1;
+   }
+   
+   if (output_filename != NULL)
+     sqlfile = fopen(output_filename, "w");
+   
+   output_recommendation(conn, index_conf, num_indexes, sqlfile);
+   
+   if (output_filename != NULL)
+     fclose(sqlfile);
+   
+   PQfinish(conn);
+   return 0;
+ }
diff -Nacr postgresql-7.4.13-orig/src/backend/Makefile postgresql-7.4.13/src/backend/Makefile
*** postgresql-7.4.13-orig/src/backend/Makefile	Fri Mar 21 18:18:34 2003
--- postgresql-7.4.13/src/backend/Makefile	Thu Oct 12 08:05:34 2006
***************
*** 14,20 ****
  
  DIRS := access bootstrap catalog parser commands executor lib libpq \
  	main nodes optimizer port postmaster regex rewrite \
! 	storage tcop utils
  
  OBJS := $(DIRS:%=%/SUBSYS.o)
  
--- 14,20 ----
  
  DIRS := access bootstrap catalog parser commands executor lib libpq \
  	main nodes optimizer port postmaster regex rewrite \
! 	storage tcop utils indexadvisor
  
  OBJS := $(DIRS:%=%/SUBSYS.o)
  
diff -Nacr postgresql-7.4.13-orig/src/backend/bootstrap/bootparse.y postgresql-7.4.13/src/backend/bootstrap/bootparse.y
*** postgresql-7.4.13-orig/src/backend/bootstrap/bootparse.y	Mon Aug  4 04:39:57 2003
--- postgresql-7.4.13/src/backend/bootstrap/bootparse.y	Thu Oct 12 08:32:34 2006
***************
*** 239,245 ****
  								LexIDStr($3),
  								LexIDStr($7),
  								$9,
! 								false, false, false, NULL, NIL);
  					do_end();
  				}
  		;
--- 239,245 ----
  								LexIDStr($3),
  								LexIDStr($7),
  								$9,
! 						    false, false, false, false, NULL, NIL);
  					do_end();
  				}
  		;
***************
*** 253,259 ****
  								LexIDStr($4),
  								LexIDStr($8),
  								$10,
! 								true, false, false, NULL, NIL);
  					do_end();
  				}
  		;
--- 253,259 ----
  								LexIDStr($4),
  								LexIDStr($8),
  								$10,
! 						    false, true, false, false, NULL, NIL);
  					do_end();
  				}
  		;
diff -Nacr postgresql-7.4.13-orig/src/backend/catalog/Makefile postgresql-7.4.13/src/backend/catalog/Makefile
*** postgresql-7.4.13-orig/src/backend/catalog/Makefile	Fri Aug  1 18:12:32 2003
--- postgresql-7.4.13/src/backend/catalog/Makefile	Thu Oct 12 09:05:40 2006
***************
*** 32,38 ****
  	pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
  	pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
  	pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \
! 	pg_depend.h indexing.h \
      )
  
  pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)
--- 32,38 ----
  	pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
  	pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
  	pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \
! 	pg_depend.h pg_indexadvisor.h indexing.h \
      )
  
  pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)
diff -Nacr postgresql-7.4.13-orig/src/backend/commands/explain.c postgresql-7.4.13/src/backend/commands/explain.c
*** postgresql-7.4.13-orig/src/backend/commands/explain.c	Mon Dec 13 01:17:52 2004
--- postgresql-7.4.13/src/backend/commands/explain.c	Thu Oct 12 08:25:13 2006
***************
*** 31,36 ****
--- 31,37 ----
  #include "utils/builtins.h"
  #include "utils/guc.h"
  #include "utils/lsyscache.h"
+ #include "indexadvisor/indexadvisor.h"
  
  
  typedef struct ExplainState
***************
*** 185,190 ****
--- 186,197 ----
  		}
  	}
  
+ 	if (enable_indexadvisor && enable_indexadvisor_explainmode) {
+ 
+ 		indexadvisor(query, false);
+ 		elog(INFO, "EXPLAIN-MODE: indexadvisor");
+ 	}
+ 
  	/* plan the query */
  	plan = planner(query, isCursor, cursorOptions);
  
diff -Nacr postgresql-7.4.13-orig/src/backend/commands/indexcmds.c postgresql-7.4.13/src/backend/commands/indexcmds.c
*** postgresql-7.4.13-orig/src/backend/commands/indexcmds.c	Thu Oct  2 08:34:03 2003
--- postgresql-7.4.13/src/backend/commands/indexcmds.c	Thu Oct 12 08:33:51 2006
***************
*** 49,55 ****
  				  char *accessMethodName, Oid accessMethodId);
  static Oid GetIndexOpClass(List *opclass, Oid attrType,
  				char *accessMethodName, Oid accessMethodId);
! static Oid	GetDefaultOpClass(Oid attrType, Oid accessMethodId);
  
  /*
   * DefineIndex
--- 49,55 ----
  				  char *accessMethodName, Oid accessMethodId);
  static Oid GetIndexOpClass(List *opclass, Oid attrType,
  				char *accessMethodName, Oid accessMethodId);
! // static Oid	GetDefaultOpClass(Oid attrType, Oid accessMethodId);
  
  /*
   * DefineIndex
***************
*** 65,70 ****
--- 65,71 ----
  			char *indexRelationName,
  			char *accessMethodName,
  			List *attributeList,
+ 	                bool virtual, /* create only a virtual index */
  			bool unique,
  			bool primary,
  			bool isconstraint,
***************
*** 245,250 ****
--- 246,252 ----
  	indexInfo->ii_ExpressionsState = NIL;
  	indexInfo->ii_Predicate = cnfPred;
  	indexInfo->ii_PredicateState = NIL;
+ 	indexInfo->ii_Virtual = virtual;
  	indexInfo->ii_Unique = unique;
  
  	classObjectId = (Oid *) palloc(numberOfAttributes * sizeof(Oid));
***************
*** 499,505 ****
  	return opClassId;
  }
  
! static Oid
  GetDefaultOpClass(Oid attrType, Oid accessMethodId)
  {
  	OpclassCandidateList opclass;
--- 501,507 ----
  	return opClassId;
  }
  
! Oid
  GetDefaultOpClass(Oid attrType, Oid accessMethodId)
  {
  	OpclassCandidateList opclass;
diff -Nacr postgresql-7.4.13-orig/src/backend/indexadvisor/Makefile postgresql-7.4.13/src/backend/indexadvisor/Makefile
*** postgresql-7.4.13-orig/src/backend/indexadvisor/Makefile	Thu Jan  1 01:00:00 1970
--- postgresql-7.4.13/src/backend/indexadvisor/Makefile	Thu Oct 12 08:04:35 2006
***************
*** 0 ****
--- 1,28 ----
+ #-------------------------------------------------------------------------
+ #
+ # Makefile--
+ #    Makefile for indexadvisor
+ #
+ #
+ #-------------------------------------------------------------------------
+ 
+ subdir = src/backend/indexadvisor
+ top_builddir = ../../..
+ include $(top_builddir)/src/Makefile.global
+ 
+ OBJS = indexadvisor.o
+ 
+ all: SUBSYS.o
+ 
+ SUBSYS.o: $(OBJS)
+ 	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
+ 
+ depend dep:
+ 	$(CC) -MM $(CFLAGS) *.c >depend
+ 
+ clean:
+ 	rm -f SUBSYS.o $(OBJS)
+ 
+ ifeq (depend,$(wildcard depend))
+ include depend
+ endif





*****************************        C   O   N   T   I   N  U   A    .   .   .





************************* retirei o resto do PATCH porque senão nao daria para mandar na lista de discussão devido ao tamanho máximo permitido ultrapassar o limite estipulado. **************************************************************************************


_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a