]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Move the "shell_add_schema()" SQL function used by the ".schema" command
authordrh <drh@noemail.net>
Thu, 15 Jun 2017 16:56:05 +0000 (16:56 +0000)
committerdrh <drh@noemail.net>
Thu, 15 Jun 2017 16:56:05 +0000 (16:56 +0000)
of the command-line shell to a different spot in the shell.c source file
so that it is not in the middle of an unrelated module.

FossilOrigin-Name: 254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270

manifest
manifest.uuid
src/shell.c

index 45ac624396f334697da3c5641da079ef7bb18034..52563b2b9871f8e84d5774f3808dd6cfb3f0c655 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\stypo\sand\simprove\sthe\swording\sof\sthe\sdescription\sof\s"Metadata"\sin\sthe\noutput\sof\sthe\ssqlite3_analyzer\stool.
-D 2017-06-15T16:45:23.229
+C Move\sthe\s"shell_add_schema()"\sSQL\sfunction\sused\sby\sthe\s".schema"\scommand\nof\sthe\scommand-line\sshell\sto\sa\sdifferent\sspot\sin\sthe\sshell.c\ssource\sfile\nso\sthat\sit\sis\snot\sin\sthe\smiddle\sof\san\sunrelated\smodule.
+D 2017-06-15T16:56:05.134
 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc
@@ -406,7 +406,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
 F src/resolve.c adf3ef9843135b1383321ad751f16f5a40c3f37925154555a3e61653d2a954e8
 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
 F src/select.c 0d2afdbdba5fbc61432c5454a35e0236e7aa4aa3756986a7d51b81a508e8083a
-F src/shell.c c45ae9a95faf5a495280bfa2d6b7956c707f347e56eb8b1985c852d152e46894
+F src/shell.c bcd3358ad6cb3f3dc7ec76ad3bd8191f123ed2425360c5c48fe431780eceb729
 F src/sqlite.h.in 67fa8bd29808e7988e0ce36c8d4c6043eb1727f94522fc612687aa5af51931e6
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
@@ -1582,7 +1582,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 9afd7a2ffd3a39456190ad05e85ff6485298aae262d9e0698a58c1d73507a36f
-R d7d9e08f1b748cb64c86b209b3f80ec6
+P ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4
+R 726cc59902873bb7eaa232bba10d7407
 U drh
-Z ab25672babe6d73331acc6dc2b1d5532
+Z 1749d6289173114f89482a05c36735c7
index d899e0cce8a296bf17bd7ded41458b2f01594a26..5621a335b60ccb7ca7f7a8d124a6ecbe393395af 100644 (file)
@@ -1 +1 @@
-ca1ff70780e07e5ee930fe7972db02e887d9b085d8ab78e878d7f966b6d684d4
\ No newline at end of file
+254617a1ccfa1736d4e53d670d80319c79c4d93ebf1de69d89ebdba3949bc270
\ No newline at end of file
index 0c109720a06e85bbb2f4b799b7e0be190297a0b2..a6818b8bfd3fa820b2e72d4b51f5a6cf7e820ac4 100644 (file)
@@ -729,6 +729,61 @@ static char quoteChar(const char *zName){
   return 0;
 }
 
+/*
+** SQL function:  shell_add_schema(S,X)
+**
+** Add the schema name X to the CREATE statement in S and return the result.
+** Examples:
+**
+**    CREATE TABLE t1(x)   ->   CREATE TABLE xyz.t1(x);
+**
+** Also works on
+**
+**    CREATE INDEX
+**    CREATE UNIQUE INDEX
+**    CREATE VIEW
+**    CREATE TRIGGER
+**    CREATE VIRTUAL TABLE
+**
+** This UDF is used by the .schema command to insert the schema name of
+** attached databases into the middle of the sqlite_master.sql field.
+*/
+static void shellAddSchemaName(
+  sqlite3_context *pCtx,
+  int nVal,
+  sqlite3_value **apVal
+){
+  static const char *aPrefix[] = {
+     "TABLE",
+     "INDEX",
+     "UNIQUE INDEX",
+     "VIEW",
+     "TRIGGER",
+     "VIRTUAL TABLE"
+  };
+  int i = 0;
+  const char *zIn = (const char*)sqlite3_value_text(apVal[0]);
+  const char *zSchema = (const char*)sqlite3_value_text(apVal[1]);
+  assert( nVal==2 );
+  if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){
+    for(i=0; i<sizeof(aPrefix)/sizeof(aPrefix[0]); i++){
+      int n = strlen30(aPrefix[i]);
+      if( strncmp(zIn+7, aPrefix[i], n)==0 && zIn[n+7]==' ' ){
+        char cQuote = quoteChar(zSchema);
+        char *z;
+        if( cQuote ){
+         z = sqlite3_mprintf("%.*s \"%w\".%s", n+7, zIn, zSchema, zIn+n+8);
+        }else{
+          z = sqlite3_mprintf("%.*s %s.%s", n+7, zIn, zSchema, zIn+n+8);
+        }
+        sqlite3_result_text(pCtx, z, -1, sqlite3_free);
+        return;
+      }
+    }
+  }
+  sqlite3_result_value(pCtx, apVal[0]);
+}
+
 /******************************************************************************
 ** SHA3 hash implementation copied from ../ext/misc/shathree.c
 */
@@ -1185,61 +1240,6 @@ static unsigned char *SHA3Final(SHA3Context *p){
   return &p->u.x[p->nRate];
 }
 
-/*
-** SQL function:  shell_add_schema(S,X)
-**
-** Add the schema name X to the CREATE statement in S and return the result.
-** Examples:
-**
-**    CREATE TABLE t1(x)   ->   CREATE TABLE xyz.t1(x);
-**
-** Also works on
-**
-**    CREATE INDEX
-**    CREATE UNIQUE INDEX
-**    CREATE VIEW
-**    CREATE TRIGGER
-**    CREATE VIRTUAL TABLE
-**
-** This UDF is used by the .schema command to insert the schema name of
-** attached databases into the middle of the sqlite_master.sql field.
-*/
-static void shellAddSchemaName(
-  sqlite3_context *pCtx,
-  int nVal,
-  sqlite3_value **apVal
-){
-  static const char *aPrefix[] = {
-     "TABLE",
-     "INDEX",
-     "UNIQUE INDEX",
-     "VIEW",
-     "TRIGGER",
-     "VIRTUAL TABLE"
-  };
-  int i = 0;
-  const char *zIn = (const char*)sqlite3_value_text(apVal[0]);
-  const char *zSchema = (const char*)sqlite3_value_text(apVal[1]);
-  assert( nVal==2 );
-  if( zIn!=0 && strncmp(zIn, "CREATE ", 7)==0 ){
-    for(i=0; i<sizeof(aPrefix)/sizeof(aPrefix[0]); i++){
-      int n = strlen30(aPrefix[i]);
-      if( strncmp(zIn+7, aPrefix[i], n)==0 && zIn[n+7]==' ' ){
-        char cQuote = quoteChar(zSchema);
-        char *z;
-        if( cQuote ){
-         z = sqlite3_mprintf("%.*s \"%w\".%s", n+7, zIn, zSchema, zIn+n+8);
-        }else{
-          z = sqlite3_mprintf("%.*s %s.%s", n+7, zIn, zSchema, zIn+n+8);
-        }
-        sqlite3_result_text(pCtx, z, -1, sqlite3_free);
-        return;
-      }
-    }
-  }
-  sqlite3_result_value(pCtx, apVal[0]);
-}
-
 /*
 ** Implementation of the sha3(X,SIZE) function.
 **