| 2801 | |
| 2802 | |
| 2803 | JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const char* filename, |
| 2804 | unsigned int dpb_length, const unsigned char* dpb) |
| 2805 | { |
| 2806 | /************************************** |
| 2807 | * |
| 2808 | * g d s _ $ c r e a t e _ d a t a b a s e |
| 2809 | * |
| 2810 | ************************************** |
| 2811 | * |
| 2812 | * Functional description |
| 2813 | * Create a nice, squeeky clean database, uncorrupted by user data. |
| 2814 | * |
| 2815 | **************************************/ |
| 2816 | try |
| 2817 | { |
| 2818 | ThreadContextHolder tdbb(user_status); |
| 2819 | MutexEnsureUnlock guardDbInit(dbInitMutex, FB_FUNCTION); |
| 2820 | |
| 2821 | UserId userId; |
| 2822 | DatabaseOptions options; |
| 2823 | PathName org_filename, expanded_name; |
| 2824 | bool is_alias = false; |
| 2825 | Firebird::RefPtr<const Config> config; |
| 2826 | Mapping mapping(Mapping::MAP_THROW_NOT_FOUND, cryptCallback); |
| 2827 | LateRefGuard lateBlocking(FB_FUNCTION); |
| 2828 | |
| 2829 | try |
| 2830 | { |
| 2831 | // Process database parameter block |
| 2832 | bool invalid_client_SQL_dialect = false; |
| 2833 | options.get(dpb, dpb_length, invalid_client_SQL_dialect); |
| 2834 | mapping.setAuthBlock(options.dpb_auth_block); |
| 2835 | if (!invalid_client_SQL_dialect && options.dpb_sql_dialect == 99) { |
| 2836 | options.dpb_sql_dialect = 0; |
| 2837 | } |
| 2838 | |
| 2839 | if (options.dpb_org_filename.hasData()) |
| 2840 | org_filename = options.dpb_org_filename; |
| 2841 | else |
| 2842 | { |
| 2843 | org_filename = filename; |
| 2844 | |
| 2845 | if (!options.dpb_utf8_filename) |
| 2846 | ISC_systemToUtf8(org_filename); |
| 2847 | |
| 2848 | ISC_unescape(org_filename); |
| 2849 | } |
| 2850 | |
| 2851 | ISC_utf8ToSystem(org_filename); |
| 2852 | |
| 2853 | // Resolve given alias name |
| 2854 | is_alias = expandDatabaseName(org_filename, expanded_name, &config); |
| 2855 | if (!is_alias) |
| 2856 | { |
| 2857 | expanded_name = filename; |
| 2858 | |
| 2859 | if (!options.dpb_utf8_filename) |
| 2860 | ISC_systemToUtf8(expanded_name); |
no test coverage detected