diff -c -r postgresql-snapshot-20020121_orig/src/backend/parser/parse_func.c postgresql-snapshot-20020121_patch/src/backend/parser/parse_func.c
*** postgresql-snapshot-20020121_orig/src/backend/parser/parse_func.c	Wed Dec 12 04:28:49 2001
--- postgresql-snapshot-20020121_patch/src/backend/parser/parse_func.c	Tue Jan 22 09:29:14 2002
***************
*** 12,18 ****
   *
   *-------------------------------------------------------------------------
   */
! 
  #include "postgres.h"
  
  #include "access/genam.h"
--- 12,18 ----
   *
   *-------------------------------------------------------------------------
   */
! #include<ctype.h> // giuseppe
  #include "postgres.h"
  
  #include "access/genam.h"
***************
*** 144,149 ****
--- 144,159 ----
  	Oid			toid = InvalidOid;
  	Expr	   *expr;
  
+ { // giuseppe
+ 	int i;
+ 	int l;
+ 
+ 	l = strlen(funcname);
+ 	for (i=0; i < l; i++)
+ 		if (isupper(funcname[i]))
+ 			funcname[i] = tolower(funcname[i]);
+ }
+ 
  	/*
  	 * Most of the rest of the parser just assumes that functions do not
  	 * have more than FUNC_MAX_ARGS parameters.  We have to test here to
diff -c -r postgresql-snapshot-20020121_orig/src/backend/parser/parse_relation.c postgresql-snapshot-20020121_patch/src/backend/parser/parse_relation.c
*** postgresql-snapshot-20020121_orig/src/backend/parser/parse_relation.c	Mon Nov  5 18:46:26 2001
--- postgresql-snapshot-20020121_patch/src/backend/parser/parse_relation.c	Tue Jan 22 09:30:26 2002
***************
*** 101,107 ****
  		int			varno = ((RangeTblRef *) nsnode)->rtindex;
  		RangeTblEntry *rte = rt_fetch(varno, pstate->p_rtable);
  
! 		if (strcmp(rte->eref->relname, refname) == 0)
  			result = (Node *) rte;
  	}
  	else if (IsA(nsnode, JoinExpr))
--- 101,107 ----
  		int			varno = ((RangeTblRef *) nsnode)->rtindex;
  		RangeTblEntry *rte = rt_fetch(varno, pstate->p_rtable);
  
! 		if (strcasecmp(rte->eref->relname, refname) == 0)
  			result = (Node *) rte;
  	}
  	else if (IsA(nsnode, JoinExpr))
***************
*** 110,116 ****
  
  		if (j->alias)
  		{
! 			if (strcmp(j->alias->relname, refname) == 0)
  				return (Node *) j;		/* matched a join alias */
  
  			/*
--- 110,116 ----
  
  		if (j->alias)
  		{
! 			if (strcasecmp(j->alias->relname, refname) == 0)
  				return (Node *) j;		/* matched a join alias */
  
  			/*
***************
*** 262,268 ****
  	foreach(c, rte->eref->attrs)
  	{
  		attnum++;
! 		if (strcmp(strVal(lfirst(c)), colname) == 0)
  		{
  			if (result)
  				elog(ERROR, "Column reference \"%s\" is ambiguous", colname);
--- 262,268 ----
  	foreach(c, rte->eref->attrs)
  	{
  		attnum++;
! 		if (strcasecmp(strVal(lfirst(c)), colname) == 0)
  		{
  			if (result)
  				elog(ERROR, "Column reference \"%s\" is ambiguous", colname);
***************
*** 324,330 ****
  	foreach(c, join->colnames)
  	{
  		attnum++;
! 		if (strcmp(strVal(lfirst(c)), colname) == 0)
  		{
  			if (result)
  				elog(ERROR, "Column reference \"%s\" is ambiguous", colname);
--- 324,330 ----
  	foreach(c, join->colnames)
  	{
  		attnum++;
! 		if (strcasecmp(strVal(lfirst(c)), colname) == 0)
  		{
  			if (result)
  				elog(ERROR, "Column reference \"%s\" is ambiguous", colname);
***************
*** 646,652 ****
  				{
  					char	   *rname = strVal(lfirst(l));
  
! 					if (strcmp(relname, rname) == 0)
  						return true;
  				}
  			}
--- 646,652 ----
  				{
  					char	   *rname = strVal(lfirst(l));
  
! 					if (strcasecmp(relname, rname) == 0)
  						return true;
  				}
  			}
diff -c -r postgresql-snapshot-20020121_orig/src/backend/parser/scan.l postgresql-snapshot-20020121_patch/src/backend/parser/scan.l
*** postgresql-snapshot-20020121_orig/src/backend/parser/scan.l	Sat Sep  8 01:17:14 2001
--- postgresql-snapshot-20020121_patch/src/backend/parser/scan.l	Tue Jan 22 09:30:26 2002
***************
*** 509,516 ****
  					 */
  					for (i = 0; yytext[i]; i++)
  					{
! 						if (isupper((unsigned char) yytext[i]))
! 							yytext[i] = tolower((unsigned char) yytext[i]);
  					}
  					if (i >= NAMEDATALEN)
                      {
--- 509,516 ----
  					 */
  					for (i = 0; yytext[i]; i++)
  					{
! //						if (isupper((unsigned char) yytext[i]))
! //							yytext[i] = tolower((unsigned char) yytext[i]);
  					}
  					if (i >= NAMEDATALEN)
                      {
diff -c -r postgresql-snapshot-20020121_orig/src/bin/pg_dump/pg_dump.c postgresql-snapshot-20020121_patch/src/bin/pg_dump/pg_dump.c
*** postgresql-snapshot-20020121_orig/src/bin/pg_dump/pg_dump.c	Fri Jan 18 20:17:05 2002
--- postgresql-snapshot-20020121_patch/src/bin/pg_dump/pg_dump.c	Tue Jan 22 09:31:19 2002
***************
*** 36,41 ****
--- 36,42 ----
  
  #include <unistd.h>				/* for getopt() */
  #include <ctype.h>
+ #include <fnmatch.h>   
  #ifdef ENABLE_NLS
  #include <locale.h>
  #endif
***************
*** 98,103 ****
--- 99,106 ----
  static PQExpBuffer getPKconstraint(TableInfo *tblInfo, IndInfo *indInfo);
  static const char *getAttrName(int attrnum, TableInfo *tblInfo);
  
+ int isTableExcluded(const char *table);
+ 
  extern char *optarg;
  extern int	optind,
  			opterr;
***************
*** 122,127 ****
--- 125,134 ----
  char		g_comment_start[10];
  char		g_comment_end[10];
  
+ /* exclude table from dump by patterns */
+ #define MAX_EXCLUDE_TABLE_PATTERNS	32
+ char	   *excludetable[MAX_EXCLUDE_TABLE_PATTERNS];
+ 
  
  typedef struct _dumpContext
  {
***************
*** 146,151 ****
--- 153,159 ----
  				 "  -C, --create             include commands to create database in dump\n"
  				 "  -d, --inserts            dump data as INSERT, rather than COPY, commands\n"
  				 "  -D, --column-inserts     dump data as INSERT commands with column names\n"
+ 		  		 "  -E, --exclude-table=TABLE        exclude  this table from dump (* allowed)\n"
  				 "  -f, --file=FILENAME      output file name\n"
  				 "  -F, --format {c|t|p}     output file format (custom, tar, plain text)\n"
  				 "  -h, --host=HOSTNAME      database server host name\n"
***************
*** 180,185 ****
--- 188,194 ----
  				 "  -C                       include commands to create database in dump\n"
  				 "  -d                       dump data as INSERT, rather than COPY, commands\n"
  				 "  -D                       dump data as INSERT commands with column names\n"
+     				 "  -E TABLE                exclude  this table from dump (* allowed)\n"        
  				 "  -f FILENAME              output file name\n"
  				 "  -F {c|t|p}               output file format (custom, tar, plain text)\n"
  				 "  -h HOSTNAME              database server host name\n"
***************
*** 574,580 ****
  		if (tblinfo[i].sequence)	/* already dumped */
  			continue;
  
! 		if (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0))
  		{
  			if (g_verbose)
  				write_msg(NULL, "preparing to dump the contents of table %s\n", classname);
--- 583,589 ----
  		if (tblinfo[i].sequence)	/* already dumped */
  			continue;
  
! 		if ( (! isTableExcluded(classname)) && (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0)))
  		{
  			if (g_verbose)
  				write_msg(NULL, "preparing to dump the contents of table %s\n", classname);
***************
*** 672,677 ****
--- 681,687 ----
  		{"blobs", no_argument, NULL, 'b'},
  		{"clean", no_argument, NULL, 'c'},
  		{"create", no_argument, NULL, 'C'},
+        		{"exclude-table", required_argument, NULL, 'E'},
  		{"file", required_argument, NULL, 'f'},
  		{"format", required_argument, NULL, 'F'},
  		{"inserts", no_argument, NULL, 'd'},
***************
*** 720,726 ****
  	strcpy(g_opaque_type, "opaque");
  
  	dataOnly = schemaOnly = dumpData = attrNames = false;
! 
  	if (!strrchr(argv[0], '/'))
  		progname = argv[0];
  	else
--- 730,742 ----
  	strcpy(g_opaque_type, "opaque");
  
  	dataOnly = schemaOnly = dumpData = attrNames = false;
!  
! 	{
! 		int i=0;
! 		for(i=0; i< MAX_EXCLUDE_TABLE_PATTERNS; i++)
! 			excludetable[i] = NULL;
! 	}
! 	
  	if (!strrchr(argv[0], '/'))
  		progname = argv[0];
  	else
***************
*** 748,756 ****
  	}
  
  #ifdef HAVE_GETOPT_LONG
! 	while ((c = getopt_long(argc, argv, "abcCdDf:F:h:inNoOp:RsS:t:uU:vWxX:zZ:V?", long_options, &optindex)) != -1)
  #else
! 	while ((c = getopt(argc, argv, "abcCdDf:F:h:inNoOp:RsS:t:uU:vWxX:zZ:V?-")) != -1)
  #endif
  
  	{
--- 764,772 ----
  	}
  
  #ifdef HAVE_GETOPT_LONG
! 	while ((c = getopt_long(argc, argv, "abcCdDE:f:F:h:inNoOp:RsS:t:uU:vWxX:zZ:V?", long_options, &optindex)) != -1)
  #else
! 	while ((c = getopt(argc, argv, "abcCdDE:f:F:h:inNoOp:RsS:t:uU:vWxX:zZ:V?-")) != -1)
  #endif
  
  	{
***************
*** 869,874 ****
--- 885,929 ----
  				}
  				break;
  
+ 			case 'E':			/* Exclude this table from dump*/
+ 				{
+ 					int			i;
+ 					char 			*s;
+ 
+ 					s = strdup(optarg);
+ 
+ 					printf("-- Exclude table:%s\n", s);
+ 					/*
+ 					 * quoted string? Then strip quotes and preserve
+ 					 * case...
+ 					 */
+ 					if (s[0] == '"')
+ 					{
+ 						strcpy(s, &s[1]);
+ 						if (*(s + strlen(s) - 1) == '"')
+ 							*(s + strlen(s) - 1) = '\0';
+ 					}
+ 					/* otherwise, convert table name to lowercase... */
+ 					else
+ 					{
+ 						for (i = 0; s[i]; i++)
+ 							if (isupper((unsigned char) s[i]))
+ 								s[i] = tolower((unsigned char) s[i]);
+ 
+ 					}
+ 					
+ 					// Save the exclude pattern to the exclude array
+ 					i=0;
+ 					while(i < MAX_EXCLUDE_TABLE_PATTERNS) {
+ 						if (!excludetable[i]){
+ 							excludetable[i] = s;
+ 							break;
+ 						} else
+ 							i++;
+ 					}		
+ 				}
+ 				break;
+ 
  			case 'u':
  				force_password = true;
  				username = simple_prompt("User name: ", 100, true);
***************
*** 4143,4150 ****
  	{
  		if (!(tblinfo[i].sequence))
  			continue;
! 		if (!tablename || (!strcmp(tblinfo[i].relname, tablename))
! 			|| (serialSeq && !strcmp(tblinfo[i].relname, serialSeq)))
  		{
  			/* becomeUser(fout, tblinfo[i].usename); */
  			dumpSequence(fout, tblinfo[i], schemaOnly, dataOnly);
--- 4198,4205 ----
  	{
  		if (!(tblinfo[i].sequence))
  			continue;
! 		if ((!isTableExcluded(tblinfo[i].relname)) && (!tablename || (!strcmp(tblinfo[i].relname, tablename))
! 			|| (serialSeq && !strcmp(tblinfo[i].relname, serialSeq))))
  		{
  			/* becomeUser(fout, tblinfo[i].usename); */
  			dumpSequence(fout, tblinfo[i], schemaOnly, dataOnly);
***************
*** 4160,4166 ****
  		if (tblinfo[i].sequence)	/* already dumped */
  			continue;
  
! 		if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0))
  		{
  
  			resetPQExpBuffer(delq);
--- 4215,4221 ----
  		if (tblinfo[i].sequence)	/* already dumped */
  			continue;
  
! 		if ( (!isTableExcluded(tblinfo[i].relname)) && (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0)))
  		{
  
  			resetPQExpBuffer(delq);
***************
*** 4400,4407 ****
  
  	for (i = 0; i < numIndexes; i++)
  	{
! 		if (tablename && tablename[0] &&
! 			(strcmp(indinfo[i].indrelname, tablename) != 0))
  			continue;
  
  		tableInd = findTableByName(tblinfo, numTables,
--- 4455,4462 ----
  
  	for (i = 0; i < numIndexes; i++)
  	{
! 		if ( isTableExcluded(indinfo[i].indrelname)  || ( tablename && tablename[0] &&
! 			(strcmp(indinfo[i].indrelname, tablename) != 0)))
  			continue;
  
  		tableInd = findTableByName(tblinfo, numTables,
***************
*** 4791,4797 ****
  
  	for (i = 0; i < numTables; i++)
  	{
! 		if (tablename && (strcmp(tblinfo[i].relname, tablename) != 0) && (strlen(tablename) > 0))
  			continue;
  
  		for (j = 0; j < tblinfo[i].ntrig; j++)
--- 4846,4852 ----
  
  	for (i = 0; i < numTables; i++)
  	{
! 		if ( isTableExcluded(tblinfo[i].relname) ||  (tablename && (strcmp(tblinfo[i].relname, tablename) != 0) && (strlen(tablename) > 0)))
  			continue;
  
  		for (j = 0; j < tblinfo[i].ntrig; j++)
***************
*** 4829,4835 ****
  	 */
  	for (t = 0; t < numTables; t++)
  	{
! 		if (tablename && (strcmp(tblinfo[t].relname, tablename) != 0) && (strlen(tablename) > 0))
  			continue;
  
  		/*
--- 4884,4890 ----
  	 */
  	for (t = 0; t < numTables; t++)
  	{
! 		if ( isTableExcluded(tblinfo[t].relname) ||  (tablename && (strcmp(tblinfo[t].relname, tablename) != 0) && (strlen(tablename) > 0)))
  			continue;
  
  		/*
***************
*** 4889,4891 ****
--- 4944,4962 ----
  
  	destroyPQExpBuffer(query);
  }
+ 
+ int isTableExcluded(const char *table) {
+    int check=false;
+    int i=0;
+ 
+    while (i < MAX_EXCLUDE_TABLE_PATTERNS && excludetable[i] ) {
+        if (! fnmatch(excludetable[i], table, FNM_PATHNAME)) {
+            check=1;
+            break;
+        }
+        i++;
+    }
+ 
+    return(check);
+ 
+ }
