diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 861de1ab607cef30b7edcfed61e2cae4461e2a90..1cfc498c25e8352171b7c859c7fea7ebc6028bc5 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -1194,7 +1194,7 @@ void catalogDestroy(void) { taosHashCleanup(gCtgMgmt.pCluster); gCtgMgmt.pCluster = NULL; - CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.lock); + if (CTG_IS_LOCKED(&gCtgMgmt.lock) == TD_RWLATCH_WRITE_FLAG_COPY) CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.lock); qInfo("catalog destroyed"); } diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 75797048cad5f6290e73edf467c6cd98b197af7e..cfb7b8a0e255cf32301984f9135f2d4711144d74 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -204,7 +204,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) { int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) { wordexp_t full_path; if (0 != wordexp(dirname, &full_path, 0)) { - // printf("failed to expand path:%s since %s", dirname, strerror(errno)); + printf("failed to expand path:%s since %s", dirname, strerror(errno)); wordfree(&full_path); return -1; } diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 872d8e740c651cd494efbe5c783390637e95efe7..dc9527c2f2a052cf2d87b6b6c374019139390beb 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -32,6 +32,700 @@ #pragma warning(disable : 4091) #include #pragma warning(pop) + +char *win_tz[139][2]={{"China Standard Time", "Asia/Shanghai"}, + {"AUS Central Standard Time", "Australia/Darwin"}, + {"AUS Eastern Standard Time", "Australia/Sydney"}, + {"Afghanistan Standard Time", "Asia/Kabul"}, + {"Alaskan Standard Time", "America/Anchorage"}, + {"Aleutian Standard Time", "America/Adak"}, + {"Altai Standard Time", "Asia/Barnaul"}, + {"Arab Standard Time", "Asia/Riyadh"}, + {"Arabian Standard Time", "Asia/Dubai"}, + {"Arabic Standard Time", "Asia/Baghdad"}, + {"Argentina Standard Time", "America/Buenos_Aires"}, + {"Astrakhan Standard Time", "Europe/Astrakhan"}, + {"Atlantic Standard Time", "America/Halifax"}, + {"Aus Central W. Standard Time", "Australia/Eucla"}, + {"Azerbaijan Standard Time", "Asia/Baku"}, + {"Azores Standard Time", "Atlantic/Azores"}, + {"Bahia Standard Time", "America/Bahia"}, + {"Bangladesh Standard Time", "Asia/Dhaka"}, + {"Belarus Standard Time", "Europe/Minsk"}, + {"Bougainville Standard Time", "Pacific/Bougainville"}, + {"Canada Central Standard Time", "America/Regina"}, + {"Cape Verde Standard Time", "Atlantic/Cape_Verde"}, + {"Caucasus Standard Time", "Asia/Yerevan"}, + {"Cen. Australia Standard Time", "Australia/Adelaide"}, + {"Central America Standard Time", "America/Guatemala"}, + {"Central Asia Standard Time", "Asia/Almaty"}, + {"Central Brazilian Standard Time", "America/Cuiaba"}, + {"Central Europe Standard Time", "Europe/Budapest"}, + {"Central European Standard Time", "Europe/Warsaw"}, + {"Central Pacific Standard Time", "Pacific/Guadalcanal"}, + {"Central Standard Time", "America/Chicago"}, + {"Central Standard Time (Mexico)", "America/Mexico_City"}, + {"Chatham Islands Standard Time", "Pacific/Chatham"}, + {"Cuba Standard Time", "America/Havana"}, + {"Dateline Standard Time", "Etc/GMT+12"}, + {"E. Africa Standard Time", "Africa/Nairobi"}, + {"E. Australia Standard Time", "Australia/Brisbane"}, + {"E. Europe Standard Time", "Europe/Chisinau"}, + {"E. South America Standard Time", "America/Sao_Paulo"}, + {"Easter Island Standard Time", "Pacific/Easter"}, + {"Eastern Standard Time", "America/New_York"}, + {"Eastern Standard Time (Mexico)", "America/Cancun"}, + {"Egypt Standard Time", "Africa/Cairo"}, + {"Ekaterinburg Standard Time", "Asia/Yekaterinburg"}, + {"FLE Standard Time", "Europe/Kiev"}, + {"Fiji Standard Time", "Pacific/Fiji"}, + {"GMT Standard Time", "Europe/London"}, + {"GTB Standard Time", "Europe/Bucharest"}, + {"Georgian Standard Time", "Asia/Tbilisi"}, + {"Greenland Standard Time", "America/Godthab"}, + {"Greenwich Standard Time", "Atlantic/Reykjavik"}, + {"Haiti Standard Time", "America/Port-au-Prince"}, + {"Hawaiian Standard Time", "Pacific/Honolulu"}, + {"India Standard Time", "Asia/Calcutta"}, + {"Iran Standard Time", "Asia/Tehran"}, + {"Israel Standard Time", "Asia/Jerusalem"}, + {"Jordan Standard Time", "Asia/Amman"}, + {"Kaliningrad Standard Time", "Europe/Kaliningrad"}, + {"Korea Standard Time", "Asia/Seoul"}, + {"Libya Standard Time", "Africa/Tripoli"}, + {"Line Islands Standard Time", "Pacific/Kiritimati"}, + {"Lord Howe Standard Time", "Australia/Lord_Howe"}, + {"Magadan Standard Time", "Asia/Magadan"}, + {"Magallanes Standard Time", "America/Punta_Arenas"}, + {"Marquesas Standard Time", "Pacific/Marquesas"}, + {"Mauritius Standard Time", "Indian/Mauritius"}, + {"Middle East Standard Time", "Asia/Beirut"}, + {"Montevideo Standard Time", "America/Montevideo"}, + {"Morocco Standard Time", "Africa/Casablanca"}, + {"Mountain Standard Time", "America/Denver"}, + {"Mountain Standard Time (Mexico)", "America/Chihuahua"}, + {"Myanmar Standard Time", "Asia/Rangoon"}, + {"N. Central Asia Standard Time", "Asia/Novosibirsk"}, + {"Namibia Standard Time", "Africa/Windhoek"}, + {"Nepal Standard Time", "Asia/Katmandu"}, + {"New Zealand Standard Time", "Pacific/Auckland"}, + {"Newfoundland Standard Time", "America/St_Johns"}, + {"Norfolk Standard Time", "Pacific/Norfolk"}, + {"North Asia East Standard Time", "Asia/Irkutsk"}, + {"North Asia Standard Time", "Asia/Krasnoyarsk"}, + {"North Korea Standard Time", "Asia/Pyongyang"}, + {"Omsk Standard Time", "Asia/Omsk"}, + {"Pacific SA Standard Time", "America/Santiago"}, + {"Pacific Standard Time", "America/Los_Angeles"}, + {"Pacific Standard Time (Mexico)", "America/Tijuana"}, + {"Pakistan Standard Time", "Asia/Karachi"}, + {"Paraguay Standard Time", "America/Asuncion"}, + {"Qyzylorda Standard Time", "Asia/Qyzylorda"}, + {"Romance Standard Time", "Europe/Paris"}, + {"Russia Time Zone 10", "Asia/Srednekolymsk"}, + {"Russia Time Zone 11", "Asia/Kamchatka"}, + {"Russia Time Zone 3", "Europe/Samara"}, + {"Russian Standard Time", "Europe/Moscow"}, + {"SA Eastern Standard Time", "America/Cayenne"}, + {"SA Pacific Standard Time", "America/Bogota"}, + {"SA Western Standard Time", "America/La_Paz"}, + {"SE Asia Standard Time", "Asia/Bangkok"}, + {"Saint Pierre Standard Time", "America/Miquelon"}, + {"Sakhalin Standard Time", "Asia/Sakhalin"}, + {"Samoa Standard Time", "Pacific/Apia"}, + {"Sao Tome Standard Time", "Africa/Sao_Tome"}, + {"Saratov Standard Time", "Europe/Saratov"}, + {"Singapore Standard Time", "Asia/Singapore"}, + {"South Africa Standard Time", "Africa/Johannesburg"}, + {"South Sudan Standard Time", "Africa/Juba"}, + {"Sri Lanka Standard Time", "Asia/Colombo"}, + {"Sudan Standard Time", "Africa/Khartoum"}, + {"Syria Standard Time", "Asia/Damascus"}, + {"Taipei Standard Time", "Asia/Taipei"}, + {"Tasmania Standard Time", "Australia/Hobart"}, + {"Tocantins Standard Time", "America/Araguaina"}, + {"Tokyo Standard Time", "Asia/Tokyo"}, + {"Tomsk Standard Time", "Asia/Tomsk"}, + {"Tonga Standard Time", "Pacific/Tongatapu"}, + {"Transbaikal Standard Time", "Asia/Chita"}, + {"Turkey Standard Time", "Europe/Istanbul"}, + {"Turks And Caicos Standard Time", "America/Grand_Turk"}, + {"US Eastern Standard Time", "America/Indianapolis"}, + {"US Mountain Standard Time", "America/Phoenix"}, + {"UTC", "Etc/UTC"}, + {"UTC+12", "Etc/GMT-12"}, + {"UTC+13", "Etc/GMT-13"}, + {"UTC-02", "Etc/GMT+2"}, + {"UTC-08", "Etc/GMT+8"}, + {"UTC-09", "Etc/GMT+9"}, + {"UTC-11", "Etc/GMT+11"}, + {"Ulaanbaatar Standard Time", "Asia/Ulaanbaatar"}, + {"Venezuela Standard Time", "America/Caracas"}, + {"Vladivostok Standard Time", "Asia/Vladivostok"}, + {"Volgograd Standard Time", "Europe/Volgograd"}, + {"W. Australia Standard Time", "Australia/Perth"}, + {"W. Central Africa Standard Time", "Africa/Lagos"}, + {"W. Europe Standard Time", "Europe/Berlin"}, + {"W. Mongolia Standard Time", "Asia/Hovd"}, + {"West Asia Standard Time", "Asia/Tashkent"}, + {"West Bank Standard Time", "Asia/Hebron"}, + {"West Pacific Standard Time", "Pacific/Port_Moresby"}, + {"Yakutsk Standard Time", "Asia/Yakutsk"}, + {"Yukon Standard Time", "America/Whitehorse"}}; +char *tz_win[554][2]={{"Asia/Shanghai", "China Standard Time"}, +{"Africa/Abidjan", "Greenwich Standard Time"}, +{"Africa/Accra", "Greenwich Standard Time"}, +{"Africa/Addis_Ababa", "E. Africa Standard Time"}, +{"Africa/Algiers", "W. Central Africa Standard Time"}, +{"Africa/Asmera", "E. Africa Standard Time"}, +{"Africa/Bamako", "Greenwich Standard Time"}, +{"Africa/Bangui", "W. Central Africa Standard Time"}, +{"Africa/Banjul", "Greenwich Standard Time"}, +{"Africa/Bissau", "Greenwich Standard Time"}, +{"Africa/Blantyre", "South Africa Standard Time"}, +{"Africa/Brazzaville", "W. Central Africa Standard Time"}, +{"Africa/Bujumbura", "South Africa Standard Time"}, +{"Africa/Cairo", "Egypt Standard Time"}, +{"Africa/Casablanca", "Morocco Standard Time"}, +{"Africa/Ceuta", "Romance Standard Time"}, +{"Africa/Conakry", "Greenwich Standard Time"}, +{"Africa/Dakar", "Greenwich Standard Time"}, +{"Africa/Dar_es_Salaam", "E. Africa Standard Time"}, +{"Africa/Djibouti", "E. Africa Standard Time"}, +{"Africa/Douala", "W. Central Africa Standard Time"}, +{"Africa/El_Aaiun", "Morocco Standard Time"}, +{"Africa/Freetown", "Greenwich Standard Time"}, +{"Africa/Gaborone", "South Africa Standard Time"}, +{"Africa/Harare", "South Africa Standard Time"}, +{"Africa/Johannesburg", "South Africa Standard Time"}, +{"Africa/Juba", "South Sudan Standard Time"}, +{"Africa/Kampala", "E. Africa Standard Time"}, +{"Africa/Khartoum", "Sudan Standard Time"}, +{"Africa/Kigali", "South Africa Standard Time"}, +{"Africa/Kinshasa", "W. Central Africa Standard Time"}, +{"Africa/Lagos", "W. Central Africa Standard Time"}, +{"Africa/Libreville", "W. Central Africa Standard Time"}, +{"Africa/Lome", "Greenwich Standard Time"}, +{"Africa/Luanda", "W. Central Africa Standard Time"}, +{"Africa/Lubumbashi", "South Africa Standard Time"}, +{"Africa/Lusaka", "South Africa Standard Time"}, +{"Africa/Malabo", "W. Central Africa Standard Time"}, +{"Africa/Maputo", "South Africa Standard Time"}, +{"Africa/Maseru", "South Africa Standard Time"}, +{"Africa/Mbabane", "South Africa Standard Time"}, +{"Africa/Mogadishu", "E. Africa Standard Time"}, +{"Africa/Monrovia", "Greenwich Standard Time"}, +{"Africa/Nairobi", "E. Africa Standard Time"}, +{"Africa/Ndjamena", "W. Central Africa Standard Time"}, +{"Africa/Niamey", "W. Central Africa Standard Time"}, +{"Africa/Nouakchott", "Greenwich Standard Time"}, +{"Africa/Ouagadougou", "Greenwich Standard Time"}, +{"Africa/Porto-Novo", "W. Central Africa Standard Time"}, +{"Africa/Sao_Tome", "Sao Tome Standard Time"}, +{"Africa/Timbuktu", "Greenwich Standard Time"}, +{"Africa/Tripoli", "Libya Standard Time"}, +{"Africa/Tunis", "W. Central Africa Standard Time"}, +{"Africa/Windhoek", "Namibia Standard Time"}, +{"America/Adak", "Aleutian Standard Time"}, +{"America/Anchorage", "Alaskan Standard Time"}, +{"America/Anguilla", "SA Western Standard Time"}, +{"America/Antigua", "SA Western Standard Time"}, +{"America/Araguaina", "Tocantins Standard Time"}, +{"America/Argentina/La_Rioja", "Argentina Standard Time"}, +{"America/Argentina/Rio_Gallegos", "Argentina Standard Time"}, +{"America/Argentina/Salta", "Argentina Standard Time"}, +{"America/Argentina/San_Juan", "Argentina Standard Time"}, +{"America/Argentina/San_Luis", "Argentina Standard Time"}, +{"America/Argentina/Tucuman", "Argentina Standard Time"}, +{"America/Argentina/Ushuaia", "Argentina Standard Time"}, +{"America/Aruba", "SA Western Standard Time"}, +{"America/Asuncion", "Paraguay Standard Time"}, +{"America/Atka", "Aleutian Standard Time"}, +{"America/Bahia", "Bahia Standard Time"}, +{"America/Bahia_Banderas", "Central Standard Time (Mexico)"}, +{"America/Barbados", "SA Western Standard Time"}, +{"America/Belem", "SA Eastern Standard Time"}, +{"America/Belize", "Central America Standard Time"}, +{"America/Blanc-Sablon", "SA Western Standard Time"}, +{"America/Boa_Vista", "SA Western Standard Time"}, +{"America/Bogota", "SA Pacific Standard Time"}, +{"America/Boise", "Mountain Standard Time"}, +{"America/Buenos_Aires", "Argentina Standard Time"}, +{"America/Cambridge_Bay", "Mountain Standard Time"}, +{"America/Campo_Grande", "Central Brazilian Standard Time"}, +{"America/Cancun", "Eastern Standard Time (Mexico)"}, +{"America/Caracas", "Venezuela Standard Time"}, +{"America/Catamarca", "Argentina Standard Time"}, +{"America/Cayenne", "SA Eastern Standard Time"}, +{"America/Cayman", "SA Pacific Standard Time"}, +{"America/Chicago", "Central Standard Time"}, +{"America/Chihuahua", "Mountain Standard Time (Mexico)"}, +{"America/Coral_Harbour", "SA Pacific Standard Time"}, +{"America/Cordoba", "Argentina Standard Time"}, +{"America/Costa_Rica", "Central America Standard Time"}, +{"America/Creston", "US Mountain Standard Time"}, +{"America/Cuiaba", "Central Brazilian Standard Time"}, +{"America/Curacao", "SA Western Standard Time"}, +{"America/Danmarkshavn", "Greenwich Standard Time"}, +{"America/Dawson", "Yukon Standard Time"}, +{"America/Dawson_Creek", "US Mountain Standard Time"}, +{"America/Denver", "Mountain Standard Time"}, +{"America/Detroit", "Eastern Standard Time"}, +{"America/Dominica", "SA Western Standard Time"}, +{"America/Edmonton", "Mountain Standard Time"}, +{"America/Eirunepe", "SA Pacific Standard Time"}, +{"America/El_Salvador", "Central America Standard Time"}, +{"America/Ensenada", "Pacific Standard Time (Mexico)"}, +{"America/Fort_Nelson", "US Mountain Standard Time"}, +{"America/Fortaleza", "SA Eastern Standard Time"}, +{"America/Glace_Bay", "Atlantic Standard Time"}, +{"America/Godthab", "Greenland Standard Time"}, +{"America/Goose_Bay", "Atlantic Standard Time"}, +{"America/Grand_Turk", "Turks And Caicos Standard Time"}, +{"America/Grenada", "SA Western Standard Time"}, +{"America/Guadeloupe", "SA Western Standard Time"}, +{"America/Guatemala", "Central America Standard Time"}, +{"America/Guayaquil", "SA Pacific Standard Time"}, +{"America/Guyana", "SA Western Standard Time"}, +{"America/Halifax", "Atlantic Standard Time"}, +{"America/Havana", "Cuba Standard Time"}, +{"America/Hermosillo", "US Mountain Standard Time"}, +{"America/Indiana/Knox", "Central Standard Time"}, +{"America/Indiana/Marengo", "US Eastern Standard Time"}, +{"America/Indiana/Petersburg", "Eastern Standard Time"}, +{"America/Indiana/Tell_City", "Central Standard Time"}, +{"America/Indiana/Vevay", "US Eastern Standard Time"}, +{"America/Indiana/Vincennes", "Eastern Standard Time"}, +{"America/Indiana/Winamac", "Eastern Standard Time"}, +{"America/Indianapolis", "US Eastern Standard Time"}, +{"America/Inuvik", "Mountain Standard Time"}, +{"America/Iqaluit", "Eastern Standard Time"}, +{"America/Jamaica", "SA Pacific Standard Time"}, +{"America/Jujuy", "Argentina Standard Time"}, +{"America/Juneau", "Alaskan Standard Time"}, +{"America/Kentucky/Monticello", "Eastern Standard Time"}, +{"America/Knox_IN", "Central Standard Time"}, +{"America/Kralendijk", "SA Western Standard Time"}, +{"America/La_Paz", "SA Western Standard Time"}, +{"America/Lima", "SA Pacific Standard Time"}, +{"America/Los_Angeles", "Pacific Standard Time"}, +{"America/Louisville", "Eastern Standard Time"}, +{"America/Lower_Princes", "SA Western Standard Time"}, +{"America/Maceio", "SA Eastern Standard Time"}, +{"America/Managua", "Central America Standard Time"}, +{"America/Manaus", "SA Western Standard Time"}, +{"America/Marigot", "SA Western Standard Time"}, +{"America/Martinique", "SA Western Standard Time"}, +{"America/Matamoros", "Central Standard Time"}, +{"America/Mazatlan", "Mountain Standard Time (Mexico)"}, +{"America/Mendoza", "Argentina Standard Time"}, +{"America/Menominee", "Central Standard Time"}, +{"America/Merida", "Central Standard Time (Mexico)"}, +{"America/Metlakatla", "Alaskan Standard Time"}, +{"America/Mexico_City", "Central Standard Time (Mexico)"}, +{"America/Miquelon", "Saint Pierre Standard Time"}, +{"America/Moncton", "Atlantic Standard Time"}, +{"America/Monterrey", "Central Standard Time (Mexico)"}, +{"America/Montevideo", "Montevideo Standard Time"}, +{"America/Montreal", "Eastern Standard Time"}, +{"America/Montserrat", "SA Western Standard Time"}, +{"America/Nassau", "Eastern Standard Time"}, +{"America/New_York", "Eastern Standard Time"}, +{"America/Nipigon", "Eastern Standard Time"}, +{"America/Nome", "Alaskan Standard Time"}, +{"America/Noronha", "UTC-02"}, +{"America/North_Dakota/Beulah", "Central Standard Time"}, +{"America/North_Dakota/Center", "Central Standard Time"}, +{"America/North_Dakota/New_Salem", "Central Standard Time"}, +{"America/Ojinaga", "Mountain Standard Time"}, +{"America/Panama", "SA Pacific Standard Time"}, +{"America/Pangnirtung", "Eastern Standard Time"}, +{"America/Paramaribo", "SA Eastern Standard Time"}, +{"America/Phoenix", "US Mountain Standard Time"}, +{"America/Port-au-Prince", "Haiti Standard Time"}, +{"America/Port_of_Spain", "SA Western Standard Time"}, +{"America/Porto_Acre", "SA Pacific Standard Time"}, +{"America/Porto_Velho", "SA Western Standard Time"}, +{"America/Puerto_Rico", "SA Western Standard Time"}, +{"America/Punta_Arenas", "Magallanes Standard Time"}, +{"America/Rainy_River", "Central Standard Time"}, +{"America/Rankin_Inlet", "Central Standard Time"}, +{"America/Recife", "SA Eastern Standard Time"}, +{"America/Regina", "Canada Central Standard Time"}, +{"America/Resolute", "Central Standard Time"}, +{"America/Rio_Branco", "SA Pacific Standard Time"}, +{"America/Santa_Isabel", "Pacific Standard Time (Mexico)"}, +{"America/Santarem", "SA Eastern Standard Time"}, +{"America/Santiago", "Pacific SA Standard Time"}, +{"America/Santo_Domingo", "SA Western Standard Time"}, +{"America/Sao_Paulo", "E. South America Standard Time"}, +{"America/Scoresbysund", "Azores Standard Time"}, +{"America/Shiprock", "Mountain Standard Time"}, +{"America/Sitka", "Alaskan Standard Time"}, +{"America/St_Barthelemy", "SA Western Standard Time"}, +{"America/St_Johns", "Newfoundland Standard Time"}, +{"America/St_Kitts", "SA Western Standard Time"}, +{"America/St_Lucia", "SA Western Standard Time"}, +{"America/St_Thomas", "SA Western Standard Time"}, +{"America/St_Vincent", "SA Western Standard Time"}, +{"America/Swift_Current", "Canada Central Standard Time"}, +{"America/Tegucigalpa", "Central America Standard Time"}, +{"America/Thule", "Atlantic Standard Time"}, +{"America/Thunder_Bay", "Eastern Standard Time"}, +{"America/Tijuana", "Pacific Standard Time (Mexico)"}, +{"America/Toronto", "Eastern Standard Time"}, +{"America/Tortola", "SA Western Standard Time"}, +{"America/Vancouver", "Pacific Standard Time"}, +{"America/Virgin", "SA Western Standard Time"}, +{"America/Whitehorse", "Yukon Standard Time"}, +{"America/Winnipeg", "Central Standard Time"}, +{"America/Yakutat", "Alaskan Standard Time"}, +{"America/Yellowknife", "Mountain Standard Time"}, +{"Antarctica/Casey", "Central Pacific Standard Time"}, +{"Antarctica/Davis", "SE Asia Standard Time"}, +{"Antarctica/DumontDUrville", "West Pacific Standard Time"}, +{"Antarctica/Macquarie", "Tasmania Standard Time"}, +{"Antarctica/Mawson", "West Asia Standard Time"}, +{"Antarctica/McMurdo", "New Zealand Standard Time"}, +{"Antarctica/Palmer", "SA Eastern Standard Time"}, +{"Antarctica/Rothera", "SA Eastern Standard Time"}, +{"Antarctica/South_Pole", "New Zealand Standard Time"}, +{"Antarctica/Syowa", "E. Africa Standard Time"}, +{"Antarctica/Vostok", "Central Asia Standard Time"}, +{"Arctic/Longyearbyen", "W. Europe Standard Time"}, +{"Asia/Aden", "Arab Standard Time"}, +{"Asia/Almaty", "Central Asia Standard Time"}, +{"Asia/Amman", "Jordan Standard Time"}, +{"Asia/Anadyr", "Russia Time Zone 11"}, +{"Asia/Aqtau", "West Asia Standard Time"}, +{"Asia/Aqtobe", "West Asia Standard Time"}, +{"Asia/Ashgabat", "West Asia Standard Time"}, +{"Asia/Ashkhabad", "West Asia Standard Time"}, +{"Asia/Atyrau", "West Asia Standard Time"}, +{"Asia/Baghdad", "Arabic Standard Time"}, +{"Asia/Bahrain", "Arab Standard Time"}, +{"Asia/Baku", "Azerbaijan Standard Time"}, +{"Asia/Bangkok", "SE Asia Standard Time"}, +{"Asia/Barnaul", "Altai Standard Time"}, +{"Asia/Beirut", "Middle East Standard Time"}, +{"Asia/Bishkek", "Central Asia Standard Time"}, +{"Asia/Brunei", "Singapore Standard Time"}, +{"Asia/Calcutta", "India Standard Time"}, +{"Asia/Chita", "Transbaikal Standard Time"}, +{"Asia/Choibalsan", "Ulaanbaatar Standard Time"}, +{"Asia/Chongqing", "China Standard Time"}, +{"Asia/Chungking", "China Standard Time"}, +{"Asia/Colombo", "Sri Lanka Standard Time"}, +{"Asia/Dacca", "Bangladesh Standard Time"}, +{"Asia/Damascus", "Syria Standard Time"}, +{"Asia/Dhaka", "Bangladesh Standard Time"}, +{"Asia/Dili", "Tokyo Standard Time"}, +{"Asia/Dubai", "Arabian Standard Time"}, +{"Asia/Dushanbe", "West Asia Standard Time"}, +{"Asia/Famagusta", "GTB Standard Time"}, +{"Asia/Gaza", "West Bank Standard Time"}, +{"Asia/Harbin", "China Standard Time"}, +{"Asia/Hebron", "West Bank Standard Time"}, +{"Asia/Hong_Kong", "China Standard Time"}, +{"Asia/Hovd", "W. Mongolia Standard Time"}, +{"Asia/Irkutsk", "North Asia East Standard Time"}, +{"Asia/Jakarta", "SE Asia Standard Time"}, +{"Asia/Jayapura", "Tokyo Standard Time"}, +{"Asia/Jerusalem", "Israel Standard Time"}, +{"Asia/Kabul", "Afghanistan Standard Time"}, +{"Asia/Kamchatka", "Russia Time Zone 11"}, +{"Asia/Karachi", "Pakistan Standard Time"}, +{"Asia/Kashgar", "Central Asia Standard Time"}, +{"Asia/Katmandu", "Nepal Standard Time"}, +{"Asia/Khandyga", "Yakutsk Standard Time"}, +{"Asia/Krasnoyarsk", "North Asia Standard Time"}, +{"Asia/Kuala_Lumpur", "Singapore Standard Time"}, +{"Asia/Kuching", "Singapore Standard Time"}, +{"Asia/Kuwait", "Arab Standard Time"}, +{"Asia/Macao", "China Standard Time"}, +{"Asia/Macau", "China Standard Time"}, +{"Asia/Magadan", "Magadan Standard Time"}, +{"Asia/Makassar", "Singapore Standard Time"}, +{"Asia/Manila", "Singapore Standard Time"}, +{"Asia/Muscat", "Arabian Standard Time"}, +{"Asia/Nicosia", "GTB Standard Time"}, +{"Asia/Novokuznetsk", "North Asia Standard Time"}, +{"Asia/Novosibirsk", "N. Central Asia Standard Time"}, +{"Asia/Omsk", "Omsk Standard Time"}, +{"Asia/Oral", "West Asia Standard Time"}, +{"Asia/Phnom_Penh", "SE Asia Standard Time"}, +{"Asia/Pontianak", "SE Asia Standard Time"}, +{"Asia/Pyongyang", "North Korea Standard Time"}, +{"Asia/Qatar", "Arab Standard Time"}, +{"Asia/Qostanay", "Central Asia Standard Time"}, +{"Asia/Qyzylorda", "Qyzylorda Standard Time"}, +{"Asia/Rangoon", "Myanmar Standard Time"}, +{"Asia/Riyadh", "Arab Standard Time"}, +{"Asia/Saigon", "SE Asia Standard Time"}, +{"Asia/Sakhalin", "Sakhalin Standard Time"}, +{"Asia/Samarkand", "West Asia Standard Time"}, +{"Asia/Seoul", "Korea Standard Time"}, +{"Asia/Singapore", "Singapore Standard Time"}, +{"Asia/Srednekolymsk", "Russia Time Zone 10"}, +{"Asia/Taipei", "Taipei Standard Time"}, +{"Asia/Tashkent", "West Asia Standard Time"}, +{"Asia/Tbilisi", "Georgian Standard Time"}, +{"Asia/Tehran", "Iran Standard Time"}, +{"Asia/Tel_Aviv", "Israel Standard Time"}, +{"Asia/Thimbu", "Bangladesh Standard Time"}, +{"Asia/Thimphu", "Bangladesh Standard Time"}, +{"Asia/Tokyo", "Tokyo Standard Time"}, +{"Asia/Tomsk", "Tomsk Standard Time"}, +{"Asia/Ujung_Pandang", "Singapore Standard Time"}, +{"Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"}, +{"Asia/Ulan_Bator", "Ulaanbaatar Standard Time"}, +{"Asia/Urumqi", "Central Asia Standard Time"}, +{"Asia/Ust-Nera", "Vladivostok Standard Time"}, +{"Asia/Vientiane", "SE Asia Standard Time"}, +{"Asia/Vladivostok", "Vladivostok Standard Time"}, +{"Asia/Yakutsk", "Yakutsk Standard Time"}, +{"Asia/Yekaterinburg", "Ekaterinburg Standard Time"}, +{"Asia/Yerevan", "Caucasus Standard Time"}, +{"Atlantic/Azores", "Azores Standard Time"}, +{"Atlantic/Bermuda", "Atlantic Standard Time"}, +{"Atlantic/Canary", "GMT Standard Time"}, +{"Atlantic/Cape_Verde", "Cape Verde Standard Time"}, +{"Atlantic/Faeroe", "GMT Standard Time"}, +{"Atlantic/Jan_Mayen", "W. Europe Standard Time"}, +{"Atlantic/Madeira", "GMT Standard Time"}, +{"Atlantic/Reykjavik", "Greenwich Standard Time"}, +{"Atlantic/South_Georgia", "UTC-02"}, +{"Atlantic/St_Helena", "Greenwich Standard Time"}, +{"Atlantic/Stanley", "SA Eastern Standard Time"}, +{"Australia/ACT", "AUS Eastern Standard Time"}, +{"Australia/Adelaide", "Cen. Australia Standard Time"}, +{"Australia/Brisbane", "E. Australia Standard Time"}, +{"Australia/Broken_Hill", "Cen. Australia Standard Time"}, +{"Australia/Canberra", "AUS Eastern Standard Time"}, +{"Australia/Currie", "Tasmania Standard Time"}, +{"Australia/Darwin", "AUS Central Standard Time"}, +{"Australia/Eucla", "Aus Central W. Standard Time"}, +{"Australia/Hobart", "Tasmania Standard Time"}, +{"Australia/LHI", "Lord Howe Standard Time"}, +{"Australia/Lindeman", "E. Australia Standard Time"}, +{"Australia/Lord_Howe", "Lord Howe Standard Time"}, +{"Australia/Melbourne", "AUS Eastern Standard Time"}, +{"Australia/NSW", "AUS Eastern Standard Time"}, +{"Australia/North", "AUS Central Standard Time"}, +{"Australia/Perth", "W. Australia Standard Time"}, +{"Australia/Queensland", "E. Australia Standard Time"}, +{"Australia/South", "Cen. Australia Standard Time"}, +{"Australia/Sydney", "AUS Eastern Standard Time"}, +{"Australia/Tasmania", "Tasmania Standard Time"}, +{"Australia/Victoria", "AUS Eastern Standard Time"}, +{"Australia/West", "W. Australia Standard Time"}, +{"Australia/Yancowinna", "Cen. Australia Standard Time"}, +{"Brazil/Acre", "SA Pacific Standard Time"}, +{"Brazil/DeNoronha", "UTC-02"}, +{"Brazil/East", "E. South America Standard Time"}, +{"Brazil/West", "SA Western Standard Time"}, +{"CST6CDT", "Central Standard Time"}, +{"Canada/Atlantic", "Atlantic Standard Time"}, +{"Canada/Central", "Central Standard Time"}, +{"Canada/Eastern", "Eastern Standard Time"}, +{"Canada/Mountain", "Mountain Standard Time"}, +{"Canada/Newfoundland", "Newfoundland Standard Time"}, +{"Canada/Pacific", "Pacific Standard Time"}, +{"Canada/Saskatchewan", "Canada Central Standard Time"}, +{"Canada/Yukon", "Yukon Standard Time"}, +{"Chile/Continental", "Pacific SA Standard Time"}, +{"Chile/EasterIsland", "Easter Island Standard Time"}, +{"Cuba", "Cuba Standard Time"}, +{"EST5EDT", "Eastern Standard Time"}, +{"Egypt", "Egypt Standard Time"}, +{"Eire", "GMT Standard Time"}, +{"Etc/GMT", "UTC"}, +{"Etc/GMT+1", "Cape Verde Standard Time"}, +{"Etc/GMT+10", "Hawaiian Standard Time"}, +{"Etc/GMT+11", "UTC-11"}, +{"Etc/GMT+12", "Dateline Standard Time"}, +{"Etc/GMT+2", "UTC-02"}, +{"Etc/GMT+3", "SA Eastern Standard Time"}, +{"Etc/GMT+4", "SA Western Standard Time"}, +{"Etc/GMT+5", "SA Pacific Standard Time"}, +{"Etc/GMT+6", "Central America Standard Time"}, +{"Etc/GMT+7", "US Mountain Standard Time"}, +{"Etc/GMT+8", "UTC-08"}, +{"Etc/GMT+9", "UTC-09"}, +{"Etc/GMT-1", "W. Central Africa Standard Time"}, +{"Etc/GMT-10", "West Pacific Standard Time"}, +{"Etc/GMT-11", "Central Pacific Standard Time"}, +{"Etc/GMT-12", "UTC+12"}, +{"Etc/GMT-13", "UTC+13"}, +{"Etc/GMT-14", "Line Islands Standard Time"}, +{"Etc/GMT-2", "South Africa Standard Time"}, +{"Etc/GMT-3", "E. Africa Standard Time"}, +{"Etc/GMT-4", "Arabian Standard Time"}, +{"Etc/GMT-5", "West Asia Standard Time"}, +{"Etc/GMT-6", "Central Asia Standard Time"}, +{"Etc/GMT-7", "SE Asia Standard Time"}, +{"Etc/GMT-8", "Singapore Standard Time"}, +{"Etc/GMT-9", "Tokyo Standard Time"}, +{"Etc/UCT", "UTC"}, +{"Etc/UTC", "UTC"}, +{"Europe/Amsterdam", "W. Europe Standard Time"}, +{"Europe/Andorra", "W. Europe Standard Time"}, +{"Europe/Astrakhan", "Astrakhan Standard Time"}, +{"Europe/Athens", "GTB Standard Time"}, +{"Europe/Belfast", "GMT Standard Time"}, +{"Europe/Belgrade", "Central Europe Standard Time"}, +{"Europe/Berlin", "W. Europe Standard Time"}, +{"Europe/Bratislava", "Central Europe Standard Time"}, +{"Europe/Brussels", "Romance Standard Time"}, +{"Europe/Bucharest", "GTB Standard Time"}, +{"Europe/Budapest", "Central Europe Standard Time"}, +{"Europe/Busingen", "W. Europe Standard Time"}, +{"Europe/Chisinau", "E. Europe Standard Time"}, +{"Europe/Copenhagen", "Romance Standard Time"}, +{"Europe/Dublin", "GMT Standard Time"}, +{"Europe/Gibraltar", "W. Europe Standard Time"}, +{"Europe/Guernsey", "GMT Standard Time"}, +{"Europe/Helsinki", "FLE Standard Time"}, +{"Europe/Isle_of_Man", "GMT Standard Time"}, +{"Europe/Istanbul", "Turkey Standard Time"}, +{"Europe/Jersey", "GMT Standard Time"}, +{"Europe/Kaliningrad", "Kaliningrad Standard Time"}, +{"Europe/Kiev", "FLE Standard Time"}, +{"Europe/Kirov", "Russian Standard Time"}, +{"Europe/Lisbon", "GMT Standard Time"}, +{"Europe/Ljubljana", "Central Europe Standard Time"}, +{"Europe/London", "GMT Standard Time"}, +{"Europe/Luxembourg", "W. Europe Standard Time"}, +{"Europe/Madrid", "Romance Standard Time"}, +{"Europe/Malta", "W. Europe Standard Time"}, +{"Europe/Mariehamn", "FLE Standard Time"}, +{"Europe/Minsk", "Belarus Standard Time"}, +{"Europe/Monaco", "W. Europe Standard Time"}, +{"Europe/Moscow", "Russian Standard Time"}, +{"Europe/Oslo", "W. Europe Standard Time"}, +{"Europe/Paris", "Romance Standard Time"}, +{"Europe/Podgorica", "Central Europe Standard Time"}, +{"Europe/Prague", "Central Europe Standard Time"}, +{"Europe/Riga", "FLE Standard Time"}, +{"Europe/Rome", "W. Europe Standard Time"}, +{"Europe/Samara", "Russia Time Zone 3"}, +{"Europe/San_Marino", "W. Europe Standard Time"}, +{"Europe/Sarajevo", "Central European Standard Time"}, +{"Europe/Saratov", "Saratov Standard Time"}, +{"Europe/Simferopol", "Russian Standard Time"}, +{"Europe/Skopje", "Central European Standard Time"}, +{"Europe/Sofia", "FLE Standard Time"}, +{"Europe/Stockholm", "W. Europe Standard Time"}, +{"Europe/Tallinn", "FLE Standard Time"}, +{"Europe/Tirane", "Central Europe Standard Time"}, +{"Europe/Tiraspol", "E. Europe Standard Time"}, +{"Europe/Ulyanovsk", "Astrakhan Standard Time"}, +{"Europe/Uzhgorod", "FLE Standard Time"}, +{"Europe/Vaduz", "W. Europe Standard Time"}, +{"Europe/Vatican", "W. Europe Standard Time"}, +{"Europe/Vienna", "W. Europe Standard Time"}, +{"Europe/Vilnius", "FLE Standard Time"}, +{"Europe/Volgograd", "Volgograd Standard Time"}, +{"Europe/Warsaw", "Central European Standard Time"}, +{"Europe/Zagreb", "Central European Standard Time"}, +{"Europe/Zaporozhye", "FLE Standard Time"}, +{"Europe/Zurich", "W. Europe Standard Time"}, +{"GB", "GMT Standard Time"}, +{"GB-Eire", "GMT Standard Time"}, +{"GMT+0", "UTC"}, +{"GMT-0", "UTC"}, +{"GMT0", "UTC"}, +{"Greenwich", "UTC"}, +{"Hongkong", "China Standard Time"}, +{"Iceland", "Greenwich Standard Time"}, +{"Indian/Antananarivo", "E. Africa Standard Time"}, +{"Indian/Chagos", "Central Asia Standard Time"}, +{"Indian/Christmas", "SE Asia Standard Time"}, +{"Indian/Cocos", "Myanmar Standard Time"}, +{"Indian/Comoro", "E. Africa Standard Time"}, +{"Indian/Kerguelen", "West Asia Standard Time"}, +{"Indian/Mahe", "Mauritius Standard Time"}, +{"Indian/Maldives", "West Asia Standard Time"}, +{"Indian/Mauritius", "Mauritius Standard Time"}, +{"Indian/Mayotte", "E. Africa Standard Time"}, +{"Indian/Reunion", "Mauritius Standard Time"}, +{"Iran", "Iran Standard Time"}, +{"Israel", "Israel Standard Time"}, +{"Jamaica", "SA Pacific Standard Time"}, +{"Japan", "Tokyo Standard Time"}, +{"Kwajalein", "UTC+12"}, +{"Libya", "Libya Standard Time"}, +{"MST7MDT", "Mountain Standard Time"}, +{"Mexico/BajaNorte", "Pacific Standard Time (Mexico)"}, +{"Mexico/BajaSur", "Mountain Standard Time (Mexico)"}, +{"Mexico/General", "Central Standard Time (Mexico)"}, +{"NZ", "New Zealand Standard Time"}, +{"NZ-CHAT", "Chatham Islands Standard Time"}, +{"Navajo", "Mountain Standard Time"}, +{"PRC", "China Standard Time"}, +{"PST8PDT", "Pacific Standard Time"}, +{"Pacific/Apia", "Samoa Standard Time"}, +{"Pacific/Auckland", "New Zealand Standard Time"}, +{"Pacific/Bougainville", "Bougainville Standard Time"}, +{"Pacific/Chatham", "Chatham Islands Standard Time"}, +{"Pacific/Easter", "Easter Island Standard Time"}, +{"Pacific/Efate", "Central Pacific Standard Time"}, +{"Pacific/Enderbury", "UTC+13"}, +{"Pacific/Fakaofo", "UTC+13"}, +{"Pacific/Fiji", "Fiji Standard Time"}, +{"Pacific/Funafuti", "UTC+12"}, +{"Pacific/Galapagos", "Central America Standard Time"}, +{"Pacific/Gambier", "UTC-09"}, +{"Pacific/Guadalcanal", "Central Pacific Standard Time"}, +{"Pacific/Guam", "West Pacific Standard Time"}, +{"Pacific/Honolulu", "Hawaiian Standard Time"}, +{"Pacific/Johnston", "Hawaiian Standard Time"}, +{"Pacific/Kiritimati", "Line Islands Standard Time"}, +{"Pacific/Kosrae", "Central Pacific Standard Time"}, +{"Pacific/Kwajalein", "UTC+12"}, +{"Pacific/Majuro", "UTC+12"}, +{"Pacific/Marquesas", "Marquesas Standard Time"}, +{"Pacific/Midway", "UTC-11"}, +{"Pacific/Nauru", "UTC+12"}, +{"Pacific/Niue", "UTC-11"}, +{"Pacific/Norfolk", "Norfolk Standard Time"}, +{"Pacific/Noumea", "Central Pacific Standard Time"}, +{"Pacific/Pago_Pago", "UTC-11"}, +{"Pacific/Palau", "Tokyo Standard Time"}, +{"Pacific/Pitcairn", "UTC-08"}, +{"Pacific/Ponape", "Central Pacific Standard Time"}, +{"Pacific/Port_Moresby", "West Pacific Standard Time"}, +{"Pacific/Rarotonga", "Hawaiian Standard Time"}, +{"Pacific/Saipan", "West Pacific Standard Time"}, +{"Pacific/Samoa", "UTC-11"}, +{"Pacific/Tahiti", "Hawaiian Standard Time"}, +{"Pacific/Tarawa", "UTC+12"}, +{"Pacific/Tongatapu", "Tonga Standard Time"}, +{"Pacific/Truk", "West Pacific Standard Time"}, +{"Pacific/Wake", "UTC+12"}, +{"Pacific/Wallis", "UTC+12"}, +{"Poland", "Central European Standard Time"}, +{"Portugal", "GMT Standard Time"}, +{"ROC", "Taipei Standard Time"}, +{"ROK", "Korea Standard Time"}, +{"Singapore", "Singapore Standard Time"}, +{"Turkey", "Turkey Standard Time"}, +{"UCT", "UTC"}, +{"US/Alaska", "Alaskan Standard Time"}, +{"US/Aleutian", "Aleutian Standard Time"}, +{"US/Arizona", "US Mountain Standard Time"}, +{"US/Central", "Central Standard Time"}, +{"US/Eastern", "Eastern Standard Time"}, +{"US/Hawaii", "Hawaiian Standard Time"}, +{"US/Indiana-Starke", "Central Standard Time"}, +{"US/Michigan", "Eastern Standard Time"}, +{"US/Mountain", "Mountain Standard Time"}, +{"US/Pacific", "Pacific Standard Time"}, +{"US/Samoa", "UTC-11"}, +{"UTC", "UTC"}, +{"Universal", "UTC"}, +{"W-SU", "Russian Standard Time"}, +{"Zulu", "UTC"}}; #elif defined(_TD_DARWIN_64) #include #include @@ -61,19 +755,33 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 #ifdef WINDOWS char winStr[TD_LOCALE_LEN * 2]; - sprintf(winStr, "TZ=%s", buf); - putenv(winStr); - tzset(); - /* - * get CURRENT time zone. - * system current time zone is affected by daylight saving time(DST) - * - * e.g., the local time zone of London in DST is GMT+01:00, - * otherwise is GMT+00:00 - */ + memset(winStr, 0, sizeof(winStr)); + for (size_t i = 0; i < 554; i++) { + if (strcmp(tz_win[i][0],buf) == 0) { + char keyPath[100]; + char keyValue[100]; + DWORD keyValueSize = sizeof(keyValue); + sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s",tz_win[i][1]); + RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&keyValue, &keyValueSize); + if (keyValueSize > 0) { + keyValue[4] = (keyValue[4] == '+' ? '-' : '+'); + keyValue[10] = 0; + sprintf(winStr, "TZ=%s:00", &(keyValue[1])); + } + break; + } + } + char *p = strchr(inTimezoneStr, '+'); + if (p == NULL) p = strchr(inTimezoneStr, '-'); + if (p == NULL) { + sprintf(winStr, "TZ=UTC+00:00:00"); + } else { + sprintf(winStr, "TZ=UTC%c%c%c:%c%c:00", (p[0] == '+' ? '-' : '+'), p[1], p[2], p[3], p[4]); + } + _putenv(winStr); + _tzset(); #ifdef _MSC_VER #if _MSC_VER >= 1900 - // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 int64_t timezone = _timezone; int32_t daylight = _daylight; char **tzname = _tzname; @@ -83,11 +791,6 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); *tsTimezone = tz; tz += daylight; - /* - * format: - * (CST, +0800) - * (BST, +0100) - */ sprintf(outTimezoneStr, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); *outDaylight = daylight; @@ -117,14 +820,36 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 } void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { -#ifdef WINDOWS - char *tz = getenv("TZ"); - if (tz == NULL || strlen(tz) == 0) { +#ifdef WINDOWS + char value[100]; + DWORD bufferSize = sizeof(value); + char *buf = getenv("TZ"); + if (buf == NULL || strlen(buf) == 0) { + RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); strcpy(outTimezoneStr, "not configured"); + if (bufferSize > 0) { + for (size_t i = 0; i < 139; i++) { + if (strcmp(win_tz[i][0],value) == 0) { + strcpy(outTimezoneStr, win_tz[i][1]); + break; + } + } + } } else { - strcpy(outTimezoneStr, tz); + strcpy(outTimezoneStr, buf); } - +#ifdef _MSC_VER +#if _MSC_VER >= 1900 + // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 + int64_t timezone = _timezone; + int32_t daylight = _daylight; + char **tzname = _tzname; +#endif +#endif + int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); + *tsTimezone = tz; + tz += daylight; + sprintf(outTimezoneStr, "%s (%s, %s%02d00)", outTimezoneStr, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); #elif defined(_TD_DARWIN_64) char buf[4096] = {0}; char *tz = NULL; diff --git a/tests/pytest/cluster/clusterSetup.py b/tests/pytest/cluster/clusterSetup.py index 87414303f850bcbd78468238e7b76aa3dbb3326e..809e0e9d25ed79246cbd4d83d39f262b0a678cd0 100644 --- a/tests/pytest/cluster/clusterSetup.py +++ b/tests/pytest/cluster/clusterSetup.py @@ -92,13 +92,13 @@ class Node: self.conn.run("yes|./install.sh") def configTaosd(self, taosConfigKey, taosConfigValue): - self.conn.run("sudo echo '%s %s' >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) + self.conn.run("sudo echo %s %s >> %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) def removeTaosConfig(self, taosConfigKey, taosConfigValue): self.conn.run("sudo sed -in-place -e '/%s %s/d' %s" % (taosConfigKey, taosConfigValue, "/etc/taos/taos.cfg")) def configHosts(self, ip, name): - self.conn.run("echo '%s %s' >> %s" % (ip, name, '/etc/hosts')) + self.conn.run("echo %s %s >> %s" % (ip, name, '/etc/hosts')) def removeData(self): try: diff --git a/tests/pytest/dockerCluster/basic.py b/tests/pytest/dockerCluster/basic.py index 871d69790d328f3dcea9fdfdac27a6abc3bb14bd..5188aa4a80a8faacfbc4056958bde2363a796449 100644 --- a/tests/pytest/dockerCluster/basic.py +++ b/tests/pytest/dockerCluster/basic.py @@ -113,7 +113,7 @@ class BuildDockerCluser: def cfg(self, option, value, nodeIndex): cfgPath = "%s/node%d/cfg/taos.cfg" % (self.dockerDir, nodeIndex) - cmd = "echo '%s %s' >> %s" % (option, value, cfgPath) + cmd = "echo %s %s >> %s" % (option, value, cfgPath) self.execCmd(cmd) def updateLocalhosts(self): @@ -122,7 +122,7 @@ class BuildDockerCluser: print(result) if result is None or result.isspace(): print("==========") - cmd = "echo '172.27.0.7 tdnode1' >> /etc/hosts" + cmd = "echo 172.27.0.7 tdnode1 >> /etc/hosts" display = "echo %s" % cmd self.execCmd(display) self.execCmd(cmd) diff --git a/tests/pytest/fulltest.bat b/tests/pytest/fulltest.bat index 5758691c8872adbfd82e9e5a5cc10c2043b23922..fd74f2ad029c982a3a3dd98ae0c8df264bab9c66 100644 --- a/tests/pytest/fulltest.bat +++ b/tests/pytest/fulltest.bat @@ -1,2 +1,22 @@ -python .\test.py -f insert\basic.py \ No newline at end of file +python .\test.py -f insert\basic.py +python .\test.py -f insert\int.py +python .\test.py -f insert\float.py +python .\test.py -f insert\bigint.py +python .\test.py -f insert\bool.py +python .\test.py -f insert\double.py +python .\test.py -f insert\smallint.py +python .\test.py -f insert\tinyint.py +python .\test.py -f insert\date.py +python .\test.py -f insert\binary.py +python .\test.py -f insert\nchar.py + +python .\test.py -f query\filter.py +python .\test.py -f query\filterCombo.py +python .\test.py -f query\queryNormal.py +python .\test.py -f query\queryError.py +python .\test.py -f query\filterAllIntTypes.py +python .\test.py -f query\filterFloatAndDouble.py +python .\test.py -f query\filterOtherTypes.py +python .\test.py -f query\querySort.py +python .\test.py -f query\queryJoin.py \ No newline at end of file diff --git a/tests/pytest/manualTest/TD-5114/rollingUpgrade.py b/tests/pytest/manualTest/TD-5114/rollingUpgrade.py index f634eb1208b69f263ea89db2440db40ec3e085e6..b2d5171972b9e5e0025c4e46e8dd1f257ed48e24 100644 --- a/tests/pytest/manualTest/TD-5114/rollingUpgrade.py +++ b/tests/pytest/manualTest/TD-5114/rollingUpgrade.py @@ -38,7 +38,7 @@ class Node: def buildTaosd(self): try: print(self.conn) - # self.conn.run('echo "1234" > /home/chr/installtest/test.log') + # self.conn.run('echo 1234 > /home/chr/installtest/test.log') self.conn.run("cd /home/chr/installtest/ && tar -xvf %s " %self.verName) self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath) except Exception as e: @@ -49,7 +49,7 @@ class Node: def rebuildTaosd(self): try: print(self.conn) - # self.conn.run('echo "1234" > /home/chr/installtest/test.log') + # self.conn.run('echo 1234 > /home/chr/installtest/test.log') self.conn.run("cd /home/chr/installtest/%s && ./install.sh " % self.installPath) except Exception as e: print("Build Taosd error for node %d " % self.index) @@ -108,7 +108,7 @@ class oneNode: # install TDengine at 192.168.103/104/141 try: node = Node(id, username, IP, passwd, version) - node.conn.run('echo "start taosd"') + node.conn.run('echo start taosd') node.buildTaosd() # clear DataPath , if need clear data node.clearData() @@ -128,7 +128,7 @@ class oneNode: # start TDengine try: node = Node(id, username, IP, passwd, version) - node.conn.run('echo "restart taosd"') + node.conn.run('echo restart taosd') # clear DataPath , if need clear data node.clearData() node.restartTaosd() @@ -149,14 +149,14 @@ class oneNode: verName = "TDengine-enterprise-server-%s-Linux-x64.tar.gz" % version # installPath = "TDengine-enterprise-server-%s" % self.version node131 = Node(131, 'ubuntu', '192.168.1.131', 'tbase125!', '2.0.20.0') - node131.conn.run('echo "upgrade cluster"') + node131.conn.run('echo upgrade cluster') node131.conn.run('sshpass -p tbase125! scp /nas/TDengine/v%s/enterprise/%s root@192.168.1.%d:/home/chr/installtest/' % (version,verName,id)) node131.conn.close() # upgrade TDengine at 192.168.103/104/141 try: node = Node(id, username, IP, passwd, version) - node.conn.run('echo "start taosd"') - node.conn.run('echo "1234" > /home/chr/test.log') + node.conn.run('echo start taosd') + node.conn.run('echo 1234 > /home/chr/test.log') node.buildTaosd() time.sleep(5) node.startTaosd() @@ -176,7 +176,7 @@ class oneNode: # backCluster TDengine at 192.168.103/104/141 try: node = Node(id, username, IP, passwd, version) - node.conn.run('echo "rollback taos"') + node.conn.run('echo rollback taos') node.rebuildTaosd() time.sleep(5) node.startTaosd() diff --git a/tests/pytest/test-all.bat b/tests/pytest/test-all.bat index 437472f7b88ac0d470d23a72bb1905727a63d097..4e3ece9b565f5fecce55798684d98875e1ffb7cc 100644 --- a/tests/pytest/test-all.bat +++ b/tests/pytest/test-all.bat @@ -14,12 +14,14 @@ for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( echo Processing %%i set /a a+=1 call %%i ARG1 -w 1 -m %1 > result_!a!.txt 2>error_!a!.txt - if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && goto :end ) else ( call :colorEcho 0a "Success" &echo. ) ) -exit +goto :end :colorEcho echo off "%~2" findstr /v /a:%1 /R "^$" "%~2" nul -del "%~2" > nul 2>&1i \ No newline at end of file +del "%~2" > nul 2>&1i + +:end \ No newline at end of file diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 12e13c9b5ca3cb0e0241a8eb3db58909a6b07779..1a1fd319cda35136282b95765aa6b0db880830bf 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -247,7 +247,7 @@ class TDDnode: paths = [] for root, dirs, files in os.walk(projPath): - if ((tool) in files): + if ((tool) in files or ("%s.exe"%tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): paths.append(os.path.join(root, tool)) diff --git a/tests/pytest/wal/addOldWalTest.py b/tests/pytest/wal/addOldWalTest.py index 2f4dcd5ce807cf7bbadfa480af6ed6342058a78a..36056d1bc2d0bef786cf4a4092521867f861b93b 100644 --- a/tests/pytest/wal/addOldWalTest.py +++ b/tests/pytest/wal/addOldWalTest.py @@ -31,7 +31,7 @@ class TDTestCase: def createOldDirAndAddWal(self): oldDir = tdDnodes.getDnodesRootDir() + "dnode1/data/vnode/vnode2/wal/old" - os.system("sudo echo 'test' >> %s/wal" % oldDir) + os.system("sudo echo test >> %s/wal" % oldDir) def run(self): diff --git a/tests/system-test/0-others/taosShell.py b/tests/system-test/0-others/taosShell.py index f6dfe3f75c795ab8bd8eefc7b9d043d75854dc2e..1fec9a0c41193d3c591816b45262ba996ed5a26a 100644 --- a/tests/system-test/0-others/taosShell.py +++ b/tests/system-test/0-others/taosShell.py @@ -3,8 +3,12 @@ import taos import sys import time import socket -import pexpect import os +import platform +if platform.system().lower() == 'windows': + import wexpect as taosExpect +else: + import pexpect as taosExpect from util.log import * from util.sql import * @@ -15,7 +19,11 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key if len(key) == 0: tdLog.exit("taos test key is null!") - taosCmd = buildPath + '/build/bin/taos ' + if platform.system().lower() == 'windows': + taosCmd = buildPath + '\\build\\bin\\taos.exe ' + taosCmd = taosCmd.replace('\\','\\\\') + else: + taosCmd = buildPath + '/build/bin/taos ' if len(cfgDir) != 0: taosCmd = taosCmd + '-c ' + cfgDir @@ -36,25 +44,30 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key tdLog.info ("taos cmd: %s" % taosCmd) - child = pexpect.spawn(taosCmd, timeout=3) + child = taosExpect.spawn(taosCmd, timeout=3) #output = child.readline() #print (output.decode()) if len(expectString) != 0: - i = child.expect([expectString, pexpect.TIMEOUT, pexpect.EOF], timeout=6) + i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) else: - i = child.expect([pexpect.TIMEOUT, pexpect.EOF], timeout=6) + i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=6) - retResult = child.before.decode() + if platform.system().lower() == 'windows': + retResult = child.before + else: + retResult = child.before.decode() print(retResult) #print(child.after.decode()) if i == 0: print ('taos login success! Here can run sql, taos> ') if len(sqlString) != 0: child.sendline (sqlString) - w = child.expect(["Query OK", pexpect.TIMEOUT, pexpect.EOF], timeout=1) + w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=1) if w == 0: return "TAOS_OK" else: + print(1) + print(retResult) return "TAOS_FAIL" else: if key == 'A' or key1 == 'A' or key == 'C' or key1 == 'C' or key == 'V' or key1 == 'V': @@ -102,7 +115,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] @@ -275,11 +288,11 @@ class TDTestCase: pwd=os.getcwd() newDbName="dbf" sqlFile = pwd + "/0-others/sql.txt" - sql1 = "echo 'create database " + newDbName + "' > " + sqlFile - sql2 = "echo 'use " + newDbName + "' >> " + sqlFile - sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile - sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile - sql5 = "echo 'show databases' >> " + sqlFile + sql1 = "echo create database " + newDbName + " > " + sqlFile + sql2 = "echo use " + newDbName + " >> " + sqlFile + sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile + sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile + sql5 = "echo show databases >> " + sqlFile os.system(sql1) os.system(sql2) os.system(sql3) diff --git a/tests/system-test/0-others/taosShellError.py b/tests/system-test/0-others/taosShellError.py index 5f2f79982a58fe33e361f7c05926fc7c276f84d7..14da924c94359cba5d5f9899771b5ad7cbc86fc2 100644 --- a/tests/system-test/0-others/taosShellError.py +++ b/tests/system-test/0-others/taosShellError.py @@ -216,11 +216,11 @@ class TDTestCase: pwd=os.getcwd() newDbName="dbf" sqlFile = pwd + "/0-others/sql.txt" - sql1 = "echo 'create database " + newDbName + "' > " + sqlFile - sql2 = "echo 'use " + newDbName + "' >> " + sqlFile - sql3 = "echo 'create table ntbf (ts timestamp, c binary(40)) no this item' >> " + sqlFile - sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile - sql5 = "echo 'show databases' >> " + sqlFile + sql1 = "echo create database " + newDbName + " > " + sqlFile + sql2 = "echo use " + newDbName + " >> " + sqlFile + sql3 = "echo create table ntbf (ts timestamp, c binary(40)) no this item >> " + sqlFile + sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile + sql5 = "echo show databases >> " + sqlFile os.system(sql1) os.system(sql2) os.system(sql3) diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 31afd027ec3e53713479a402b0eb92fbf2e61db8..da8876a47cd60fe80e2270d7561bb3754343998d 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -17,6 +17,8 @@ import sys import getopt import subprocess import time +import base64 +import json from distutils.log import warn as printf from fabric2 import Connection sys.path.append("../pytest") @@ -38,8 +40,9 @@ if __name__ == "__main__": stop = 0 restart = False windows = 0 - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [ - 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows']) + updateCfgDict = {} + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrwd:', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows', 'updateCfgDict']) for key, value in opts: if key in ['-h', '--help']: tdLog.printNoPrefix( @@ -53,6 +56,7 @@ if __name__ == "__main__": tdLog.printNoPrefix('-g valgrind Test Flag') tdLog.printNoPrefix('-r taosd restart test') tdLog.printNoPrefix('-w taos on windows') + tdLog.printNoPrefix('-d update cfg dict, base64 json str') sys.exit(0) if key in ['-r', '--restart']: @@ -88,6 +92,12 @@ if __name__ == "__main__": if key in ['-w', '--windows']: windows = 1 + if key in ['-d', '--updateCfgDict']: + try: + updateCfgDict = eval(base64.b64decode(value.encode()).decode()) + except: + print('updateCfgDict convert fail.') + sys.exit(0) if (stop != 0): if (valgrind == 0): toBeKilled = "taosd" @@ -127,15 +137,47 @@ if __name__ == "__main__": if windows: tdCases.logSql(logSql) tdLog.info("Procedures for testing self-deployment") - td_clinet = TDSimClient("C:\\TDengine") - td_clinet.deploy() - remote_conn = Connection("root@%s"%host) - with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): - remote_conn.run("python3 ./test.py") + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + key_word = 'tdCases.addWindows' + is_test_framework = 0 + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + updateCfgDictStr = '' + if is_test_framework: + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + if ((json.dumps(updateCfgDict) == '{}') and (ucase.updatecfgDict is not None)): + updateCfgDict = ucase.updatecfgDict + updateCfgDictStr = "-d %s"%base64.b64encode(json.dumps(updateCfgDict).encode()).decode() + except : + pass + else: + pass + tdDnodes.deploy(1,updateCfgDict) + if masterIp == "" or masterIp == "localhost": + tdDnodes.startWin(1) + else: + remote_conn = Connection("root@%s"%host) + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + remote_conn.run("python3 ./test.py %s"%updateCfgDictStr) + # print("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr) + # os.system("docker exec -d cross_platform bash -c \"cd ~/test/community/tests/system-test && python3 ./test.py %s\""%updateCfgDictStr) + # time.sleep(2) conn = taos.connect( host="%s"%(host), - config=td_clinet.cfgDir) - tdCases.runOneWindows(conn, fileName) + config=tdDnodes.sim.getCfgDir()) + if is_test_framework: + tdCases.runOneWindows(conn, fileName) + else: + tdCases.runAllWindows(conn) else: tdDnodes.init(deployPath) tdDnodes.setTestCluster(testCluster) @@ -153,16 +195,13 @@ if __name__ == "__main__": uModule = importlib.import_module(moduleName) try: ucase = uModule.TDTestCase() - tdDnodes.deploy(1,ucase.updatecfgDict) - except : - tdDnodes.deploy(1,{}) - else: - pass - tdDnodes.deploy(1,{}) + if (json.dumps(updateCfgDict) == '{}'): + updateCfgDict = ucase.updatecfgDict + except: + pass + tdDnodes.deploy(1,updateCfgDict) tdDnodes.start(1) - - tdCases.logSql(logSql) if testCluster: diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 284693795ee471ad2d631758970c3033dc8e0c6c..295fae68b30e85e787a7b8b491a354bcc3125709 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -1,9 +1,13 @@ aux_source_directory(src SHELL_SRC) add_executable(shell ${SHELL_SRC}) +if(TD_WINDOWS) + target_link_libraries(shell PUBLIC taos_static) +else() + target_link_libraries(shell PUBLIC taos) +endif () target_link_libraries( shell - PUBLIC taos PRIVATE os common transport util ) target_include_directories( diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 1639fd1ca681ab0bb980b2fd1fca8b34d58e15f3..cd6613b17a2d6d62ef4ce969b27004f1b5e7df72 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -36,6 +36,8 @@ #define SHELL_VERSION "Print program version." #define SHELL_EMAIL "" +static int32_t shellParseSingleOpt(int32_t key, char *arg); + void shellPrintHelp() { char indent[] = " "; printf("Usage: taos [OPTION...] \n\n"); @@ -90,6 +92,21 @@ static struct argp_option shellOptions[] = { {0}, }; +static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); } + +static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""}; + +static void shellParseArgsUseArgp(int argc, char *argv[]) { + argp_program_version = shell.info.programVersion; + argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args); +} + +#endif + +#ifndef ARGP_ERR_UNKNOWN + #define ARGP_ERR_UNKNOWN E2BIG +#endif + static int32_t shellParseSingleOpt(int32_t key, char *arg) { SShellArgs *pArgs = &shell.args; @@ -196,8 +213,8 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { } shellParseSingleOpt(key[1], val); i++; - } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'c' || key[1] == 'r' || key[1] == 'k' || key[1] == 't' || - key[1] == 'V') { + } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'C' || key[1] == 'r' || key[1] == 'k' || + key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1) { shellParseSingleOpt(key[1], NULL); } else { fprintf(stderr, "invalid option %s\n", key); @@ -208,21 +225,10 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { return 0; } -static error_t shellParseOpt(int32_t key, char *arg, struct argp_state *state) { return shellParseSingleOpt(key, arg); } - -static struct argp shellArgp = {shellOptions, shellParseOpt, "", ""}; - -static void shellParseArgsUseArgp(int argc, char *argv[]) { - argp_program_version = shell.info.programVersion; - argp_parse(&shellArgp, argc, argv, 0, 0, &shell.args); -} - -#endif - static void shellInitArgs(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { if (strncmp(argv[i], "-p", 2) == 0) { - printf(shell.info.clientVersion, tsOsName, taos_get_client_info()); + // printf(shell.info.clientVersion, tsOsName, taos_get_client_info()); if (strlen(argv[i]) == 2) { printf("Enter password: "); taosSetConsoleEcho(false); @@ -341,7 +347,7 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) { #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) shell.info.osname = "Windows"; snprintf(shell.history.file, TSDB_FILENAME_LEN, "C:/TDengine/%s", SHELL_HISTORY_FILE); - // if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1; + if (shellParseArgsWithoutArgp(argc, argv) != 0) return -1; #elif defined(_TD_DARWIN_64) shell.info.osname = "Darwin"; snprintf(shell.history.file, TSDB_FILENAME_LEN, "%s/%s", getpwuid(getuid())->pw_dir, SHELL_HISTORY_FILE);