Commits

Anonymous committed 2028840

Fixes:

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>

Comments (0)

Files changed (4)

src/backend/parser/analyze.c

  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
 	 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! */

src/backend/parser/catalog_utils.c

  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
     CandidateList candidates;
     int ncandidates;
 
+#ifdef NULL_PATCH
+    if (!arg2) arg2=arg1;
+    if (!arg1) arg1=arg2;
+#endif
+
     if (!(tup = SearchSysCacheTuple(OPRNAME,
 				    PointerGetDatum(op),
 				    ObjectIdGetDatum(arg1),

src/backend/parser/parse_query.c

  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
 
 	    /* null const */
 	    con = makeConst(0, 0, (Datum)NULL, TRUE, 0, FALSE);
+#ifdef NULL_PATCH
+	    return con;
+#else
 	    return NULL /*con*/;
+#endif
 	}
     }
 

src/backend/parser/parser.c

  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
     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;
 	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);
     
     
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.