NAMEDATALEN configuration option patch - Mailing list pgsql-patches

From Bill McGonigle
Subject NAMEDATALEN configuration option patch
Date
Msg-id 200105161959.f4GJxgA53138@postgresql.org
Whole thread Raw
Responses Re: NAMEDATALEN configuration option patch
List pgsql-patches
Attached is a patch that will allow the user to specify the value of
NAMEDATALEN on the configure command line with a '--with-namedatalen='
option.   I did this since otherwise I'll need to hack the source for each
release until eternity so my tables will fit and this is easier to script.

Disclaimer: this is my first venture into the world of autoconf, (and
postgres hacking!) but it works OK for me.  The only possible problem I
forsee is if an external program includes "postgres_ext.h" and there is a
name collision with something in config.h.  I couldn't find anyone
grepping the source tree besides genbki.sh, but that would be something to
watch for.  This tree works on my RedHat 7.1 machine from a clean unpack,
patch, autoconf, configure, make, make install, initdb, startup, and
loading lots of tables and data with psql.

This is a patch against the 7.1 release.  Please let me know if you need
something different.

-Bill

------


diff -r -c -x configure postgresql-7.1/INSTALL postgresql-7.1-namedatalen/
INSTALL
*** postgresql-7.1/INSTALL    Fri Apr  6 13:06:04 2001
--- postgresql-7.1-namedatalen/INSTALL    Wed May 16 14:10:42 2001
***************
*** 278,283 ****
--- 278,292 ----
             you specify it here then both server and clients will have the
             same default compiled in, which can be very convenient.

+      --with-namedatalen=NUMBER
+
+           Set NUMBER as the length of the name data type.  The name data
+           type is used internally for the names of tables, columns,
indexes,
+           etc. If you are using long table or column names you might
want to
+           increase this value from the default of 32 to a larger number,
+           like 256. Beware, databases with different NAMEDATALEN values
are
+           NOT binary compatible.
+
        --with-CXX

             Build the C++ interface library.
diff -r -c -x configure postgresql-7.1/configure.in
postgresql-7.1-namedatalen/configure.in
*** postgresql-7.1/configure.in    Fri Apr 13 17:22:46 2001
--- postgresql-7.1-namedatalen/configure.in    Wed May 16 14:00:16 2001
***************
*** 225,230 ****
--- 225,242 ----
   AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}")
   AC_SUBST(default_port)

+
+ #
+ # name type size (--with-namedatalen), default 32
+ #
+ AC_MSG_CHECKING([for name type size])
+ PGAC_ARG_REQ(with, namedatalen, [  --with-namedatalen=NAMESIZE   change
name type size [32]],
+              [namedatalen=$withval],
+              [namedatalen=32])
+ AC_MSG_RESULT([$namedatalen])
+ AC_DEFINE_UNQUOTED(DEF_NAMEDATALEN, ${namedatalen})
+ AC_SUBST(namedatalen)
+
   #
   # Maximum number of allowed connections (--with-maxbackends), default 32
   #
diff -r -c -x configure postgresql-7.1/src/backend/catalog/genbki.sh
postgresql-7.1-namedatalen/src/backend/catalog/genbki.sh
*** postgresql-7.1/src/backend/catalog/genbki.sh    Sun Jan 28 21:53:36 2001
--- postgresql-7.1-namedatalen/src/backend/catalog/genbki.sh    Wed May 16 14:
03:40 2001
***************
*** 118,127 ****
   trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$
${OUTPUT_PREFIX}.description.$$" 0 1 2 3 15


! # Get NAMEDATALEN from postgres_ext.h
   for dir in $INCLUDE_DIRS; do
!     if [ -f "$dir/postgres_ext.h" ]; then
!         NAMEDATALEN=`grep '#define[     ]*NAMEDATALEN' $dir/postgres_ext.h
| $AWK '{ print $3 }'`
           break
       fi
   done
--- 118,127 ----
   trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$
${OUTPUT_PREFIX}.description.$$" 0 1 2 3 15


! # Get DEF_NAMEDATALEN from config.h (hey, this is consistant!)
   for dir in $INCLUDE_DIRS; do
!     if [ -f "$dir/config.h" ]; then
!         NAMEDATALEN=`grep '#define[     ]*DEF_NAMEDATALEN' $dir/config.h |
$AWK '{ print $3 }'`
           break
       fi
   done
diff -r -c -x configure postgresql-7.1/src/include/config.h.in
postgresql-7.1-namedatalen/src/include/config.h.in
*** postgresql-7.1/src/include/config.h.in    Fri Mar 23 19:54:58 2001
--- postgresql-7.1-namedatalen/src/include/config.h.in    Wed May 16 14:00:16
2001
***************
*** 75,80 ****
--- 75,88 ----
   #undef DEF_PGPORT_STR

   /*
+  * DEF_NAMEDATALEN is the length of the name type, used internally for
table
+  * and column names.  Databases created with different NAMEDATALEN's are
not
+  * binary compatible.  The default value is 32.
+  *
+ */
+ #undef DEF_NAMEDATALEN
+
+ /*
    * Default soft limit on number of backend server processes per
postmaster;
    * this is just the default setting for the postmaster's -N switch.
    * (--with-maxbackends=N)
diff -r -c -x configure postgresql-7.1/src/include/postgres_ext.h
postgresql-7.1-namedatalen/src/include/postgres_ext.h
*** postgresql-7.1/src/include/postgres_ext.h    Fri Mar 23 19:55:01 2001
--- postgresql-7.1-namedatalen/src/include/postgres_ext.h    Wed May 16 14:00:
16 2001
***************
*** 23,28 ****
--- 23,30 ----
   #ifndef POSTGRES_EXT_H
   #define POSTGRES_EXT_H

+ #include "config.h"
+
   /*
    * Object ID is a fundamental type in Postgres.
    */
***************
*** 40,45 ****
    *
    * NOTE that databases with different NAMEDATALEN's cannot interoperate!
    */
! #define NAMEDATALEN 32

   #endif
--- 42,47 ----
    *
    * NOTE that databases with different NAMEDATALEN's cannot interoperate!
    */
! #define NAMEDATALEN DEF_NAMEDATALEN

   #endif

pgsql-patches by date:

Previous
From: Bill McGonigle
Date:
Subject:
Next
From: Oleg Bartunov
Date:
Subject: Re: GIST question