]> granicus.if.org Git - postgresql/commitdiff
Fixes:
authorMarc G. Fournier <scrappy@hub.org>
Fri, 19 Jul 1996 07:24:11 +0000 (07:24 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Fri, 19 Jul 1996 07:24:11 +0000 (07:24 +0000)
I have written some patches which add support for NULLs to Postgres95.
In fact support for NULLs was already present in postgres, but it had been
disabled because not completely debugged, I believe. My patches simply add
some checks here and there. To enable the new code you must add -DNULL_PATCH
to CFLAGS in Makefile.global. After recompiling you can do things like:

insert into a (x, y) values (1, NULL);
update a set x = NULL where x = 0;

You can't still use a "where x=NULL" clause, you must use ISNULL instead.
This could probably be an easy fix to do.

Submitted by: Massimo Dal Zotto <dz@cs.unitn.it>

src/backend/parser/analyze.c
src/backend/parser/catalog_utils.c
src/backend/parser/parse_query.c
src/backend/parser/parser.c

index 504e557abee8651596a9219dca069fcd20ecdaac..3f44037ca74db5dbe09efc9f0f954cacd2274a8e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.1.1.1 1996/07/09 06:21:39 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.2 1996/07/19 07:24:06 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1313,6 +1313,11 @@ make_targetlist_expr(ParseState *pstate,
         elog(WARN, "make_targetlist_expr: invalid use of NULL expression");
 
      type_id = exprType(expr);
+#ifdef NULL_PATCH
+     if (!type_id) {
+        type_len = 0;
+     } else
+#endif
      type_len = tlen(get_id_type(type_id));
 
      /* I have no idea what the following does! */
index a4fc775c4525c8b4577bc168e2510ed903a1fd40..ad84da0b91603b65c60c0307d3561c4a970c4aca 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.1.1.1 1996/07/09 06:21:40 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.2 1996/07/19 07:24:08 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -471,6 +471,11 @@ oper(char *op, int arg1, int arg2)
     CandidateList candidates;
     int ncandidates;
 
+#ifdef NULL_PATCH
+    if (!arg2) arg2=arg1;
+    if (!arg1) arg1=arg2;
+#endif
+
     if (!(tup = SearchSysCacheTuple(OPRNAME,
                                    PointerGetDatum(op),
                                    ObjectIdGetDatum(arg1),
index 37c955017efa4ee0db9ac5326887eef365c75e21..974238aed47ba053a500929226a85ded41147b0c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.1.1.1 1996/07/09 06:21:40 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.2 1996/07/19 07:24:09 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -617,7 +617,11 @@ make_const(Value *value)
 
            /* null const */
            con = makeConst(0, 0, (Datum)NULL, TRUE, 0, FALSE);
+#ifdef NULL_PATCH
+           return con;
+#else
            return NULL /*con*/;
+#endif
        }
     }
 
index e0dae907588f339c3831ec21876692da7e297519..752db2f1f676fa583e3b148aa532ac26342c22fa 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.1.1.1 1996/07/09 06:21:40 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.2 1996/07/19 07:24:11 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -302,6 +302,10 @@ parser_typecast2(Node *expr, int exprType, Type tp, int typlen)
     Assert(IsA(expr,Const));
     
     switch (exprType) {
+#ifdef NULL_PATCH
+      case 0: /* NULL */
+       break;
+#endif
     case 23: /* int4 */
        const_string = (char *) palloc(256);
        string_palloced = true;
@@ -352,6 +356,18 @@ parser_typecast2(Node *expr, int exprType, Type tp, int typlen)
        elog(WARN,"unknown type%d ",exprType);
     }
     
+#ifdef NULL_PATCH
+    if (!exprType) {
+       adt = makeConst((Oid)typeid(tp),
+                       (Size) 0,
+                       (Datum) NULL,
+                       true,   /* isnull */
+                       0       /* was omitted */,
+                       0       /* not a set */);
+       return ((Node*) adt);
+    }
+#endif
+
     cp = instr2 (tp, const_string, typlen);