Change on-disk representation of NUMERIC datatype so that the sign_dscale
authorTom Lane
Tue, 25 Sep 2007 22:21:55 +0000 (22:21 +0000)
committerTom Lane
Tue, 25 Sep 2007 22:21:55 +0000 (22:21 +0000)
word comes before the weight instead of after.  This will allow future
binary-compatible extension of the representation to support compact formats,
as discussed on pgsql-hackers around 2007/06/18.  The reason to do it now is
that we've already pretty well broken any chance of simple in-place upgrade
from 8.2 to 8.3, but it's possible that 8.3 to 8.4 (or whenever we get around
to squeezing NUMERIC) could otherwise be data-compatible.

src/include/catalog/catversion.h
src/include/utils/numeric.h

index d00770acc2112f11370d419a4a94783995069583..9776bc10daecd2ac346b6807e3fa22369bf7384d 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.428 2007/09/25 20:03:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.429 2007/09/25 22:21:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 200709241
+#define CATALOG_VERSION_NO 200709251
 
 #endif
index cffba1e164197e57308d1267309f1b398a1c4cfb..e14251591e930aeecd6a7ff50baab3cf3212a35e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1998-2007, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/utils/numeric.h,v 1.24 2007/02/27 23:48:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/numeric.h,v 1.25 2007/09/25 22:21:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 typedef struct NumericData
 {
    int32       vl_len_;        /* varlena header (do not touch directly!) */
-   int16       n_weight;       /* Weight of 1st digit  */
    uint16      n_sign_dscale;  /* Sign + display scale */
+   int16       n_weight;       /* Weight of 1st digit  */
    char        n_data[1];      /* Digits (really array of NumericDigit) */
 } NumericData;
 
 typedef NumericData *Numeric;
 
-#define NUMERIC_HDRSZ  (VARHDRSZ + sizeof(int16) + sizeof(uint16))
+#define NUMERIC_HDRSZ  (VARHDRSZ + sizeof(uint16) + sizeof(int16))
 
 
 /*