Fallo Initdb (Era: Sumar TIMESTAMP + TIME en el Source Code)

From: Luis D(dot) García <ldgarc(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Fallo Initdb (Era: Sumar TIMESTAMP + TIME en el Source Code)
Date: 2007-08-23 03:42:15
Message-ID: 3de424340708222042t8bb0b04u381d0fbcc9f228aa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola que tal, ya hace unos meses estuve por aquí consultando la manera en la
cual
podría hacer la suma de un TIMESTAMP y un TIME desde el código fuente de
PostgreSQL y de esas conversaciones principalmente con Alvaro Herrera la
recomendación era que cambiase el método que estaba utilizando para
almacenar los
valores del TIMESTAMP y el TIME, los cuales almacenaba en el pg_class como
*chars a los tipos Timestamp e Interval respectivos.

El log de los mails de aquellas conversaciones los pueden ver aquí:
http://archives.postgresql.org/pgsql-es-ayuda/2007-03/msg00631.php

En aquel momento tuve que abandonar la codificación para atender otros
asuntos de mi
carrera, pero ahora debo retomar el trabajo para culminar mi tesis.

En esta ocasión tuve un problema con el Initdb una vez que hice los cambios
respectivos en el pg_class. El problema que me da es el siguiente:

crini(at)ldgarc-LINUX:~/Documents/Pasantia/fuentes/rt-postgre2/postgresql-8.1.4>
initdb -D /home/crini/pgsql/data

The files belonging to this database system will be owned by user "crini".
This user must also own the server process.

The database cluster will be initialized with locale es_ES.UTF-8.
The default database encoding has accordingly been set to UTF8.

fixing permissions on existing directory /home/crini/pgsql/data ... ok
creating directory /home/crini/pgsql/data/global ... ok
creating directory /home/crini/pgsql/data/pg_xlog ... ok
creating directory /home/crini/pgsql/data/pg_xlog/archive_status ... ok
creating directory /home/crini/pgsql/data/pg_clog ... ok
creating directory /home/crini/pgsql/data/pg_subtrans ... ok
creating directory /home/crini/pgsql/data/pg_twophase ... ok
creating directory /home/crini/pgsql/data/pg_multixact/members ... ok
creating directory /home/crini/pgsql/data/pg_multixact/offsets ... ok
creating directory /home/crini/pgsql/data/base ... ok
creating directory /home/crini/pgsql/data/base/1 ... ok
creating directory /home/crini/pgsql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /home/crini/pgsql/data/base/1 ... FATAL:
syntax error at line 2056: unexpected character "*"
child process exited with exit code 1
initdb: removing contents of data directory "/home/crini/pgsql/data"

crini(at)ldgarc-LINUX:~/Documents/Pasantia/fuentes/rt-postgre2/postgresql-8.1.4>

1. Los cambios que hice en el pg_class.h fueron los siguientes:

En vista de que al compilar no me reconocía los tipos de datos Timestamp e
Interval
respectivos, me copié de la manera en la cual definen en el pg_authid el
atributo
rolvaliduntil como un timestamptz, haciendo un #define el cual pueden ver
aquí.<http://doxygen.postgresql.org/pg__authid_8h.html#d5d5a0029a3e17b4d49a9ef8c45e868c>

Lo que coloco a continuación en negritas son los últimos cambios que realicé
cuando
surgió el error con el Initdb.
.
.
/* ----------------
* pg_class definition. cpp turns this into
* typedef struct FormData_pg_class
* ----------------
*/

#define timestamp Datum
#define interval Datum

/* ----------------
* This structure is actually variable-length (the last attribute is
.
.
.
CATALOG(pg_class,1259) BKI_BOOTSTRAP
{
NameData relname; /* class name */
Oid relnamespace; /* OID of namespace containing this
class */
Oid reltype; /* OID of associated entry in pg_type */
.
.
.
timestamp rellastvalidtime; /* -- ldgarcia: valid time for the last
tuple inserted in this relation*/
interval *relfrequency; /* -- ldgarcia: class time frequency
value*/
.
.
.
/*
* relacl may or may not be present, see note above!
*/
aclitem relacl[1]; /* we declare this just for the catalog
*/
} FormData_pg_class;

#undef timestamp
#undef interval
.
.
.
/* ----------------
* initial contents of pg_class
*
* NOTE: only "bootstrapped" relations need to be declared here. Be sure
that
* the OIDs listed here match those given in their CATALOG macros.
* ----------------
*/

DATA(insert OID = 1247 ( pg_type PGNSP 71 PGUID 0 1247 0 0 0 0 0 f f
r 23 0 0 0 0 0 t f f f 0 f NULL 0 f 0 _null_ _null_ NULL f _null_ ));
DESCR("");
DATA(insert OID = 1249 ( pg_attribute PGNSP 75 PGUID 0 1249 0 0 0 0 0 f
f r 17 0 0 0 0 0 f f f f 0 f NULL 0 f 0 _null_ _null_ NULL f _null_ ));
DESCR("");
DATA(insert OID = 1255 ( pg_proc PGNSP 81 PGUID 0 1255 0 0 0 0 0 f f
r 18 0 0 0 0 0 t f f f 0 f NULL 0 f 0 _null_ _null_ NULL f _null_ ));
DESCR("");
DATA(insert OID = 1259 ( pg_class PGNSP 83 PGUID 0 1259 0 0 0 0 0 f
f r 35 0 0 0 0 0 t f f f 0 f NULL 0 f 0 _null_ _null_ NULL f _null_ ));
DESCR("");

2. Adicionalmente al cambiar dichas definiciones en el pg_class tuve
entonces que
cambiar los valores iniciales de dicha estructura en el pg_atribute.h así:

/* ----------------
* pg_class
* ----------------
*/
#define Schema_pg_class \
{ 1259, {"relname"}, 19, -1, NAMEDATALEN, 1, 0, -1, -1, false, 'p',
'i', true, false, false, true, 0 }, \
{ 1259, {"relnamespace"}, 26, -1, 4, 2, 0, -1, -1, true, 'p', 'i',
true, false, false, true, 0 }, \
.
.
.
{ 1259, {"rellastvalidtime"}, 1114, -1, 8, 31, 0, -1, -1, false, 'p',
'i', true, false, false, true, 0 }, \
{ 1259, {"relfrequency"}, 1186, -1, 16, 32, 0, -1, -1, false, 'p',
'i', true, false, false, true, 0 }, \
.
.
.
{ 1259, {"relacl"}, 1034, -1, -1, 35, 1, -1, -1, false, 'x', 'i',
false, false, false, true, 0 }

DATA(insert ( 1259 relname 19 -1 NAMEDATALEN 1 0 -1 -1 f p i t
f f t 0));
DATA(insert ( 1259 relnamespace 26 -1 4 2 0 -1 -1 t p i t f f t
0));
.
.
.
DATA(insert ( 1259 rellastvalidtime 1114 -1 8 31 0 -1 -1 f p i t f f
t 0));
DATA(insert ( 1259 relfrequency 1186 -1 16 32 0 -1 -1 f p i t f f t
0));
.
.
.
DATA(insert ( 1259 relacl 1034 -1 -1 35 1 -1 -1 f x i f f f t 0));
DATA(insert ( 1259 ctid 27 0 6 -1 0 -1 -1 f p s t f f t
0));
DATA(insert ( 1259 oid 26 0 4 -2 0 -1 -1 t p i t f f t 0));
DATA(insert ( 1259 xmin 28 0 4 -3 0 -1 -1 t p i t f f t
0));
DATA(insert ( 1259 cmin 29 0 4 -4 0 -1 -1 t p i t f f t
0));
DATA(insert ( 1259 xmax 28 0 4 -5 0 -1 -1 t p i t f f t
0));
DATA(insert ( 1259 cmax 29 0 4 -6 0 -1 -1 t p i t f f t
0));
DATA(insert ( 1259 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t
0));

En fin, pienso que los detalles por los cuales me da el error en el initdb
se debe a esos
cambios, ya que los demás cambios que he hecho en el resto del código fuente
de
PostgreSQL sólo afectan los casos en los cuales el usuario utiliza una
sintaxis no
soportada por Postgre hasta ahora, por lo que pienso que no deberían tener
nada que
ver con las sentencias establecidas en el Initdb.c

Aquí pueden revisar online el código fuente de los dos archivos en cuestión:
- PG_CLASS <http://doxygen.postgresql.org/pg__class_8h-source.html>
- PG_ATTRIBUTE <http://doxygen.postgresql.org/pg__attribute_8h-source.html>

Saludos y gracias de antemano.

PD: espero puedan ayudarme en esto y si hay alguna manera en la cual puedan
entender mejor lo que he realizado en los cambios sólo diganme sus dudas y
trataré de
aclararlas.

--
Luis D. García M.

Telf: (+58) 2418662663
Cel.: (+58) 4143482018

- FACYT - UC -
- Computación -

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2007-08-23 05:43:25 Fwd: Recuperar data desde el directorio /data
Previous Message José Angel Torres Orellana 2007-08-23 03:34:07 Urgente necesito recuperar desde directorio /data