uw7-0.patch

application/x-patch

Filename: uw7-0.patch
Type: application/x-patch
Part: 0
Message: [REL6.4] Mixed case table name problems with some fixes.

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
src/backend/catalog/heap.c 8 2
src/bin/psql/psql.c 7 2
*** src/backend/catalog/heap.c.orig	Sat Nov 14 22:20:46 1998
--- src/backend/catalog/heap.c	Sat Nov 14 22:25:27 1998
***************
*** 1444,1450 ****
  	extern GlobalMemory CacheCxt;
  
  start:;
! 	sprintf(str, "select %s%s from %.*s", attrdef->adsrc, cast,
  			NAMEDATALEN, rel->rd_rel->relname.data);
  	setheapoverride(true);
  	planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);
--- 1444,1453 ----
  	extern GlobalMemory CacheCxt;
  
  start:;
! 	/* Surround table name with double quotes to allow mixed-case and
! 	 * whitespaces in names. - BGA 1998-11-14
! 	 */
! 	sprintf(str, "select %s%s from \"%.*s\"", attrdef->adsrc, cast,
  			NAMEDATALEN, rel->rd_rel->relname.data);
  	setheapoverride(true);
  	planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);
***************
*** 1515,1521 ****
  	char		nulls[4] = {' ', ' ', ' ', ' '};
  	extern GlobalMemory CacheCxt;
  
! 	sprintf(str, "select 1 from %.*s where %s",
  			NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
  	setheapoverride(true);
  	planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);
--- 1518,1527 ----
  	char		nulls[4] = {' ', ' ', ' ', ' '};
  	extern GlobalMemory CacheCxt;
  
! 	/* Check for table's existance. Surround table name with double-quotes
! 	 * to allow mixed-case and whitespace names. - thomas 1998-11-12
! 	 */
! 	sprintf(str, "select 1 from \"%.*s\" where %s",
  			NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
  	setheapoverride(true);
  	planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);
*** src/bin/psql/psql.c.orig	Sun Nov 15 00:56:34 1998
--- src/bin/psql/psql.c	Sun Nov 15 01:32:54 1998
***************
*** 460,471 ****
  				perror("malloc");
  
  			/* load table table */
  			for (i = 0; i < nColumns; i++)
  			{
! 				table[i] = (char *) malloc(PQgetlength(res, i, 1) * sizeof(char) + 1);
  				if (table[i] == NULL)
  					perror("malloc");
! 				strcpy(table[i], PQgetvalue(res, i, 1));
  			}
  
  			PQclear(res);
--- 460,476 ----
  				perror("malloc");
  
  			/* load table table */
+ 			/* Put double quotes around the table name to allow for mixed-case
+ 			 * and whitespaces in the table name. - BGA 1998-11-14
+ 			 */
  			for (i = 0; i < nColumns; i++)
  			{
! 				table[i] = (char *) malloc(PQgetlength(res, i, 1) * sizeof(char) + 3);
  				if (table[i] == NULL)
  					perror("malloc");
! 				strcpy(table[i], "\"");
! 				strcat(table[i], PQgetvalue(res, i, 1));
! 				strcat(table[i], "\"");
  			}
  
  			PQclear(res);