Re: [PATCHES] remove TCL_ARRAYS

2008-02-29 Thread Alvaro Herrera
Tom Lane wrote:
> Alvaro Herrera <[EMAIL PROTECTED]> writes:
> > This patch removes the TCL_ARRAY symbol.
> 
> If you're going to remove it you should actually remove it
> (eg from pg_config_manual.h).

Oops.  Thanks, removed from there too.


-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [PATCHES] remove TCL_ARRAYS

2008-02-29 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> This patch removes the TCL_ARRAY symbol.

If you're going to remove it you should actually remove it
(eg from pg_config_manual.h).

> This seems to be a leftover
> from when pgtcl was around in the backend;

Yeah, it was supporting some kluge or other in the libpgtcl client.
AFAICT from the 7.x code, the client-side kluge was never enabled by
default anyway, so it seems unlikely anyone will miss it.

regards, tom lane

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[PATCHES] remove TCL_ARRAYS

2008-02-29 Thread Alvaro Herrera
This patch removes the TCL_ARRAY symbol.  This seems to be a leftover
from when pgtcl was around in the backend; if enabled, it causes
array_out to emit bogus array values:

alvherre=# create table bar ( a text);
CREATE TABLE
alvherre=# insert into bar values ('foo"');
INSERT 0 1
alvherre=# select array_append('{}', a) from bar;
 array_append 
--
 {"foo""}
(1 ligne)

The correct value is

alvherre=# select array_append('{}', a) from bar;
 array_append 
--
 {"foo\""}
(1 ligne)


Of course, the system does not accept the TCL_ARRAY value back.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/utils/adt/arrayfuncs.c
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/adt/arrayfuncs.c,v
retrieving revision 1.140
diff -c -p -r1.140 arrayfuncs.c
*** src/backend/utils/adt/arrayfuncs.c	1 Jan 2008 19:45:52 -	1.140
--- src/backend/utils/adt/arrayfuncs.c	29 Feb 2008 14:30:28 -
*** array_out(PG_FUNCTION_ARGS)
*** 1030,1038 
  if (ch == '"' || ch == '\\')
  {
  	needquote = true;
- #ifndef TCL_ARRAYS
  	overall_length += 1;
- #endif
  }
  else if (ch == '{' || ch == '}' || ch == typdelim ||
  		 isspace((unsigned char) ch))
--- 1030,1036 
*** array_out(PG_FUNCTION_ARGS)
*** 1103,1109 
  		if (needquotes[k])
  		{
  			APPENDCHAR('"');
- #ifndef TCL_ARRAYS
  			for (tmp = values[k]; *tmp; tmp++)
  			{
  char		ch = *tmp;
--- 1101,1106 
*** array_out(PG_FUNCTION_ARGS)
*** 1113,1121 
  *p++ = ch;
  			}
  			*p = '\0';
- #else
- 			APPENDSTR(values[k]);
- #endif
  			APPENDCHAR('"');
  		}
  		else
--- 1110,1115 

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster