rhodes 2.3.2 → 2.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +18 -0
- data/CREDITS +38 -0
- data/README.md +2 -2
- data/Rakefile +60 -2
- data/bin/set-rhodes-sdk.bat +1 -0
- data/doc/application.txt +11 -0
- data/doc/build.txt +156 -39
- data/doc/configuration.txt +1 -10
- data/doc/connect-to-web-services.txt +6 -6
- data/doc/device-caps.txt +48 -5
- data/doc/extensions.txt +8 -1
- data/doc/rhom.txt +16 -0
- data/doc/synchronization.txt +56 -14
- data/doc/ui.txt +23 -2
- data/installer/instant-rhodes.nsi +6 -6
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +4 -2
- data/lib/extensions/barcode/ext/barcode/platform/wm/Rakefile +1 -1
- data/lib/extensions/digest-md5/ext/Rakefile +3 -3
- data/lib/extensions/digest-md5/ext/build +0 -1
- data/lib/extensions/digest-sha1/ext/Rakefile +1 -1
- data/lib/extensions/digest-sha1/ext/build +0 -1
- data/lib/extensions/digest/ext/Rakefile +3 -3
- data/lib/extensions/digest/ext/build +0 -1
- data/lib/extensions/fcntl/ext/Rakefile +1 -1
- data/lib/extensions/mspec/mspec/guards/guard.rb +4 -0
- data/lib/extensions/mspec/mspec/helpers/environment.rb +4 -0
- data/lib/extensions/nfc/ext.yml +2 -0
- data/lib/extensions/nfc/ext/build +12 -0
- data/lib/extensions/nfc/ext/build.bat +8 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +25 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +94 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/ext_build.files +4 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +404 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/Nfc.java +138 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessage.java +34 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcMessagePack.java +33 -0
- data/lib/extensions/nfc/ext/nfc/platform/android/src/com/nfc/NfcRecord.java +149 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +22 -0
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +2034 -0
- data/lib/extensions/nfc/nfc.rb +120 -0
- data/lib/extensions/rholang/{lang_ca.rb → rholang/lang_ca.rb} +0 -0
- data/lib/extensions/rholang/{lang_cf.rb → rholang/lang_cf.rb} +0 -0
- data/lib/extensions/rholang/{lang_chef.rb → rholang/lang_chef.rb} +0 -0
- data/lib/extensions/rholang/{lang_cs.rb → rholang/lang_cs.rb} +0 -0
- data/lib/extensions/rholang/{lang_da.rb → rholang/lang_da.rb} +0 -0
- data/lib/extensions/rholang/{lang_de.rb → rholang/lang_de.rb} +0 -0
- data/lib/extensions/rholang/{lang_es.rb → rholang/lang_es.rb} +0 -0
- data/lib/extensions/rholang/{lang_es_ar.rb → rholang/lang_es_ar.rb} +0 -0
- data/lib/extensions/rholang/{lang_fi.rb → rholang/lang_fi.rb} +0 -0
- data/lib/extensions/rholang/{lang_fr.rb → rholang/lang_fr.rb} +0 -0
- data/lib/extensions/rholang/{lang_it.rb → rholang/lang_it.rb} +0 -0
- data/lib/extensions/rholang/{lang_ko.rb → rholang/lang_ko.rb} +0 -0
- data/lib/extensions/rholang/{lang_nl.rb → rholang/lang_nl.rb} +0 -0
- data/lib/extensions/rholang/{lang_no.rb → rholang/lang_no.rb} +0 -0
- data/lib/extensions/rholang/{lang_pt.rb → rholang/lang_pt.rb} +0 -0
- data/lib/extensions/rholang/{lang_pt_br.rb → rholang/lang_pt_br.rb} +0 -0
- data/lib/extensions/rholang/{lang_ru.rb → rholang/lang_ru.rb} +0 -0
- data/lib/extensions/rholang/{lang_se.rb → rholang/lang_se.rb} +0 -0
- data/lib/extensions/rholang/{lang_sr.rb → rholang/lang_sr.rb} +0 -0
- data/lib/extensions/rholang/{rhoerror_ru.rb → rholang/rhoerror_ru.rb} +0 -0
- data/lib/extensions/rholang/{rhomsg_ru.rb → rholang/rhomsg_ru.rb} +0 -0
- data/lib/framework/date/format.rb +2 -0
- data/lib/framework/dateOrig.rb +17 -8
- data/lib/framework/rational18.rb +532 -0
- data/lib/framework/res/back_btn.wp7.png +0 -0
- data/lib/framework/res/blue_pushpin.wp7.png +0 -0
- data/lib/framework/res/blue_pushpin_small.wp7.png +0 -0
- data/lib/framework/res/callout.wp7.png +0 -0
- data/lib/framework/res/callout_link.wp7.png +0 -0
- data/lib/framework/res/esri.wp7.png +0 -0
- data/lib/framework/res/forward_btn.wp7.png +0 -0
- data/lib/framework/res/home_btn.wp7.png +0 -0
- data/lib/framework/res/options_btn.wp7.png +0 -0
- data/lib/framework/res/refresh_btn.wp7.png +0 -0
- data/lib/framework/rho/render.rb +8 -1
- data/lib/framework/rho/rho.rb +30 -7
- data/lib/framework/rho/rhoapplication.rb +9 -4
- data/lib/framework/rho/rhofsconnector.rb +5 -1
- data/lib/framework/rho/rhotabbar.rb +8 -0
- data/lib/framework/rho/rhotoolbar.rb +1 -1
- data/lib/framework/rho/rhoviewhelpers.rb +18 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +46 -1
- data/lib/framework/rholang/localization_simplified.rb +17 -16
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
- data/lib/framework/rhom/rhom_object_factory.rb +115 -12
- data/lib/framework/rhosystem.rb +135 -0
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/lib/test/apps/rhoconfig.txt +23 -23
- data/platform/android/Rhodes/AndroidManifest.full.xml +101 -0
- data/platform/android/Rhodes/AndroidManifest.xml +10 -15
- data/platform/android/Rhodes/default.properties +11 -0
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +59 -53
- data/platform/android/Rhodes/jni/include/rhodes.h +1 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesApplication.h +21 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_alert_PopupActivity.h +21 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +10 -2
- data/platform/android/Rhodes/jni/src/alert.cpp +2 -1
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -0
- data/platform/android/Rhodes/jni/src/fileapi.cpp +671 -84
- data/platform/android/Rhodes/jni/src/nativebar.cpp +18 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +92 -1
- data/platform/android/Rhodes/res/values/styles.xml +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +35 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -13
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +130 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +6 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +6 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +7 -36
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +43 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +2 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +63 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +6 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +19 -282
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +354 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +4 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +71 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +107 -37
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +156 -56
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +0 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +40 -32
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/ExternalHttpHandler.java +14 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +46 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +4 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +3 -1
- data/platform/android/build/RhodesSRC_build.files +28 -25
- data/platform/android/build/android.rake +230 -54
- data/platform/android/build/androidcommon.rb +1 -1
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/bb/Hsqldb/BlackBerry_App_Descriptor.xml +20 -0
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +1 -5
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +6 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBase.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/rowio/RowOutputBinary.java +1 -1
- data/platform/bb/RubyVM/BlackBerry_App_Descriptor.xml +20 -0
- data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -0
- data/platform/bb/RubyVM/src/com/rho/RhoLogOutputSink.java +0 -1
- data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +12 -10
- data/platform/bb/RubyVM/src/com/rho/RhoThread.java +16 -0
- data/platform/bb/RubyVM/src/com/rho/RhoTimer.java +89 -0
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +20 -13
- data/platform/bb/RubyVM/src/com/rho/SplashScreen.java +1 -2
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/TimeInterval.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +54 -48
- data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +0 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +1 -0
- data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/JSONStructIterator.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +16 -8
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +52 -29
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -3
- data/platform/bb/build/RubyVM_build.files +1 -0
- data/platform/bb/build/bb.rake +29 -9
- data/platform/bb/rhodes/BlackBerry_App_Descriptor.xml +23 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +1 -1
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +0 -4
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +13 -20
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +183 -157
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +22 -0
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +1 -1
- data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +0 -4
- data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +13 -20
- data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +183 -157
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +46 -1
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +8 -1
- data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +13 -3
- data/platform/iphone/Classes/AppManager/AppManager.h +5 -1
- data/platform/iphone/Classes/AppManager/AppManager.m +170 -7
- data/platform/iphone/Classes/DateTimePicker.m +14 -1
- data/platform/iphone/Classes/DateTimePickerDelegate.h +2 -0
- data/platform/iphone/Classes/DateTimePickerDelegate.m +36 -2
- data/platform/iphone/Classes/NativeBar.h +1 -0
- data/platform/iphone/Classes/NativeBar.m +15 -3
- data/platform/iphone/Classes/Phonebook/phonebook.m +8 -9
- data/platform/iphone/Classes/Rhodes.m +50 -6
- data/platform/iphone/Classes/SimpleMainView.m +7 -6
- data/platform/iphone/Classes/SplitView/RightViewController.h +3 -1
- data/platform/iphone/Classes/SplitView/RightViewController.m +14 -1
- data/platform/iphone/Classes/TabbedMainView.h +4 -0
- data/platform/iphone/Classes/TabbedMainView.m +43 -26
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +4 -0
- data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +3 -3
- data/platform/iphone/rbuild/iphone.rake +168 -119
- data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -2
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +3 -3
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +2 -2
- data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +3 -3
- data/platform/shared/SyncClient/SyncClient.cpp +20 -8
- data/platform/shared/SyncClient/SyncClient.h +2 -1
- data/platform/shared/common/RhoDefs.h +4 -0
- data/platform/shared/common/RhoPort.h +22 -0
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhoTime.cpp +73 -0
- data/platform/shared/common/RhoTime.h +26 -53
- data/platform/shared/common/RhodesApp.cpp +29 -28
- data/platform/shared/common/RhodesApp.h +4 -1
- data/platform/shared/common/StringConverter.h +37 -10
- data/platform/shared/common/app_build_capabilities.h +2 -0
- data/platform/shared/common/rhoparams.cpp +25 -12
- data/platform/shared/common/rhoparams.h +10 -8
- data/platform/shared/db/DBAdapter.cpp +0 -22
- data/platform/shared/json/RJSONTokener.c +15 -23
- data/platform/shared/net/AsyncHttp.cpp +9 -8
- data/platform/shared/net/HttpServer.cpp +61 -19
- data/platform/shared/net/HttpServer.h +2 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +3 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +151 -402
- data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +154 -403
- data/platform/shared/ruby/ext/rho/rhoruby.c +4 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
- data/platform/shared/ruby/ext/system/system.i +8 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +80 -5
- data/platform/shared/ruby/file.c +6 -4
- data/platform/shared/ruby/gc.c +1 -1
- data/platform/shared/ruby/linux/ruby/config.h +7 -2
- data/platform/shared/ruby/missing/acosh.c +3 -3
- data/platform/shared/ruby/wince/_time.h +1 -1
- data/platform/shared/ruby/wince/stdlib.c +1 -1
- data/platform/shared/ruby/wince/string_wce.c +2 -2
- data/platform/shared/ruby/wince/sys/timeb.c +1 -0
- data/platform/shared/ruby/wince/time_wce.c +8 -0
- data/platform/shared/ruby/wince/wince.c +7 -7
- data/platform/shared/ruby/wince/wince.h +22 -0
- data/platform/shared/rubyext/System.cpp +19 -1
- data/platform/shared/sqlite/sqlite3.c +18993 -8129
- data/platform/shared/sqlite/sqlite3.h +953 -358
- data/platform/shared/sqlite/sqlite3ext.h +42 -0
- data/platform/shared/sync/SyncEngine.cpp +10 -0
- data/platform/shared/sync/SyncSource.cpp +41 -19
- data/platform/shared/sync/SyncSource.h +1 -1
- data/platform/shared/tcmalloc/rhomem.h +7 -2
- data/platform/shared/tcmalloc/windows/port.h +2 -0
- data/platform/shared/unzip/unzip.cpp +1 -0
- data/platform/shared/xruby/src/com/xruby/compiler/parser/RubyParser.java +11 -1
- data/platform/wm/RhoLib/RhoLib.vcproj +182 -24
- data/platform/wm/build/wm.rake +16 -3
- data/platform/wm/rhodes.sln +106 -113
- data/platform/wm/rhodes/Alert.cpp +6 -7
- data/platform/wm/rhodes/AppManager.cpp +8 -17
- data/platform/wm/rhodes/DateTimePicker.cpp +3 -0
- data/platform/wm/rhodes/DateTimePicker.h +2 -0
- data/platform/wm/rhodes/MainWindow.cpp +36 -16
- data/platform/wm/rhodes/MainWindow.h +6 -3
- data/platform/wm/rhodes/OutlookApp.cpp +3 -3
- data/platform/wm/rhodes/Rhodes.cpp +46 -27
- data/platform/wm/rhodes/Rhodes.rc +16 -3
- data/platform/wm/rhodes/RingtoneManager.cpp +7 -7
- data/platform/wm/rhodes/RingtoneManager.h +1 -1
- data/platform/wm/rhodes/Utils.cpp +2 -1
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1 -13
- data/platform/wm/rhodes/bluetooth/Bluetooth.h +1 -2
- data/platform/wm/rhodes/camera/Camera.cpp +6 -12
- data/platform/wm/rhodes/phonebook/phonebook.cpp +11 -11
- data/platform/wm/rhodes/phonebook/phonebook.h +1 -1
- data/platform/wm/rhodes/resource.h +3 -1
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +7 -5
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +6 -6
- data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +6 -1
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +84 -19
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +2 -2
- data/platform/wm/rhodes/rhodes.vcproj +316 -73
- data/platform/wm/rhodes/signature/Signature.cpp +336 -6
- data/platform/wm/rhodes/signature/Signature.h +55 -0
- data/platform/wm/rhodes/stdafx.h +7 -4
- data/platform/wm/rubylib/rubylib.vcproj +261 -91
- data/platform/wm/sqlite3/sqlite3.vcproj +223 -69
- data/platform/wm/syncengine/syncengine.vcproj +220 -66
- data/platform/wm/tcmalloc/tcmalloc.vcproj +197 -43
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/ConsoleStream.cs +107 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/Loader.cs +1037 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +1476 -0
- data/platform/wp7/RhoAppRunner/Program.cs +55 -0
- data/platform/wp7/RhoAppRunner/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoAppRunner/RhoAppRunner.csproj +69 -0
- data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +7 -0
- data/platform/wp7/RhoRubyExtGen/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoRubyExtGen/RhoAsyncHttp.cs +38 -0
- data/platform/wp7/RhoRubyExtGen/RhoDatabase.cs +93 -0
- data/platform/wp7/RhoRubyExtGen/RhoJSON.cs +37 -0
- data/platform/wp7/RhoRubyExtGen/RhoNativeBar.cs +106 -0
- data/platform/wp7/RhoRubyExtGen/RhoRubyExtGen.csproj +75 -0
- data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +123 -0
- data/platform/wp7/RhoRubyExtGen/RhoWebView.cs +42 -0
- data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +309 -0
- data/platform/wp7/RhoRubyLib/Properties/AssemblyInfo.cs +36 -0
- data/platform/wp7/RhoRubyLib/RhoAppAdapter.cs +96 -0
- data/platform/wp7/RhoRubyLib/RhoRuby.cs +296 -0
- data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +155 -0
- data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +107 -0
- data/platform/wp7/RhoRubyLib/common/IInputStream.cs +21 -0
- data/platform/wp7/RhoRubyLib/common/Mutex.cs +30 -0
- data/platform/wp7/RhoRubyLib/common/RhoConf.cs +389 -0
- data/platform/wp7/RhoRubyLib/common/RhoEmptyProfiler.cs +27 -0
- data/platform/wp7/RhoRubyLib/common/RhoFile.cs +332 -0
- data/platform/wp7/RhoRubyLib/common/RhoFilePath.cs +89 -0
- data/platform/wp7/RhoRubyLib/common/RhoParamArray.cs +33 -0
- data/platform/wp7/RhoRubyLib/common/RhoParams.cs +66 -0
- data/platform/wp7/RhoRubyLib/common/RhoProfiler.cs +145 -0
- data/platform/wp7/RhoRubyLib/common/RhoResourceMap.cs +68 -0
- data/platform/wp7/RhoRubyLib/common/RhoStd.cs +205 -0
- data/platform/wp7/RhoRubyLib/common/RhoThread.cs +114 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +504 -0
- data/platform/wp7/RhoRubyLib/common/ThreadQueue.cs +199 -0
- data/platform/wp7/RhoRubyLib/common/TimeInterval.cs +56 -0
- data/platform/wp7/RhoRubyLib/common/Tokenizer.cs +52 -0
- data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +1129 -0
- data/platform/wp7/RhoRubyLib/db/DBAttrManager.cs +92 -0
- data/platform/wp7/RhoRubyLib/db/DBException.cs +35 -0
- data/platform/wp7/RhoRubyLib/db/IDBCallback.cs +10 -0
- data/platform/wp7/RhoRubyLib/db/IDBResult.cs +33 -0
- data/platform/wp7/RhoRubyLib/db/IDBStorage.cs +32 -0
- data/platform/wp7/RhoRubyLib/db/SqliteCopyResult.cs +79 -0
- data/platform/wp7/RhoRubyLib/db/SqliteResult.cs +267 -0
- data/platform/wp7/RhoRubyLib/db/SqliteStorage.cs +319 -0
- data/platform/wp7/RhoRubyLib/json/JSONArrayIterator.cs +63 -0
- data/platform/wp7/RhoRubyLib/json/JSONEntry.cs +96 -0
- data/platform/wp7/RhoRubyLib/json/JSONStructIterator.cs +77 -0
- data/platform/wp7/RhoRubyLib/json/JsonParser.cs +483 -0
- data/platform/wp7/RhoRubyLib/json/RJSONTokener.cs +406 -0
- data/platform/wp7/RhoRubyLib/logging/IRhoLogSink.cs +12 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogConf.cs +161 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogFileSink.cs +174 -0
- data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +320 -0
- data/platform/wp7/RhoRubyLib/net/AsyncHttp.cs +362 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +466 -0
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +717 -0
- data/platform/wp7/RhoRubyLib/net/NetResponse.cs +64 -0
- data/platform/wp7/RhoRubyLib/net/URI.cs +187 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +43 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +177 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +39 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +19 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +117 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +199 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +49 -0
- data/platform/wp7/RhoRubyLib/sync/ClientRegister.cs +142 -0
- data/platform/wp7/RhoRubyLib/sync/ISyncProtocol.cs +23 -0
- data/platform/wp7/RhoRubyLib/sync/ISyncStatusListener.cs +10 -0
- data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +1051 -0
- data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +651 -0
- data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +79 -0
- data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +1105 -0
- data/platform/wp7/RhoRubyLib/sync/SyncThread.cs +301 -0
- data/platform/wp7/WPApplication.sln +50 -0
- data/platform/wp7/WPApplication/App.xaml +19 -0
- data/platform/wp7/WPApplication/App.xaml.cs +211 -0
- data/platform/wp7/WPApplication/ApplicationIcon.png +0 -0
- data/platform/wp7/WPApplication/Background.png +0 -0
- data/platform/wp7/WPApplication/MainPage.xaml +44 -0
- data/platform/wp7/WPApplication/MainPage.xaml.cs +132 -0
- data/platform/wp7/WPApplication/Properties/AppManifest.xml +6 -0
- data/platform/wp7/WPApplication/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/WPApplication/Properties/WMAppManifest.xml +32 -0
- data/platform/wp7/WPApplication/SplashScreenImage.jpg +0 -0
- data/platform/wp7/WPApplication/WPApplication.csproj +201 -0
- data/platform/wp7/WPApplication/WP_PlatformAdaptationLayer.cs +88 -0
- data/platform/wp7/WPApplication/app_manifest.txt +1 -0
- data/platform/wp7/WPApplication/readme.htm +40 -0
- data/platform/wp7/WPApplication/readme2.htm +37 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.bb.erb +29 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/edit.erb +32 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/index.bb.erb +21 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/index.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/model1.rb +10 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/model1_controller.rb +58 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/new.bb.erb +29 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/new.erb +31 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/show.bb.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/Model1/show.erb +28 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/controller.rb +75 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/home.bb.erb +17 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/home.erb +20 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/index.bb.erb +32 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/index.erb +30 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/login.bb.erb +35 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/login.erb +27 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.bb.erb +15 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/reset.erb +17 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.bb.erb +3 -0
- data/platform/wp7/WPApplication/rho/apps/app/Settings/wait.erb +5 -0
- data/platform/wp7/WPApplication/rho/apps/app/application.rb +16 -0
- data/platform/wp7/WPApplication/rho/apps/app/helpers/application_helper.rb +126 -0
- data/platform/wp7/WPApplication/rho/apps/app/helpers/browser_helper.rb +18 -0
- data/platform/wp7/WPApplication/rho/apps/app/index.bb.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/index.erb +26 -0
- data/platform/wp7/WPApplication/rho/apps/app/layout.erb +45 -0
- data/platform/wp7/WPApplication/rho/apps/app/loading.html +11 -0
- data/platform/wp7/WPApplication/rho/apps/app_manifest.txt +1 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/android.css +330 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/blackberry.css +115 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/iphone.css +410 -0
- data/platform/wp7/WPApplication/rho/apps/public/css/windows_mobile.css +222 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/IUI_LICENSE.txt +21 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_check_on.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/btn_radio_on.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/disclosure.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/android/ic_menu_more.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/backButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/blueButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/cancel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/grayButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/disclosure_detail.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/backButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/blueButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/cancel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/chevron.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/grayButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listArrowSel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/listGroup.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/loading.gif +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/on_off.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/pinstripes.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/selection.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/thumb.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggle.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toggleOn.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/toolbar.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/jqtouch/whiteButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/radiobutton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/select.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iphone/switch.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/iui-logo-touch-icon.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrow.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrowDown.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listArrowSel.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/listGroup.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/loading.gif +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/pinstripes.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/right_button.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/selection.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/thumb.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toggle.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toggleOn.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolButton_new.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/toolbar.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/images/whiteButton.png +0 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch-iphone.css +9 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.css +374 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.js +742 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jqtouch.transitions.js +60 -0
- data/platform/wp7/WPApplication/rho/apps/public/jqtouch/jquery.1.3.2.min.js +19 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/application.js +1 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rho.js +4 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation-wm.js +59 -0
- data/platform/wp7/WPApplication/rho/apps/public/js/rhogeolocation.js +11 -0
- data/platform/wp7/WPApplication/rho/apps/rhoconfig.txt +32 -0
- data/platform/wp7/WPApplication/rhoconfig.txt +32 -0
- data/platform/wp7/WPApplication/windows_mobile.css +222 -0
- data/platform/wp7/build/wp.rake +261 -0
- data/platform/wp7/rhodes.sln +79 -0
- data/platform/wp7/rhodes/App.xaml +19 -0
- data/platform/wp7/rhodes/App.xaml.cs +144 -0
- data/platform/wp7/rhodes/Background.png +0 -0
- data/platform/wp7/rhodes/MainPage.xaml +44 -0
- data/platform/wp7/rhodes/MainPage.xaml.cs +98 -0
- data/platform/wp7/rhodes/Properties/AppManifest.xml +6 -0
- data/platform/wp7/rhodes/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/rhodes/Properties/WMAppManifest.xml +31 -0
- data/platform/wp7/rhodes/Rhodes.csproj +127 -0
- data/platform/wp7/rhodes/SplashScreenImage.jpg +0 -0
- data/platform/wp7/rhodes/icon.png +0 -0
- data/platform/wp7/sqlite3/Properties/AssemblyInfo.cs +35 -0
- data/platform/wp7/sqlite3/SQLiteClient.cs +550 -0
- data/platform/wp7/sqlite3/SqliteWrapper/BtreeInt_h.cs +774 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Btree_h.cs +280 -0
- data/platform/wp7/sqlite3/SqliteWrapper/ClassDiagram1.cd +1306 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Delagates.cs +365 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Hash_h.cs +133 -0
- data/platform/wp7/sqlite3/SqliteWrapper/VdbeInt_h.cs +620 -0
- data/platform/wp7/sqlite3/SqliteWrapper/Vdbe_h.cs +302 -0
- data/platform/wp7/sqlite3/SqliteWrapper/_Custom.cs +449 -0
- data/platform/wp7/sqlite3/SqliteWrapper/alter_c.cs +872 -0
- data/platform/wp7/sqlite3/SqliteWrapper/analyze_c.cs +757 -0
- data/platform/wp7/sqlite3/SqliteWrapper/attach_c.cs +628 -0
- data/platform/wp7/sqlite3/SqliteWrapper/auth_c.cs +268 -0
- data/platform/wp7/sqlite3/SqliteWrapper/backup_c.cs +737 -0
- data/platform/wp7/sqlite3/SqliteWrapper/bitvec_c.cs +509 -0
- data/platform/wp7/sqlite3/SqliteWrapper/btmutex_c.cs +379 -0
- data/platform/wp7/sqlite3/SqliteWrapper/btree_c.cs +9138 -0
- data/platform/wp7/sqlite3/SqliteWrapper/build_c.cs +4189 -0
- data/platform/wp7/sqlite3/SqliteWrapper/callback_c.cs +548 -0
- data/platform/wp7/sqlite3/SqliteWrapper/complete_c.cs +342 -0
- data/platform/wp7/sqlite3/SqliteWrapper/ctime_cs.cs +408 -0
- data/platform/wp7/sqlite3/SqliteWrapper/date_c.cs +1317 -0
- data/platform/wp7/sqlite3/SqliteWrapper/delete_c.cs +726 -0
- data/platform/wp7/sqlite3/SqliteWrapper/expr_c.cs +4406 -0
- data/platform/wp7/sqlite3/SqliteWrapper/fault_c.cs +115 -0
- data/platform/wp7/sqlite3/SqliteWrapper/fkey_c.cs +1330 -0
- data/platform/wp7/sqlite3/SqliteWrapper/func_c.cs +2025 -0
- data/platform/wp7/sqlite3/SqliteWrapper/global_c.cs +228 -0
- data/platform/wp7/sqlite3/SqliteWrapper/hash_c.cs +351 -0
- data/platform/wp7/sqlite3/SqliteWrapper/hwtime_c.cs +101 -0
- data/platform/wp7/sqlite3/SqliteWrapper/insert_c.cs +2122 -0
- data/platform/wp7/sqlite3/SqliteWrapper/journal_c.cs +247 -0
- data/platform/wp7/sqlite3/SqliteWrapper/keywordhash_h.cs +302 -0
- data/platform/wp7/sqlite3/SqliteWrapper/legacy_c.cs +223 -0
- data/platform/wp7/sqlite3/SqliteWrapper/loadext_c.cs +683 -0
- data/platform/wp7/sqlite3/SqliteWrapper/main_c.cs +2716 -0
- data/platform/wp7/sqlite3/SqliteWrapper/malloc_c.cs +977 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mem_Pool.cs +394 -0
- data/platform/wp7/sqlite3/SqliteWrapper/memjournal_c.cs +315 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_c.cs +182 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_h.cs +91 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_noop_c.cs +202 -0
- data/platform/wp7/sqlite3/SqliteWrapper/mutex_w32.cs +344 -0
- data/platform/wp7/sqlite3/SqliteWrapper/notify_c.cs +347 -0
- data/platform/wp7/sqlite3/SqliteWrapper/opcodes_c.cs +171 -0
- data/platform/wp7/sqlite3/SqliteWrapper/opcodes_h.cs +346 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_c.cs +367 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_common_h.cs +174 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_h.cs +295 -0
- data/platform/wp7/sqlite3/SqliteWrapper/os_win_c.cs +1255 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pager_c.cs +6078 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pager_h.cs +188 -0
- data/platform/wp7/sqlite3/SqliteWrapper/parse_c.cs +4045 -0
- data/platform/wp7/sqlite3/SqliteWrapper/parse_h.cs +331 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache1_c.cs +969 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache_c.cs +712 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pcache_h.cs +213 -0
- data/platform/wp7/sqlite3/SqliteWrapper/pragma_c.cs +1767 -0
- data/platform/wp7/sqlite3/SqliteWrapper/prepare_c.cs +1015 -0
- data/platform/wp7/sqlite3/SqliteWrapper/printf_c.cs +1300 -0
- data/platform/wp7/sqlite3/SqliteWrapper/random_c.cs +201 -0
- data/platform/wp7/sqlite3/SqliteWrapper/resolve_c.cs +1396 -0
- data/platform/wp7/sqlite3/SqliteWrapper/rowset_c.cs +519 -0
- data/platform/wp7/sqlite3/SqliteWrapper/select_c.cs +4878 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqlite3_h.cs +6253 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqlite3ext_h.cs +397 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteInt_h.cs +4075 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteLimit_h.cs +214 -0
- data/platform/wp7/sqlite3/SqliteWrapper/sqliteicu_h.cs +39 -0
- data/platform/wp7/sqlite3/SqliteWrapper/status_c.cs +155 -0
- data/platform/wp7/sqlite3/SqliteWrapper/table_c.cs +222 -0
- data/platform/wp7/sqlite3/SqliteWrapper/tokenize_c.cs +673 -0
- data/platform/wp7/sqlite3/SqliteWrapper/trigger_c.cs +1219 -0
- data/platform/wp7/sqlite3/SqliteWrapper/update_c.cs +766 -0
- data/platform/wp7/sqlite3/SqliteWrapper/utf_c.cs +612 -0
- data/platform/wp7/sqlite3/SqliteWrapper/util_c.cs +1476 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vacuum_c.cs +382 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbe_c.cs +6566 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeapi_c.cs +1557 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeaux_c.cs +4019 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbeblob_c.cs +396 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbemem_c.cs +1480 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vdbetrace_c.cs +181 -0
- data/platform/wp7/sqlite3/SqliteWrapper/vtab_c.cs +957 -0
- data/platform/wp7/sqlite3/SqliteWrapper/walker_c.cs +174 -0
- data/platform/wp7/sqlite3/SqliteWrapper/where_c.cs +4651 -0
- data/platform/wp7/sqlite3/sqlite3.csproj +155 -0
- data/rakefile.rb +60 -2
- data/res/build-tools/7za.exe +0 -0
- data/res/build-tools/RhoAppRunner.exe +0 -0
- data/res/build-tools/xruby-0.3.3.jar +0 -0
- data/res/generators/rhogen.rb +9 -1
- data/res/generators/templates/application/app/Settings/reset.erb +1 -1
- data/res/generators/templates/application/app/layout.erb +17 -10
- data/res/generators/templates/application/build.yml +5 -3
- data/res/generators/templates/application/public/jqtouch/changes.txt +20 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +12 -4
- data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
- data/res/generators/templates/application/public/js/wp7.js +7 -0
- data/res/generators/templates/model/controller.rb +5 -6
- data/rhobuild.yml.example +1 -0
- data/rhodes.gemspec +2 -1
- data/spec/framework_spec/app/spec/core/dir/close_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/dir/shared/pwd.rb +13 -11
- data/spec/framework_spec/app/spec/core/env/shared/store.rb +12 -10
- data/spec/framework_spec/app/spec/core/env/update_spec.rb +1 -0
- data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +3 -2
- data/spec/framework_spec/app/spec/core/file/fixtures/file_types.rb +7 -1
- data/spec/framework_spec/app/spec/core/file/flock_spec.rb +8 -1
- data/spec/framework_spec/app/spec/core/file/ftype_spec.rb +5 -3
- data/spec/framework_spec/app/spec/core/file/lchmod_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/setgid_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/setuid_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/file/stat/ftype_spec.rb +6 -4
- data/spec/framework_spec/app/spec/core/file/truncate_spec.rb +5 -1
- data/spec/framework_spec/app/spec/core/float/to_s_spec.rb +1 -1
- data/spec/framework_spec/app/spec/core/process/gid_spec.rb +5 -3
- data/spec/framework_spec/app/spec/core/process/groups_spec.rb +11 -9
- data/spec/framework_spec/app/spec/core/process/uid_spec.rb +5 -3
- data/spec/framework_spec/app/spec/language/execution_spec.rb +10 -6
- data/spec/framework_spec/app/spec/shared/file/directory.rb +6 -1
- data/spec/framework_spec/app/spec/shared/file/executable.rb +7 -1
- data/spec/framework_spec/app/spec/shared/file/file.rb +6 -1
- data/spec/framework_spec/app/spec/shared/file/readable.rb +13 -4
- data/spec/framework_spec/app/spec/shared/file/writable.rb +6 -1
- data/spec/phone_spec/app/spec/rho_controller_spec.rb +11 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +11 -0
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +102 -6
- data/spec/phone_spec/app/spec/string/end_with_spec.rb +4 -1
- data/spec/phone_spec/app/spec/string/slice_spec.rb +5 -1
- data/spec/phone_spec/app/spec/string/start_with_spec.rb +4 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +73 -6
- data/spec/phone_spec/app/spec_runner.rb +7 -3
- metadata +380 -41
- data/Manifest.txt +0 -5819
- data/platform/bb/Hsqldb/Hsqldb.cso +0 -5
- data/platform/bb/Hsqldb/Hsqldb.jdp +0 -197
- data/platform/bb/RhoBundle/RhoBundle.cso +0 -5
- data/platform/bb/RhoBundle/RhoBundle.jdp +0 -42
- data/platform/bb/RubyVM/RubyVM.cso +0 -5
- data/platform/bb/RubyVM/RubyVM.jdp +0 -467
- data/platform/bb/rhodes/rhodes.csl +0 -3
- data/platform/bb/rhodes/rhodes.cso +0 -5
- data/platform/bb/rhodes/rhodes.jdp +0 -104
@@ -0,0 +1,101 @@
|
|
1
|
+
namespace Community.CsharpSqlite
|
2
|
+
{
|
3
|
+
using sqlite_u3264 = System.UInt64;
|
4
|
+
|
5
|
+
public partial class Sqlite3
|
6
|
+
{
|
7
|
+
/*
|
8
|
+
** 2008 May 27
|
9
|
+
**
|
10
|
+
** The author disclaims copyright to this source code. In place of
|
11
|
+
** a legal notice, here is a blessing:
|
12
|
+
**
|
13
|
+
** May you do good and not evil.
|
14
|
+
** May you find forgiveness for yourself and forgive others.
|
15
|
+
** May you share freely, never taking more than you give.
|
16
|
+
**
|
17
|
+
******************************************************************************
|
18
|
+
**
|
19
|
+
** This file contains inline asm code for retrieving "high-performance"
|
20
|
+
** counters for x86 class CPUs.
|
21
|
+
**
|
22
|
+
** $Id: hwtime.h,v 1.3 2008/08/01 14:33:15 shane Exp $
|
23
|
+
**
|
24
|
+
*************************************************************************
|
25
|
+
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
|
26
|
+
** C#-SQLite is an independent reimplementation of the SQLite software library
|
27
|
+
**
|
28
|
+
** $Header$
|
29
|
+
*************************************************************************
|
30
|
+
*/
|
31
|
+
//#if !_HWTIME_H_
|
32
|
+
//#define _HWTIME_H_
|
33
|
+
|
34
|
+
/*
|
35
|
+
** The following routine only works on pentium-class (or newer) processors.
|
36
|
+
** It uses the RDTSC opcode to read the cycle count value out of the
|
37
|
+
** processor and returns that value. This can be used for high-res
|
38
|
+
** profiling.
|
39
|
+
*/
|
40
|
+
#if ((__GNUC__) || (_MSC_VER)) && ((i386) || (__i386__) || (_M_IX86))
|
41
|
+
|
42
|
+
#if (__GNUC__)
|
43
|
+
|
44
|
+
__inline__ sqlite_u3264 sqlite3Hwtime(void){
|
45
|
+
unsigned int lo, hi;
|
46
|
+
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
|
47
|
+
return (sqlite_u3264)hi << 32 | lo;
|
48
|
+
}
|
49
|
+
|
50
|
+
#elif (_MSC_VER)
|
51
|
+
|
52
|
+
__declspec(naked) __inline sqlite_u3264 __cdecl sqlite3Hwtime(void){
|
53
|
+
__asm {
|
54
|
+
rdtsc
|
55
|
+
ret ; return value at EDX:EAX
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
#endif
|
60
|
+
|
61
|
+
#elif ((__GNUC__) && (__x86_64__))
|
62
|
+
|
63
|
+
__inline__ sqlite_u3264 sqlite3Hwtime(void){
|
64
|
+
unsigned long val;
|
65
|
+
__asm__ __volatile__ ("rdtsc" : "=A" (val));
|
66
|
+
return val;
|
67
|
+
}
|
68
|
+
|
69
|
+
#elif ( (__GNUC__) && (__ppc__))
|
70
|
+
|
71
|
+
__inline__ sqlite_u3264 sqlite3Hwtime(void){
|
72
|
+
unsigned long long retval;
|
73
|
+
unsigned long junk;
|
74
|
+
__asm__ __volatile__ ("\n\
|
75
|
+
1: mftbu %1\n\
|
76
|
+
mftb %L0\n\
|
77
|
+
mftbu %0\n\
|
78
|
+
cmpw %0,%1\n\
|
79
|
+
bne 1b"
|
80
|
+
: "=r" (retval), "=r" (junk));
|
81
|
+
return retval;
|
82
|
+
}
|
83
|
+
|
84
|
+
#else
|
85
|
+
|
86
|
+
//#error Need implementation of sqlite3Hwtime() for your platform.
|
87
|
+
|
88
|
+
/*
|
89
|
+
** To compile without implementing sqlite3Hwtime() for your platform,
|
90
|
+
** you can remove the above #error and use the following
|
91
|
+
** stub function. You will lose timing support for many
|
92
|
+
** of the debugging and testing utilities, but it should at
|
93
|
+
** least compile and run.
|
94
|
+
*/
|
95
|
+
static sqlite_u3264 sqlite3Hwtime() { return (sqlite_u3264)System.DateTime.Now.Ticks; }// (sqlite_u3264)0 ); }
|
96
|
+
|
97
|
+
#endif
|
98
|
+
|
99
|
+
//#endif //* !_HWTIME_H_) */
|
100
|
+
}
|
101
|
+
}
|
@@ -0,0 +1,2122 @@
|
|
1
|
+
using System;
|
2
|
+
using System.Diagnostics;
|
3
|
+
using System.Text;
|
4
|
+
|
5
|
+
using Pgno = System.UInt32;
|
6
|
+
using u8 = System.Byte;
|
7
|
+
using u32 = System.UInt32;
|
8
|
+
|
9
|
+
namespace Community.CsharpSqlite
|
10
|
+
{
|
11
|
+
public partial class Sqlite3
|
12
|
+
{
|
13
|
+
/*
|
14
|
+
** 2001 September 15
|
15
|
+
**
|
16
|
+
** The author disclaims copyright to this source code. In place of
|
17
|
+
** a legal notice, here is a blessing:
|
18
|
+
**
|
19
|
+
** May you do good and not evil.
|
20
|
+
** May you find forgiveness for yourself and forgive others.
|
21
|
+
** May you share freely, never taking more than you give.
|
22
|
+
**
|
23
|
+
*************************************************************************
|
24
|
+
** This file contains C code routines that are called by the parser
|
25
|
+
** to handle INSERT statements in SQLite.
|
26
|
+
*************************************************************************
|
27
|
+
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
|
28
|
+
** C#-SQLite is an independent reimplementation of the SQLite software library
|
29
|
+
**
|
30
|
+
** SQLITE_SOURCE_ID: 2010-03-09 19:31:43 4ae453ea7be69018d8c16eb8dabe05617397dc4d
|
31
|
+
**
|
32
|
+
** $Header$
|
33
|
+
*************************************************************************
|
34
|
+
*/
|
35
|
+
//#include "sqliteInt.h"
|
36
|
+
|
37
|
+
/*
|
38
|
+
** Generate code that will open a table for reading.
|
39
|
+
*/
|
40
|
+
static void sqlite3OpenTable(
|
41
|
+
Parse p, /* Generate code into this VDBE */
|
42
|
+
int iCur, /* The cursor number of the table */
|
43
|
+
int iDb, /* The database index in sqlite3.aDb[] */
|
44
|
+
Table pTab, /* The table to be opened */
|
45
|
+
int opcode /* OP_OpenRead or OP_OpenWrite */
|
46
|
+
)
|
47
|
+
{
|
48
|
+
Vdbe v;
|
49
|
+
if ( IsVirtual( pTab ) ) return;
|
50
|
+
v = sqlite3GetVdbe( p );
|
51
|
+
Debug.Assert( opcode == OP_OpenWrite || opcode == OP_OpenRead );
|
52
|
+
sqlite3TableLock( p, iDb, pTab.tnum, ( opcode == OP_OpenWrite ) ? (byte)1 : (byte)0, pTab.zName );
|
53
|
+
sqlite3VdbeAddOp3( v, opcode, iCur, pTab.tnum, iDb );
|
54
|
+
sqlite3VdbeChangeP4( v, -1, ( pTab.nCol ), P4_INT32 );//SQLITE_INT_TO_PTR( pTab.nCol ), P4_INT32 );
|
55
|
+
VdbeComment( v, "%s", pTab.zName );
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
** Return a pointer to the column affinity string associated with index
|
60
|
+
** pIdx. A column affinity string has one character for each column in
|
61
|
+
** the table, according to the affinity of the column:
|
62
|
+
**
|
63
|
+
** Character Column affinity
|
64
|
+
** ------------------------------
|
65
|
+
** 'a' TEXT
|
66
|
+
** 'b' NONE
|
67
|
+
** 'c' NUMERIC
|
68
|
+
** 'd' INTEGER
|
69
|
+
** 'e' REAL
|
70
|
+
**
|
71
|
+
** An extra 'b' is appended to the end of the string to cover the
|
72
|
+
** rowid that appears as the last column in every index.
|
73
|
+
**
|
74
|
+
** Memory for the buffer containing the column index affinity string
|
75
|
+
** is managed along with the rest of the Index structure. It will be
|
76
|
+
** released when sqlite3DeleteIndex() is called.
|
77
|
+
*/
|
78
|
+
static string sqlite3IndexAffinityStr( Vdbe v, Index pIdx )
|
79
|
+
{
|
80
|
+
if ( pIdx.zColAff == null || pIdx.zColAff[0] == '\0' )
|
81
|
+
{
|
82
|
+
/* The first time a column affinity string for a particular index is
|
83
|
+
** required, it is allocated and populated here. It is then stored as
|
84
|
+
** a member of the Index structure for subsequent use.
|
85
|
+
**
|
86
|
+
** The column affinity string will eventually be deleted by
|
87
|
+
** sqliteDeleteIndex() when the Index structure itself is cleaned
|
88
|
+
** up.
|
89
|
+
*/
|
90
|
+
int n;
|
91
|
+
Table pTab = pIdx.pTable;
|
92
|
+
sqlite3 db = sqlite3VdbeDb( v );
|
93
|
+
StringBuilder pIdx_zColAff = new StringBuilder( pIdx.nColumn + 2 );// (char *)sqlite3Malloc(pIdx.nColumn+2);
|
94
|
+
// if ( pIdx_zColAff == null )
|
95
|
+
// {
|
96
|
+
// db.mallocFailed = 1;
|
97
|
+
// return null;
|
98
|
+
// }
|
99
|
+
for ( n = 0; n < pIdx.nColumn; n++ )
|
100
|
+
{
|
101
|
+
pIdx_zColAff.Append( pTab.aCol[pIdx.aiColumn[n]].affinity );
|
102
|
+
}
|
103
|
+
pIdx_zColAff.Append( SQLITE_AFF_NONE );
|
104
|
+
pIdx_zColAff.Append( '\0' );
|
105
|
+
pIdx.zColAff = pIdx_zColAff.ToString();
|
106
|
+
}
|
107
|
+
return pIdx.zColAff;
|
108
|
+
}
|
109
|
+
|
110
|
+
/*
|
111
|
+
** Set P4 of the most recently inserted opcode to a column affinity
|
112
|
+
** string for table pTab. A column affinity string has one character
|
113
|
+
** for each column indexed by the index, according to the affinity of the
|
114
|
+
** column:
|
115
|
+
**
|
116
|
+
** Character Column affinity
|
117
|
+
** ------------------------------
|
118
|
+
** 'a' TEXT
|
119
|
+
** 'b' NONE
|
120
|
+
** 'c' NUMERIC
|
121
|
+
** 'd' INTEGER
|
122
|
+
** 'e' REAL
|
123
|
+
*/
|
124
|
+
static void sqlite3TableAffinityStr( Vdbe v, Table pTab )
|
125
|
+
{
|
126
|
+
/* The first time a column affinity string for a particular table
|
127
|
+
** is required, it is allocated and populated here. It is then
|
128
|
+
** stored as a member of the Table structure for subsequent use.
|
129
|
+
**
|
130
|
+
** The column affinity string will eventually be deleted by
|
131
|
+
** sqlite3DeleteTable() when the Table structure itself is cleaned up.
|
132
|
+
*/
|
133
|
+
if ( pTab.zColAff == null )
|
134
|
+
{
|
135
|
+
StringBuilder zColAff;
|
136
|
+
int i;
|
137
|
+
sqlite3 db = sqlite3VdbeDb( v );
|
138
|
+
|
139
|
+
zColAff = new StringBuilder( pTab.nCol + 1 );// (char*)sqlite3Malloc(db, pTab.nCol + 1);
|
140
|
+
if ( zColAff == null )
|
141
|
+
{
|
142
|
+
//// db.mallocFailed = 1;
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
for ( i = 0; i < pTab.nCol; i++ )
|
147
|
+
{
|
148
|
+
zColAff.Append( pTab.aCol[i].affinity );
|
149
|
+
}
|
150
|
+
//zColAff.Append( '\0' );
|
151
|
+
|
152
|
+
pTab.zColAff = zColAff.ToString();
|
153
|
+
}
|
154
|
+
|
155
|
+
sqlite3VdbeChangeP4( v, -1, pTab.zColAff, 0 );
|
156
|
+
}
|
157
|
+
|
158
|
+
/*
|
159
|
+
** Return non-zero if the table pTab in database iDb or any of its indices
|
160
|
+
** have been opened at any point in the VDBE program beginning at location
|
161
|
+
** iStartAddr throught the end of the program. This is used to see if
|
162
|
+
** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
|
163
|
+
** run without using temporary table for the results of the SELECT.
|
164
|
+
*/
|
165
|
+
static bool readsTable( Parse p, int iStartAddr, int iDb, Table pTab )
|
166
|
+
{
|
167
|
+
Vdbe v = sqlite3GetVdbe( p );
|
168
|
+
int i;
|
169
|
+
int iEnd = sqlite3VdbeCurrentAddr( v );
|
170
|
+
#if !SQLITE_OMIT_VIRTUALTABLE
|
171
|
+
VTable pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p,db, pTab) : null;
|
172
|
+
#endif
|
173
|
+
|
174
|
+
for ( i = iStartAddr; i < iEnd; i++ )
|
175
|
+
{
|
176
|
+
VdbeOp pOp = sqlite3VdbeGetOp( v, i );
|
177
|
+
Debug.Assert( pOp != null );
|
178
|
+
if ( pOp.opcode == OP_OpenRead && pOp.p3 == iDb )
|
179
|
+
{
|
180
|
+
Index pIndex;
|
181
|
+
int tnum = pOp.p2;
|
182
|
+
if ( tnum == pTab.tnum )
|
183
|
+
{
|
184
|
+
return true;
|
185
|
+
}
|
186
|
+
for ( pIndex = pTab.pIndex; pIndex != null; pIndex = pIndex.pNext )
|
187
|
+
{
|
188
|
+
if ( tnum == pIndex.tnum )
|
189
|
+
{
|
190
|
+
return true;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
#if !SQLITE_OMIT_VIRTUALTABLE
|
195
|
+
if( pOp.opcode==OP_VOpen && pOp.p4.pVtab==pVTab){
|
196
|
+
Debug.Assert( pOp.p4.pVtab!=0 );
|
197
|
+
Debug.Assert( pOp.p4type==P4_VTAB );
|
198
|
+
return true;
|
199
|
+
}
|
200
|
+
#endif
|
201
|
+
}
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
|
205
|
+
#if !SQLITE_OMIT_AUTOINCREMENT
|
206
|
+
/*
|
207
|
+
** Locate or create an AutoincInfo structure associated with table pTab
|
208
|
+
** which is in database iDb. Return the register number for the register
|
209
|
+
** that holds the maximum rowid.
|
210
|
+
**
|
211
|
+
** There is at most one AutoincInfo structure per table even if the
|
212
|
+
** same table is autoincremented multiple times due to inserts within
|
213
|
+
** triggers. A new AutoincInfo structure is created if this is the
|
214
|
+
** first use of table pTab. On 2nd and subsequent uses, the original
|
215
|
+
** AutoincInfo structure is used.
|
216
|
+
**
|
217
|
+
** Three memory locations are allocated:
|
218
|
+
**
|
219
|
+
** (1) Register to hold the name of the pTab table.
|
220
|
+
** (2) Register to hold the maximum ROWID of pTab.
|
221
|
+
** (3) Register to hold the rowid in sqlite_sequence of pTab
|
222
|
+
**
|
223
|
+
** The 2nd register is the one that is returned. That is all the
|
224
|
+
** insert routine needs to know about.
|
225
|
+
*/
|
226
|
+
static int autoIncBegin(
|
227
|
+
Parse pParse, /* Parsing context */
|
228
|
+
int iDb, /* Index of the database holding pTab */
|
229
|
+
Table pTab /* The table we are writing to */
|
230
|
+
)
|
231
|
+
{
|
232
|
+
int memId = 0; /* Register holding maximum rowid */
|
233
|
+
if ( ( pTab.tabFlags & TF_Autoincrement ) != 0 )
|
234
|
+
{
|
235
|
+
Parse pToplevel = sqlite3ParseToplevel( pParse );
|
236
|
+
AutoincInfo pInfo;
|
237
|
+
|
238
|
+
pInfo = pToplevel.pAinc;
|
239
|
+
while ( pInfo != null && pInfo.pTab != pTab ) { pInfo = pInfo.pNext; }
|
240
|
+
if ( pInfo == null )
|
241
|
+
{
|
242
|
+
pInfo = new AutoincInfo();//sqlite3DbMallocRaw(pParse.db, sizeof(*pInfo));
|
243
|
+
//if( pInfo==0 ) return 0;
|
244
|
+
pInfo.pNext = pToplevel.pAinc;
|
245
|
+
pToplevel.pAinc = pInfo;
|
246
|
+
pInfo.pTab = pTab;
|
247
|
+
pInfo.iDb = iDb;
|
248
|
+
pToplevel.nMem++; /* Register to hold name of table */
|
249
|
+
pInfo.regCtr = ++pToplevel.nMem; /* Max rowid register */
|
250
|
+
pToplevel.nMem++; /* Rowid in sqlite_sequence */
|
251
|
+
}
|
252
|
+
memId = pInfo.regCtr;
|
253
|
+
}
|
254
|
+
return memId;
|
255
|
+
}
|
256
|
+
|
257
|
+
/*
|
258
|
+
** This routine generates code that will initialize all of the
|
259
|
+
** register used by the autoincrement tracker.
|
260
|
+
*/
|
261
|
+
static void sqlite3AutoincrementBegin( Parse pParse )
|
262
|
+
{
|
263
|
+
AutoincInfo p; /* Information about an AUTOINCREMENT */
|
264
|
+
sqlite3 db = pParse.db; /* The database connection */
|
265
|
+
Db pDb; /* Database only autoinc table */
|
266
|
+
int memId; /* Register holding max rowid */
|
267
|
+
int addr; /* A VDBE address */
|
268
|
+
Vdbe v = pParse.pVdbe; /* VDBE under construction */
|
269
|
+
|
270
|
+
/* This routine is never called during trigger-generation. It is
|
271
|
+
** only called from the top-level */
|
272
|
+
Debug.Assert( pParse.pTriggerTab == null );
|
273
|
+
Debug.Assert( pParse == sqlite3ParseToplevel( pParse ) );
|
274
|
+
|
275
|
+
Debug.Assert( v != null ); /* We failed long ago if this is not so */
|
276
|
+
for ( p = pParse.pAinc; p != null; p = p.pNext )
|
277
|
+
{
|
278
|
+
pDb = db.aDb[p.iDb];
|
279
|
+
memId = p.regCtr;
|
280
|
+
sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenRead );
|
281
|
+
addr = sqlite3VdbeCurrentAddr( v );
|
282
|
+
sqlite3VdbeAddOp4( v, OP_String8, 0, memId - 1, 0, p.pTab.zName, 0 );
|
283
|
+
sqlite3VdbeAddOp2( v, OP_Rewind, 0, addr + 9 );
|
284
|
+
sqlite3VdbeAddOp3( v, OP_Column, 0, 0, memId );
|
285
|
+
sqlite3VdbeAddOp3( v, OP_Ne, memId - 1, addr + 7, memId );
|
286
|
+
sqlite3VdbeChangeP5( v, SQLITE_JUMPIFNULL );
|
287
|
+
sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 );
|
288
|
+
sqlite3VdbeAddOp3( v, OP_Column, 0, 1, memId );
|
289
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, addr + 9 );
|
290
|
+
sqlite3VdbeAddOp2( v, OP_Next, 0, addr + 2 );
|
291
|
+
sqlite3VdbeAddOp2( v, OP_Integer, 0, memId );
|
292
|
+
sqlite3VdbeAddOp0( v, OP_Close );
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
/*
|
297
|
+
** Update the maximum rowid for an autoincrement calculation.
|
298
|
+
**
|
299
|
+
** This routine should be called when the top of the stack holds a
|
300
|
+
** new rowid that is about to be inserted. If that new rowid is
|
301
|
+
** larger than the maximum rowid in the memId memory cell, then the
|
302
|
+
** memory cell is updated. The stack is unchanged.
|
303
|
+
*/
|
304
|
+
static void autoIncStep( Parse pParse, int memId, int regRowid )
|
305
|
+
{
|
306
|
+
if ( memId > 0 )
|
307
|
+
{
|
308
|
+
sqlite3VdbeAddOp2( pParse.pVdbe, OP_MemMax, memId, regRowid );
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
/*
|
313
|
+
** This routine generates the code needed to write autoincrement
|
314
|
+
** maximum rowid values back into the sqlite_sequence register.
|
315
|
+
** Every statement that might do an INSERT into an autoincrement
|
316
|
+
** table (either directly or through triggers) needs to call this
|
317
|
+
** routine just before the "exit" code.
|
318
|
+
*/
|
319
|
+
static void sqlite3AutoincrementEnd( Parse pParse )
|
320
|
+
{
|
321
|
+
AutoincInfo p;
|
322
|
+
Vdbe v = pParse.pVdbe;
|
323
|
+
sqlite3 db = pParse.db;
|
324
|
+
|
325
|
+
Debug.Assert( v != null );
|
326
|
+
for ( p = pParse.pAinc; p != null; p = p.pNext )
|
327
|
+
{
|
328
|
+
Db pDb = db.aDb[p.iDb];
|
329
|
+
int j1, j2, j3, j4, j5;
|
330
|
+
int iRec;
|
331
|
+
int memId = p.regCtr;
|
332
|
+
|
333
|
+
iRec = sqlite3GetTempReg( pParse );
|
334
|
+
sqlite3OpenTable( pParse, 0, p.iDb, pDb.pSchema.pSeqTab, OP_OpenWrite );
|
335
|
+
j1 = sqlite3VdbeAddOp1( v, OP_NotNull, memId + 1 );
|
336
|
+
j2 = sqlite3VdbeAddOp0( v, OP_Rewind );
|
337
|
+
j3 = sqlite3VdbeAddOp3( v, OP_Column, 0, 0, iRec );
|
338
|
+
j4 = sqlite3VdbeAddOp3( v, OP_Eq, memId - 1, 0, iRec );
|
339
|
+
sqlite3VdbeAddOp2( v, OP_Next, 0, j3 );
|
340
|
+
sqlite3VdbeJumpHere( v, j2 );
|
341
|
+
sqlite3VdbeAddOp2( v, OP_NewRowid, 0, memId + 1 );
|
342
|
+
j5 = sqlite3VdbeAddOp0( v, OP_Goto );
|
343
|
+
sqlite3VdbeJumpHere( v, j4 );
|
344
|
+
sqlite3VdbeAddOp2( v, OP_Rowid, 0, memId + 1 );
|
345
|
+
sqlite3VdbeJumpHere( v, j1 );
|
346
|
+
sqlite3VdbeJumpHere( v, j5 );
|
347
|
+
sqlite3VdbeAddOp3( v, OP_MakeRecord, memId - 1, 2, iRec );
|
348
|
+
sqlite3VdbeAddOp3( v, OP_Insert, 0, iRec, memId + 1 );
|
349
|
+
sqlite3VdbeChangeP5( v, OPFLAG_APPEND );
|
350
|
+
sqlite3VdbeAddOp0( v, OP_Close );
|
351
|
+
sqlite3ReleaseTempReg( pParse, iRec );
|
352
|
+
}
|
353
|
+
}
|
354
|
+
#else
|
355
|
+
/*
|
356
|
+
** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines
|
357
|
+
** above are all no-ops
|
358
|
+
*/
|
359
|
+
//# define autoIncBegin(A,B,C) (0)
|
360
|
+
//# define autoIncStep(A,B,C)
|
361
|
+
#endif // * SQLITE_OMIT_AUTOINCREMENT */
|
362
|
+
|
363
|
+
|
364
|
+
/* Forward declaration */
|
365
|
+
//static int xferOptimization(
|
366
|
+
// Parse pParse, /* Parser context */
|
367
|
+
// Table pDest, /* The table we are inserting into */
|
368
|
+
// Select pSelect, /* A SELECT statement to use as the data source */
|
369
|
+
// int onError, /* How to handle constraint errors */
|
370
|
+
// int iDbDest /* The database of pDest */
|
371
|
+
//);
|
372
|
+
|
373
|
+
/*
|
374
|
+
** This routine is call to handle SQL of the following forms:
|
375
|
+
**
|
376
|
+
** insert into TABLE (IDLIST) values(EXPRLIST)
|
377
|
+
** insert into TABLE (IDLIST) select
|
378
|
+
**
|
379
|
+
** The IDLIST following the table name is always optional. If omitted,
|
380
|
+
** then a list of all columns for the table is substituted. The IDLIST
|
381
|
+
** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted.
|
382
|
+
**
|
383
|
+
** The pList parameter holds EXPRLIST in the first form of the INSERT
|
384
|
+
** statement above, and pSelect is NULL. For the second form, pList is
|
385
|
+
** NULL and pSelect is a pointer to the select statement used to generate
|
386
|
+
** data for the insert.
|
387
|
+
**
|
388
|
+
** The code generated follows one of four templates. For a simple
|
389
|
+
** select with data coming from a VALUES clause, the code executes
|
390
|
+
** once straight down through. Pseudo-code follows (we call this
|
391
|
+
** the "1st template"):
|
392
|
+
**
|
393
|
+
** open write cursor to <table> and its indices
|
394
|
+
** puts VALUES clause expressions onto the stack
|
395
|
+
** write the resulting record into <table>
|
396
|
+
** cleanup
|
397
|
+
**
|
398
|
+
** The three remaining templates assume the statement is of the form
|
399
|
+
**
|
400
|
+
** INSERT INTO <table> SELECT ...
|
401
|
+
**
|
402
|
+
** If the SELECT clause is of the restricted form "SELECT * FROM <table2>" -
|
403
|
+
** in other words if the SELECT pulls all columns from a single table
|
404
|
+
** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and
|
405
|
+
** if <table2> and <table1> are distinct tables but have identical
|
406
|
+
** schemas, including all the same indices, then a special optimization
|
407
|
+
** is invoked that copies raw records from <table2> over to <table1>.
|
408
|
+
** See the xferOptimization() function for the implementation of this
|
409
|
+
** template. This is the 2nd template.
|
410
|
+
**
|
411
|
+
** open a write cursor to <table>
|
412
|
+
** open read cursor on <table2>
|
413
|
+
** transfer all records in <table2> over to <table>
|
414
|
+
** close cursors
|
415
|
+
** foreach index on <table>
|
416
|
+
** open a write cursor on the <table> index
|
417
|
+
** open a read cursor on the corresponding <table2> index
|
418
|
+
** transfer all records from the read to the write cursors
|
419
|
+
** close cursors
|
420
|
+
** end foreach
|
421
|
+
**
|
422
|
+
** The 3rd template is for when the second template does not apply
|
423
|
+
** and the SELECT clause does not read from <table> at any time.
|
424
|
+
** The generated code follows this template:
|
425
|
+
**
|
426
|
+
** EOF <- 0
|
427
|
+
** X <- A
|
428
|
+
** goto B
|
429
|
+
** A: setup for the SELECT
|
430
|
+
** loop over the rows in the SELECT
|
431
|
+
** load values into registers R..R+n
|
432
|
+
** yield X
|
433
|
+
** end loop
|
434
|
+
** cleanup after the SELECT
|
435
|
+
** EOF <- 1
|
436
|
+
** yield X
|
437
|
+
** goto A
|
438
|
+
** B: open write cursor to <table> and its indices
|
439
|
+
** C: yield X
|
440
|
+
** if EOF goto D
|
441
|
+
** insert the select result into <table> from R..R+n
|
442
|
+
** goto C
|
443
|
+
** D: cleanup
|
444
|
+
**
|
445
|
+
** The 4th template is used if the insert statement takes its
|
446
|
+
** values from a SELECT but the data is being inserted into a table
|
447
|
+
** that is also read as part of the SELECT. In the third form,
|
448
|
+
** we have to use a intermediate table to store the results of
|
449
|
+
** the select. The template is like this:
|
450
|
+
**
|
451
|
+
** EOF <- 0
|
452
|
+
** X <- A
|
453
|
+
** goto B
|
454
|
+
** A: setup for the SELECT
|
455
|
+
** loop over the tables in the SELECT
|
456
|
+
** load value into register R..R+n
|
457
|
+
** yield X
|
458
|
+
** end loop
|
459
|
+
** cleanup after the SELECT
|
460
|
+
** EOF <- 1
|
461
|
+
** yield X
|
462
|
+
** halt-error
|
463
|
+
** B: open temp table
|
464
|
+
** L: yield X
|
465
|
+
** if EOF goto M
|
466
|
+
** insert row from R..R+n into temp table
|
467
|
+
** goto L
|
468
|
+
** M: open write cursor to <table> and its indices
|
469
|
+
** rewind temp table
|
470
|
+
** C: loop over rows of intermediate table
|
471
|
+
** transfer values form intermediate table into <table>
|
472
|
+
** end loop
|
473
|
+
** D: cleanup
|
474
|
+
*/
|
475
|
+
// OVERLOADS, so I don't need to rewrite parse.c
|
476
|
+
static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, int null_4, IdList pColumn, int onError )
|
477
|
+
{ sqlite3Insert( pParse, pTabList, null, null, pColumn, onError ); }
|
478
|
+
static void sqlite3Insert( Parse pParse, SrcList pTabList, int null_3, Select pSelect, IdList pColumn, int onError )
|
479
|
+
{ sqlite3Insert( pParse, pTabList, null, pSelect, pColumn, onError ); }
|
480
|
+
static void sqlite3Insert( Parse pParse, SrcList pTabList, ExprList pList, int null_4, IdList pColumn, int onError )
|
481
|
+
{ sqlite3Insert( pParse, pTabList, pList, null, pColumn, onError ); }
|
482
|
+
static void sqlite3Insert(
|
483
|
+
Parse pParse, /* Parser context */
|
484
|
+
SrcList pTabList, /* Name of table into which we are inserting */
|
485
|
+
ExprList pList, /* List of values to be inserted */
|
486
|
+
Select pSelect, /* A SELECT statement to use as the data source */
|
487
|
+
IdList pColumn, /* Column names corresponding to IDLIST. */
|
488
|
+
int onError /* How to handle constraint errors */
|
489
|
+
)
|
490
|
+
{
|
491
|
+
sqlite3 db; /* The main database structure */
|
492
|
+
Table pTab; /* The table to insert into. aka TABLE */
|
493
|
+
string zTab; /* Name of the table into which we are inserting */
|
494
|
+
string zDb; /* Name of the database holding this table */
|
495
|
+
int i = 0;
|
496
|
+
int j = 0;
|
497
|
+
int idx = 0; /* Loop counters */
|
498
|
+
Vdbe v; /* Generate code into this virtual machine */
|
499
|
+
Index pIdx; /* For looping over indices of the table */
|
500
|
+
int nColumn; /* Number of columns in the data */
|
501
|
+
int nHidden = 0; /* Number of hidden columns if TABLE is virtual */
|
502
|
+
int baseCur = 0; /* VDBE VdbeCursor number for pTab */
|
503
|
+
int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */
|
504
|
+
int endOfLoop = 0; /* Label for the end of the insertion loop */
|
505
|
+
bool useTempTable = false; /* Store SELECT results in intermediate table */
|
506
|
+
int srcTab = 0; /* Data comes from this temporary cursor if >=0 */
|
507
|
+
int addrInsTop = 0; /* Jump to label "D" */
|
508
|
+
int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */
|
509
|
+
int addrSelect = 0; /* Address of coroutine that implements the SELECT */
|
510
|
+
SelectDest dest; /* Destination for SELECT on rhs of INSERT */
|
511
|
+
int iDb; /* Index of database holding TABLE */
|
512
|
+
Db pDb; /* The database containing table being inserted into */
|
513
|
+
bool appendFlag = false; /* True if the insert is likely to be an append */
|
514
|
+
|
515
|
+
/* Register allocations */
|
516
|
+
int regFromSelect = 0; /* Base register for data coming from SELECT */
|
517
|
+
int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
|
518
|
+
int regRowCount = 0; /* Memory cell used for the row counter */
|
519
|
+
int regIns; /* Block of regs holding rowid+data being inserted */
|
520
|
+
int regRowid; /* registers holding insert rowid */
|
521
|
+
int regData; /* register holding first column to insert */
|
522
|
+
int regRecord; /* Holds the assemblied row record */
|
523
|
+
int regEof = 0; /* Register recording end of SELECT data */
|
524
|
+
int[] aRegIdx = null; /* One register allocated to each index */
|
525
|
+
|
526
|
+
|
527
|
+
#if !SQLITE_OMIT_TRIGGER
|
528
|
+
bool isView = false; /* True if attempting to insert into a view */
|
529
|
+
Trigger pTrigger; /* List of triggers on pTab, if required */
|
530
|
+
int tmask = 0; /* Mask of trigger times */
|
531
|
+
#endif
|
532
|
+
|
533
|
+
db = pParse.db;
|
534
|
+
dest = new SelectDest();// memset( &dest, 0, sizeof( dest ) );
|
535
|
+
|
536
|
+
if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ )
|
537
|
+
{
|
538
|
+
goto insert_cleanup;
|
539
|
+
}
|
540
|
+
|
541
|
+
/* Locate the table into which we will be inserting new information.
|
542
|
+
*/
|
543
|
+
Debug.Assert( pTabList.nSrc == 1 );
|
544
|
+
zTab = pTabList.a[0].zName;
|
545
|
+
if ( NEVER( zTab == null ) ) goto insert_cleanup;
|
546
|
+
pTab = sqlite3SrcListLookup( pParse, pTabList );
|
547
|
+
if ( pTab == null )
|
548
|
+
{
|
549
|
+
goto insert_cleanup;
|
550
|
+
}
|
551
|
+
iDb = sqlite3SchemaToIndex( db, pTab.pSchema );
|
552
|
+
Debug.Assert( iDb < db.nDb );
|
553
|
+
pDb = db.aDb[iDb];
|
554
|
+
zDb = pDb.zName;
|
555
|
+
#if !SQLITE_OMIT_AUTHORIZATION
|
556
|
+
if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab.zName, 0, zDb) ){
|
557
|
+
goto insert_cleanup;
|
558
|
+
}
|
559
|
+
#endif
|
560
|
+
/* Figure out if we have any triggers and if the table being
|
561
|
+
** inserted into is a view
|
562
|
+
*/
|
563
|
+
#if !SQLITE_OMIT_TRIGGER
|
564
|
+
pTrigger = sqlite3TriggersExist( pParse, pTab, TK_INSERT, null, ref tmask );
|
565
|
+
isView = pTab.pSelect != null;
|
566
|
+
#else
|
567
|
+
Trigger pTrigger = null; //# define pTrigger 0
|
568
|
+
int tmask = 0; //# define tmask 0
|
569
|
+
bool isView = false;
|
570
|
+
#endif
|
571
|
+
#if SQLITE_OMIT_VIEW
|
572
|
+
//# undef isView
|
573
|
+
isView = false;
|
574
|
+
#endif
|
575
|
+
#if !SQLITE_OMIT_TRIGGER
|
576
|
+
Debug.Assert( ( pTrigger != null && tmask != 0 ) || ( pTrigger == null && tmask == 0 ) );
|
577
|
+
#endif
|
578
|
+
|
579
|
+
#if !SQLITE_OMIT_VIEW
|
580
|
+
/* If pTab is really a view, make sure it has been initialized.
|
581
|
+
** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual
|
582
|
+
** module table).
|
583
|
+
*/
|
584
|
+
if ( sqlite3ViewGetColumnNames( pParse, pTab ) != -0 )
|
585
|
+
{
|
586
|
+
goto insert_cleanup;
|
587
|
+
}
|
588
|
+
#endif
|
589
|
+
|
590
|
+
/* Ensure that:
|
591
|
+
* (a) the table is not read-only,
|
592
|
+
* (b) that if it is a view then ON INSERT triggers exist
|
593
|
+
*/
|
594
|
+
if ( sqlite3IsReadOnly( pParse, pTab, tmask ) )
|
595
|
+
{
|
596
|
+
goto insert_cleanup;
|
597
|
+
}
|
598
|
+
|
599
|
+
/* Allocate a VDBE
|
600
|
+
*/
|
601
|
+
v = sqlite3GetVdbe( pParse );
|
602
|
+
if ( v == null ) goto insert_cleanup;
|
603
|
+
if ( pParse.nested == 0 ) sqlite3VdbeCountChanges( v );
|
604
|
+
sqlite3BeginWriteOperation( pParse, ( pSelect != null || pTrigger != null ) ? 1 : 0, iDb );
|
605
|
+
|
606
|
+
#if !SQLITE_OMIT_XFER_OPT
|
607
|
+
/* If the statement is of the form
|
608
|
+
**
|
609
|
+
** INSERT INTO <table1> SELECT * FROM <table2>;
|
610
|
+
**
|
611
|
+
** Then special optimizations can be applied that make the transfer
|
612
|
+
** very fast and which reduce fragmentation of indices.
|
613
|
+
**
|
614
|
+
** This is the 2nd template.
|
615
|
+
*/
|
616
|
+
if ( pColumn == null && xferOptimization( pParse, pTab, pSelect, onError, iDb ) != 0 )
|
617
|
+
{
|
618
|
+
Debug.Assert( null == pTrigger );
|
619
|
+
Debug.Assert( pList == null );
|
620
|
+
goto insert_end;
|
621
|
+
}
|
622
|
+
#endif // * SQLITE_OMIT_XFER_OPT */
|
623
|
+
|
624
|
+
/* If this is an AUTOINCREMENT table, look up the sequence number in the
|
625
|
+
** sqlite_sequence table and store it in memory cell regAutoinc.
|
626
|
+
*/
|
627
|
+
regAutoinc = autoIncBegin( pParse, iDb, pTab );
|
628
|
+
|
629
|
+
/* Figure out how many columns of data are supplied. If the data
|
630
|
+
** is coming from a SELECT statement, then generate a co-routine that
|
631
|
+
** produces a single row of the SELECT on each invocation. The
|
632
|
+
** co-routine is the common header to the 3rd and 4th templates.
|
633
|
+
*/
|
634
|
+
if ( pSelect != null )
|
635
|
+
{
|
636
|
+
/* Data is coming from a SELECT. Generate code to implement that SELECT
|
637
|
+
** as a co-routine. The code is common to both the 3rd and 4th
|
638
|
+
** templates:
|
639
|
+
**
|
640
|
+
** EOF <- 0
|
641
|
+
** X <- A
|
642
|
+
** goto B
|
643
|
+
** A: setup for the SELECT
|
644
|
+
** loop over the tables in the SELECT
|
645
|
+
** load value into register R..R+n
|
646
|
+
** yield X
|
647
|
+
** end loop
|
648
|
+
** cleanup after the SELECT
|
649
|
+
** EOF <- 1
|
650
|
+
** yield X
|
651
|
+
** halt-error
|
652
|
+
**
|
653
|
+
** On each invocation of the co-routine, it puts a single row of the
|
654
|
+
** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1.
|
655
|
+
** (These output registers are allocated by sqlite3Select().) When
|
656
|
+
** the SELECT completes, it sets the EOF flag stored in regEof.
|
657
|
+
*/
|
658
|
+
int rc = 0, j1;
|
659
|
+
|
660
|
+
regEof = ++pParse.nMem;
|
661
|
+
sqlite3VdbeAddOp2( v, OP_Integer, 0, regEof ); /* EOF <- 0 */
|
662
|
+
#if SQLITE_DEBUG
|
663
|
+
VdbeComment( v, "SELECT eof flag" );
|
664
|
+
#endif
|
665
|
+
sqlite3SelectDestInit( dest, SRT_Coroutine, ++pParse.nMem );
|
666
|
+
addrSelect = sqlite3VdbeCurrentAddr( v ) + 2;
|
667
|
+
sqlite3VdbeAddOp2( v, OP_Integer, addrSelect - 1, dest.iParm );
|
668
|
+
j1 = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 );
|
669
|
+
#if SQLITE_DEBUG
|
670
|
+
VdbeComment( v, "Jump over SELECT coroutine" );
|
671
|
+
#endif
|
672
|
+
/* Resolve the expressions in the SELECT statement and execute it. */
|
673
|
+
rc = sqlite3Select( pParse, pSelect, ref dest );
|
674
|
+
Debug.Assert( pParse.nErr == 0 || rc != 0 );
|
675
|
+
if ( rc != 0 || NEVER( pParse.nErr != 0 ) /*|| db.mallocFailed != 0 */ )
|
676
|
+
{
|
677
|
+
goto insert_cleanup;
|
678
|
+
}
|
679
|
+
sqlite3VdbeAddOp2( v, OP_Integer, 1, regEof ); /* EOF <- 1 */
|
680
|
+
sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm ); /* yield X */
|
681
|
+
sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_INTERNAL, OE_Abort );
|
682
|
+
#if SQLITE_DEBUG
|
683
|
+
VdbeComment( v, "End of SELECT coroutine" );
|
684
|
+
#endif
|
685
|
+
sqlite3VdbeJumpHere( v, j1 ); /* label B: */
|
686
|
+
|
687
|
+
regFromSelect = dest.iMem;
|
688
|
+
Debug.Assert( pSelect.pEList != null );
|
689
|
+
nColumn = pSelect.pEList.nExpr;
|
690
|
+
Debug.Assert( dest.nMem == nColumn );
|
691
|
+
|
692
|
+
/* Set useTempTable to TRUE if the result of the SELECT statement
|
693
|
+
** should be written into a temporary table (template 4). Set to
|
694
|
+
** FALSE if each* row of the SELECT can be written directly into
|
695
|
+
** the destination table (template 3).
|
696
|
+
**
|
697
|
+
** A temp table must be used if the table being updated is also one
|
698
|
+
** of the tables being read by the SELECT statement. Also use a
|
699
|
+
** temp table in the case of row triggers.
|
700
|
+
*/
|
701
|
+
if ( pTrigger != null || readsTable( pParse, addrSelect, iDb, pTab ) )
|
702
|
+
{
|
703
|
+
useTempTable = true;
|
704
|
+
}
|
705
|
+
|
706
|
+
if ( useTempTable )
|
707
|
+
{
|
708
|
+
/* Invoke the coroutine to extract information from the SELECT
|
709
|
+
** and add it to a transient table srcTab. The code generated
|
710
|
+
** here is from the 4th template:
|
711
|
+
**
|
712
|
+
** B: open temp table
|
713
|
+
** L: yield X
|
714
|
+
** if EOF goto M
|
715
|
+
** insert row from R..R+n into temp table
|
716
|
+
** goto L
|
717
|
+
** M: ...
|
718
|
+
*/
|
719
|
+
int regRec; /* Register to hold packed record */
|
720
|
+
int regTempRowid; /* Register to hold temp table ROWID */
|
721
|
+
int addrTop; /* Label "L" */
|
722
|
+
int addrIf; /* Address of jump to M */
|
723
|
+
|
724
|
+
srcTab = pParse.nTab++;
|
725
|
+
regRec = sqlite3GetTempReg( pParse );
|
726
|
+
regTempRowid = sqlite3GetTempReg( pParse );
|
727
|
+
sqlite3VdbeAddOp2( v, OP_OpenEphemeral, srcTab, nColumn );
|
728
|
+
addrTop = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm );
|
729
|
+
addrIf = sqlite3VdbeAddOp1( v, OP_If, regEof );
|
730
|
+
sqlite3VdbeAddOp3( v, OP_MakeRecord, regFromSelect, nColumn, regRec );
|
731
|
+
sqlite3VdbeAddOp2( v, OP_NewRowid, srcTab, regTempRowid );
|
732
|
+
sqlite3VdbeAddOp3( v, OP_Insert, srcTab, regRec, regTempRowid );
|
733
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, addrTop );
|
734
|
+
sqlite3VdbeJumpHere( v, addrIf );
|
735
|
+
sqlite3ReleaseTempReg( pParse, regRec );
|
736
|
+
sqlite3ReleaseTempReg( pParse, regTempRowid );
|
737
|
+
}
|
738
|
+
}
|
739
|
+
else
|
740
|
+
{
|
741
|
+
/* This is the case if the data for the INSERT is coming from a VALUES
|
742
|
+
** clause
|
743
|
+
*/
|
744
|
+
NameContext sNC;
|
745
|
+
sNC = new NameContext();// memset( &sNC, 0, sNC ).Length;
|
746
|
+
sNC.pParse = pParse;
|
747
|
+
srcTab = -1;
|
748
|
+
Debug.Assert( !useTempTable );
|
749
|
+
nColumn = pList != null ? pList.nExpr : 0;
|
750
|
+
for ( i = 0; i < nColumn; i++ )
|
751
|
+
{
|
752
|
+
if ( sqlite3ResolveExprNames( sNC, ref pList.a[i].pExpr ) != 0 )
|
753
|
+
{
|
754
|
+
goto insert_cleanup;
|
755
|
+
}
|
756
|
+
}
|
757
|
+
}
|
758
|
+
|
759
|
+
/* Make sure the number of columns in the source data matches the number
|
760
|
+
** of columns to be inserted into the table.
|
761
|
+
*/
|
762
|
+
if ( IsVirtual( pTab ) )
|
763
|
+
{
|
764
|
+
for ( i = 0; i < pTab.nCol; i++ )
|
765
|
+
{
|
766
|
+
nHidden += ( IsHiddenColumn( pTab.aCol[i] ) ? 1 : 0 );
|
767
|
+
}
|
768
|
+
}
|
769
|
+
if ( pColumn == null && nColumn != 0 && nColumn != ( pTab.nCol - nHidden ) )
|
770
|
+
{
|
771
|
+
sqlite3ErrorMsg( pParse,
|
772
|
+
"table %S has %d columns but %d values were supplied",
|
773
|
+
pTabList, 0, pTab.nCol - nHidden, nColumn );
|
774
|
+
goto insert_cleanup;
|
775
|
+
}
|
776
|
+
if ( pColumn != null && nColumn != pColumn.nId )
|
777
|
+
{
|
778
|
+
sqlite3ErrorMsg( pParse, "%d values for %d columns", nColumn, pColumn.nId );
|
779
|
+
goto insert_cleanup;
|
780
|
+
}
|
781
|
+
|
782
|
+
/* If the INSERT statement included an IDLIST term, then make sure
|
783
|
+
** all elements of the IDLIST really are columns of the table and
|
784
|
+
** remember the column indices.
|
785
|
+
**
|
786
|
+
** If the table has an INTEGER PRIMARY KEY column and that column
|
787
|
+
** is named in the IDLIST, then record in the keyColumn variable
|
788
|
+
** the index into IDLIST of the primary key column. keyColumn is
|
789
|
+
** the index of the primary key as it appears in IDLIST, not as
|
790
|
+
** is appears in the original table. (The index of the primary
|
791
|
+
** key in the original table is pTab.iPKey.)
|
792
|
+
*/
|
793
|
+
if ( pColumn != null )
|
794
|
+
{
|
795
|
+
for ( i = 0; i < pColumn.nId; i++ )
|
796
|
+
{
|
797
|
+
pColumn.a[i].idx = -1;
|
798
|
+
}
|
799
|
+
for ( i = 0; i < pColumn.nId; i++ )
|
800
|
+
{
|
801
|
+
for ( j = 0; j < pTab.nCol; j++ )
|
802
|
+
{
|
803
|
+
if ( sqlite3StrICmp( pColumn.a[i].zName, pTab.aCol[j].zName ) == 0 )
|
804
|
+
{
|
805
|
+
pColumn.a[i].idx = j;
|
806
|
+
if ( j == pTab.iPKey )
|
807
|
+
{
|
808
|
+
keyColumn = i;
|
809
|
+
}
|
810
|
+
break;
|
811
|
+
}
|
812
|
+
}
|
813
|
+
if ( j >= pTab.nCol )
|
814
|
+
{
|
815
|
+
if ( sqlite3IsRowid( pColumn.a[i].zName ) )
|
816
|
+
{
|
817
|
+
keyColumn = i;
|
818
|
+
}
|
819
|
+
else
|
820
|
+
{
|
821
|
+
sqlite3ErrorMsg( pParse, "table %S has no column named %s",
|
822
|
+
pTabList, 0, pColumn.a[i].zName );
|
823
|
+
pParse.nErr++;
|
824
|
+
goto insert_cleanup;
|
825
|
+
}
|
826
|
+
}
|
827
|
+
}
|
828
|
+
}
|
829
|
+
|
830
|
+
/* If there is no IDLIST term but the table has an integer primary
|
831
|
+
** key, the set the keyColumn variable to the primary key column index
|
832
|
+
** in the original table definition.
|
833
|
+
*/
|
834
|
+
if ( pColumn == null && nColumn > 0 )
|
835
|
+
{
|
836
|
+
keyColumn = pTab.iPKey;
|
837
|
+
}
|
838
|
+
|
839
|
+
/* Initialize the count of rows to be inserted
|
840
|
+
*/
|
841
|
+
if ( ( db.flags & SQLITE_CountRows ) != 0 )
|
842
|
+
{
|
843
|
+
regRowCount = ++pParse.nMem;
|
844
|
+
sqlite3VdbeAddOp2( v, OP_Integer, 0, regRowCount );
|
845
|
+
}
|
846
|
+
|
847
|
+
/* If this is not a view, open the table and and all indices */
|
848
|
+
if ( !isView )
|
849
|
+
{
|
850
|
+
int nIdx;
|
851
|
+
|
852
|
+
baseCur = pParse.nTab;
|
853
|
+
nIdx = sqlite3OpenTableAndIndices( pParse, pTab, baseCur, OP_OpenWrite );
|
854
|
+
aRegIdx = new int[nIdx + 1];// sqlite3DbMallocRaw( db, sizeof( int ) * ( nIdx + 1 ) );
|
855
|
+
if ( aRegIdx == null )
|
856
|
+
{
|
857
|
+
goto insert_cleanup;
|
858
|
+
}
|
859
|
+
for ( i = 0; i < nIdx; i++ )
|
860
|
+
{
|
861
|
+
aRegIdx[i] = ++pParse.nMem;
|
862
|
+
}
|
863
|
+
}
|
864
|
+
|
865
|
+
/* This is the top of the main insertion loop */
|
866
|
+
if ( useTempTable )
|
867
|
+
{
|
868
|
+
/* This block codes the top of loop only. The complete loop is the
|
869
|
+
** following pseudocode (template 4):
|
870
|
+
**
|
871
|
+
** rewind temp table
|
872
|
+
** C: loop over rows of intermediate table
|
873
|
+
** transfer values form intermediate table into <table>
|
874
|
+
** end loop
|
875
|
+
** D: ...
|
876
|
+
*/
|
877
|
+
addrInsTop = sqlite3VdbeAddOp1( v, OP_Rewind, srcTab );
|
878
|
+
addrCont = sqlite3VdbeCurrentAddr( v );
|
879
|
+
}
|
880
|
+
else if ( pSelect != null )
|
881
|
+
{
|
882
|
+
/* This block codes the top of loop only. The complete loop is the
|
883
|
+
** following pseudocode (template 3):
|
884
|
+
**
|
885
|
+
** C: yield X
|
886
|
+
** if EOF goto D
|
887
|
+
** insert the select result into <table> from R..R+n
|
888
|
+
** goto C
|
889
|
+
** D: ...
|
890
|
+
*/
|
891
|
+
addrCont = sqlite3VdbeAddOp1( v, OP_Yield, dest.iParm );
|
892
|
+
addrInsTop = sqlite3VdbeAddOp1( v, OP_If, regEof );
|
893
|
+
}
|
894
|
+
|
895
|
+
/* Allocate registers for holding the rowid of the new row,
|
896
|
+
** the content of the new row, and the assemblied row record.
|
897
|
+
*/
|
898
|
+
regRecord = ++pParse.nMem;
|
899
|
+
regRowid = regIns = pParse.nMem + 1;
|
900
|
+
pParse.nMem += pTab.nCol + 1;
|
901
|
+
if ( IsVirtual( pTab ) )
|
902
|
+
{
|
903
|
+
regRowid++;
|
904
|
+
pParse.nMem++;
|
905
|
+
}
|
906
|
+
regData = regRowid + 1;
|
907
|
+
|
908
|
+
/* Run the BEFORE and INSTEAD OF triggers, if there are any
|
909
|
+
*/
|
910
|
+
endOfLoop = sqlite3VdbeMakeLabel( v );
|
911
|
+
#if !SQLITE_OMIT_TRIGGER
|
912
|
+
if ( ( tmask & TRIGGER_BEFORE ) != 0 )
|
913
|
+
{
|
914
|
+
int regCols = sqlite3GetTempRange( pParse, pTab.nCol + 1 );
|
915
|
+
|
916
|
+
/* build the NEW.* reference row. Note that if there is an INTEGER
|
917
|
+
** PRIMARY KEY into which a NULL is being inserted, that NULL will be
|
918
|
+
** translated into a unique ID for the row. But on a BEFORE trigger,
|
919
|
+
** we do not know what the unique ID will be (because the insert has
|
920
|
+
** not happened yet) so we substitute a rowid of -1
|
921
|
+
*/
|
922
|
+
if ( keyColumn < 0 )
|
923
|
+
{
|
924
|
+
sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols );
|
925
|
+
}
|
926
|
+
else
|
927
|
+
{
|
928
|
+
int j1;
|
929
|
+
if ( useTempTable )
|
930
|
+
{
|
931
|
+
sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regCols );
|
932
|
+
}
|
933
|
+
else
|
934
|
+
{
|
935
|
+
Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */
|
936
|
+
sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regCols );
|
937
|
+
}
|
938
|
+
j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regCols );
|
939
|
+
sqlite3VdbeAddOp2( v, OP_Integer, -1, regCols );
|
940
|
+
sqlite3VdbeJumpHere( v, j1 );
|
941
|
+
sqlite3VdbeAddOp1( v, OP_MustBeInt, regCols );
|
942
|
+
}
|
943
|
+
/* Cannot have triggers on a virtual table. If it were possible,
|
944
|
+
** this block would have to account for hidden column.
|
945
|
+
*/
|
946
|
+
Debug.Assert( !IsVirtual( pTab ) );
|
947
|
+
/* Create the new column data
|
948
|
+
*/
|
949
|
+
for ( i = 0 ; i < pTab.nCol ; i++ )
|
950
|
+
{
|
951
|
+
if ( pColumn == null )
|
952
|
+
{
|
953
|
+
j = i;
|
954
|
+
}
|
955
|
+
else
|
956
|
+
{
|
957
|
+
for ( j = 0 ; j < pColumn.nId ; j++ )
|
958
|
+
{
|
959
|
+
if ( pColumn.a[j].idx == i ) break;
|
960
|
+
}
|
961
|
+
}
|
962
|
+
if ( pColumn != null && j >= pColumn.nId )
|
963
|
+
{
|
964
|
+
sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regCols + i + 1 );
|
965
|
+
}
|
966
|
+
else if ( useTempTable )
|
967
|
+
{
|
968
|
+
sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, regCols + i + 1 );
|
969
|
+
}
|
970
|
+
else
|
971
|
+
{
|
972
|
+
Debug.Assert( pSelect == null ); /* Otherwise useTempTable is true */
|
973
|
+
sqlite3ExprCodeAndCache( pParse, pList.a[j].pExpr, regCols + i + 1 );
|
974
|
+
}
|
975
|
+
}
|
976
|
+
|
977
|
+
/* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,
|
978
|
+
** do not attempt any conversions before assembling the record.
|
979
|
+
** If this is a real table, attempt conversions as required by the
|
980
|
+
** table column affinities.
|
981
|
+
*/
|
982
|
+
if ( !isView )
|
983
|
+
{
|
984
|
+
sqlite3VdbeAddOp2( v, OP_Affinity, regCols + 1, pTab.nCol );
|
985
|
+
sqlite3TableAffinityStr( v, pTab );
|
986
|
+
}
|
987
|
+
|
988
|
+
/* Fire BEFORE or INSTEAD OF triggers */
|
989
|
+
sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_BEFORE,
|
990
|
+
pTab, regCols - pTab.nCol - 1, onError, endOfLoop );
|
991
|
+
|
992
|
+
sqlite3ReleaseTempRange( pParse, regCols, pTab.nCol + 1 );
|
993
|
+
}
|
994
|
+
#endif
|
995
|
+
|
996
|
+
/* Push the record number for the new entry onto the stack. The
|
997
|
+
** record number is a randomly generate integer created by NewRowid
|
998
|
+
** except when the table has an INTEGER PRIMARY KEY column, in which
|
999
|
+
** case the record number is the same as that column.
|
1000
|
+
*/
|
1001
|
+
if ( !isView )
|
1002
|
+
{
|
1003
|
+
if ( IsVirtual( pTab ) )
|
1004
|
+
{
|
1005
|
+
/* The row that the VUpdate opcode will delete: none */
|
1006
|
+
sqlite3VdbeAddOp2( v, OP_Null, 0, regIns );
|
1007
|
+
}
|
1008
|
+
if ( keyColumn >= 0 )
|
1009
|
+
{
|
1010
|
+
if ( useTempTable )
|
1011
|
+
{
|
1012
|
+
sqlite3VdbeAddOp3( v, OP_Column, srcTab, keyColumn, regRowid );
|
1013
|
+
}
|
1014
|
+
else if ( pSelect != null )
|
1015
|
+
{
|
1016
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + keyColumn, regRowid );
|
1017
|
+
}
|
1018
|
+
else
|
1019
|
+
{
|
1020
|
+
VdbeOp pOp;
|
1021
|
+
sqlite3ExprCode( pParse, pList.a[keyColumn].pExpr, regRowid );
|
1022
|
+
pOp = sqlite3VdbeGetOp( v, -1 );
|
1023
|
+
if ( ALWAYS( pOp != null ) && pOp.opcode == OP_Null && !IsVirtual( pTab ) )
|
1024
|
+
{
|
1025
|
+
appendFlag = true;
|
1026
|
+
pOp.opcode = OP_NewRowid;
|
1027
|
+
pOp.p1 = baseCur;
|
1028
|
+
pOp.p2 = regRowid;
|
1029
|
+
pOp.p3 = regAutoinc;
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
/* If the PRIMARY KEY expression is NULL, then use OP_NewRowid
|
1033
|
+
** to generate a unique primary key value.
|
1034
|
+
*/
|
1035
|
+
if ( !appendFlag )
|
1036
|
+
{
|
1037
|
+
int j1;
|
1038
|
+
if ( !IsVirtual( pTab ) )
|
1039
|
+
{
|
1040
|
+
j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regRowid );
|
1041
|
+
sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc );
|
1042
|
+
sqlite3VdbeJumpHere( v, j1 );
|
1043
|
+
}
|
1044
|
+
else
|
1045
|
+
{
|
1046
|
+
j1 = sqlite3VdbeCurrentAddr( v );
|
1047
|
+
sqlite3VdbeAddOp2( v, OP_IsNull, regRowid, j1 + 2 );
|
1048
|
+
}
|
1049
|
+
sqlite3VdbeAddOp1( v, OP_MustBeInt, regRowid );
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
else if ( IsVirtual( pTab ) )
|
1053
|
+
{
|
1054
|
+
sqlite3VdbeAddOp2( v, OP_Null, 0, regRowid );
|
1055
|
+
}
|
1056
|
+
else
|
1057
|
+
{
|
1058
|
+
sqlite3VdbeAddOp3( v, OP_NewRowid, baseCur, regRowid, regAutoinc );
|
1059
|
+
appendFlag = true;
|
1060
|
+
}
|
1061
|
+
autoIncStep( pParse, regAutoinc, regRowid );
|
1062
|
+
|
1063
|
+
/* Push onto the stack, data for all columns of the new entry, beginning
|
1064
|
+
** with the first column.
|
1065
|
+
*/
|
1066
|
+
nHidden = 0;
|
1067
|
+
for ( i = 0; i < pTab.nCol; i++ )
|
1068
|
+
{
|
1069
|
+
int iRegStore = regRowid + 1 + i;
|
1070
|
+
if ( i == pTab.iPKey )
|
1071
|
+
{
|
1072
|
+
/* The value of the INTEGER PRIMARY KEY column is always a NULL.
|
1073
|
+
** Whenever this column is read, the record number will be substituted
|
1074
|
+
** in its place. So will fill this column with a NULL to avoid
|
1075
|
+
** taking up data space with information that will never be used. */
|
1076
|
+
sqlite3VdbeAddOp2( v, OP_Null, 0, iRegStore );
|
1077
|
+
continue;
|
1078
|
+
}
|
1079
|
+
if ( pColumn == null )
|
1080
|
+
{
|
1081
|
+
if ( IsHiddenColumn( pTab.aCol[i] ) )
|
1082
|
+
{
|
1083
|
+
Debug.Assert( IsVirtual( pTab ) );
|
1084
|
+
j = -1;
|
1085
|
+
nHidden++;
|
1086
|
+
}
|
1087
|
+
else
|
1088
|
+
{
|
1089
|
+
j = i - nHidden;
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
else
|
1093
|
+
{
|
1094
|
+
for ( j = 0; j < pColumn.nId; j++ )
|
1095
|
+
{
|
1096
|
+
if ( pColumn.a[j].idx == i ) break;
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
if ( j < 0 || nColumn == 0 || ( pColumn != null && j >= pColumn.nId ) )
|
1100
|
+
{
|
1101
|
+
sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, iRegStore );
|
1102
|
+
}
|
1103
|
+
else if ( useTempTable )
|
1104
|
+
{
|
1105
|
+
sqlite3VdbeAddOp3( v, OP_Column, srcTab, j, iRegStore );
|
1106
|
+
}
|
1107
|
+
else if ( pSelect != null )
|
1108
|
+
{
|
1109
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regFromSelect + j, iRegStore );
|
1110
|
+
}
|
1111
|
+
else
|
1112
|
+
{
|
1113
|
+
sqlite3ExprCode( pParse, pList.a[j].pExpr, iRegStore );
|
1114
|
+
}
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
/* Generate code to check constraints and generate index keys and
|
1118
|
+
** do the insertion.
|
1119
|
+
*/
|
1120
|
+
#if !SQLITE_OMIT_VIRTUALTABLE
|
1121
|
+
if( IsVirtual(pTab) ){
|
1122
|
+
const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
|
1123
|
+
sqlite3VtabMakeWritable(pParse, pTab);
|
1124
|
+
sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab.nCol+2, regIns, pVTab, P4_VTAB);
|
1125
|
+
sqlite3MayAbort(pParse);
|
1126
|
+
}else
|
1127
|
+
#endif
|
1128
|
+
{
|
1129
|
+
int isReplace = 0; /* Set to true if constraints may cause a replace */
|
1130
|
+
sqlite3GenerateConstraintChecks( pParse, pTab, baseCur, regIns, aRegIdx,
|
1131
|
+
keyColumn >= 0 ? 1 : 0, false, onError, endOfLoop, ref isReplace
|
1132
|
+
);
|
1133
|
+
sqlite3FkCheck( pParse, pTab, 0, regIns );
|
1134
|
+
sqlite3CompleteInsertion(
|
1135
|
+
pParse, pTab, baseCur, regIns, aRegIdx, false, appendFlag, isReplace == 0
|
1136
|
+
);
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
/* Update the count of rows that are inserted
|
1141
|
+
*/
|
1142
|
+
if ( ( db.flags & SQLITE_CountRows ) != 0 )
|
1143
|
+
{
|
1144
|
+
sqlite3VdbeAddOp2( v, OP_AddImm, regRowCount, 1 );
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
#if !SQLITE_OMIT_TRIGGER
|
1148
|
+
if ( pTrigger != null )
|
1149
|
+
{
|
1150
|
+
/* Code AFTER triggers */
|
1151
|
+
sqlite3CodeRowTrigger( pParse, pTrigger, TK_INSERT, null, TRIGGER_AFTER,
|
1152
|
+
pTab, regData - 2 - pTab.nCol, onError, endOfLoop );
|
1153
|
+
}
|
1154
|
+
#endif
|
1155
|
+
|
1156
|
+
/* The bottom of the main insertion loop, if the data source
|
1157
|
+
** is a SELECT statement.
|
1158
|
+
*/
|
1159
|
+
sqlite3VdbeResolveLabel( v, endOfLoop );
|
1160
|
+
if ( useTempTable )
|
1161
|
+
{
|
1162
|
+
sqlite3VdbeAddOp2( v, OP_Next, srcTab, addrCont );
|
1163
|
+
sqlite3VdbeJumpHere( v, addrInsTop );
|
1164
|
+
sqlite3VdbeAddOp1( v, OP_Close, srcTab );
|
1165
|
+
}
|
1166
|
+
else if ( pSelect != null )
|
1167
|
+
{
|
1168
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, addrCont );
|
1169
|
+
sqlite3VdbeJumpHere( v, addrInsTop );
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
if ( !IsVirtual( pTab ) && !isView )
|
1173
|
+
{
|
1174
|
+
/* Close all tables opened */
|
1175
|
+
sqlite3VdbeAddOp1( v, OP_Close, baseCur );
|
1176
|
+
for ( idx = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, idx++ )
|
1177
|
+
{
|
1178
|
+
sqlite3VdbeAddOp1( v, OP_Close, idx + baseCur );
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
insert_end:
|
1183
|
+
/* Update the sqlite_sequence table by storing the content of the
|
1184
|
+
** maximum rowid counter values recorded while inserting into
|
1185
|
+
** autoincrement tables.
|
1186
|
+
*/
|
1187
|
+
if ( pParse.nested == 0 && pParse.pTriggerTab == null )
|
1188
|
+
{
|
1189
|
+
sqlite3AutoincrementEnd( pParse );
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
/*
|
1193
|
+
** Return the number of rows inserted. If this routine is
|
1194
|
+
** generating code because of a call to sqlite3NestedParse(), do not
|
1195
|
+
** invoke the callback function.
|
1196
|
+
*/
|
1197
|
+
if ( ( db.flags & SQLITE_CountRows ) != 0 && 0 == pParse.nested && null == pParse.pTriggerTab )
|
1198
|
+
{
|
1199
|
+
sqlite3VdbeAddOp2( v, OP_ResultRow, regRowCount, 1 );
|
1200
|
+
sqlite3VdbeSetNumCols( v, 1 );
|
1201
|
+
sqlite3VdbeSetColName( v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC );
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
insert_cleanup:
|
1205
|
+
sqlite3SrcListDelete( db, ref pTabList );
|
1206
|
+
sqlite3ExprListDelete( db, ref pList );
|
1207
|
+
sqlite3SelectDelete( db, ref pSelect );
|
1208
|
+
sqlite3IdListDelete( db, ref pColumn );
|
1209
|
+
sqlite3DbFree( db, ref aRegIdx );
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
/* Make sure "isView" and other macros defined above are undefined. Otherwise
|
1213
|
+
** thely may interfere with compilation of other functions in this file
|
1214
|
+
** (or in another file, if this file becomes part of the amalgamation). */
|
1215
|
+
//#ifdef isView
|
1216
|
+
// #undef isView
|
1217
|
+
//#endif
|
1218
|
+
//#ifdef pTrigger
|
1219
|
+
// #undef pTrigger
|
1220
|
+
//#endif
|
1221
|
+
//#ifdef tmask
|
1222
|
+
// #undef tmask
|
1223
|
+
//#endif
|
1224
|
+
|
1225
|
+
/*
|
1226
|
+
** Generate code to do constraint checks prior to an INSERT or an UPDATE.
|
1227
|
+
**
|
1228
|
+
** The input is a range of consecutive registers as follows:
|
1229
|
+
**
|
1230
|
+
** 1. The rowid of the row after the update.
|
1231
|
+
**
|
1232
|
+
** 2. The data in the first column of the entry after the update.
|
1233
|
+
**
|
1234
|
+
** i. Data from middle columns...
|
1235
|
+
**
|
1236
|
+
** N. The data in the last column of the entry after the update.
|
1237
|
+
**
|
1238
|
+
** The regRowid parameter is the index of the register containing (1).
|
1239
|
+
**
|
1240
|
+
** If isUpdate is true and rowidChng is non-zero, then rowidChng contains
|
1241
|
+
** the address of a register containing the rowid before the update takes
|
1242
|
+
** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate
|
1243
|
+
** is false, indicating an INSERT statement, then a non-zero rowidChng
|
1244
|
+
** indicates that the rowid was explicitly specified as part of the
|
1245
|
+
** INSERT statement. If rowidChng is false, it means that the rowid is
|
1246
|
+
** computed automatically in an insert or that the rowid value is not
|
1247
|
+
** modified by an update.
|
1248
|
+
**
|
1249
|
+
** The code generated by this routine store new index entries into
|
1250
|
+
** registers identified by aRegIdx[]. No index entry is created for
|
1251
|
+
** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is
|
1252
|
+
** the same as the order of indices on the linked list of indices
|
1253
|
+
** attached to the table.
|
1254
|
+
**
|
1255
|
+
** This routine also generates code to check constraints. NOT NULL,
|
1256
|
+
** CHECK, and UNIQUE constraints are all checked. If a constraint fails,
|
1257
|
+
** then the appropriate action is performed. There are five possible
|
1258
|
+
** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.
|
1259
|
+
**
|
1260
|
+
** Constraint type Action What Happens
|
1261
|
+
** --------------- ---------- ----------------------------------------
|
1262
|
+
** any ROLLBACK The current transaction is rolled back and
|
1263
|
+
** sqlite3_exec() returns immediately with a
|
1264
|
+
** return code of SQLITE_CONSTRAINT.
|
1265
|
+
**
|
1266
|
+
** any ABORT Back out changes from the current command
|
1267
|
+
** only (do not do a complete rollback) then
|
1268
|
+
** cause sqlite3_exec() to return immediately
|
1269
|
+
** with SQLITE_CONSTRAINT.
|
1270
|
+
**
|
1271
|
+
** any FAIL Sqlite_exec() returns immediately with a
|
1272
|
+
** return code of SQLITE_CONSTRAINT. The
|
1273
|
+
** transaction is not rolled back and any
|
1274
|
+
** prior changes are retained.
|
1275
|
+
**
|
1276
|
+
** any IGNORE The record number and data is popped from
|
1277
|
+
** the stack and there is an immediate jump
|
1278
|
+
** to label ignoreDest.
|
1279
|
+
**
|
1280
|
+
** NOT NULL REPLACE The NULL value is replace by the default
|
1281
|
+
** value for that column. If the default value
|
1282
|
+
** is NULL, the action is the same as ABORT.
|
1283
|
+
**
|
1284
|
+
** UNIQUE REPLACE The other row that conflicts with the row
|
1285
|
+
** being inserted is removed.
|
1286
|
+
**
|
1287
|
+
** CHECK REPLACE Illegal. The results in an exception.
|
1288
|
+
**
|
1289
|
+
** Which action to take is determined by the overrideError parameter.
|
1290
|
+
** Or if overrideError==OE_Default, then the pParse.onError parameter
|
1291
|
+
** is used. Or if pParse.onError==OE_Default then the onError value
|
1292
|
+
** for the constraint is used.
|
1293
|
+
**
|
1294
|
+
** The calling routine must open a read/write cursor for pTab with
|
1295
|
+
** cursor number "baseCur". All indices of pTab must also have open
|
1296
|
+
** read/write cursors with cursor number baseCur+i for the i-th cursor.
|
1297
|
+
** Except, if there is no possibility of a REPLACE action then
|
1298
|
+
** cursors do not need to be open for indices where aRegIdx[i]==0.
|
1299
|
+
*/
|
1300
|
+
static void sqlite3GenerateConstraintChecks(
|
1301
|
+
Parse pParse, /* The parser context */
|
1302
|
+
Table pTab, /* the table into which we are inserting */
|
1303
|
+
int baseCur, /* Index of a read/write cursor pointing at pTab */
|
1304
|
+
int regRowid, /* Index of the range of input registers */
|
1305
|
+
int[] aRegIdx, /* Register used by each index. 0 for unused indices */
|
1306
|
+
int rowidChng, /* True if the rowid might collide with existing entry */
|
1307
|
+
bool isUpdate, /* True for UPDATE, False for INSERT */
|
1308
|
+
int overrideError, /* Override onError to this if not OE_Default */
|
1309
|
+
int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
|
1310
|
+
ref int pbMayReplace /* OUT: Set to true if constraint may cause a replace */
|
1311
|
+
)
|
1312
|
+
{
|
1313
|
+
|
1314
|
+
int i; /* loop counter */
|
1315
|
+
Vdbe v; /* VDBE under constrution */
|
1316
|
+
int nCol; /* Number of columns */
|
1317
|
+
int onError; /* Conflict resolution strategy */
|
1318
|
+
int j1; /* Addresss of jump instruction */
|
1319
|
+
int j2 = 0, j3; /* Addresses of jump instructions */
|
1320
|
+
int regData; /* Register containing first data column */
|
1321
|
+
int iCur; /* Table cursor number */
|
1322
|
+
Index pIdx; /* Pointer to one of the indices */
|
1323
|
+
bool seenReplace = false; /* True if REPLACE is used to resolve INT PK conflict */
|
1324
|
+
int regOldRowid = ( rowidChng != 0 && isUpdate ) ? rowidChng : regRowid;
|
1325
|
+
|
1326
|
+
v = sqlite3GetVdbe( pParse );
|
1327
|
+
Debug.Assert( v != null );
|
1328
|
+
Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */
|
1329
|
+
nCol = pTab.nCol;
|
1330
|
+
regData = regRowid + 1;
|
1331
|
+
|
1332
|
+
|
1333
|
+
/* Test all NOT NULL constraints.
|
1334
|
+
*/
|
1335
|
+
for ( i = 0; i < nCol; i++ )
|
1336
|
+
{
|
1337
|
+
if ( i == pTab.iPKey )
|
1338
|
+
{
|
1339
|
+
continue;
|
1340
|
+
}
|
1341
|
+
onError = pTab.aCol[i].notNull;
|
1342
|
+
if ( onError == OE_None ) continue;
|
1343
|
+
if ( overrideError != OE_Default )
|
1344
|
+
{
|
1345
|
+
onError = overrideError;
|
1346
|
+
}
|
1347
|
+
else if ( onError == OE_Default )
|
1348
|
+
{
|
1349
|
+
onError = OE_Abort;
|
1350
|
+
}
|
1351
|
+
if ( onError == OE_Replace && pTab.aCol[i].pDflt == null )
|
1352
|
+
{
|
1353
|
+
onError = OE_Abort;
|
1354
|
+
}
|
1355
|
+
Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail
|
1356
|
+
|| onError == OE_Ignore || onError == OE_Replace );
|
1357
|
+
switch ( onError )
|
1358
|
+
{
|
1359
|
+
case OE_Abort:
|
1360
|
+
{
|
1361
|
+
sqlite3MayAbort( pParse );
|
1362
|
+
goto case OE_Fail;
|
1363
|
+
}
|
1364
|
+
case OE_Rollback:
|
1365
|
+
case OE_Fail:
|
1366
|
+
{
|
1367
|
+
string zMsg;
|
1368
|
+
j1 = sqlite3VdbeAddOp3( v, OP_HaltIfNull,
|
1369
|
+
SQLITE_CONSTRAINT, onError, regData + i );
|
1370
|
+
zMsg = sqlite3MPrintf( pParse.db, "%s.%s may not be NULL",
|
1371
|
+
pTab.zName, pTab.aCol[i].zName );
|
1372
|
+
sqlite3VdbeChangeP4( v, -1, zMsg, P4_DYNAMIC );
|
1373
|
+
break;
|
1374
|
+
}
|
1375
|
+
case OE_Ignore:
|
1376
|
+
{
|
1377
|
+
sqlite3VdbeAddOp2( v, OP_IsNull, regData + i, ignoreDest );
|
1378
|
+
break;
|
1379
|
+
}
|
1380
|
+
default:
|
1381
|
+
{
|
1382
|
+
Debug.Assert( onError == OE_Replace );
|
1383
|
+
j1 = sqlite3VdbeAddOp1( v, OP_NotNull, regData + i );
|
1384
|
+
sqlite3ExprCode( pParse, pTab.aCol[i].pDflt, regData + i );
|
1385
|
+
sqlite3VdbeJumpHere( v, j1 );
|
1386
|
+
break;
|
1387
|
+
}
|
1388
|
+
}
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
/* Test all CHECK constraints
|
1392
|
+
*/
|
1393
|
+
#if !SQLITE_OMIT_CHECK
|
1394
|
+
if ( pTab.pCheck != null && ( pParse.db.flags & SQLITE_IgnoreChecks ) == 0 )
|
1395
|
+
{
|
1396
|
+
int allOk = sqlite3VdbeMakeLabel( v );
|
1397
|
+
pParse.ckBase = regData;
|
1398
|
+
sqlite3ExprIfTrue( pParse, pTab.pCheck, allOk, SQLITE_JUMPIFNULL );
|
1399
|
+
onError = overrideError != OE_Default ? overrideError : OE_Abort;
|
1400
|
+
if ( onError == OE_Ignore )
|
1401
|
+
{
|
1402
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest );
|
1403
|
+
}
|
1404
|
+
else
|
1405
|
+
{
|
1406
|
+
sqlite3HaltConstraint( pParse, onError, (string)null, 0 );
|
1407
|
+
}
|
1408
|
+
sqlite3VdbeResolveLabel( v, allOk );
|
1409
|
+
}
|
1410
|
+
#endif // * !SQLITE_OMIT_CHECK) */
|
1411
|
+
|
1412
|
+
/* If we have an INTEGER PRIMARY KEY, make sure the primary key
|
1413
|
+
** of the new record does not previously exist. Except, if this
|
1414
|
+
** is an UPDATE and the primary key is not changing, that is OK.
|
1415
|
+
*/
|
1416
|
+
if ( rowidChng != 0 )
|
1417
|
+
{
|
1418
|
+
onError = pTab.keyConf;
|
1419
|
+
if ( overrideError != OE_Default )
|
1420
|
+
{
|
1421
|
+
onError = overrideError;
|
1422
|
+
}
|
1423
|
+
else if ( onError == OE_Default )
|
1424
|
+
{
|
1425
|
+
onError = OE_Abort;
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
if ( isUpdate )
|
1429
|
+
{
|
1430
|
+
j2 = sqlite3VdbeAddOp3( v, OP_Eq, regRowid, 0, rowidChng );
|
1431
|
+
}
|
1432
|
+
j3 = sqlite3VdbeAddOp3( v, OP_NotExists, baseCur, 0, regRowid );
|
1433
|
+
switch ( onError )
|
1434
|
+
{
|
1435
|
+
default:
|
1436
|
+
{
|
1437
|
+
onError = OE_Abort;
|
1438
|
+
/* Fall thru into the next case */
|
1439
|
+
}
|
1440
|
+
goto case OE_Rollback;
|
1441
|
+
case OE_Rollback:
|
1442
|
+
case OE_Abort:
|
1443
|
+
case OE_Fail:
|
1444
|
+
{
|
1445
|
+
sqlite3HaltConstraint(
|
1446
|
+
pParse, onError, "PRIMARY KEY must be unique", P4_STATIC );
|
1447
|
+
break;
|
1448
|
+
}
|
1449
|
+
case OE_Replace:
|
1450
|
+
{
|
1451
|
+
/* If there are DELETE triggers on this table and the
|
1452
|
+
** recursive-triggers flag is set, call GenerateRowDelete() to
|
1453
|
+
** remove the conflicting row from the the table. This will fire
|
1454
|
+
** the triggers and remove both the table and index b-tree entries.
|
1455
|
+
**
|
1456
|
+
** Otherwise, if there are no triggers or the recursive-triggers
|
1457
|
+
** flag is not set, but the table has one or more indexes, call
|
1458
|
+
** GenerateRowIndexDelete(). This removes the index b-tree entries
|
1459
|
+
** only. The table b-tree entry will be replaced by the new entry
|
1460
|
+
** when it is inserted.
|
1461
|
+
**
|
1462
|
+
** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,
|
1463
|
+
** also invoke MultiWrite() to indicate that this VDBE may require
|
1464
|
+
** statement rollback (if the statement is aborted after the delete
|
1465
|
+
** takes place). Earlier versions called sqlite3MultiWrite() regardless,
|
1466
|
+
** but being more selective here allows statements like:
|
1467
|
+
**
|
1468
|
+
** REPLACE INTO t(rowid) VALUES($newrowid)
|
1469
|
+
**
|
1470
|
+
** to run without a statement journal if there are no indexes on the
|
1471
|
+
** table.
|
1472
|
+
*/
|
1473
|
+
Trigger pTrigger = null;
|
1474
|
+
if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 )
|
1475
|
+
{
|
1476
|
+
int iDummy = 0;
|
1477
|
+
pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, ref iDummy );
|
1478
|
+
}
|
1479
|
+
if ( pTrigger != null || sqlite3FkRequired( pParse, pTab, null, 0 ) != 0 )
|
1480
|
+
{
|
1481
|
+
sqlite3MultiWrite(pParse);
|
1482
|
+
sqlite3GenerateRowDelete(
|
1483
|
+
pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace
|
1484
|
+
);
|
1485
|
+
}
|
1486
|
+
else
|
1487
|
+
if (pTab.pIndex != null)
|
1488
|
+
{
|
1489
|
+
sqlite3MultiWrite(pParse);
|
1490
|
+
sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
|
1491
|
+
}
|
1492
|
+
seenReplace = true;
|
1493
|
+
break;
|
1494
|
+
}
|
1495
|
+
case OE_Ignore:
|
1496
|
+
{
|
1497
|
+
Debug.Assert( !seenReplace );
|
1498
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest );
|
1499
|
+
break;
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
sqlite3VdbeJumpHere( v, j3 );
|
1503
|
+
if ( isUpdate )
|
1504
|
+
{
|
1505
|
+
sqlite3VdbeJumpHere( v, j2 );
|
1506
|
+
}
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
/* Test all UNIQUE constraints by creating entries for each UNIQUE
|
1510
|
+
** index and making sure that duplicate entries do not already exist.
|
1511
|
+
** Add the new records to the indices as we go.
|
1512
|
+
*/
|
1513
|
+
for ( iCur = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, iCur++ )
|
1514
|
+
{
|
1515
|
+
int regIdx;
|
1516
|
+
int regR;
|
1517
|
+
|
1518
|
+
if ( aRegIdx[iCur] == 0 ) continue; /* Skip unused indices */
|
1519
|
+
|
1520
|
+
/* Create a key for accessing the index entry */
|
1521
|
+
regIdx = sqlite3GetTempRange( pParse, pIdx.nColumn + 1 );
|
1522
|
+
for ( i = 0; i < pIdx.nColumn; i++ )
|
1523
|
+
{
|
1524
|
+
int idx = pIdx.aiColumn[i];
|
1525
|
+
if ( idx == pTab.iPKey )
|
1526
|
+
{
|
1527
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i );
|
1528
|
+
}
|
1529
|
+
else
|
1530
|
+
{
|
1531
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regData + idx, regIdx + i );
|
1532
|
+
}
|
1533
|
+
}
|
1534
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i );
|
1535
|
+
sqlite3VdbeAddOp3( v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur] );
|
1536
|
+
sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), 0 );
|
1537
|
+
sqlite3ExprCacheAffinityChange( pParse, regIdx, pIdx.nColumn + 1 );
|
1538
|
+
|
1539
|
+
/* Find out what action to take in case there is an indexing conflict */
|
1540
|
+
onError = pIdx.onError;
|
1541
|
+
if ( onError == OE_None )
|
1542
|
+
{
|
1543
|
+
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
|
1544
|
+
continue; /* pIdx is not a UNIQUE index */
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
if ( overrideError != OE_Default )
|
1548
|
+
{
|
1549
|
+
onError = overrideError;
|
1550
|
+
}
|
1551
|
+
else if ( onError == OE_Default )
|
1552
|
+
{
|
1553
|
+
onError = OE_Abort;
|
1554
|
+
}
|
1555
|
+
if ( seenReplace )
|
1556
|
+
{
|
1557
|
+
if ( onError == OE_Ignore ) onError = OE_Replace;
|
1558
|
+
else if ( onError == OE_Fail ) onError = OE_Abort;
|
1559
|
+
}
|
1560
|
+
|
1561
|
+
|
1562
|
+
/* Check to see if the new index entry will be unique */
|
1563
|
+
regR = sqlite3GetTempReg( pParse );
|
1564
|
+
sqlite3VdbeAddOp2( v, OP_SCopy, regOldRowid, regR );
|
1565
|
+
j3 = sqlite3VdbeAddOp4( v, OP_IsUnique, baseCur + iCur + 1, 0,
|
1566
|
+
regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx),
|
1567
|
+
P4_INT32 );
|
1568
|
+
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
|
1569
|
+
|
1570
|
+
/* Generate code that executes if the new index entry is not unique */
|
1571
|
+
Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail
|
1572
|
+
|| onError == OE_Ignore || onError == OE_Replace );
|
1573
|
+
switch ( onError )
|
1574
|
+
{
|
1575
|
+
case OE_Rollback:
|
1576
|
+
case OE_Abort:
|
1577
|
+
case OE_Fail:
|
1578
|
+
{
|
1579
|
+
int j;
|
1580
|
+
StrAccum errMsg = new StrAccum(200);
|
1581
|
+
string zSep;
|
1582
|
+
string zErr;
|
1583
|
+
|
1584
|
+
sqlite3StrAccumInit( errMsg, null, 0, 200 );
|
1585
|
+
errMsg.db = pParse.db;
|
1586
|
+
zSep = pIdx.nColumn > 1 ? "columns " : "column ";
|
1587
|
+
for ( j = 0; j < pIdx.nColumn; j++ )
|
1588
|
+
{
|
1589
|
+
string zCol = pTab.aCol[pIdx.aiColumn[j]].zName;
|
1590
|
+
sqlite3StrAccumAppend( errMsg, zSep, -1 );
|
1591
|
+
zSep = ", ";
|
1592
|
+
sqlite3StrAccumAppend( errMsg, zCol, -1 );
|
1593
|
+
}
|
1594
|
+
sqlite3StrAccumAppend( errMsg,
|
1595
|
+
pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1 );
|
1596
|
+
zErr = sqlite3StrAccumFinish( errMsg );
|
1597
|
+
sqlite3HaltConstraint( pParse, onError, zErr, 0 );
|
1598
|
+
sqlite3DbFree( errMsg.db, ref zErr );
|
1599
|
+
break;
|
1600
|
+
}
|
1601
|
+
case OE_Ignore:
|
1602
|
+
{
|
1603
|
+
Debug.Assert( !seenReplace );
|
1604
|
+
sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest );
|
1605
|
+
break;
|
1606
|
+
}
|
1607
|
+
default:
|
1608
|
+
{
|
1609
|
+
Trigger pTrigger = null;
|
1610
|
+
Debug.Assert( onError == OE_Replace );
|
1611
|
+
sqlite3MultiWrite( pParse );
|
1612
|
+
if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 )
|
1613
|
+
{
|
1614
|
+
int iDummy = 0;
|
1615
|
+
pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, ref iDummy );
|
1616
|
+
}
|
1617
|
+
sqlite3GenerateRowDelete(
|
1618
|
+
pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
|
1619
|
+
);
|
1620
|
+
seenReplace = true;
|
1621
|
+
break;
|
1622
|
+
}
|
1623
|
+
}
|
1624
|
+
sqlite3VdbeJumpHere( v, j3 );
|
1625
|
+
sqlite3ReleaseTempReg( pParse, regR );
|
1626
|
+
}
|
1627
|
+
//if ( pbMayReplace )
|
1628
|
+
{
|
1629
|
+
pbMayReplace = seenReplace ? 1 : 0;
|
1630
|
+
}
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
/*
|
1634
|
+
** This routine generates code to finish the INSERT or UPDATE operation
|
1635
|
+
** that was started by a prior call to sqlite3GenerateConstraintChecks.
|
1636
|
+
** A consecutive range of registers starting at regRowid contains the
|
1637
|
+
** rowid and the content to be inserted.
|
1638
|
+
**
|
1639
|
+
** The arguments to this routine should be the same as the first six
|
1640
|
+
** arguments to sqlite3GenerateConstraintChecks.
|
1641
|
+
*/
|
1642
|
+
static void sqlite3CompleteInsertion(
|
1643
|
+
Parse pParse, /* The parser context */
|
1644
|
+
Table pTab, /* the table into which we are inserting */
|
1645
|
+
int baseCur, /* Index of a read/write cursor pointing at pTab */
|
1646
|
+
int regRowid, /* Range of content */
|
1647
|
+
int[] aRegIdx, /* Register used by each index. 0 for unused indices */
|
1648
|
+
bool isUpdate, /* True for UPDATE, False for INSERT */
|
1649
|
+
bool appendBias, /* True if this is likely to be an append */
|
1650
|
+
bool useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
|
1651
|
+
)
|
1652
|
+
{
|
1653
|
+
int i;
|
1654
|
+
Vdbe v;
|
1655
|
+
int nIdx;
|
1656
|
+
Index pIdx;
|
1657
|
+
u8 pik_flags;
|
1658
|
+
int regData;
|
1659
|
+
int regRec;
|
1660
|
+
|
1661
|
+
v = sqlite3GetVdbe( pParse );
|
1662
|
+
Debug.Assert( v != null );
|
1663
|
+
Debug.Assert( pTab.pSelect == null ); /* This table is not a VIEW */
|
1664
|
+
for ( nIdx = 0, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, nIdx++ ) { }
|
1665
|
+
for ( i = nIdx - 1; i >= 0; i-- )
|
1666
|
+
{
|
1667
|
+
if ( aRegIdx[i] == 0 ) continue;
|
1668
|
+
sqlite3VdbeAddOp2( v, OP_IdxInsert, baseCur + i + 1, aRegIdx[i] );
|
1669
|
+
if ( useSeekResult )
|
1670
|
+
{
|
1671
|
+
sqlite3VdbeChangeP5( v, OPFLAG_USESEEKRESULT );
|
1672
|
+
}
|
1673
|
+
}
|
1674
|
+
regData = regRowid + 1;
|
1675
|
+
regRec = sqlite3GetTempReg( pParse );
|
1676
|
+
sqlite3VdbeAddOp3( v, OP_MakeRecord, regData, pTab.nCol, regRec );
|
1677
|
+
sqlite3TableAffinityStr( v, pTab );
|
1678
|
+
sqlite3ExprCacheAffinityChange( pParse, regData, pTab.nCol );
|
1679
|
+
if ( pParse.nested != 0 )
|
1680
|
+
{
|
1681
|
+
pik_flags = 0;
|
1682
|
+
}
|
1683
|
+
else
|
1684
|
+
{
|
1685
|
+
pik_flags = OPFLAG_NCHANGE;
|
1686
|
+
pik_flags |= ( isUpdate ? OPFLAG_ISUPDATE : OPFLAG_LASTROWID );
|
1687
|
+
}
|
1688
|
+
if ( appendBias )
|
1689
|
+
{
|
1690
|
+
pik_flags |= OPFLAG_APPEND;
|
1691
|
+
}
|
1692
|
+
if ( useSeekResult )
|
1693
|
+
{
|
1694
|
+
pik_flags |= OPFLAG_USESEEKRESULT;
|
1695
|
+
}
|
1696
|
+
sqlite3VdbeAddOp3( v, OP_Insert, baseCur, regRec, regRowid );
|
1697
|
+
if ( pParse.nested == 0 )
|
1698
|
+
{
|
1699
|
+
sqlite3VdbeChangeP4( v, -1, pTab.zName, P4_STATIC );
|
1700
|
+
}
|
1701
|
+
sqlite3VdbeChangeP5( v, pik_flags );
|
1702
|
+
}
|
1703
|
+
|
1704
|
+
/*
|
1705
|
+
** Generate code that will open cursors for a table and for all
|
1706
|
+
** indices of that table. The "baseCur" parameter is the cursor number used
|
1707
|
+
** for the table. Indices are opened on subsequent cursors.
|
1708
|
+
**
|
1709
|
+
** Return the number of indices on the table.
|
1710
|
+
*/
|
1711
|
+
static int sqlite3OpenTableAndIndices(
|
1712
|
+
Parse pParse, /* Parsing context */
|
1713
|
+
Table pTab, /* Table to be opened */
|
1714
|
+
int baseCur, /* VdbeCursor number assigned to the table */
|
1715
|
+
int op /* OP_OpenRead or OP_OpenWrite */
|
1716
|
+
)
|
1717
|
+
{
|
1718
|
+
int i;
|
1719
|
+
int iDb;
|
1720
|
+
Index pIdx;
|
1721
|
+
Vdbe v;
|
1722
|
+
|
1723
|
+
if ( IsVirtual( pTab ) ) return 0;
|
1724
|
+
iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema );
|
1725
|
+
v = sqlite3GetVdbe( pParse );
|
1726
|
+
Debug.Assert( v != null );
|
1727
|
+
sqlite3OpenTable( pParse, baseCur, iDb, pTab, op );
|
1728
|
+
for ( i = 1, pIdx = pTab.pIndex; pIdx != null; pIdx = pIdx.pNext, i++ )
|
1729
|
+
{
|
1730
|
+
KeyInfo pKey = sqlite3IndexKeyinfo( pParse, pIdx );
|
1731
|
+
Debug.Assert( pIdx.pSchema == pTab.pSchema );
|
1732
|
+
sqlite3VdbeAddOp4( v, op, i + baseCur, pIdx.tnum, iDb,
|
1733
|
+
pKey, P4_KEYINFO_HANDOFF );
|
1734
|
+
#if SQLITE_DEBUG
|
1735
|
+
VdbeComment( v, "%s", pIdx.zName );
|
1736
|
+
#endif
|
1737
|
+
}
|
1738
|
+
if ( pParse.nTab < baseCur + i )
|
1739
|
+
{
|
1740
|
+
pParse.nTab = baseCur + i;
|
1741
|
+
}
|
1742
|
+
return i - 1;
|
1743
|
+
}
|
1744
|
+
|
1745
|
+
|
1746
|
+
#if SQLITE_TEST
|
1747
|
+
/*
|
1748
|
+
** The following global variable is incremented whenever the
|
1749
|
+
** transfer optimization is used. This is used for testing
|
1750
|
+
** purposes only - to make sure the transfer optimization really
|
1751
|
+
** is happening when it is suppose to.
|
1752
|
+
*/
|
1753
|
+
//static int sqlite3_xferopt_count = 0;
|
1754
|
+
#endif // * SQLITE_TEST */
|
1755
|
+
|
1756
|
+
|
1757
|
+
#if !SQLITE_OMIT_XFER_OPT
|
1758
|
+
/*
|
1759
|
+
** Check to collation names to see if they are compatible.
|
1760
|
+
*/
|
1761
|
+
static bool xferCompatibleCollation( string z1, string z2 )
|
1762
|
+
{
|
1763
|
+
if ( z1 == null )
|
1764
|
+
{
|
1765
|
+
return z2 == null;
|
1766
|
+
}
|
1767
|
+
if ( z2 == null )
|
1768
|
+
{
|
1769
|
+
return false;
|
1770
|
+
}
|
1771
|
+
return sqlite3StrICmp( z1, z2 ) == 0;
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
|
1775
|
+
/*
|
1776
|
+
** Check to see if index pSrc is compatible as a source of data
|
1777
|
+
** for index pDest in an insert transfer optimization. The rules
|
1778
|
+
** for a compatible index:
|
1779
|
+
**
|
1780
|
+
** * The index is over the same set of columns
|
1781
|
+
** * The same DESC and ASC markings occurs on all columns
|
1782
|
+
** * The same onError processing (OE_Abort, OE_Ignore, etc)
|
1783
|
+
** * The same collating sequence on each column
|
1784
|
+
*/
|
1785
|
+
static bool xferCompatibleIndex( Index pDest, Index pSrc )
|
1786
|
+
{
|
1787
|
+
int i;
|
1788
|
+
Debug.Assert( pDest != null && pSrc != null );
|
1789
|
+
Debug.Assert( pDest.pTable != pSrc.pTable );
|
1790
|
+
if ( pDest.nColumn != pSrc.nColumn )
|
1791
|
+
{
|
1792
|
+
return false; /* Different number of columns */
|
1793
|
+
}
|
1794
|
+
if ( pDest.onError != pSrc.onError )
|
1795
|
+
{
|
1796
|
+
return false; /* Different conflict resolution strategies */
|
1797
|
+
}
|
1798
|
+
for ( i = 0; i < pSrc.nColumn; i++ )
|
1799
|
+
{
|
1800
|
+
if ( pSrc.aiColumn[i] != pDest.aiColumn[i] )
|
1801
|
+
{
|
1802
|
+
return false; /* Different columns indexed */
|
1803
|
+
}
|
1804
|
+
if ( pSrc.aSortOrder[i] != pDest.aSortOrder[i] )
|
1805
|
+
{
|
1806
|
+
return false; /* Different sort orders */
|
1807
|
+
}
|
1808
|
+
if ( !xferCompatibleCollation( pSrc.azColl[i], pDest.azColl[i] ) )
|
1809
|
+
{
|
1810
|
+
return false; /* Different collating sequences */
|
1811
|
+
}
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
/* If no test above fails then the indices must be compatible */
|
1815
|
+
return true;
|
1816
|
+
}
|
1817
|
+
|
1818
|
+
/*
|
1819
|
+
** Attempt the transfer optimization on INSERTs of the form
|
1820
|
+
**
|
1821
|
+
** INSERT INTO tab1 SELECT * FROM tab2;
|
1822
|
+
**
|
1823
|
+
** This optimization is only attempted if
|
1824
|
+
**
|
1825
|
+
** (1) tab1 and tab2 have identical schemas including all the
|
1826
|
+
** same indices and constraints
|
1827
|
+
**
|
1828
|
+
** (2) tab1 and tab2 are different tables
|
1829
|
+
**
|
1830
|
+
** (3) There must be no triggers on tab1
|
1831
|
+
**
|
1832
|
+
** (4) The result set of the SELECT statement is "*"
|
1833
|
+
**
|
1834
|
+
** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY,
|
1835
|
+
** or LIMIT clause.
|
1836
|
+
**
|
1837
|
+
** (6) The SELECT statement is a simple (not a compound) select that
|
1838
|
+
** contains only tab2 in its FROM clause
|
1839
|
+
**
|
1840
|
+
** This method for implementing the INSERT transfers raw records from
|
1841
|
+
** tab2 over to tab1. The columns are not decoded. Raw records from
|
1842
|
+
** the indices of tab2 are transfered to tab1 as well. In so doing,
|
1843
|
+
** the resulting tab1 has much less fragmentation.
|
1844
|
+
**
|
1845
|
+
** This routine returns TRUE if the optimization is attempted. If any
|
1846
|
+
** of the conditions above fail so that the optimization should not
|
1847
|
+
** be attempted, then this routine returns FALSE.
|
1848
|
+
*/
|
1849
|
+
static int xferOptimization(
|
1850
|
+
Parse pParse, /* Parser context */
|
1851
|
+
Table pDest, /* The table we are inserting into */
|
1852
|
+
Select pSelect, /* A SELECT statement to use as the data source */
|
1853
|
+
int onError, /* How to handle constraint errors */
|
1854
|
+
int iDbDest /* The database of pDest */
|
1855
|
+
)
|
1856
|
+
{
|
1857
|
+
ExprList pEList; /* The result set of the SELECT */
|
1858
|
+
Table pSrc; /* The table in the FROM clause of SELECT */
|
1859
|
+
Index pSrcIdx, pDestIdx; /* Source and destination indices */
|
1860
|
+
SrcList_item pItem; /* An element of pSelect.pSrc */
|
1861
|
+
int i; /* Loop counter */
|
1862
|
+
int iDbSrc; /* The database of pSrc */
|
1863
|
+
int iSrc, iDest; /* Cursors from source and destination */
|
1864
|
+
int addr1, addr2; /* Loop addresses */
|
1865
|
+
int emptyDestTest; /* Address of test for empty pDest */
|
1866
|
+
int emptySrcTest; /* Address of test for empty pSrc */
|
1867
|
+
Vdbe v; /* The VDBE we are building */
|
1868
|
+
KeyInfo pKey; /* Key information for an index */
|
1869
|
+
int regAutoinc; /* Memory register used by AUTOINC */
|
1870
|
+
bool destHasUniqueIdx = false; /* True if pDest has a UNIQUE index */
|
1871
|
+
int regData, regRowid; /* Registers holding data and rowid */
|
1872
|
+
|
1873
|
+
if ( pSelect == null )
|
1874
|
+
{
|
1875
|
+
return 0; /* Must be of the form INSERT INTO ... SELECT ... */
|
1876
|
+
}
|
1877
|
+
#if !SQLITE_OMIT_TRIGGER
|
1878
|
+
if ( sqlite3TriggerList( pParse, pDest ) != null )
|
1879
|
+
{
|
1880
|
+
return 0; /* tab1 must not have triggers */
|
1881
|
+
}
|
1882
|
+
#endif
|
1883
|
+
|
1884
|
+
if ( ( pDest.tabFlags & TF_Virtual ) != 0 )
|
1885
|
+
{
|
1886
|
+
return 0; /* tab1 must not be a virtual table */
|
1887
|
+
}
|
1888
|
+
if ( onError == OE_Default )
|
1889
|
+
{
|
1890
|
+
onError = OE_Abort;
|
1891
|
+
}
|
1892
|
+
if ( onError != OE_Abort && onError != OE_Rollback )
|
1893
|
+
{
|
1894
|
+
return 0; /* Cannot do OR REPLACE or OR IGNORE or OR FAIL */
|
1895
|
+
}
|
1896
|
+
Debug.Assert( pSelect.pSrc != null ); /* allocated even if there is no FROM clause */
|
1897
|
+
if ( pSelect.pSrc.nSrc != 1 )
|
1898
|
+
{
|
1899
|
+
return 0; /* FROM clause must have exactly one term */
|
1900
|
+
}
|
1901
|
+
if ( pSelect.pSrc.a[0].pSelect != null )
|
1902
|
+
{
|
1903
|
+
return 0; /* FROM clause cannot contain a subquery */
|
1904
|
+
}
|
1905
|
+
if ( pSelect.pWhere != null )
|
1906
|
+
{
|
1907
|
+
return 0; /* SELECT may not have a WHERE clause */
|
1908
|
+
}
|
1909
|
+
if ( pSelect.pOrderBy != null )
|
1910
|
+
{
|
1911
|
+
return 0; /* SELECT may not have an ORDER BY clause */
|
1912
|
+
}
|
1913
|
+
/* Do not need to test for a HAVING clause. If HAVING is present but
|
1914
|
+
** there is no ORDER BY, we will get an error. */
|
1915
|
+
if ( pSelect.pGroupBy != null )
|
1916
|
+
{
|
1917
|
+
return 0; /* SELECT may not have a GROUP BY clause */
|
1918
|
+
}
|
1919
|
+
if ( pSelect.pLimit != null )
|
1920
|
+
{
|
1921
|
+
return 0; /* SELECT may not have a LIMIT clause */
|
1922
|
+
}
|
1923
|
+
Debug.Assert( pSelect.pOffset == null ); /* Must be so if pLimit==0 */
|
1924
|
+
if ( pSelect.pPrior != null )
|
1925
|
+
{
|
1926
|
+
return 0; /* SELECT may not be a compound query */
|
1927
|
+
}
|
1928
|
+
if ( ( pSelect.selFlags & SF_Distinct ) != 0 )
|
1929
|
+
{
|
1930
|
+
return 0; /* SELECT may not be DISTINCT */
|
1931
|
+
}
|
1932
|
+
pEList = pSelect.pEList;
|
1933
|
+
Debug.Assert( pEList != null );
|
1934
|
+
if ( pEList.nExpr != 1 )
|
1935
|
+
{
|
1936
|
+
return 0; /* The result set must have exactly one column */
|
1937
|
+
}
|
1938
|
+
Debug.Assert( pEList.a[0].pExpr != null );
|
1939
|
+
if ( pEList.a[0].pExpr.op != TK_ALL )
|
1940
|
+
{
|
1941
|
+
return 0; /* The result set must be the special operator "*" */
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
/* At this point we have established that the statement is of the
|
1945
|
+
** correct syntactic form to participate in this optimization. Now
|
1946
|
+
** we have to check the semantics.
|
1947
|
+
*/
|
1948
|
+
pItem = pSelect.pSrc.a[0];
|
1949
|
+
pSrc = sqlite3LocateTable( pParse, 0, pItem.zName, pItem.zDatabase );
|
1950
|
+
if ( pSrc == null )
|
1951
|
+
{
|
1952
|
+
return 0; /* FROM clause does not contain a real table */
|
1953
|
+
}
|
1954
|
+
if ( pSrc == pDest )
|
1955
|
+
{
|
1956
|
+
return 0; /* tab1 and tab2 may not be the same table */
|
1957
|
+
}
|
1958
|
+
if ( ( pSrc.tabFlags & TF_Virtual ) != 0 )
|
1959
|
+
{
|
1960
|
+
return 0; /* tab2 must not be a virtual table */
|
1961
|
+
}
|
1962
|
+
if ( pSrc.pSelect != null )
|
1963
|
+
{
|
1964
|
+
return 0; /* tab2 may not be a view */
|
1965
|
+
}
|
1966
|
+
if ( pDest.nCol != pSrc.nCol )
|
1967
|
+
{
|
1968
|
+
return 0; /* Number of columns must be the same in tab1 and tab2 */
|
1969
|
+
}
|
1970
|
+
if ( pDest.iPKey != pSrc.iPKey )
|
1971
|
+
{
|
1972
|
+
return 0; /* Both tables must have the same INTEGER PRIMARY KEY */
|
1973
|
+
}
|
1974
|
+
for ( i = 0; i < pDest.nCol; i++ )
|
1975
|
+
{
|
1976
|
+
if ( pDest.aCol[i].affinity != pSrc.aCol[i].affinity )
|
1977
|
+
{
|
1978
|
+
return 0; /* Affinity must be the same on all columns */
|
1979
|
+
}
|
1980
|
+
if ( !xferCompatibleCollation( pDest.aCol[i].zColl, pSrc.aCol[i].zColl ) )
|
1981
|
+
{
|
1982
|
+
return 0; /* Collating sequence must be the same on all columns */
|
1983
|
+
}
|
1984
|
+
if ( pDest.aCol[i].notNull != 0 && pSrc.aCol[i].notNull == 0 )
|
1985
|
+
{
|
1986
|
+
return 0; /* tab2 must be NOT NULL if tab1 is */
|
1987
|
+
}
|
1988
|
+
}
|
1989
|
+
for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext )
|
1990
|
+
{
|
1991
|
+
if ( pDestIdx.onError != OE_None )
|
1992
|
+
{
|
1993
|
+
destHasUniqueIdx = true;
|
1994
|
+
}
|
1995
|
+
for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext )
|
1996
|
+
{
|
1997
|
+
if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) break;
|
1998
|
+
}
|
1999
|
+
if ( pSrcIdx == null )
|
2000
|
+
{
|
2001
|
+
return 0; /* pDestIdx has no corresponding index in pSrc */
|
2002
|
+
}
|
2003
|
+
}
|
2004
|
+
#if !SQLITE_OMIT_CHECK
|
2005
|
+
if (pDest.pCheck != null && 0 != sqlite3ExprCompare(pSrc.pCheck, pDest.pCheck))
|
2006
|
+
{
|
2007
|
+
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
|
2008
|
+
}
|
2009
|
+
#endif
|
2010
|
+
|
2011
|
+
/* If we get this far, it means either:
|
2012
|
+
**
|
2013
|
+
** * We can always do the transfer if the table contains an
|
2014
|
+
** an integer primary key
|
2015
|
+
**
|
2016
|
+
** * We can conditionally do the transfer if the destination
|
2017
|
+
** table is empty.
|
2018
|
+
*/
|
2019
|
+
#if SQLITE_TEST
|
2020
|
+
sqlite3_xferopt_count.iValue++;
|
2021
|
+
#endif
|
2022
|
+
iDbSrc = sqlite3SchemaToIndex( pParse.db, pSrc.pSchema );
|
2023
|
+
v = sqlite3GetVdbe( pParse );
|
2024
|
+
sqlite3CodeVerifySchema( pParse, iDbSrc );
|
2025
|
+
iSrc = pParse.nTab++;
|
2026
|
+
iDest = pParse.nTab++;
|
2027
|
+
regAutoinc = autoIncBegin( pParse, iDbDest, pDest );
|
2028
|
+
sqlite3OpenTable( pParse, iDest, iDbDest, pDest, OP_OpenWrite );
|
2029
|
+
if ( ( pDest.iPKey < 0 && pDest.pIndex != null ) || destHasUniqueIdx )
|
2030
|
+
{
|
2031
|
+
/* If tables do not have an INTEGER PRIMARY KEY and there
|
2032
|
+
** are indices to be copied and the destination is not empty,
|
2033
|
+
** we have to disallow the transfer optimization because the
|
2034
|
+
** the rowids might change which will mess up indexing.
|
2035
|
+
**
|
2036
|
+
** Or if the destination has a UNIQUE index and is not empty,
|
2037
|
+
** we also disallow the transfer optimization because we cannot
|
2038
|
+
** insure that all entries in the union of DEST and SRC will be
|
2039
|
+
** unique.
|
2040
|
+
*/
|
2041
|
+
addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iDest, 0 );
|
2042
|
+
emptyDestTest = sqlite3VdbeAddOp2( v, OP_Goto, 0, 0 );
|
2043
|
+
sqlite3VdbeJumpHere( v, addr1 );
|
2044
|
+
}
|
2045
|
+
else
|
2046
|
+
{
|
2047
|
+
emptyDestTest = 0;
|
2048
|
+
}
|
2049
|
+
sqlite3OpenTable( pParse, iSrc, iDbSrc, pSrc, OP_OpenRead );
|
2050
|
+
emptySrcTest = sqlite3VdbeAddOp2( v, OP_Rewind, iSrc, 0 );
|
2051
|
+
regData = sqlite3GetTempReg( pParse );
|
2052
|
+
regRowid = sqlite3GetTempReg( pParse );
|
2053
|
+
if ( pDest.iPKey >= 0 )
|
2054
|
+
{
|
2055
|
+
addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid );
|
2056
|
+
addr2 = sqlite3VdbeAddOp3( v, OP_NotExists, iDest, 0, regRowid );
|
2057
|
+
sqlite3HaltConstraint(
|
2058
|
+
pParse, onError, "PRIMARY KEY must be unique", P4_STATIC );
|
2059
|
+
sqlite3VdbeJumpHere( v, addr2 );
|
2060
|
+
autoIncStep( pParse, regAutoinc, regRowid );
|
2061
|
+
}
|
2062
|
+
else if ( pDest.pIndex == null )
|
2063
|
+
{
|
2064
|
+
addr1 = sqlite3VdbeAddOp2( v, OP_NewRowid, iDest, regRowid );
|
2065
|
+
}
|
2066
|
+
else
|
2067
|
+
{
|
2068
|
+
addr1 = sqlite3VdbeAddOp2( v, OP_Rowid, iSrc, regRowid );
|
2069
|
+
Debug.Assert( ( pDest.tabFlags & TF_Autoincrement ) == 0 );
|
2070
|
+
}
|
2071
|
+
sqlite3VdbeAddOp2( v, OP_RowData, iSrc, regData );
|
2072
|
+
sqlite3VdbeAddOp3( v, OP_Insert, iDest, regData, regRowid );
|
2073
|
+
sqlite3VdbeChangeP5( v, OPFLAG_NCHANGE | OPFLAG_LASTROWID | OPFLAG_APPEND );
|
2074
|
+
sqlite3VdbeChangeP4( v, -1, pDest.zName, 0 );
|
2075
|
+
sqlite3VdbeAddOp2( v, OP_Next, iSrc, addr1 );
|
2076
|
+
for ( pDestIdx = pDest.pIndex; pDestIdx != null; pDestIdx = pDestIdx.pNext )
|
2077
|
+
{
|
2078
|
+
for ( pSrcIdx = pSrc.pIndex; pSrcIdx != null; pSrcIdx = pSrcIdx.pNext )
|
2079
|
+
{
|
2080
|
+
if ( xferCompatibleIndex( pDestIdx, pSrcIdx ) ) break;
|
2081
|
+
}
|
2082
|
+
Debug.Assert( pSrcIdx != null );
|
2083
|
+
sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 );
|
2084
|
+
sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 );
|
2085
|
+
pKey = sqlite3IndexKeyinfo( pParse, pSrcIdx );
|
2086
|
+
sqlite3VdbeAddOp4( v, OP_OpenRead, iSrc, pSrcIdx.tnum, iDbSrc,
|
2087
|
+
pKey, P4_KEYINFO_HANDOFF );
|
2088
|
+
#if SQLITE_DEBUG
|
2089
|
+
VdbeComment( v, "%s", pSrcIdx.zName );
|
2090
|
+
#endif
|
2091
|
+
pKey = sqlite3IndexKeyinfo( pParse, pDestIdx );
|
2092
|
+
sqlite3VdbeAddOp4( v, OP_OpenWrite, iDest, pDestIdx.tnum, iDbDest,
|
2093
|
+
pKey, P4_KEYINFO_HANDOFF );
|
2094
|
+
#if SQLITE_DEBUG
|
2095
|
+
VdbeComment( v, "%s", pDestIdx.zName );
|
2096
|
+
#endif
|
2097
|
+
addr1 = sqlite3VdbeAddOp2( v, OP_Rewind, iSrc, 0 );
|
2098
|
+
sqlite3VdbeAddOp2( v, OP_RowKey, iSrc, regData );
|
2099
|
+
sqlite3VdbeAddOp3( v, OP_IdxInsert, iDest, regData, 1 );
|
2100
|
+
sqlite3VdbeAddOp2( v, OP_Next, iSrc, addr1 + 1 );
|
2101
|
+
sqlite3VdbeJumpHere( v, addr1 );
|
2102
|
+
}
|
2103
|
+
sqlite3VdbeJumpHere( v, emptySrcTest );
|
2104
|
+
sqlite3ReleaseTempReg( pParse, regRowid );
|
2105
|
+
sqlite3ReleaseTempReg( pParse, regData );
|
2106
|
+
sqlite3VdbeAddOp2( v, OP_Close, iSrc, 0 );
|
2107
|
+
sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 );
|
2108
|
+
if ( emptyDestTest != 0 )
|
2109
|
+
{
|
2110
|
+
sqlite3VdbeAddOp2( v, OP_Halt, SQLITE_OK, 0 );
|
2111
|
+
sqlite3VdbeJumpHere( v, emptyDestTest );
|
2112
|
+
sqlite3VdbeAddOp2( v, OP_Close, iDest, 0 );
|
2113
|
+
return 0;
|
2114
|
+
}
|
2115
|
+
else
|
2116
|
+
{
|
2117
|
+
return 1;
|
2118
|
+
}
|
2119
|
+
}
|
2120
|
+
#endif // * SQLITE_OMIT_XFER_OPT */
|
2121
|
+
}
|
2122
|
+
}
|