[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    [sqlite] Re: insert default values - supporting it?
From:       Mario Frasca <m.r.frasca () sron ! nl>
Date:       2006-07-31 13:23:15
Message-ID: 44CE0443.6020602 () sron ! nl
[Download RAW message or body]

I'm throwing this here, I assume that it would not be too much work to 
complete this patch. the aim is to support the sql92 syntax insert into 
<table> default values;

any comments? hints?

thanks in advance,
Mario Frasca.

cvs diff: Diffing src
Index: src/insert.c
===================================================================
RCS file: /sqlite/sqlite/src/insert.c,v
retrieving revision 1.170
diff -u -r1.170 insert.c
--- src/insert.c	19 Jun 2006 03:05:10 -0000	1.170
+++ src/insert.c	31 Jul 2006 13:04:19 -0000
@@ -123,6 +123,7 @@
 **
 **    insert into TABLE (IDLIST) values(EXPRLIST)
 **    insert into TABLE (IDLIST) select
+**    insert into TABLE default values
 **
 ** The IDLIST following the table name is always optional.  If omitted,
 ** then a list of all columns for the table is substituted.  The IDLIST
@@ -380,7 +381,16 @@
     }else{
       sqlite3VdbeJumpHere(v, iInitCode);
     }
-  }else{
+  }else if (pList == 0){
+    assert( pColumns == 0 );
+    /* This is the case if no data has been supplied and DEFAULT VALUES are
+    ** to be inserted.  a minimal impact approach would be to create here a
+    ** temporary list of columns containing just the primary key and a
+    ** temporary list of values containing just a NULL.  the rest of the
+    ** function would remain untouched.
+    */
+    nColumn = 0;
+  } else{
     /* This is the case if the data for the INSERT is coming from a VALUES
     ** clause
     */
Index: src/parse.y
===================================================================
RCS file: /sqlite/sqlite/src/parse.y,v
retrieving revision 1.206
diff -u -r1.206 parse.y
--- src/parse.y	11 Jul 2006 10:42:36 -0000	1.206
+++ src/parse.y	31 Jul 2006 13:04:19 -0000
@@ -598,6 +598,8 @@
 cmd ::= insert_cmd(R) INTO fullname(X) inscollist_opt(F) 
         VALUES LP itemlist(Y) RP.
             {sqlite3Insert(pParse, X, Y, 0, F, R);}
+cmd ::= insert_cmd(R) INTO fullname(X) DEFAULT VALUES.
+            {sqlite3Insert(pParse, X, 0, 0, 0, R);}
 cmd ::= insert_cmd(R) INTO fullname(X) inscollist_opt(F) select(S).
             {sqlite3Insert(pParse, X, 0, S, F, R);}
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic