El 02/02/2012 20:42, Alvaro Herrera escribió:
Excerpts from Kernel's message of jue feb 02 13:35:45 -0300 2012:
El 02/02/2012 15:10, Alvaro Herrera escribió:
Excerpts from Kernel's message of jue feb 02 08:20:16 -0300 2012:
Hola cuando ejecuto este query una vez funciona y otra no

ERROR EN EL LOG:
2012-02-02 11:42:49 CET LOG: proceso de servidor (PID 12556) fue
terminado por una señal 11: Segmentation fault
Hm, ¿hay errores en el log del kernel?  A mí me parece que puede ser
problema de hardware.  Si ejecutas cada select que forma parte de la
función crosstab directamente, ¿se cae también?

SELECT ARRAY[i.trabajador::text, i.nombre_trabajador::text,
   to_char(i.anyo, '9999')] As row_name,
   CASE
                WHEN i.mes = 1::int THEN 'jan'::text
                WHEN i.mes = 2::int THEN 'feb'::text
                WHEN i.mes = 3::int THEN 'mar'::text
                WHEN i.mes = 4::int THEN 'apr'::text
                WHEN i.mes = 5::int THEN 'may'::text
                WHEN i.mes = 6::int THEN 'jun'::text
                WHEN i.mes = 7::int THEN 'jul'::text
                WHEN i.mes = 8::int THEN 'aug'::text
                WHEN i.mes = 9::int THEN 'sep'::text
                WHEN i.mes = 10::int THEN 'oct'::text
                WHEN i.mes = 11::int THEN 'nov'::text
                WHEN i.mes = 12::int THEN 'dec'::text
                ELSE NULL::text
            END AS mes, i.s_fichados
   FROM liv_tiempos_muertos_mes i
   WHERE i.anyo = 2012;

y

                 SELECT to_char(date '2012-01-01' + (n ||
'month')::interval, 'mon') As short_mname FROM generate_series(0,11) n;
Funcionan perfectamente las dos,  en otra maquina me sucede lo mismo
funcionan una vez si y otras no, comentar por si sirve de algo que
liv_tiempos_muertos_mes es una vista
Hm, la cuestión es que si fuera un bug de Postgres, la caída se
manifestaría todas las veces ... a menos que se trate de memoria sin
inicializar.  Hmm.  ¿Puedes mandar un ejemplo completo que reproduzca el
problema, incluyendo definiciones de tablas y datos de ejemplo?
Deberías poder instalarlo en una BD limpia, nuevita de initdb, y causar
la caída aunque sea ocasionalmente.

Lo otro es que no has manifestado la versión de Postgres que estás
usando.

Voy a  prepararlo este fin de semana ahora no puedo
Un dato la vista liv_tiempos_muertos esta creada sobre otras 3 o cuatro vistas
La version es una 8.4.2 de 64 bits , en dos maquinas distintas


ADJUNTO TABLAS


CREATE TABLE li03trab
(
  empresa character(2) NOT NULL,
  trabajador character(10) NOT NULL,
  nombre character(30) NOT NULL,
  apellidos character(30) NOT NULL,
  seccion character(30) NOT NULL,
  CONSTRAINT li03trab_pkey PRIMARY KEY (empresa, trabajador)
)
WITH (
  OIDS=FALSE
);


);


);

-- FICHERO PARA ALMACENAR LOS ARTICULOS ASOCIADOS A LOS PARTES DE TRABAJO
-- DROP TABLE li22apar;

CREATE TABLE li22apar
(
  empresa character(2) NOT NULL,
  parte smallint NOT NULL,
  fecha date NOT NULL,
  id_linea character(10) NOT NULL,
  articulo character(16) NOT NULL,
  formato character(16) NOT NULL,
  n_linea smallint NOT NULL,
  orden smallint NOT NULL,
  cantidad numeric(14,2),
  cantidad_producida numeric(14,2),
  tiempo_total numeric(14,2),
  unidades_optimas numeric(12,4),
  por_minimo numeric(14,2),
  por_productividad numeric(14,2),
  tiempo_optimo numeric(14,2),
  trabajadores_optimo smallint,
  trabajadores_real smallint,
  num_incidencias smallint,
  mesa smallint,
  CONSTRAINT li22apar_pkey PRIMARY KEY (empresa, fecha, id_linea, parte, 
n_linea)
)
WITH (
  OIDS=FALSE
);


-- DATOS INSERTADOS DESDE PHP

-- FICHERO PARA ALMACENAR LAS INCIDENCIAS EN PRODUCCION DE LOS ARTICULOS 
ASOCIADOS A LOS PARTES DE TRABAJO
-- DROP TABLE li23ipar;

CREATE TABLE li23ipar
(
  empresa character(2) NOT NULL,
  parte smallint NOT NULL,
  fecha date NOT NULL,
  id_linea character(10) NOT NULL,
  n_linea smallint NOT NULL,
  n_accion smallint NOT NULL,
  id_accion character(10) NOT NULL,
  estado character(5) NOT NULL,
  fecha_hora_inicio timestamp(3) without time zone NOT NULL,
  fecha_hora_fin timestamp(3) without time zone,
  unidades_informadas numeric(14,2),
  terminado character(1),
  CONSTRAINT li23ipar_pkey PRIMARY KEY (empresa, fecha, parte, id_linea, 
n_linea, n_accion)
)
WITH (
  OIDS=FALSE
);



-- FICHERO PARA ALMACENAR LAS INCIDENCIAS DE LOS TRABAJADORES.
-- SE INSERTARAN LOS TRABAJOS DESTINADOS EN CADA PARTE
-- ASI COMO LOS TIEMPOS MUERTOS (ENTRADA -> LLEGADA AL PUESTO DE TRABAJO -> 
SALIDA)
-- DROP TABLE li30itra;

CREATE TABLE li30itra
(
  empresa character(2) NOT NULL,
  trabajador character(10) NOT NULL,
  fecha_hora_inicio timestamp(3) without time zone NOT NULL,
  fecha_hora_fin timestamp(3) without time zone,
  parte smallint, -- prueba
  fecha date,
  id_linea character(10),
  n_linea smallint,
  n_accion smallint,
  id_accion character(10),
  dedicacion smallint NOT NULL
)
WITH (
  OIDS=FALSE
);


-- Index: li30itrab_pa

-- DROP INDEX li30itrab_pa;

CREATE INDEX li30itrab_pa
  ON li30itra
  USING btree
  (empresa, fecha, id_linea, parte, n_linea, n_accion);

-- Index: li30itrab_tr

-- DROP INDEX li30itrab_tr;

CREATE INDEX li30itrab_tr
  ON li30itra
  USING btree
  (empresa, trabajador, fecha_hora_inicio);


-- HISTORICOS --  

-- FICHERO PARA ALMACENAR LAS INCIDENCIAS DE LOS TRABAJADORES.
-- SE INSERTARAN LOS TRABAJOS DESTINADOS EN CADA PARTE
-- ASI COMO LOS TIEMPOS MUERTOS (ENTRADA -> LLEGADA AL PUESTO DE TRABAJO -> 
SALIDA)
-- DROP TABLE li40itra;

CREATE TABLE li40itra
(
  empresa character(2) NOT NULL,
  trabajador character(10) NOT NULL,
  fecha_hora_inicio timestamp(3) without time zone NOT NULL,
  fecha_hora_fin timestamp(3) without time zone,
  parte smallint, -- prueba
  fecha date,
  id_linea character(10),
  n_linea smallint,
  n_accion smallint,
  id_accion character(10),
  dedicacion smallint NOT NULL
)
WITH (
  OIDS=FALSE
);


-- Index: li40itrab_pa

-- DROP INDEX li40itrab_pa;

CREATE INDEX li40itrab_pa
  ON li40itra
  USING btree
  (empresa, fecha, id_linea, parte, n_linea, n_accion);

-- Index: li40itrab_tr

-- DROP INDEX li40itrab_tr;

CREATE INDEX li40itrab_tr
  ON li40itra
  USING btree
  (empresa, trabajador, fecha_hora_inicio);


CREATE TABLE li92apar
(
  empresa character(2) NOT NULL,
  parte smallint NOT NULL,
  fecha date NOT NULL,
  id_linea character(10) NOT NULL,
  articulo character(16) NOT NULL,
  formato character(16) NOT NULL,
  n_linea smallint NOT NULL,
  orden smallint NOT NULL,
  cantidad numeric(14,2),
  cantidad_producida numeric(14,2),
  tiempo_total numeric(14,2),
  unidades_optimas numeric(12,4),
  por_minimo numeric(14,2),
  por_productividad numeric(14,2),
  tiempo_optimo numeric(14,2),
  trabajadores_optimo smallint,
  trabajadores_real smallint,
  num_incidencias smallint,
  mesa smallint,
  CONSTRAINT li92apar_pkey PRIMARY KEY (empresa, fecha, id_linea, parte, 
n_linea)
)
WITH (
  OIDS=FALSE
);


-- DATOS INSERTADOS DESDE PHP

-- FICHERO PARA ALMACENAR LAS INCIDENCIAS EN PRODUCCION DE LOS ARTICULOS 
ASOCIADOS A LOS PARTES DE TRABAJO
-- DROP TABLE li93ipar;

CREATE TABLE li93ipar
(
  empresa character(2) NOT NULL,
  parte smallint NOT NULL,
  fecha date NOT NULL,
  id_linea character(10) NOT NULL,
  n_linea smallint NOT NULL,
  n_accion smallint NOT NULL,
  id_accion character(10) NOT NULL,
  estado character(5) NOT NULL,
  fecha_hora_inicio timestamp(3) without time zone NOT NULL,
  fecha_hora_fin timestamp(3) without time zone,
  unidades_informadas numeric(14,2),
  terminado character(1),
  CONSTRAINT li93ipar_pkey PRIMARY KEY (empresa, fecha, parte, id_linea, 
n_linea, n_accion)
)
WITH (
  OIDS=FALSE
);
-- DROP VIEW liv_tiempo_trabajador;
CREATE OR REPLACE VIEW liv_tiempo_trabajador AS 
 SELECT 'Activas' as tipo, a.empresa, a.trabajador, (d.nombre::text || ' 
'::text) || d.apellidos::text AS nombre_trabajador, a.id_accion, h.nombre AS 
nombre_accion, a.fecha_hora_inicio, a.fecha_hora_fin, a.parte, a.fecha, 
a.id_linea, a.n_linea, a.n_accion, c.terminado, date(a.fecha_hora_inicio) AS 
fecha_inicio, to_char(a.fecha_hora_inicio, 'HH24:MI:SS'::text) AS hora_inicio, 
date(a.fecha_hora_fin) AS fecha_final, to_char(a.fecha_hora_fin, 
'HH24:MI:SS'::text) AS hora_final, div(date_part('epoch'::text, 
a.fecha_hora_fin - a.fecha_hora_inicio)::numeric, 60::numeric) AS minutos, 
date_part('epoch'::text, a.fecha_hora_fin - a.fecha_hora_inicio) AS segundos, 
(to_char(div(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 'FM99900'::text) || ':'::text) 
|| to_char(div(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text) AS 
tiempo_total, ((to_char(div(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 'FM99900'::text) || ':'::text) 
|| to_char(div(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text || 
':'::text)) || to_char(mod(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text) AS 
tiempo_total_s, 
        CASE
            WHEN c.estado IS NULL THEN 'Fuera de Linea'::text
            WHEN c.estado = 'A'::bpchar THEN 'Linea produciendo'::text
            WHEN c.estado = 'R'::bpchar THEN 'Linea produciciendo con 
problemas'::text
            WHEN c.estado = 'P'::bpchar THEN 'Linea parada'::text
            ELSE NULL::text
        END AS nombre_estado, b.articulo, b.formato
   FROM li30itra a
   JOIN li10acci h ON a.empresa = h.empresa AND a.id_accion = h.id_accion
   LEFT JOIN li22apar b ON a.empresa = b.empresa AND a.fecha = b.fecha AND 
a.parte = b.parte AND a.id_linea = b.id_linea AND a.n_linea = b.n_linea
   LEFT JOIN li23ipar c ON a.empresa = c.empresa AND a.fecha = c.fecha AND 
a.parte = c.parte AND a.id_linea = c.id_linea AND a.n_linea = c.n_linea AND 
a.n_accion = c.n_accion
   LEFT JOIN li03trab d ON a.empresa = d.empresa AND a.trabajador = d.trabajador
 UNION ALL 
 SELECT 'Historico' as tipo, a.empresa, a.trabajador, (d.nombre::text || ' 
'::text) || d.apellidos::text AS nombre_trabajador, a.id_accion, h.nombre AS 
nombre_accion, a.fecha_hora_inicio, a.fecha_hora_fin, a.parte, a.fecha, 
a.id_linea, a.n_linea, a.n_accion, c.terminado, date(a.fecha_hora_inicio) AS 
fecha_inicio, to_char(a.fecha_hora_inicio, 'HH24:MI:SS'::text) AS hora_inicio, 
date(a.fecha_hora_fin) AS fecha_final, to_char(a.fecha_hora_fin, 
'HH24:MI:SS'::text) AS hora_final, div(date_part('epoch'::text, 
a.fecha_hora_fin - a.fecha_hora_inicio)::numeric, 60::numeric) AS minutos, 
date_part('epoch'::text, a.fecha_hora_fin - a.fecha_hora_inicio) AS segundos, 
(to_char(div(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 'FM99900'::text) || ':'::text) 
|| to_char(div(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text) AS 
tiempo_total, ((to_char(div(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 'FM99900'::text) || ':'::text) 
|| to_char(div(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text || 
':'::text)) || to_char(mod(mod(date_part('epoch'::text, a.fecha_hora_fin - 
a.fecha_hora_inicio)::numeric, 3600::numeric), 60::numeric), 'FM00'::text) AS 
tiempo_total_s, 
        CASE
            WHEN c.estado IS NULL THEN 'Fuera de Linea'::text
            WHEN c.estado = 'A'::bpchar THEN 'Linea produciendo'::text
            WHEN c.estado = 'R'::bpchar THEN 'Linea produciciendo con 
problemas'::text
            WHEN c.estado = 'P'::bpchar THEN 'Linea parada'::text
            ELSE NULL::text
        END AS nombre_estado, b.articulo, b.formato
   FROM li40itra a
   JOIN li10acci h ON a.empresa = h.empresa AND a.id_accion = h.id_accion
   LEFT JOIN li92apar b ON a.empresa = b.empresa AND a.fecha = b.fecha AND 
a.parte = b.parte AND a.id_linea = b.id_linea AND a.n_linea = b.n_linea
   LEFT JOIN li93ipar c ON a.empresa = c.empresa AND a.fecha = c.fecha AND 
a.parte = c.parte AND a.id_linea = c.id_linea AND a.n_linea = c.n_linea AND 
a.n_accion = c.n_accion
   LEFT JOIN li03trab d ON a.empresa = d.empresa AND a.trabajador = 
d.trabajador;
   
-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a