mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Previous "64-bit fix" for intagg didn't actually work. This is already
fixed properly in CVS tip, but we need a band-aid for back branches. Per report from Ron Mayer.
This commit is contained in:
		@@ -144,10 +144,12 @@ int_agg_state(PG_FUNCTION_ARGS)
 | 
				
			|||||||
	PGARRAY    *state;
 | 
						PGARRAY    *state;
 | 
				
			||||||
	PGARRAY    *p;
 | 
						PGARRAY    *p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (PG_ARGISNULL(0))
 | 
						/*
 | 
				
			||||||
		state = NULL;
 | 
						 * We can keep a pointer in the datum even though nodeAgg thinks it's
 | 
				
			||||||
	else
 | 
						 * an int4.  Note we assume the initial state of int4 zero will look
 | 
				
			||||||
		state = (PGARRAY *) PG_GETARG_POINTER(0);
 | 
						 * like a null pointer.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						state = (PGARRAY *) PG_GETARG_POINTER(0);
 | 
				
			||||||
	p = GetPGArray(state, 1);
 | 
						p = GetPGArray(state, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!PG_ARGISNULL(1))
 | 
						if (!PG_ARGISNULL(1))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,22 @@
 | 
				
			|||||||
-- Adjust this setting to control where the objects get created.
 | 
					-- Adjust this setting to control where the objects get created.
 | 
				
			||||||
SET search_path = public;
 | 
					SET search_path = public;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- The aggregate transition state (denoted INT4 in caps below) is really
 | 
				
			||||||
 | 
					-- an array, ie, int4[].  We have to lie and pretend it is a pass-by-value
 | 
				
			||||||
 | 
					-- datatype so that nodeAgg.c will not try to do memory management for it.
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Internal function for the aggregate
 | 
					-- Internal function for the aggregate
 | 
				
			||||||
-- Is called for each item in an aggregation
 | 
					-- Is called for each item in an aggregation
 | 
				
			||||||
CREATE OR REPLACE FUNCTION int_agg_state (int4[], int4)
 | 
					CREATE OR REPLACE FUNCTION int_agg_state (INT4, int4)
 | 
				
			||||||
RETURNS int4[]
 | 
					RETURNS INT4
 | 
				
			||||||
AS 'MODULE_PATHNAME','int_agg_state'
 | 
					AS 'MODULE_PATHNAME','int_agg_state'
 | 
				
			||||||
LANGUAGE 'C';
 | 
					LANGUAGE 'C' STRICT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Internal function for the aggregate
 | 
					-- Internal function for the aggregate
 | 
				
			||||||
-- Is called at the end of the aggregation, and returns an array.
 | 
					-- Is called at the end of the aggregation, and returns an array.
 | 
				
			||||||
CREATE OR REPLACE FUNCTION int_agg_final_array (int4[])
 | 
					CREATE OR REPLACE FUNCTION int_agg_final_array (INT4)
 | 
				
			||||||
RETURNS int4[]
 | 
					RETURNS int4[]
 | 
				
			||||||
AS 'MODULE_PATHNAME','int_agg_final_array'
 | 
					AS 'MODULE_PATHNAME','int_agg_final_array'
 | 
				
			||||||
LANGUAGE 'C' STRICT;
 | 
					LANGUAGE 'C' STRICT;
 | 
				
			||||||
@@ -20,14 +26,15 @@ LANGUAGE 'C' STRICT;
 | 
				
			|||||||
CREATE AGGREGATE int_array_aggregate (
 | 
					CREATE AGGREGATE int_array_aggregate (
 | 
				
			||||||
	BASETYPE = int4,
 | 
						BASETYPE = int4,
 | 
				
			||||||
	SFUNC = int_agg_state,
 | 
						SFUNC = int_agg_state,
 | 
				
			||||||
	STYPE = int4[],
 | 
						STYPE = INT4,
 | 
				
			||||||
	FINALFUNC = int_agg_final_array
 | 
						FINALFUNC = int_agg_final_array,
 | 
				
			||||||
 | 
						INITCOND = 0
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- The aggregate component functions are not designed to be called
 | 
					-- The aggregate component functions are not designed to be called
 | 
				
			||||||
-- independently, so disable public access to them
 | 
					-- independently, so disable public access to them
 | 
				
			||||||
REVOKE ALL ON FUNCTION int_agg_state (int4[], int4) FROM PUBLIC;
 | 
					REVOKE ALL ON FUNCTION int_agg_state (INT4, int4) FROM PUBLIC;
 | 
				
			||||||
REVOKE ALL ON FUNCTION int_agg_final_array (int4[]) FROM PUBLIC;
 | 
					REVOKE ALL ON FUNCTION int_agg_final_array (INT4) FROM PUBLIC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- The enumeration function
 | 
					-- The enumeration function
 | 
				
			||||||
-- returns each element in a one dimensional integer array
 | 
					-- returns each element in a one dimensional integer array
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user